From 0584c7f0947eafedee50aa0d47483b3136fc8cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 8 Jan 2020 11:43:44 +0100 Subject: [PATCH] Gamepad: Parse SDL_GAMECONTROLLERCONFIG env after default mappings Addresses comment https://github.com/godotengine/godot/issues/21918#issuecomment-458764923. --- main/input_default.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/main/input_default.cpp b/main/input_default.cpp index 820069dba32..a13ddeb2b6b 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -727,9 +727,17 @@ InputDefault::InputDefault() { fallback_mapping = -1; + // Parse default mappings. + { + int i = 0; + while (DefaultControllerMappings::mappings[i]) { + parse_mapping(DefaultControllerMappings::mappings[i++]); + } + } + + // If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides. String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG"); if (env_mapping != "") { - Vector entries = env_mapping.split("\n"); for (int i = 0; i < entries.size(); i++) { if (entries[i] == "") @@ -737,12 +745,6 @@ InputDefault::InputDefault() { parse_mapping(entries[i]); } } - - int i = 0; - while (DefaultControllerMappings::mappings[i]) { - - parse_mapping(DefaultControllerMappings::mappings[i++]); - } } void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {