Fixed gamecontroller database sorting script not sorting the whole database.
authorPhilipp Wiesemann
Wed, 29 Oct 2014 22:44:35 +0100
changeset 92055302aee2916a
parent 9204 b331795924d3
child 9206 f20d288435bd
Fixed gamecontroller database sorting script not sorting the whole database.

The script was originally written for an SDL_gamecontrollerdb.h which had groups
of mappings separated by single lines starting with a "#". This was changed some
time ago to #endif/#if pairs. Because the script assumed only a single #endif in
the whole file it no longer worked correctly and only processed the first group.
src/joystick/sort_controllers.py
     1.1 --- a/src/joystick/sort_controllers.py	Wed Oct 29 22:41:01 2014 +0100
     1.2 +++ b/src/joystick/sort_controllers.py	Wed Oct 29 22:44:35 2014 +0100
     1.3 @@ -40,15 +40,17 @@
     1.4      controller_guids = {}
     1.5  
     1.6  for line in input:
     1.7 -    if ( parsing_controllers ):
     1.8 +    if (parsing_controllers):
     1.9          if (line.startswith("{")):
    1.10              output.write(line)
    1.11 -        elif (line.startswith("#endif")):
    1.12 +        elif (line.startswith("    NULL")):
    1.13              parsing_controllers = False
    1.14              write_controllers()
    1.15              output.write(line)
    1.16 -        elif (line.startswith("#")):
    1.17 +        elif (line.startswith("#if")):
    1.18              print("Parsing " + line.strip())
    1.19 +            output.write(line)
    1.20 +        elif (line.startswith("#endif")):
    1.21              write_controllers()
    1.22              output.write(line)
    1.23          else: