Dolphin, the GameCube and Wii emulator - Forums

Full Version: Vibration on Controller w/ Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do you vibrate your controller using a script in dolphin? (Tldr: Tested a bunch of things that didn't work, and I need help.)

Skyward Sword is and has been one of my favorite games to own and play on the Wii, and getting it to work via dolphin has been a really fun experience. I've got it working just fine on my Switch Pro Controller. I've customized almost all the settings available, including motion controls, moving, swinging the sword, playing the harp, everything works great. That's because I created a toggled variable with the controller profile, allowing me to switch between different modes to fine tune settings. The 3 modes I have currently for the controller are FlightMode, HarpMode, and Standard. Switching between the modes works fine, but I was starting to run into a problem. Sometimes I would toggle a mode to change my control scheme, not realize I had that mode active, and then get hurt by some random enemy because my movements were affected. 

The idea I had in mind to mitigate this was to set up the vibration to where if I pressed certain button on the controller while a certain mode was active, I would have my controller vibrate. Here is when I ran into issues:
Code:
`Motor L`| `Motor R`| if($tFlight,`Thumb R`,0)

The idea behind this was that since this was in the Rumble section, if $tFlight > 0 and `Thumb R` was pressed, the 'or' operation between `Motor L`, `Motor R`, and my if statement could return True, my controller would rumble if the conditions were correct. It was vibrating on rolling into an object - the game could trigger vibration just fine. At first I thought it was an issue with my $tFlight variable, so I did another test. This time I just tried to activate rumble with a button like so:
Code:
`Motor L`| `Motor R`| `Button B`

That didn't work either. Pressing 'B' on my controller would not activate the vibration, even if the 'or' operation should return True. Then, I thought that since valid controller 'inputs' were listed in a menu and only Motor L and Motor R were in the list, I would have better luck simply setting a variable somewhere else to True, and putting that in the or statement. After all, 'Functions' is not a selection menu so I realized an if statement probably would not be supported, but 'User Variables' did show up as a valid option. So I finally tried this:
Code:
`Motor L`| `Motor R`| $motorFlightActive   ------->  (Under A button) $motorFlightActive=`Button A`| `Button A`

I had the controller menu up while playing the game and found that the game did in-fact detect the 'A' press and '$motorFlightActive' should be set to true, yet it was not causing my controller to vibrate. Does dolphin support user-controlled vibration? Is there a better way to conveniently toggle and un-toggle different controller profiles? Any help would be much appreciated.

A txt document listing my current controls: [attachment=20906]
The ini file (attached as text): [attachment=20907]

Not sure if this is relevant, but since they're required by the rules, here are the operating specs of my computer below: 
CPU- Intel i7-13700KF  3.40 GHz
GPU- Nvidia Rtx 4070
Ram- 32 gigs
OS- Windows 11, x64
Dolphin Version: 5.0-21088
I'm not completely following what high-level behavior you are trying to achieve so I'll just try to explain some things.

Expressions within the "Rumble" section are currently very limited.
You can't do much other than make outputs or variables take on the rumble strength value.

Be aware that you can reference output names within any input expression.
e.g. Using this as your Control Stick Up mapping will rumble Motor L at the strength that you push up on your stick:
Code:
`Motor L`=`Left Y+`

Though, doing an assignment to `Motor L` like that is going to cause fighting over what the motor strength should actually be if you also have `Motor L` mapped in the Rumble section.

Instead:
You can assign the game's rumble value to a variable in your Rumble mapping:
Code:
$rumble

And reference that variable to combine it with whatever other rumble trickery you want in another mapping, e.g. Control Stick Up mapping:
This would activate `Motor L` when the game normally commands rumble, or while you are pressing `Button A`.

Code:
`Motor L`=$rumble|`Button A`,`Left Y+`

Note that basically any one input mapping can be used for that purpose. You can just stick all the logic before the comma operator, and then follow the comma with whatever normal mapping you desired.
Expressions before the comma operator are evaluated and then the result is discarded, so you can use it to just perform any logic, potentially unrelated to the actual mapping that you are configuring here.