-
Notifications
You must be signed in to change notification settings - Fork 1
/
XInputUWPFix.c
38 lines (34 loc) · 924 Bytes
/
XInputUWPFix.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode >= 0)
{
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT)lParam;
if (p->vkCode >= 195 && p->vkCode <= 218)
{
return 1;
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
void __stdcall EntryPoint(void)
{
// Prevent application from running multiple times
CreateMutexA(0, FALSE, "Local\\$XInputUWPFix$");
if (GetLastError() != ERROR_ALREADY_EXISTS)
{
// Add Low Level Keyboard Hook to filter keyboard messages
HHOOK hhkLowLevelKbd = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, 0, 0);
// Process messages so hook works
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Cleanup
UnhookWindowsHookEx(hhkLowLevelKbd);
}
ExitProcess(0);
}