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/x11 | |
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/x11')
-rw-r--r-- | platform/x11/joypad_linux.cpp | 11 | ||||
-rw-r--r-- | platform/x11/joypad_linux.h | 1 |
2 files changed, 1 insertions, 11 deletions
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp index 362999661e..bdbd2912a6 100644 --- a/platform/x11/joypad_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -219,15 +219,6 @@ void JoypadLinux::monitor_joypads() { } } -int JoypadLinux::get_free_joy_slot() const { - - for (int i = 0; i < JOYPADS_MAX; i++) { - - if (joypads[i].fd == -1) return i; - } - return -1; -} - int JoypadLinux::get_joy_from_path(String p_path) const { for (int i = 0; i < JOYPADS_MAX; i++) { @@ -329,7 +320,7 @@ void JoypadLinux::setup_joypad_properties(int p_id) { void JoypadLinux::open_joypad(const char *p_path) { - int joy_num = get_free_joy_slot(); + int joy_num = input->get_unused_joy_id(); int fd = open(p_path, O_RDWR | O_NONBLOCK); if (fd != -1 && joy_num != -1) { diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h index 18ad199f6b..310f5c1488 100644 --- a/platform/x11/joypad_linux.h +++ b/platform/x11/joypad_linux.h @@ -81,7 +81,6 @@ private: static void joy_thread_func(void *p_user); int get_joy_from_path(String path) const; - int get_free_joy_slot() const; void setup_joypad_properties(int p_id); void close_joypad(int p_id = -1); |