Wiimote Script inspired by JSM

Official forum for open source FreePIE discussion and development.
Post Reply
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Wiimote Script inspired by JSM

Post by GermanSani »

Hi,

I wrote a script that simulates the use of a Wiimote, in combination with a Nunchuck, as a Gyromouse.
I got the inspiration for many things in it from the Joyshock Mapper which is made by JibbSmart.

So far I have only tested it on Win10 with a -TR-Remote with inbuilt Motion Plus. But I guess that it should work fine also with a Motion-Plus adapter.
Let me know if there's anyting not working right or if you have any kind of feedback.
I'll try to help as much as I can with my quite basic programming skills but am surely willing to learn as well. ^^

Thank you and have fun :)
You do not have the required permissions to view the files attached to this post.
Last edited by GermanSani on Fri Jun 04, 2021 12:12 pm, edited 16 times in total.
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

New Version, new features:

- Possibility to make the Cursor move faster by a multiplier when moving the Wiimote faster around (I called it "SpeedBoost")

- Added the possibility of "Hold-Mapping".
This means you now can assign two additional keys to most buttons, one that will be pressed when you keep the button pressed for a certain (configurable) time and one that is pressed when you just tap the button.
So now you can theoretically assign up to 64 keys, practically you can use up to 38.

I have tried to test it as good as possible but if you encounter any errors feel free to tell me about it. :)
Last edited by GermanSani on Fri Apr 30, 2021 11:06 am, edited 1 time in total.
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

So, another update as I just had a little bit more time to spend:

- Possibility to hold the Wiimote horizontally
- Nunchuck can now als be removed
- Options to adjust cursor movement for TR and Non-TR-Wiimotes
- Pressing the GyroOff-Button and having RememberSpeed enabled will now gradually slow down the cursor (configurable)
- Skipable Mouse-Buttons
- Thread Interval customizable + explications

Everything SHOULD work fine but, still, if you find any errors or mistakes (or have better ideas for some of my code) let me know.

Edit:
Just saw that there was a bug with the Scroll-Wheel.
Additional there's now the possibility to use the Nunchuck-Stick for controlling the mouse as well if you want to.
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

So I've put the next version in a .rar-File now as I can't post much longer code anymore.
I'd like to make it shorter but I, at the moment, just don't know what I could wrote more efficiently or at least shorter in it.

Well, in this version there's new:

- You can decide if you want to use 4 directions of the Nunchuck-Stick as mappable or 8 directions.
The 8 directions option, however, isn't a good choice when moving around with the Stick (like in e.g. a FPS) as the dedicated areas for each button prevent a smooth transition between directions.
- The recalibration now only starts when you press 1 + 2 for more than 3 seconds.
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Another update that again adds some new things:

- The Stick-Mouse is now toggleable (and the toggling of the toggling is toggleable (yep, that sentence sounds weird but that's the accurate description ^^) as well so you can also till use the Stick while pressing the GyroOff-Button)

- The Nunchuck-Shake can be replaced by tilting the Nunchuck to the left and right, each for an input

- Added the NCStickOuterRing-Option, that allows to simualte a button press as soon as you reach the edges with the Nunchuck-Stick

- The duration, for how long you have to press the 1 + 2 buttons until recalibration starts, is now customizable

- The sensitivity of the Nunchuck-Stick for pressing keys can be adjusted

- Nunchuck-Buttons can be used for Mouse-Buttons

- Tilting the Wiimote left / right can now also be mapped to keys

- Scrolling with the Mouse-Wheel can now also be done when tilting the Nunchuck
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Version 1.6:

- Added the possibility to use the Nunchuck of a second connected Wiimote instead of one attached to the Wiimote that also simulates the GyroMouse.
This makes the GyroMouse much smoother as FreePIE doesn't need to switch between MotionPlus and Nunchuck constantly anymore.

If you know another solution with preferably not having to use a second Wiimote I'd be happy to hear about it. :)

- Fixed a Problem that prevented disabling the Nunchuck
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Version 1.7:

Close to be final, I hope there are no problems left as I hope that I found all bugs. :)

- Added:
x GyroOff now toggleable
x Smoothing as an Option (thanks to JibbSmart's JSM-Code)
x Configurable Snap-Stick-Rotation as an Option when tilting the Nunchuck / Wiimote (chooseable)

- Optimized the script so that the Key-Up-Statements won't be called continously anymore when a button is not pressed
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Version 1.8:

- Additionaly to the Outer-Ring-Button you now also have the possibility to map an Inner-Ring-Button for the Nunchuck-Stick

- Option to disable the Mouse-Buttons while pressing the Alternate-Button to use Key-Mappings

- Scroll-Wheel:
x If you only use a Wiimote, scrolling is done by tilting the Wiimote left / right
x If you use a Nunchuck in combination, scrolling is done by tilting the Nunchuck up / down
x This way, tilting the Nunchuck / Wiimote Left / Right can more oftenly be used for Key-Mappings and the hard-coded nature also takes aways some complexity
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Version 1.8.1:

- Added an "InGameSens"-Setting so that the "AdjustSnapDeg"-Value only needs to be calculated once for each game (similar to the "Real World Calibration"-Value in JSM)

- Added an InstantTurn-Setting.
If you set this to False you'll see how the camera turns / the cursor moves into position.
I integrated this mostly as some games like No Man's Sky seem to limit the Mouse-Speed so the turns, as the script is doing them, can't be done instantly.
For the time that the turn takes place the script won't take any input however.
But as you can also adjust the TurnSpeed so that it doesn't take more than some miliseconds this shouldn't be a problem anymore and for most games InstantTurn should work without problem anyway.
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Version 1.8.2:

- Splitted the Functions inside the Script for a better understanding

- Added a Continous Rotation Mode for the Tilting, so now you can decide between that and the Snap Stick

- Made it optional to check for multiple mappings of the same key in one layout (there are 2 layouts: Normal and Alternate) as the problem with this should be fixed now (I hope I've tested all possibilities)
aidept
One Eyed Hopeful
Posts: 1
Joined: Sun Jan 16, 2022 8:55 am

Re: Wiimote Script inspired by JSM

Post by aidept »

GermanSani wrote: Fri Jun 04, 2021 7:10 am Version 1.8.2:
Hi. Good work!
But all are inversed on my PC!
When I point the remote to the left, mouse go to the right.
When remote pointed Up, mouse cursor go down.
Where to modify this in the script, please?
Thank you!
GermanSani
One Eyed Hopeful
Posts: 12
Joined: Sun Feb 28, 2021 8:44 am

Re: Wiimote Script inspired by JSM

Post by GermanSani »

Hi aidept,

change TRMoteX to 1 and TRMoteY to -1.

This is the section with the default values inside the code where you can change that:

#If you're using a Wiimote without the "-TR" in the devicename under "Bluetooth Devices" change TRMoteX to -1 and TRMoteY to 1
#If you're not sure just test which combination works for you
global TRMoteX
TRMoteX = -1
global TRMoteY
TRMoteY = 1

I read somewhere that the MotionPlus-Wiimotes have an invers behaviour so I put that in. ^^
I hope it helps.
MeteorFalling2
One Eyed Hopeful
Posts: 42
Joined: Thu Dec 08, 2016 10:23 pm

Re: Wiimote Script inspired by JSM

Post by MeteorFalling2 »

This is really nice. I'm still looking over the script to understand it, but you've done a really good job creating toggles, alternate binding, press and hold, shake, etc. I also like how clean the script is, as well as the really useful documentation/comment sections. This is very functional and useful work that you've done.

I'm looking into expanding the Wiimote further by using Vjoy, and I think can learn a lot from your script to make it work. Thanks. If you are curious, the advantages to using Vjoy is for the joystick detection (smooth walking/run) and for the access of on-screen radial menus from Steam's controller overlay (or hopefully, Kozek's SC-Controller), as well as the ability to create action sets for different aspects of a game (driving/steering, flying, manning turrets, etc). It's really useful stuff.
Post Reply

Return to “FreePIE”