mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 17:18:38 +00:00
- gameinput_host_test decides the skip before mapping: LoadLibraryExW of GameInput.dll from System32. Only "not found" skips (77); an import that then binds to nothing is a failure. Breaking host ordinal binding in Loader::resolve now fails the test (4 failures) instead of skipping. - The gameinput_host fixture links in Debug: /RTC1 with /NODEFAULTLIB left _RTC_InitBase, _RTC_Shutdown and _RTC_CheckStackVars unresolved, so the fixture defines them as no-ops when runtime checks are on. - The fixture reports E_FAIL, not S_OK, when GameInputCreate fails, and the test counts a gamepad as attached only when the library was created. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
44 lines
2.0 KiB
C++
44 lines
2.0 KiB
C++
// A DLL that does what a title's input code does first: GameInputCreate, a timestamp, a gamepad reading. It uses the
|
|
// Windows SDK's public GameInput.h and links against the SDK's gameinput.lib, so GameInputCreate is imported from
|
|
// GameInput.dll (by ordinal) like any title's import. Built without the CRT: DllMain does nothing and the exports call
|
|
// only GameInput. gameinput_host_test maps it with the loader. No game data.
|
|
#include <windows.h>
|
|
|
|
#include <GameInput.h>
|
|
|
|
extern "C" BOOL WINAPI gameinput_host_main(HINSTANCE, DWORD, LPVOID) { return TRUE; }
|
|
|
|
#ifdef __MSVC_RUNTIME_CHECKS
|
|
// Debug builds compile with /RTC1 (the Visual Studio generator's default), whose checks call into the CRT; /NODEFAULTLIB
|
|
// leaves these three unresolved (LNK1120). The checks have nothing to check here, so they do nothing.
|
|
extern "C" {
|
|
void __cdecl _RTC_InitBase() {}
|
|
void __cdecl _RTC_Shutdown() {}
|
|
void __fastcall _RTC_CheckStackVars(void*, void*) {}
|
|
}
|
|
#endif
|
|
|
|
// Returns 1 when the library was created. reading_hr is S_OK with a gamepad attached and
|
|
// GAMEINPUT_E_READING_NOT_FOUND without one (E_FAIL when the library was not created); state_ok is 1 when
|
|
// GetGamepadState succeeded on a reading.
|
|
extern "C" __declspec(dllexport) int gameinput_host_probe(long* create_hr, unsigned long long* timestamp,
|
|
long* reading_hr, int* state_ok) {
|
|
IGameInput* input = nullptr;
|
|
IGameInputReading* reading = nullptr;
|
|
const HRESULT hr = GameInputCreate(&input);
|
|
*create_hr = hr;
|
|
*timestamp = 0;
|
|
*reading_hr = E_FAIL; // not S_OK: a failed GameInputCreate must not look like an attached gamepad
|
|
*state_ok = 0;
|
|
if (FAILED(hr) || !input) return 0;
|
|
*timestamp = input->GetCurrentTimestamp();
|
|
*reading_hr = input->GetCurrentReading(GameInputKindGamepad, nullptr, &reading);
|
|
if (SUCCEEDED(*reading_hr) && reading) {
|
|
GameInputGamepadState state;
|
|
*state_ok = reading->GetGamepadState(&state) ? 1 : 0;
|
|
reading->Release();
|
|
}
|
|
input->Release();
|
|
return 1;
|
|
}
|