forum

This filthy casual's Wiimote GlovePIE script

posted
Total Posts
3
Topic Starter
GravSuit
I had fun making the LEDs do stuff. Helping promote Wiimote masterrace propagation. Please, don't ask for help setting up bluetooth with the Wiimote in this thread. There are plenty of guides (I used the one on the Dolphin emulator's website).

I'm using version 0.45, if that matters. Original script authors are referenced on the second line of code, Bighead from the GlovePIE forum's multimedia mouse script, CrimsonC and Steelgun123's taiko script from here. I wonder if anyone has a better IR mouse script.

Press the home button to switch modes (nabbed from Bighead's mouse scripting):
- First mode has only the player 1 LED on, it has a sort of click stop, makes it a lot more possible to double click (good for desktop navigation)

- Second has a sort of LED chaser thing, turns off the stop for button presses

- if you have a Nunchuk plugged in, the third mode has a taiko setup (which I haven't really tried at all). Left/right click switch to -/+. I have no idea if it works reliably. I think I did improve on it a bit; I added a sort of stop, so the key in question doesn't get pressed multiple times when you swing the Wiimote/Nunchuk. I wonder if I should apply the stop to any other buttons, as sort of a debounce script thingy (oh, thingy passed the spellcheck).


Currently smoothing is on for the mouse in both mode 1 and 2/3. You can turn it off in the mode switching code area.


EDIT: debounce thing looks pretty in a text editor, but osu doesn't think so. removing that chunk.

SPOILER
// Script heavily modified by GravSuit
// References Bighead's mouse script, CrimsonC and Steelgun123 taiko script
/*------------------------------------------------------------------------------
Mouse + Multi-Media Player GlovePIE Script - v1.4
By: Bighead
------------------------------------------------------------------------------*/
//Configuration, Start in Mode 1.
if (starting) then
var.smoothmouse = true
var.dualscreens = false
var.clickfreeze = 240ms
var.mode = 0
var.ledselect = 0
var.reverse = 0
var.ledpause = 125ms
Wiimote.Led1 = 1
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
PIE.FrameRate = 120Hz
endif
//------------------------------------------------------------------------------
//Small battery display in debug
Debug = "Battery at " + wiimote.Battery

// Mode swap function when pressing Home button.
if (Wiimote.Home) then
Wiimote.Rumble = true
if (var.mode == 0) then
var.mode = 1
var.smoothmouse = true
var.clickfreeze = 0ms
elseif (var.mode == 1) then
var.mode = 2
elseif (var.mode == 2) then
var.mode = 0
var.smoothmouse = true
var.dualscreens = false
var.clickfreeze = 240ms
endif
wait 300ms
Wiimote.Rumble = false
if (var.mode == 0) then
Wiimote.Led1 = 1
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
endif
endif

// Messing around with Wiimote LEDs
// Mode 1, Standard Osu controls LEDs
if (var.mode == 1) then
if (var.ledselect == 0) then
Wiimote.Led1 = 1
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
elseif (var.ledselect == 1) then
Wiimote.Led1 = 0
Wiimote.Led2 = 1
Wiimote.Led3 = 0
Wiimote.Led4 = 0
elseif (var.ledselect == 2) then
Wiimote.Led1 = 0
Wiimote.Led2 = 0
Wiimote.Led3 = 1
Wiimote.Led4 = 0
elseif (var.ledselect == 3) then
Wiimote.Led1 = 0
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 1
endif

if (var.ledselect == 0) then
var.reverse = 0
var.ledpause = 200ms
endif

if (var.ledselect == 1) then
if (var.reverse == 0) then
var.ledpause = 100ms
else
var.ledpause = 60ms
endif
endif

if (var.ledselect == 2) then
if (var.reverse == 1) then
var.ledpause = 100ms
else
var.ledpause = 60ms
endif
endif
if (var.ledselect == 3) then
var.reverse = 1
var.ledpause = 200ms
endif

if (var.reverse == 0) then
var.ledselect = var.ledselect + 1
else
var.ledselect = var.ledselect - 1
endif
wait var.ledpause
endif

// Mode 2, taiko LEDs

if (var.mode == 2) then
Wiimote.Led1 = 1
Wiimote.Led2 = 0
Wiimote.Led3 = 1
Wiimote.Led4 = 0
wait 250ms
Wiimote.Led1 = 0
Wiimote.Led2 = 1
Wiimote.Led3 = 0
Wiimote.Led4 = 1
wait 250ms
endif

//------------------------------------------------------------------------------
// Mouse Buttons/Pointer/Sensor
Keyboard.RepeatFakeKeys = false
var.pressA = (KeepDown(Pressed(Wiimote.A), var.clickfreeze))
var.pressB = (KeepDown(Pressed(Wiimote.B), var.clickfreeze))
var.pressM = (var.mode == 0) AND (KeepDown(Pressed(Wiimote.1), 200ms))
var.checkPress = (var.pressA) OR (var.pressB) OR (var.pressM)
// Adjust X for dual screens and slightly speed up Y to somewhat match X.
if (var.dualscreens) then
var.wiiX = MapRange(Wiimote.PointerX, 0, 1, 0.1, 1.90)
var.wiiY = MapRange(Wiimote.PointerY, 0, 1, -0.25, 1.25)
var.smoothdb = 0.00075
// Or just adjust so wiimote actually reaches the corners.
else
var.wiiX = MapRange(Wiimote.PointerX, 0, 1, 0.1, 0.9)
var.wiiY = MapRange(Wiimote.PointerY, 0, 1, -0.1, 1.1)
var.smoothdb = 0.00025
endif
// Update the mouse pointer with WiiMote values.
if (Wiimote.PointerVisible) AND (var.checkPress == false) then
if (var.smoothmouse) then
Mouse.X = Smooth(var.wiiX, 10, var.smoothdb)
Mouse.Y = Smooth(var.wiiY, 10, var.smoothdb)
else
Mouse.X = var.wiiX
Mouse.Y = var.wiiY
endif
endif
//------------------------------------------------------------------------------
// Mouse Buttons (Mode 0 and 1)
if (var.mode == 0 or var.mode == 1) then
Mouse.LeftButton = (Wiimote.A)
Mouse.RightButton = (Wiimote.B)
endif
//------------------------------------------------------------------------------
// CrimsonC and Steelgun123 taiko script cannibalized
// Game mode
if (var.mode == 2) then

key.x = Wiimote.A
key.c = Nunchuk.CButton
key.z = Nunchuk.ZButton
key.v = Wiimote.B
Mouse.LeftButton = Wiimote.minus
Mouse.RightButton = wiimote.plus
key.down = Wiimote.Down
key.up = Wiimote.Up
key.left = Wiimote.Left
key.right = Wiimote.Right
key.enter = Wiimote.One

key.c = wiimote.RawAccY < -15
key.x = wiimote.Nunchuk.RawAccY < -13

/*
if (var.downdirnunchuk == true and var.nunstruck == false) then
key.x = true
var.nunstruck = true
elseif (var.downdirnunchuk == true and var.nunstruck == true) then
key.x = false
var.nunstruck = true
else
key.x = false
var.nunstruck = false
endif

if (var.downdir == true and var.struck == false) then
key.c = true
var.struck = true
elseif (var.downdir == true and var.struck == true) then
key.c = false
var.struck = true
else
key.c = false
var.struck = false
endif
*/

endif

//------------------------------------------------------------------------------
Jing Yuan
so, what does gameplay look like?
Renevant
might be wrong, but i think this belongs here: 2

anyways, cool idea, but you should show some pics/video of it
Please sign in to reply.

New reply