1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Fixed hotkeys not working with default dinput8 keyboard hook

Fixes hotkeys not working in Beach Life after intro movie.
This commit is contained in:
narzoul 2024-06-30 10:42:49 +02:00
parent a442239ac1
commit a5636bef12
4 changed files with 31 additions and 2 deletions

View File

@ -10,8 +10,7 @@ namespace
{ {
Compat::CriticalSection g_logCs; Compat::CriticalSection g_logCs;
std::ofstream g_logFile; std::ofstream g_logFile;
static std::ostringstream g_initialLogStream; std::ostringstream g_initialLogStream;
} }
namespace Compat namespace Compat

View File

@ -3,6 +3,7 @@
#include <tuple> #include <tuple>
#include <Windows.h> #include <Windows.h>
#include <hidusage.h>
#include <winternl.h> #include <winternl.h>
#include <Common/BitSet.h> #include <Common/BitSet.h>
@ -249,6 +250,24 @@ namespace
return { MulDiv(pt.x, 100, dpiScale), MulDiv(pt.y, 100, dpiScale) }; return { MulDiv(pt.x, 100, dpiScale), MulDiv(pt.y, 100, dpiScale) };
} }
BOOL WINAPI registerRawInputDevices(PCRAWINPUTDEVICE pRawInputDevices, UINT uiNumDevices, UINT cbSize)
{
LOG_FUNC("RegisterRawInputDevices", Compat::array(pRawInputDevices, uiNumDevices), uiNumDevices, cbSize);
if (1 == uiNumDevices &&
HID_USAGE_PAGE_GENERIC == pRawInputDevices->usUsagePage &&
HID_USAGE_GENERIC_KEYBOARD == pRawInputDevices->usUsage &&
pRawInputDevices->hwndTarget)
{
char className[32] = {};
GetClassNameA(pRawInputDevices->hwndTarget, className, sizeof(className));
if (0 == strcmp(className, "DIEmWin"))
{
return LOG_RESULT(FALSE);
}
}
return LOG_RESULT(CALL_ORIG_FUNC(RegisterRawInputDevices)(pRawInputDevices, uiNumDevices, cbSize));
}
void resetKeyboardHook() void resetKeyboardHook()
{ {
Gdi::GuiThread::execute([]() Gdi::GuiThread::execute([]()
@ -421,6 +440,7 @@ namespace Input
g_physicalToLogicalPointForPerMonitorDPI = reinterpret_cast<decltype(&PhysicalToLogicalPointForPerMonitorDPI)>( g_physicalToLogicalPointForPerMonitorDPI = reinterpret_cast<decltype(&PhysicalToLogicalPointForPerMonitorDPI)>(
GetProcAddress(GetModuleHandle("user32"), "PhysicalToLogicalPointForPerMonitorDPI")); GetProcAddress(GetModuleHandle("user32"), "PhysicalToLogicalPointForPerMonitorDPI"));
HOOK_FUNCTION(user32, RegisterRawInputDevices, registerRawInputDevices);
HOOK_FUNCTION(user32, SetCursorPos, setCursorPos); HOOK_FUNCTION(user32, SetCursorPos, setCursorPos);
HOOK_FUNCTION(user32, SetWindowsHookExA, setWindowsHookExA); HOOK_FUNCTION(user32, SetWindowsHookExA, setWindowsHookExA);
HOOK_FUNCTION(user32, SetWindowsHookExW, setWindowsHookExW); HOOK_FUNCTION(user32, SetWindowsHookExW, setWindowsHookExW);

View File

@ -462,6 +462,15 @@ std::ostream& operator<<(std::ostream& os, const POINTS& p)
<< p.y; << p.y;
} }
std::ostream& operator<<(std::ostream& os, const RAWINPUTDEVICE& input)
{
return Compat::LogStruct(os)
<< Compat::hex(input.usUsagePage)
<< Compat::hex(input.usUsage)
<< Compat::hex(input.dwFlags)
<< input.hwndTarget;
}
std::ostream& operator<<(std::ostream& os, const RECT& rect) std::ostream& operator<<(std::ostream& os, const RECT& rect)
{ {
return Compat::LogStruct(os) return Compat::LogStruct(os)

View File

@ -42,6 +42,7 @@ std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXA& vi);
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXW& vi); std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXW& vi);
std::ostream& operator<<(std::ostream& os, const POINT& p); std::ostream& operator<<(std::ostream& os, const POINT& p);
std::ostream& operator<<(std::ostream& os, const POINTS& p); std::ostream& operator<<(std::ostream& os, const POINTS& p);
std::ostream& operator<<(std::ostream& os, const RAWINPUTDEVICE& input);
std::ostream& operator<<(std::ostream& os, const RECT& rect); std::ostream& operator<<(std::ostream& os, const RECT& rect);
std::ostream& operator<<(std::ostream& os, const SIZE& size); std::ostream& operator<<(std::ostream& os, const SIZE& size);
std::ostream& operator<<(std::ostream& os, const STYLESTRUCT& ss); std::ostream& operator<<(std::ostream& os, const STYLESTRUCT& ss);