Page 1 of 1

Need help making a sript for wiimote motion for vjoy

Posted: Mon May 02, 2016 12:04 pm
by Ea4492
Does anyone have a script or know how to write one for the wiimotes axis to vjoy. I used to use Glovepie with ppjoy, but ppjoy is dead and doesnt work in windows 10. Im trying to use the wiimote as a steering wheel for Racing games in MAME and other emulators. i have a script and i managed to get motion mapped but it doesnt work right. Thanks in advance.

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

Re: Need help making a sript for wiimote motion for vjoy

Posted: Sat Jun 02, 2018 1:25 pm
by TheDeadeye
Hey did you ever figure this out?

Re: Need help making a sript for wiimote motion for vjoy

Posted: Mon Jun 04, 2018 2:33 am
by Jabberwock
That script is not working because Wii acceleration values are rather different than vJoy axis values, so you cannot map them one to one, you also have to consider Earth's acceleration. Moreover, using all axes at the same time is not practical, as it is somewhat hard to account for that by moving the Wiimote in 3D space. For a simple implementation of the wheel axis see this thread:

https://www.mtbs3d.com/phpbb/viewtopic. ... 39&t=22821