src/joystick/sort_controllers.py
author Sam Lantinga
Fri, 27 Jan 2017 21:23:27 -0800
changeset 10861 71d8f9afb690
parent 9205 5302aee2916a
child 11430 884105e0943f
permissions -rwxr-xr-x
Fixed bug 3569 - GL_UpdateViewport leaves PROJECTION matrix selected

Tom Seddon

GL_ActivateRenderer may call GL_UpdateViewport, which leaves the GL_PROJECTION matrix selected. But after GL_ResetState, the GL_MODELVIEW matrix is selected, suggesting that's the intended default state.

It seems at least like these should be consistent. Presumably GL_UpdateViewport should be doing a glMatrixMode(GL_MODELVIEW) before it finishes.
     1 #!/usr/bin/env python
     2 #
     3 # Script to sort the game controller database entries in SDL_gamecontroller.c
     4 
     5 import re
     6 
     7 
     8 filename = "SDL_gamecontrollerdb.h"
     9 input = open(filename)
    10 output = open(filename + ".new", "w")
    11 parsing_controllers = False
    12 controllers = []
    13 controller_guids = {}
    14 split_pattern = re.compile(r'([^"]*")([^,]*,)([^,]*,)([^"]*)(".*)')
    15 
    16 def save_controller(line):
    17     global controllers
    18     match = split_pattern.match(line)
    19     entry = [ match.group(1), match.group(2), match.group(3) ]
    20     bindings = sorted(match.group(4).split(","))
    21     if (bindings[0] == ""):
    22         bindings.pop(0)
    23     entry.extend(",".join(bindings) + ",")
    24     entry.append(match.group(5))
    25     controllers.append(entry)
    26 
    27 def write_controllers():
    28     global controllers
    29     global controller_guids
    30     for entry in sorted(controllers, key=lambda entry: entry[2]):
    31         line = "".join(entry) + "\n"
    32         if not line.endswith(",\n") and not line.endswith("*/\n"):
    33             print("Warning: '%s' is missing a comma at the end of the line" % (line))
    34         if (entry[1] in controller_guids):
    35             print("Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2]))
    36         controller_guids[entry[1]] = entry
    37 
    38         output.write(line)
    39     controllers = []
    40     controller_guids = {}
    41 
    42 for line in input:
    43     if (parsing_controllers):
    44         if (line.startswith("{")):
    45             output.write(line)
    46         elif (line.startswith("    NULL")):
    47             parsing_controllers = False
    48             write_controllers()
    49             output.write(line)
    50         elif (line.startswith("#if")):
    51             print("Parsing " + line.strip())
    52             output.write(line)
    53         elif (line.startswith("#endif")):
    54             write_controllers()
    55             output.write(line)
    56         else:
    57             save_controller(line)
    58     else:
    59         if (line.startswith("static const char *s_ControllerMappings")):
    60             parsing_controllers = True
    61 
    62         output.write(line)
    63 
    64 output.close()
    65 print("Finished writing %s.new" % filename)