Created
December 20, 2014 01:59
-
-
Save bb010g/98c449a369b551f904b8 to your computer and use it in GitHub Desktop.
Super Smash Land FreePIE Config
This file contains hidden or 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
def setKeyB(key, pred): | |
if pred: | |
keyboard.setKeyDown(key) | |
elif keyboard.getKeyDown(key): | |
keyboard.setKeyUp(key) | |
def tapKeyB(key, pred): | |
if pred: | |
keyboard.setKeyDown(key) | |
keyboard.setKeyUp(key) | |
def setKeyJ(key, stick, dir): | |
if (abs(stick) > .5) & (math.copysign(1, stick) == dir): | |
keyboard.setKeyDown(key) | |
elif keyboard.getKeyDown(key): | |
keyboard.setKeyUp(key) | |
def setKeysJ(keys, exclude, stick, dir): | |
if (abs(stick) > .5) & (math.copysign(1, stick) == dir): | |
for key in exclude: | |
keyboard.setKeyUp(key) | |
for key in keys: | |
keyboard.setKeyDown(key) | |
def gamecube(stick): | |
return 1. * stick / 700. | |
gc_x = 0 | |
gc_a = 1 | |
gc_b = 2 | |
gc_y = 3 | |
gc_z = 7 | |
gc_start = 9 | |
class FakeJoy(): | |
def getDown(self, button): | |
return False | |
x = 0 | |
y = 0 | |
z = 0 | |
zRotation = 0 | |
try: | |
joystick[0] | |
except IndexError: | |
joystick = [FakeJoy(), FakeJoy(), FakeJoy(), FakeJoy()] | |
try: | |
joystick[1] | |
except IndexError: | |
joystick = [FakeJoy(), FakeJoy(), FakeJoy(), FakeJoy()] | |
key_start = Key.Return | |
key_select = Key.Backspace | |
p1 = dict( | |
u = Key.UpArrow, | |
d = Key.DownArrow, | |
l = Key.LeftArrow, | |
r = Key.RightArrow, | |
a = Key.X, | |
b = Key.Z, | |
jy = xbox360[0].leftStickY - gamecube(joystick[0].y), | |
jx = xbox360[0].leftStickX + gamecube(joystick[0].x), | |
cy = xbox360[0].rightStickY - gamecube(joystick[0].z), | |
cx = xbox360[0].rightStickX + gamecube(joystick[0].zRotation), | |
ia = xbox360[0].b | joystick[0].getDown(gc_a), | |
ia_t = xbox360[0].a | joystick[0].getDown(gc_b), | |
ib = xbox360[0].x | xbox360[0].y | joystick[0].getDown(gc_x) | joystick[0].getDown(gc_y), | |
istart = xbox360[0].start | joystick[0].getDown(gc_start), | |
iselect = xbox360[0].back | joystick[0].getDown(gc_z) | |
) | |
p2 = dict( | |
u = Key.W, | |
d = Key.S, | |
l = Key.A, | |
r = Key.D, | |
a = Key.R, | |
b = Key.E, | |
jy = xbox360[1].leftStickY - gamecube(joystick[1].y), | |
jx = xbox360[1].leftStickX + gamecube(joystick[1].x), | |
cy = xbox360[1].rightStickY - gamecube(joystick[1].z), | |
cx = xbox360[1].rightStickX + gamecube(joystick[1].zRotation), | |
ia = xbox360[1].b | joystick[1].getDown(gc_a), | |
ia_t = xbox360[1].a | joystick[1].getDown(gc_b), | |
ib = xbox360[1].x | xbox360[1].y | joystick[1].getDown(gc_x) | joystick[1].getDown(gc_y), | |
istart = xbox360[1].start | joystick[1].getDown(gc_start), | |
iselect = xbox360[1].back | joystick[1].getDown(gc_z) | |
) | |
players = [p1, p2] | |
def update(): | |
setKeyB(key_start, reduce(lambda acc, p: acc | p['istart'], players, False)) | |
setKeyB(key_select, reduce(lambda acc, p: acc | p['iselect'], players, False)) | |
for p in players: | |
setKeyJ(p['u'], p['jy'], 1) | |
setKeyJ(p['d'], p['jy'], -1) | |
setKeyJ(p['l'], p['jx'], -1) | |
setKeyJ(p['r'], p['jx'], 1) | |
setKeyB(p['a'], p['ia']) | |
tapKeyB(p['a'], p['ia_t']) | |
setKeyB(p['b'], p['ib']) | |
setKeysJ([p['a'], p['u']], [p['d'], p['l'], p['r']], p['cy'], 1) | |
setKeysJ([p['a'], p['d']], [p['u'], p['l'], p['r']], p['cy'], -1) | |
setKeysJ([p['a'], p['l']], [p['u'], p['d'], p['r']], p['cx'], -1) | |
setKeysJ([p['a'], p['r']], [p['u'], p['d'], p['l']], p['cx'], 1) | |
update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment