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  # Check for duplicates
32  for entry in controllers:
33  if (entry[1] in controller_guids):
34  current_name = entry[2]
35  existing_name = controller_guids[entry[1]][2]
36  print("Warning: entry '%s' is duplicate of entry '%s'" % (current_name, existing_name))
37 
38  if (not current_name.startswith("(DUPE)")):
39  entry[2] = "(DUPE) " + current_name
40 
41  if (not existing_name.startswith("(DUPE)")):
42  controller_guids[entry[1]][2] = "(DUPE) " + existing_name
43 
44  controller_guids[entry[1]] = entry
45 
46  for entry in sorted(controllers, key=lambda entry: entry[2]+"-"+entry[1]):
47  line = "".join(entry) + "\n"
48  line = line.replace("\t", " ")
49  if not line.endswith(",\n") and not line.endswith("*/\n"):
50  print("Warning: '%s' is missing a comma at the end of the line" % (line))
51  output.write(line)
52 
53  controllers = []
54  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 IOS_JoystickInit(), IOS_MFIJoystickUpdate(), and SDL_GameControllerAddMappingsFromRW().

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 main(), 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.