fossephate / JoyCon-Driver

A vJoy feeder for the Nintendo Switch JoyCons and Pro Controller
https://fosse.co/latest.zip
MIT License
1.07k stars 194 forks source link

Add "shake" virtual buttons #38

Open natinusala opened 7 years ago

natinusala commented 7 years ago

It would be a good idea to add "shake" virtual buttons for emulators/games which don't support motion controls. Basically, when the driver detects that one of the Joy Cons was shaken, it presses the appropriate button.

Multiple buttons could be added : one per JoyCon, and one for any Joy Con.

A good example would be the Dolphin Wii emulator, with the WiiMote shake control.

fossephate commented 7 years ago

Thanks for the idea, this would be great for games like super Mario Galaxy on dolphin, the hard part is defining a "shake", I might make a quick hack to make this happen sometime soon but I have some tests coming up and need to study

natinusala commented 7 years ago

I guess a shake is just a quick acceleration defined by a threshold, and throttled by a pause between each acceleration to prevent spamming. If we can configure the acceleration threshold and pause, it can work for every use case.

See this Stack Overflow anwser for a sample code (for Android accelerometer but I guess it's the same here) : https://stackoverflow.com/questions/5271448/how-to-detect-shake-event-with-android

Migushthe2nd commented 7 years ago

You can already configure dolphin to shake the WiiMote when you shake your joycon. On the "Motion Controlls and IR" tab I have set Y and Z to 'Slider 0+-' and 'Slider 1+-'. Works like a charm.