IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJJJJJJJJJJJKKKKKKKKKKKKKKKKKKKKLLLLLLLLLLLLLLLLLLLL instead of just IJKL.
Do I need to add anything extra like deadzones or timing interval?
Code: Select all
def analogStick():
if wiimote[0].nunchuck.stick.y > 40:
keyboard.setPressed(Key.I)
if wiimote[0].nunchuck.stick.y < -40:
keyboard.setPressed(Key.K)
if wiimote[0].nunchuck.stick.x > 40:
keyboard.setPressed(Key.L)
if wiimote[0].nunchuck.stick.x < -40:
keyboard.setPressed(Key.J)
def map_wiimote_to_key(wiimote_index, wiimote_button, key):
# Check the global wiimote object's button state and set the global
# keyboard object's corresponding key.
if wiimote[wiimote_index].buttons.button_down(wiimote_button):
keyboard.setKeyDown(key)
else:
keyboard.setKeyUp(key)
def map_nunchuck_to_key(wiimote_index, wiimote_button, key):
# Check the global nunchuck object's button state and set the global
# keyboard object's corresponding key.
if wiimote[wiimote_index].nunchuck.buttons.button_down(wiimote_button):
keyboard.setKeyDown(key)
else:
keyboard.setKeyUp(key)
def update():
# Sideways controls (DPad). Map each of our desired keys.
map_wiimote_to_key(0, WiimoteButtons.DPadRight, Key.D)
map_wiimote_to_key(0, WiimoteButtons.DPadLeft, Key.A)
map_wiimote_to_key(0, WiimoteButtons.DPadUp, Key.W)
map_wiimote_to_key(0, WiimoteButtons.DPadDown, Key.S)
# 1 button --> 1 key
map_wiimote_to_key(0, WiimoteButtons.One, Key.D1)
# 2 button --> 2 key
map_wiimote_to_key(0, WiimoteButtons.Two, Key.D2)
# - button --> - key
map_wiimote_to_key(0, WiimoteButtons.Minus, Key.Minus)
# + button --> + key
map_wiimote_to_key(0, WiimoteButtons.Plus, Key.NumberPadPlus)
# A button --> X key
map_wiimote_to_key(0, WiimoteButtons.A, Key.X)
# B button --> B key
map_wiimote_to_key(0, WiimoteButtons.B, Key.B)
# Home button --> Return key
map_wiimote_to_key(0, WiimoteButtons.Home, Key.Return)
#nunchuck
map_nunchuck_to_key(0, NunchuckButtons.C, Key.C)
map_nunchuck_to_key(0, NunchuckButtons.Z, Key.Z)
# If we're starting up, then hook up our update function.
if starting:
global previous
previous = False
wiimote[0].nunchuck.update += analogStick
wiimote[0].buttons.update += update