Skip to content

Commit

Permalink
Gamepad: Parse SDL_GAMECONTROLLERCONFIG env after default mappings
Browse files Browse the repository at this point in the history
Addresses comment godotengine#21918 (comment).
  • Loading branch information
akien-mga committed Jan 8, 2020
1 parent ed22a4c commit 0584c7f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions main/input_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,22 +727,24 @@ 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<String> entries = env_mapping.split("\n");
for (int i = 0; i < entries.size(); i++) {
if (entries[i] == "")
continue;
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) {
Expand Down

0 comments on commit 0584c7f

Please sign in to comment.