I am trying to write a script that maps Wii Remote (no Nunchuck) buttons to vJoy virtual buttons. It involves reserving the A and B buttons as toggles to switch mappings (of just the Wii Remote's One and Two buttons, at the moment). Everything seems to work save the following problem:
After holding down a toggle, holding down either the One or Two button, and releasing the toggle; the One/Two button will continue to fire after its own release. In order to stop One/Two from firing, a toggle button has to be repressed (or released after the release of One/Two). I would like One/Two to not continuously fire regardless of the button release order. Thank you kindly in advance for your thoughts and comments!
I am running Windows 7 Home Premium SP1 64-bit, FreePIE 1.9.611.0, vJoy 2.0.5-050515 (latest), and the WIDCOMM (Broadcom) Bluetooth Stack 6.5.0.3200 that came with my ASUS Maximus V Formula motherboard and its integrated Bluetooth solution. I am using a RVL-CNT-01 (non -TR), black, Wii MotionPlus Wii Remote. I have tested with ppJoy but only have one of vJoy or ppJoy installed at a given time.
Disclaimer: I am not a programmer nor very knowledgeable about Python.
Code: Select all
#Mapping between a Player 1 Wii Remote and vJoy 2. Requires 15 vJoy buttons.
#No Toggle
def noTogglePair(vJoyButton, WiimoteButton):
vJoy[1].setButton(vJoyButton, wiimote[0].buttons.button_down(WiimoteButton))
#This mapping will be used when not pressing a toggle.
def noToggleMap():
noTogglePair(0, WiimoteButtons.DPadUp)
noTogglePair(1, WiimoteButtons.DPadDown)
noTogglePair(2, WiimoteButtons.DPadLeft)
noTogglePair(3, WiimoteButtons.DPadRight)
noTogglePair(4, WiimoteButtons.A)
noTogglePair(5, WiimoteButtons.B)
noTogglePair(6, WiimoteButtons.One)
noTogglePair(7, WiimoteButtons.Two)
noTogglePair(8, WiimoteButtons.Minus)
noTogglePair(9, WiimoteButtons.Plus)
noTogglePair(10, WiimoteButtons.Home)
#Toggle 1
Toggle1 = WiimoteButtons.A
def Toggle1Pair(vJoyButton, WiimoteButton):
vJoy[1].setButton(vJoyButton, wiimote[0].buttons.button_down(Toggle1 and WiimoteButton))
#This mapping will be used when holding the above toggle.
def Toggle1Map():
Toggle1Pair(0, WiimoteButtons.DPadUp)
Toggle1Pair(1, WiimoteButtons.DPadDown)
Toggle1Pair(2, WiimoteButtons.DPadLeft)
Toggle1Pair(3, WiimoteButtons.DPadRight)
Toggle1Pair(4, WiimoteButtons.A)
Toggle1Pair(5, WiimoteButtons.B)
Toggle1Pair(11, WiimoteButtons.One)
Toggle1Pair(12, WiimoteButtons.Two)
Toggle1Pair(8, WiimoteButtons.Minus)
Toggle1Pair(9, WiimoteButtons.Plus)
Toggle1Pair(10, WiimoteButtons.Home)
#Toggle 2
Toggle2 = WiimoteButtons.B
def Toggle2Pair(vJoyButton, WiimoteButton):
vJoy[1].setButton(vJoyButton, wiimote[0].buttons.button_down(Toggle2 and WiimoteButton))
#This mapping will be used when holding the above toggle.
def Toggle2Map():
Toggle2Pair(0, WiimoteButtons.DPadUp)
Toggle2Pair(1, WiimoteButtons.DPadDown)
Toggle2Pair(2, WiimoteButtons.DPadLeft)
Toggle2Pair(3, WiimoteButtons.DPadRight)
Toggle2Pair(4, WiimoteButtons.A)
Toggle2Pair(5, WiimoteButtons.B)
Toggle2Pair(13, WiimoteButtons.One)
Toggle2Pair(14, WiimoteButtons.Two)
Toggle2Pair(8, WiimoteButtons.Minus)
Toggle2Pair(9, WiimoteButtons.Plus)
Toggle2Pair(10, WiimoteButtons.Home)
#Update subroutine
def updateWiimote():
if wiimote[0].buttons.button_down(Toggle2):
Toggle2Map()
elif wiimote[0].buttons.button_down(Toggle1):
Toggle1Map()
else:
noToggleMap()
#Actually apply update subroutine at start up
if starting:
wiimote[0].buttons.update += updateWiimote