It is currently Sun Nov 18, 2018 3:07 pm



Reply to topic  [ 3 posts ] 
 Need help making a sript for wiimote motion for vjoy 
Author Message
One Eyed Hopeful

Joined: Mon May 02, 2016 11:49 am
Posts: 1
Reply with quote
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:
#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


Mon May 02, 2016 12:04 pm
Profile
One Eyed Hopeful

Joined: Sat Jun 02, 2018 1:24 pm
Posts: 2
Reply with quote
Hey did you ever figure this out?


Sat Jun 02, 2018 1:25 pm
Profile
Cross Eyed!

Joined: Mon Mar 02, 2015 3:58 pm
Posts: 119
Reply with quote
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.php?f=139&t=22821


Mon Jun 04, 2018 2:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.