Advertisement
miguelmartins1987

FreePIE Wiimote to Keyboard

Dec 29th, 2013
2,332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. #This is a script for FreePIE (http://andersmalmgren.github.io/FreePIE/)
  2. #It maps buttons on Wiimote 0 to keys on the keyboard
  3. #Hopefully, this will help people having trouble making a simple "Wiimote to Keyboard" script
  4. #I'm releasing this under public domain. I assume there's no problem with that?
  5.  
  6. def map_wiimote_to_key(wiimote_index, wiimote_button, key):
  7.     if wiimote[wiimote_index].buttons.button_down(wiimote_button):
  8.         keyboard.setKeyDown(key)
  9.     else:
  10.         keyboard.setKeyUp(key)
  11.  
  12. def update():
  13.     #Sideways controls (DPad)
  14.     map_wiimote_to_key(0, WiimoteButtons.DPadRight, Key.UpArrow)
  15.     map_wiimote_to_key(0, WiimoteButtons.DPadLeft, Key.DownArrow)
  16.     map_wiimote_to_key(0, WiimoteButtons.DPadUp, Key.LeftArrow)
  17.     map_wiimote_to_key(0, WiimoteButtons.DPadDown, Key.RightArrow)
  18.     #1 button --> Z key
  19.     map_wiimote_to_key(0, WiimoteButtons.One, Key.Z)
  20.     #2 button --> X key
  21.     map_wiimote_to_key(0, WiimoteButtons.Two, Key.X)
  22.     #- button --> Right shift key
  23.     map_wiimote_to_key(0, WiimoteButtons.Minus, Key.RightShift)
  24.     #+ button --> Enter key
  25.     map_wiimote_to_key(0, WiimoteButtons.Plus, Key.Return)
  26.  
  27. if starting:
  28.     wiimote[0].buttons.update += update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement