sort_controllers Namespace Reference

## Functions

def | save_controller (line)
def | write_controllers ()

## Variables

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

## Function Documentation

## save_controller()

def sort_controllers.save_controller | ( |  | line | ) |

Definition at line 16 of file sort_controllers.py.

Referenced by write_controllers().

def save_controller(line):
global controllers
match = split_pattern.match(line)
entry = [ match.group(1), match.group(2), match.group(3) ]
bindings = sorted(match.group(4).split(","))
if (bindings[0] == ""):
bindings.pop(0)
entry.extend(",".join(bindings) + ",")
entry.append(match.group(5))
controllers.append(entry)
sort_controllers.save_controller
def save_controller(line)
Definition: sort_controllers.py:16

## write_controllers()

def sort_controllers.write_controllers | ( |  | ) |

Definition at line 27 of file sort_controllers.py.

References save_controller().

def write_controllers():
global controllers
global controller_guids
for entry in sorted(controllers, key=lambda entry: entry[2]):
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 = {}
sort_controllers.write_controllers
def write_controllers()
Definition: sort_controllers.py:27

## Variable Documentation

## controller_guids

dictionary sort_controllers.controller_guids = {}

Definition at line 13 of file sort_controllers.py.

## controllers

list sort_controllers.controllers = []

Definition at line 12 of file sort_controllers.py.

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

## filename

string sort_controllers.filename = "SDL_gamecontrollerdb.h"

Definition at line 8 of file sort_controllers.py.

Referenced by main().

## input

sort_controllers.input = open(filename)

Definition at line 9 of file sort_controllers.py.

## output

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

Definition at line 10 of file sort_controllers.py.

Referenced by main(), SDL_LogOutput(), and stdlib_sscanf().

## parsing_controllers

bool sort_controllers.parsing_controllers = False

Definition at line 11 of file sort_controllers.py.

## split_pattern

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

Definition at line 14 of file sort_controllers.py.