1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

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
This commit is contained in:
Andreas Haas
2017-03-25 23:41:00 +01:00
parent ed3134088b
commit 8c06da0d49
8 changed files with 20 additions and 42 deletions

View File

@@ -1157,6 +1157,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 < JOYSTICKS_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];