SDL  2.0
sort_controllers Namespace Reference

Functions

def save_controller
 
def write_controllers
 

Variables

string filename = "SDL_gamecontrollerdb.h"
 
tuple input = open(filename)
 
tuple output = open(filename + ".new", "w")
 
 parsing_controllers = False
 
list controllers = []
 
dictionary controller_guids = {}
 
tuple split_pattern = re.compile(r'([^"]*")([^,]*,)([^,]*,)([^"]*)(".*)')
 

Function Documentation

def sort_controllers.save_controller (   line)

Definition at line 16 of file sort_controllers.py.

Referenced by write_controllers().

16 
17 def save_controller(line):
18  global controllers
19  match = split_pattern.match(line)
20  entry = [ match.group(1), match.group(2), match.group(3) ]
21  bindings = sorted(match.group(4).split(","))
22  if (bindings[0] == ""):
23  bindings.pop(0)
24  entry.extend(",".join(bindings) + ",")
25  entry.append(match.group(5))
26  controllers.append(entry)
def sort_controllers.write_controllers ( )

Definition at line 27 of file sort_controllers.py.

References save_controller().

27 
28 def write_controllers():
29  global controllers
30  global controller_guids
31  for entry in sorted(controllers, key=lambda entry: entry[2]):
32  line = "".join(entry) + "\n"
33  line = line.replace("\t", " ")
34  if not line.endswith(",\n") and not line.endswith("*/\n"):
35  print("Warning: '%s' is missing a comma at the end of the line" % (line))
36  if (entry[1] in controller_guids):
37  print("Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2]))
38  controller_guids[entry[1]] = entry
39 
40  output.write(line)
41  controllers = []
42  controller_guids = {}

Variable Documentation

dictionary sort_controllers.controller_guids = {}

Definition at line 13 of file sort_controllers.py.

list sort_controllers.controllers = []

Definition at line 12 of file sort_controllers.py.

Referenced by SDL_GameControllerAddMappingsFromRW(), SDL_SYS_JoystickInit(), and SDL_SYS_MFIJoystickUpdate().

string sort_controllers.filename = "SDL_gamecontrollerdb.h"

Definition at line 8 of file sort_controllers.py.

Referenced by main().

tuple sort_controllers.input = open(filename)

Definition at line 9 of file sort_controllers.py.

tuple sort_controllers.output = open(filename + ".new", "w")

Definition at line 10 of file sort_controllers.py.

Referenced by SDL_LogOutput(), and stdlib_sscanf().

sort_controllers.parsing_controllers = False

Definition at line 11 of file sort_controllers.py.

tuple sort_controllers.split_pattern = re.compile(r'([^"]*")([^,]*,)([^,]*,)([^"]*)(".*)')

Definition at line 14 of file sort_controllers.py.