diff options
author | chai <chaifix@163.com> | 2019-01-31 18:38:35 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-31 18:38:35 +0800 |
commit | 2ec55fd974a63b705a4777c256d2222c874fa043 (patch) | |
tree | 48f1fea59ee9fc713a28a9aac3f05b98dc5ae66f /Source/3rdParty/SDL2/src/joystick/sort_controllers.py | |
parent | c581dfbf1e849f393861d15e82aa6446c0c1c310 (diff) |
*SDL project
Diffstat (limited to 'Source/3rdParty/SDL2/src/joystick/sort_controllers.py')
-rw-r--r-- | Source/3rdParty/SDL2/src/joystick/sort_controllers.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Source/3rdParty/SDL2/src/joystick/sort_controllers.py b/Source/3rdParty/SDL2/src/joystick/sort_controllers.py index 47213c2..32f065a 100644 --- a/Source/3rdParty/SDL2/src/joystick/sort_controllers.py +++ b/Source/3rdParty/SDL2/src/joystick/sort_controllers.py @@ -27,16 +27,28 @@ def save_controller(line): def write_controllers(): global controllers global controller_guids - for entry in sorted(controllers, key=lambda entry: entry[2]): + # Check for duplicates + for entry in controllers: + if (entry[1] in controller_guids): + current_name = entry[2] + existing_name = controller_guids[entry[1]][2] + print("Warning: entry '%s' is duplicate of entry '%s'" % (current_name, existing_name)) + + if (not current_name.startswith("(DUPE)")): + entry[2] = "(DUPE) " + current_name + + if (not existing_name.startswith("(DUPE)")): + controller_guids[entry[1]][2] = "(DUPE) " + existing_name + + controller_guids[entry[1]] = entry + + for entry in sorted(controllers, key=lambda entry: entry[2]+"-"+entry[1]): line = "".join(entry) + "\n" line = line.replace("\t", " ") if not line.endswith(",\n") and not line.endswith("*/\n"): print("Warning: '%s' is missing a comma at the end of the line" % (line)) - if (entry[1] in controller_guids): - print("Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2])) - controller_guids[entry[1]] = entry - output.write(line) + controllers = [] controller_guids = {} |