-
-
Save boomlinde/3108517639b70d772275f8499c908ff5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
mist = { | |
'right': 0x01, 'left': 0x02, 'down': 0x04, 'up': 0x08, | |
'a': 0x10, 'b': 0x20, 'select': 0x40, 'start': 0x80, | |
'x': 0x100, 'y': 0x200, 'l': 0x400, 'r': 0x800, | |
'l2': 0x1000, 'r2': 0x2000, 'l3': 0x4000, 'r3': 0x8000, | |
} | |
cpsgames = [ | |
'dino', 'sf2', 'punisher', 'knights', 'ffight', 'varth', | |
] | |
controllers = [ | |
{ | |
'name': 'Retro-Bit Official Sega Genesis USB Controller 8-Button Arcade Pad', | |
'buttons': ( | |
'right', 'left', 'down', 'up', | |
'y', 'b', 'a', 'x', 'l', 'r', 'z', 'c', 'mode', 'start' | |
), | |
'vid': 0x0f0d, | |
'pid': 0x00c1, | |
'mappings': { | |
'default': { | |
'right': 'right', 'left': 'left', 'down': 'down', 'up': 'up', | |
'a': 'b', 'b': 'a', 'x': 'y', 'y': 'x', | |
'l': 'l', 'r': 'r', 'start': 'start', 'mode': 'select', | |
}, | |
'genesis': { | |
'right': 'right', 'left': 'left', 'down': 'down', 'up': 'up', | |
'a': 'a', 'b': 'b', 'c': 'select', 'x': 'x', 'y': 'y', 'z': 'l', | |
'start': 'start', 'mode': 'r', | |
}, | |
'snes': { | |
'right': 'right', 'left': 'left', 'down': 'down', 'up': 'up', | |
'a': 'b', 'b': 'a', 'x': 'y', 'y': 'x', | |
'l': 'l', 'r': 'r', 'start': 'start', 'mode': 'select', | |
}, | |
'nes': { | |
'right': 'right', 'left': 'left', 'down': 'down', 'up': 'up', | |
'a': 'b', 'b': 'a', 'start': 'start', 'mode': 'select', | |
}, | |
'cps': { | |
'right': 'right', 'left': 'left', 'down': 'down', 'up': 'up', | |
'a': 'a', 'b': 'b', 'c': 'select', 'x': 'start', 'y': 'x', | |
'z': 'y', 'mode': 'r', 'start': 'l' | |
}, | |
'ecofghtr': { | |
'right': 'right', 'left': 'left', 'down': 'down', 'up': 'up', | |
'a': 'a', 'b': 'b', 'c': 'select', 'x': 'start', 'y': 'x', | |
'z': 'y', 'mode': 'r', 'start': 'l', 'l': 'a', 'r': 'select', | |
}, | |
}, | |
}, | |
] | |
def mapctrl(mapping, button): | |
return '%x' % mist.get(mapping.get(button, ''), 0) | |
if __name__ == '__main__': | |
if len(sys.argv) == 1: | |
for i, c in enumerate(controllers): | |
print '%d:\t%s (%04x,%04x %s)' % (i, c['name'], c['vid'], c['pid'], ', '.join(c['buttons'])) | |
sys.exit(0) | |
c = controllers[int(sys.argv[1])] | |
mappings = c['mappings'] | |
for m in mappings: | |
a = [m] | |
if m == 'cps': | |
a = cpsgames | |
for x in a: | |
if x != 'default': | |
print '[%s]' % x | |
out = ['%04x' % c['vid'], '%04x' % c['pid']] + [ | |
mapctrl(mappings[m], button) | |
for button in c['buttons'] | |
] | |
print 'joystick_remap=' + ','.join(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to list numbered controllers
to output mapping config for the MiST for controller 0.