Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAmulet committed Jan 14, 2023
0 parents commit b6cd038
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.obj
*.exe
*.zip
7 changes: 7 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2022 BlueAmulet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# XInputUWPFix

Disables the use of a game controller to navigate UWP applications. This program installs a Low Level Keyboard Hook to filter out keyboard events with VK Codes between 0xC3 and 0xDA.

Download the latest release [here](https://github.com/BlueAmulet/XInputUWPFix/releases/latest)

Disclaimer: Due to the use of a global hook, antivirus or anti-cheat software may complain about the use of this program. I am not responsible for any issues or damages that may result from the use of this program.

## Installation

A `install.bat` and `uninstall.bat` file is provided to add/remove the program to run on startup.

## Building

This program is designed to be built with Visual Studio 2022. Open a `x64 Native Tools Command Prompt` and run `build.bat`

The linker options used are designed to make the exe small.
38 changes: 38 additions & 0 deletions XInputUWPFix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@cl /O1 XInputUWPFix.c /link /nodefaultlib /subsystem:windows /entry:EntryPoint /debug:none /emitpogophaseinfo /emittoolversioninfo:no /merge:.pdata=.rdata kernel32.lib user32.lib
3 changes: 3 additions & 0 deletions install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v XInputUWPFix /d "\"%~dp0\XInputUWPFix.exe\"" /f
pause
3 changes: 3 additions & 0 deletions uninstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v XInputUWPFix /f
pause

0 comments on commit b6cd038

Please sign in to comment.