Skip to content

Instantly share code, notes, and snippets.

@arpruss
Created February 21, 2023 05:45
Show Gist options
  • Select an option

  • Save arpruss/bc69fae73ec906423a0d59c85ad76a7f to your computer and use it in GitHub Desktop.

Select an option

Save arpruss/bc69fae73ec906423a0d59c85ad76a7f to your computer and use it in GitHub Desktop.
wiimote freepie script for Internet Arcade
wiiTranslate = { WiimoteButtons.DPadDown: Key.DownArrow,
WiimoteButtons.DPadUp: Key.UpArrow,
WiimoteButtons.DPadLeft: Key.LeftArrow,
WiimoteButtons.DPadRight: Key.RightArrow,
WiimoteButtons.B: Key.LeftControl,
WiimoteButtons.A: Key.LeftAlt
}
nunchuckTranslate = { NunchuckButtons.C: Key.LeftAlt, NunchuckButtons.Z: Key.LeftControl }
def translate(buttonDown,map):
for k in map:
if buttonDown(k):
keyboard.setKeyDown(map[k])
else:
keyboard.setKeyUp(map[k])
def stick(threshold,stick,up,down,left,right):
def axis(x, left, right):
if x <= -threshold:
keyboard.setKeyDown(left)
else:
keyboard.setKeyUp(left)
if x >= threshold:
keyboard.setKeyDown(right)
else:
keyboard.setKeyUp(right)
axis(stick.x,left,right)
axis(stick.y,down,up)
for i in range(2):
if wiimote[i].balanceBoard.weight:
diagnostics.watch(wiimote[i].balanceBoard.centerOfGravity)
stick(15,wiimote[i].balanceBoard.centerOfGravity, Key.UpArrow, Key.DownArrow, Key.LeftArrow, Key.RightArrow)
else:
translate(wiimote[i].buttons.button_down, wiiTranslate)
translate(wiimote[i].nunchuck.buttons.button_down, nunchuckTranslate)
stick(35,wiimote[i].nunchuck.stick, Key.UpArrow, Key.DownArrow, Key.LeftArrow, Key.RightArrow)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment