diff options
author | Andreas Haas <liu.gam3@gmail.com> | 2017-02-21 17:02:49 +0100 |
---|---|---|
committer | Andreas Haas <liu.gam3@gmail.com> | 2017-02-26 21:01:31 +0100 |
commit | a175ac7032407af8e0ffe9fcb23edd5b57c6548f (patch) | |
tree | 55b9a768892e2c01d15075b1a7861eae078ce009 /platform/windows | |
parent | de0045cf1b0a5e20fbf74da192039d344ee8d0c7 (diff) |
Better handling of joypad device IDs.
Now InputDefault is responsible for giving out joypad device IDs to the platform, instead of each platform handling this itself.
This makes it possible for c++ modules to add their own "custom" gamepad devices, without the risk of messing up events in case the user also has regular gamepads attached (using the OS code).
For now, it's implemented for the main desktop platforms.
Possible targets for future work: android, uwp, javascript
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/joypad.cpp | 14 | ||||
-rw-r--r-- | platform/windows/joypad.h | 1 |
2 files changed, 2 insertions, 13 deletions
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp index f2848268fc..4c1eeb425a 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad.cpp @@ -87,16 +87,6 @@ bool JoypadWindows::have_device(const GUID &p_guid) { return false; } -int JoypadWindows::check_free_joy_slot() const { - - for (int i = 0; i < JOYPADS_MAX; i++) { - - if (!attached_joypads[i]) - return i; - } - return -1; -} - // adapted from SDL2, works a lot better than the MSDN version bool JoypadWindows::is_xinput_device(const GUID *p_guid) { @@ -146,7 +136,7 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE* instance) { HRESULT hr; - int num = check_free_joy_slot(); + int num = input->get_unused_joy_id(); if (have_device(instance->guidInstance) || num == -1) return false; @@ -296,7 +286,7 @@ void JoypadWindows::probe_joypads() { dwResult = xinput_get_state(i, &x_joypads[i].state); if ( dwResult == ERROR_SUCCESS) { - int id = check_free_joy_slot(); + int id = input->get_unused_joy_id(); if (id != -1 && !x_joypads[i].attached) { x_joypads[i].attached = true; diff --git a/platform/windows/joypad.h b/platform/windows/joypad.h index 63eee8c015..d6670c90db 100644 --- a/platform/windows/joypad.h +++ b/platform/windows/joypad.h @@ -132,7 +132,6 @@ private: void load_xinput(); void unload_xinput(); - int check_free_joy_slot() const; unsigned int post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad); bool have_device(const GUID &p_guid); |