Windows: Bring back hook input, this time with fixes for right Shift and Pause.
This commit is contained in:
@@ -200,23 +200,9 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
BOOL bCtrlDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
|
BOOL bCtrlDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
|
||||||
BOOL is_over_window = (GetForegroundWindow() == ((HWND) main_window->winId()));
|
BOOL is_over_window = (GetForegroundWindow() == ((HWND) main_window->winId()));
|
||||||
BOOL ret = TRUE;
|
BOOL ret = TRUE;
|
||||||
/* Leave this in, in case we have to still bring hook input back. */
|
|
||||||
#ifdef HOOK_INPUT_TESTS
|
|
||||||
static int last = 0;
|
static int last = 0;
|
||||||
|
|
||||||
pclog("Old: %08X, %08X, %08X, %i\n", lpKdhs->scanCode, lpKdhs->flags, lpKdhs->vkCode, last);
|
|
||||||
|
|
||||||
if (!last && (lpKdhs->scanCode == 0x00000036))
|
|
||||||
lpKdhs->flags &= ~LLKHF_EXTENDED;
|
|
||||||
|
|
||||||
if (lpKdhs->scanCode == 0x00000236)
|
|
||||||
last = 1;
|
|
||||||
else if (last && (lpKdhs->scanCode == 0x00000036))
|
|
||||||
last = 0;
|
|
||||||
|
|
||||||
pclog("New: %08X, %08X, %08X, %i\n", lpKdhs->scanCode, lpKdhs->flags, lpKdhs->vkCode, last);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (show_second_monitors) for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) {
|
if (show_second_monitors) for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) {
|
||||||
const auto &secondaryRenderer = main_window->renderers[monitor_index];
|
const auto &secondaryRenderer = main_window->renderers[monitor_index];
|
||||||
is_over_window = is_over_window || ((secondaryRenderer != nullptr) &&
|
is_over_window = is_over_window || ((secondaryRenderer != nullptr) &&
|
||||||
@@ -246,7 +232,26 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
else if ((lpKdhs->scanCode >= 0x5b) && (lpKdhs->scanCode <= 0x5d) && (lpKdhs->flags & LLKHF_EXTENDED))
|
else if ((lpKdhs->scanCode >= 0x5b) && (lpKdhs->scanCode <= 0x5d) && (lpKdhs->flags & LLKHF_EXTENDED))
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
else
|
else
|
||||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
ret = CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||||
|
|
||||||
|
if (lpKdhs->scanCode == 0x00000045) {
|
||||||
|
if ((lpKdhs->flags & LLKHF_EXTENDED) && (lpKdhs->vkCode == 0x00000090)) {
|
||||||
|
/* NumLock. */
|
||||||
|
lpKdhs->flags &= ~LLKHF_EXTENDED;
|
||||||
|
} else if (!(lpKdhs->flags & LLKHF_EXTENDED) && (lpKdhs->vkCode == 0x00000013)) {
|
||||||
|
/* Pause - send E1 1D. */
|
||||||
|
pclog("Send E1 1D\n");
|
||||||
|
win_keyboard_handle(0xe1, 0, 0, 0);
|
||||||
|
win_keyboard_handle(0x1d, 0, 0, 0);
|
||||||
|
}
|
||||||
|
} else if (!last && (lpKdhs->scanCode == 0x00000036))
|
||||||
|
/* Non-fake right shift. */
|
||||||
|
lpKdhs->flags &= ~LLKHF_EXTENDED;
|
||||||
|
|
||||||
|
if (lpKdhs->scanCode == 0x00000236)
|
||||||
|
last = 1;
|
||||||
|
else if (last && (lpKdhs->scanCode == 0x00000036))
|
||||||
|
last = 0;
|
||||||
|
|
||||||
win_keyboard_handle(lpKdhs->scanCode, lpKdhs->flags & LLKHF_UP, lpKdhs->flags & LLKHF_EXTENDED, 0);
|
win_keyboard_handle(lpKdhs->scanCode, lpKdhs->flags & LLKHF_UP, lpKdhs->flags & LLKHF_EXTENDED, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ WindowsRawInputFilter::Register(MainWindow *window)
|
|||||||
.hwndTarget = nullptr}
|
.hwndTarget = nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (RegisterRawInputDevices(rid, 2, sizeof(rid[0])) == FALSE)
|
if (hook_enabled && (RegisterRawInputDevices(&(rid[1]), 1, sizeof(rid[0])) == FALSE))
|
||||||
|
return std::unique_ptr<WindowsRawInputFilter>(nullptr);
|
||||||
|
else if (!hook_enabled && (RegisterRawInputDevices(rid, 2, sizeof(rid[0])) == FALSE))
|
||||||
return std::unique_ptr<WindowsRawInputFilter>(nullptr);
|
return std::unique_ptr<WindowsRawInputFilter>(nullptr);
|
||||||
|
|
||||||
std::unique_ptr<WindowsRawInputFilter> inputfilter(new WindowsRawInputFilter(window));
|
std::unique_ptr<WindowsRawInputFilter> inputfilter(new WindowsRawInputFilter(window));
|
||||||
@@ -97,6 +99,9 @@ WindowsRawInputFilter::~WindowsRawInputFilter()
|
|||||||
.hwndTarget = NULL}
|
.hwndTarget = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (hook_enabled)
|
||||||
|
RegisterRawInputDevices(&(rid[1]), 1, sizeof(rid[0]));
|
||||||
|
else
|
||||||
RegisterRawInputDevices(rid, 2, sizeof(rid[0]));
|
RegisterRawInputDevices(rid, 2, sizeof(rid[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,13 +160,11 @@ WindowsRawInputFilter::handle_input(HRAWINPUT input)
|
|||||||
mouse_handle(raw);
|
mouse_handle(raw);
|
||||||
break;
|
break;
|
||||||
case RIM_TYPEHID:
|
case RIM_TYPEHID:
|
||||||
{
|
|
||||||
win_joystick_handle(raw);
|
win_joystick_handle(raw);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* The following is more or less a direct copy of the old WIN32 implementation */
|
/* The following is more or less a direct copy of the old WIN32 implementation */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user