diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-02-26 21:30:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-26 21:30:24 +0100 |
commit | 34a0aa6900880235f2ca78a7631f30cd3e3ecb2c (patch) | |
tree | 3287927e4f90dc9a6c0c1d9487780407fdc610fc /main | |
parent | 3de1415b6a0e3ad5bb39b6bcc3958305b0d415d4 (diff) | |
parent | a175ac7032407af8e0ffe9fcb23edd5b57c6548f (diff) |
Merge pull request #7862 from Hinsbart/joypad_connections
Better handling of joypad device IDs.
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 9 | ||||
-rw-r--r-- | main/input_default.h | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index 0561f2bb34..a9f643c785 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -1214,6 +1214,15 @@ int InputDefault::get_joy_button_index_from_string(String p_button) { ERR_FAIL_V(-1); } +int InputDefault::get_unused_joy_id() { + for (int i=0;i<JOYPADS_MAX;i++) { + if (!joy_names.has(i) || !joy_names[i].connected) { + return i; + } + } + return -1; +} + String InputDefault::get_joy_axis_string(int p_axis) { ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, ""); return _axes[p_axis]; diff --git a/main/input_default.h b/main/input_default.h index 3e41c494c1..78bc0f4355 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -134,6 +134,11 @@ public: HAT_LEFT, HAT_MAX, }; + + enum { + JOYPADS_MAX = 16, + }; + struct JoyAxis { int min; float value; @@ -243,6 +248,8 @@ public: virtual int get_joy_axis_index_from_string(String p_axis); virtual int get_joy_button_index_from_string(String p_button); + int get_unused_joy_id(); + bool is_joy_mapped(int p_device); String get_joy_guid_remapped(int p_device) const; void set_fallback_mapping(String p_guid); |