Code: Select all
#Mapping between a Player 1 Wii Remote and vJoy 2. Requires 15 vJoy buttons.
toggle1 = wiimote[0].buttons.button_down(WiimoteButtons.A)
toggle2 = wiimote[0].buttons.button_down(WiimoteButtons.B)
def pair(vJoyButton, WiimoteButton):
vJoy[1].setButton(vJoyButton, wiimote[0].buttons.button_down(WiimoteButton))
#This mapping will be used when not pressing a toggle.
def noToggleMap():
pair(0, WiimoteButtons.DPadUp)
pair(1, WiimoteButtons.DPadDown)
pair(2, WiimoteButtons.DPadLeft)
pair(3, WiimoteButtons.DPadRight)
pair(4, WiimoteButtons.A)
pair(5, WiimoteButtons.B)
pair(6, WiimoteButtons.One)
pair(7, WiimoteButtons.Two)
pair(8, WiimoteButtons.Minus)
pair(9, WiimoteButtons.Plus)
pair(10, WiimoteButtons.Home)
vJoy[1].setButton(11, False)
vJoy[1].setButton(12, False)
vJoy[1].setButton(13, False)
vJoy[1].setButton(14, False)
#This mapping will be used when holding toggle1.
def toggle1Map():
pair(0, WiimoteButtons.DPadUp)
pair(1, WiimoteButtons.DPadDown)
pair(2, WiimoteButtons.DPadLeft)
pair(3, WiimoteButtons.DPadRight)
pair(4, WiimoteButtons.A)
pair(5, WiimoteButtons.B)
pair(11, WiimoteButtons.One)
pair(12, WiimoteButtons.Two)
pair(8, WiimoteButtons.Minus)
pair(9, WiimoteButtons.Plus)
pair(10, WiimoteButtons.Home)
vJoy[1].setButton(6, False)
vJoy[1].setButton(7, False)
vJoy[1].setButton(13, False)
vJoy[1].setButton(14, False)
#This mapping will be used for Wiimote Axis
vJoy[1].x = wiimote[0].acceleration.x
vJoy[1].y = wiimote[0].acceleration.y
vJoy[1].z = wiimote[0].acceleration.z
#This mapping will be used when holding toggle2.
def toggle2Map():
pair(0, WiimoteButtons.DPadUp)
pair(1, WiimoteButtons.DPadDown)
pair(2, WiimoteButtons.DPadLeft)
pair(3, WiimoteButtons.DPadRight)
pair(4, WiimoteButtons.A)
pair(5, WiimoteButtons.B)
pair(13, WiimoteButtons.One)
pair(14, WiimoteButtons.Two)
pair(8, WiimoteButtons.Minus)
pair(9, WiimoteButtons.Plus)
pair(10, WiimoteButtons.Home)
vJoy[1].setButton(6, False)
vJoy[1].setButton(7, False)
vJoy[1].setButton(11, False)
vJoy[1].setButton(12, False)
#Update subroutine
def updateWiimote():
if toggle2:
toggle2Map()
elif toggle1:
toggle1Map()
else:
noToggleMap()
#Actually apply update subroutine at start up
if starting:
wiimote[0].buttons.update += updateWiimote