diff --git a/dinput8_nojoy/dinput8_nojoy.cpp b/dinput8_nojoy/dinput8_nojoy.cpp new file mode 100644 index 0000000..00fb8c4 --- /dev/null +++ b/dinput8_nojoy/dinput8_nojoy.cpp @@ -0,0 +1,65 @@ +#include "dinput8_nojoy.hpp" + +typedef HRESULT (WINAPI *DirectInput8Create_t)(HINSTANCE, DWORD, REFIID, LPVOID*, LPUNKNOWN); +typedef HRESULT (WINAPI *EnumDevices_t)(LPDIRECTINPUT8, DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD); + +HMODULE dinput8; +DirectInput8Create_t DirectInput8Create_orig; +EnumDevices_t EnumDevices_orig; +LPDIENUMDEVICESCALLBACK EnumDevices_callback_orig; + +BOOL WINAPI DllMain( + HINSTANCE inst, + unsigned long reason, + void* info + ) { + switch (reason) { + case DLL_PROCESS_ATTACH: { + dinput8 = LoadLibrary(LR"(C:\Windows\System32\dinput8.dll)"); + DirectInput8Create_orig = reinterpret_cast(GetProcAddress(dinput8, "DirectInput8Create")); + } break; + case DLL_PROCESS_DETACH: { + FreeLibrary(dinput8); + } break; + } + + return TRUE; +} + +BOOL WINAPI EnumDevices_callback_hook(LPCDIDEVICEINSTANCE device, LPVOID data) { + auto type = device->dwDevType & 0x1F; + if (type == DI8DEVTYPE_MOUSE || type == DI8DEVTYPE_KEYBOARD) { + return EnumDevices_callback_orig(device, data); + } else { + return DIENUM_CONTINUE; + } +} + +HRESULT WINAPI EnumDevices_hook( + LPDIRECTINPUT8 iface, + DWORD type, + LPDIENUMDEVICESCALLBACK callback, + LPVOID data, + DWORD flags) { + EnumDevices_callback_orig = callback; + return EnumDevices_orig(iface, type, EnumDevices_callback_hook, data, flags); +} + +extern "C" long WINAPI DirectInput8Create_hook( + HINSTANCE inst, + DWORD ver, + REFIID id, + LPVOID* iface, + LPUNKNOWN aggreg) { + auto retval = DirectInput8Create_orig(inst, ver, id, iface, aggreg); + + auto idinput8 = reinterpret_cast(*iface); + auto& EnumDevices_vtable = idinput8->lpVtbl->EnumDevices; + + if (EnumDevices_vtable != EnumDevices_hook) { + EnumDevices_orig = EnumDevices_vtable; + EnumDevices_vtable = EnumDevices_hook; + } + + return retval; +} diff --git a/dinput8_nojoy/dinput8_nojoy.def b/dinput8_nojoy/dinput8_nojoy.def new file mode 100644 index 0000000..a2857d3 --- /dev/null +++ b/dinput8_nojoy/dinput8_nojoy.def @@ -0,0 +1,3 @@ +LIBRARY dinput8 +EXPORTS + DirectInput8Create = _DirectInput8Create_hook@20 @1 diff --git a/dinput8_nojoy/dinput8_nojoy.hpp b/dinput8_nojoy/dinput8_nojoy.hpp new file mode 100644 index 0000000..f11287f --- /dev/null +++ b/dinput8_nojoy/dinput8_nojoy.hpp @@ -0,0 +1,9 @@ +#pragma once + +#define DIRECTINPUT_VERSION 0x0800 +#define CINTERFACE +#include + +extern "C" HRESULT WINAPI DirectInput8Create_hook(HINSTANCE, DWORD, REFIID, LPVOID*, LPUNKNOWN); +HRESULT WINAPI EnumDevices_hook(LPDIRECTINPUT8, DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD); +BOOL WINAPI EnumDevices_callback_hook(LPCDIDEVICEINSTANCE, LPVOID); diff --git a/dinput8_nojoy/dinput8_nojoy.vcxproj b/dinput8_nojoy/dinput8_nojoy.vcxproj new file mode 100644 index 0000000..831bfb4 --- /dev/null +++ b/dinput8_nojoy/dinput8_nojoy.vcxproj @@ -0,0 +1,164 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {5232A0A8-E3F2-4166-B28E-DD69B96243F3} + Win32Proj + dinput8_nojoy + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + dinput8 + + + true + dinput8 + + + false + dinput8 + + + false + dinput8 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;DINPUT8_NOJOY_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + dinput8_nojoy.def + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;DINPUT8_NOJOY_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + dinput8_nojoy.def + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;DINPUT8_NOJOY_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + dinput8_nojoy.def + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;DINPUT8_NOJOY_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + dinput8_nojoy.def + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dinput8_nojoy/dinput8_nojoy.vcxproj.filters b/dinput8_nojoy/dinput8_nojoy.vcxproj.filters new file mode 100644 index 0000000..3074995 --- /dev/null +++ b/dinput8_nojoy/dinput8_nojoy.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file