summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorAndrés Botero <0xafbf@gmail.com>2023-04-07 17:44:38 +0200
committerYuri Sizov <yuris@humnom.net>2023-04-07 17:44:38 +0200
commit02d0f090c0ab62adb9ebb8798dbd474f91b1d0a1 (patch)
tree38dce69cb460b05f49898cbfb2bf23e4fd0cf55b /platform/windows
parent2b0acb61be451158c8dc29577318f0cfb0f113e1 (diff)
Added guide button to controller db, changed to use secret XInput function.
(cherry picked from commit f249a9ce19e4d1bea28a5742e5c4e49f19e67c0d)
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/joypad_windows.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index 7ae26e6cf4..91efe09160 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -516,11 +516,13 @@ void JoypadWindows::joypad_vibration_stop_xinput(int p_device, uint64_t p_timest
void JoypadWindows::load_xinput() {
xinput_get_state = &_xinput_get_state;
xinput_set_state = &_xinput_set_state;
+ bool legacy_xinput = false;
xinput_dll = LoadLibrary("XInput1_4.dll");
if (!xinput_dll) {
xinput_dll = LoadLibrary("XInput1_3.dll");
if (!xinput_dll) {
xinput_dll = LoadLibrary("XInput9_1_0.dll");
+ legacy_xinput = true;
}
}
@@ -529,7 +531,9 @@ void JoypadWindows::load_xinput() {
return;
}
- XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputGetState");
+ // (LPCSTR)100 is the magic number to get XInputGetStateEx, which also provides the state for the guide button
+ LPCSTR get_state_func_name = legacy_xinput ? "XInputGetState" : (LPCSTR)100;
+ XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, get_state_func_name);
XInputSetState_t set_func = (XInputSetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputSetState");
if (!func || !set_func) {
unload_xinput();