shonumi / gbe-plus

DMG/GBC/GBA emulator and experimental NDS emulator.
GNU General Public License v2.0
530 stars 80 forks source link

[Request] Motion Control support #131

Open eVenent opened 2 years ago

eVenent commented 2 years ago

Recently SameBoy has released v0.15 build with support for motion controls and its great. Emulator mGBA has it in dev builds for longer time. Maybe it is possible to do it in GBE+ too? It's the only one special hardware feature which is not available on GBE+ according to emu wiki. Sameboy implemented "the mouse, as well as a joystick, can be used for motion controls. On the Cocoa frontend, a supported controller's motion controls can be used as well." I like it but I would like to request Cemu hook support (Cemu, Dolphin, Citra, etc.) on PC. I think it is easier than adding support for every controller which supports gyro. Cemu hook is already integrated in emulators and uses the motion sensors in controllers like Steam Controller, Dualshock 4, DualSense, Switch Pro Controller, Joy-Cons to play motion sensor games (like Kirby Tilt 'n' Tumble, Command Master or even Tony Hawk's Motion (USA) with motion pak). What is good with this implementation is that 3rd party programs (like eg. reWASD which added cemu hook for every controller with gyro) are responsible for sending motion signal in proper way.

Main website: https://cemuhook.sshnuke.net/ UDP Pad motion data provider info: https://cemuhook.sshnuke.net/padudpserver.html

shonumi commented 2 years ago

I'd rather avoid using any additional programs or software libraries such as Cemu Hook. One of the goals behind GBE+ is minimal build dependencies, so just SDL2 and optionally Qt (for the GUI) and SDL_net (for networking).

Fortunately SDL2 natively supports working with gyroscopes, so I'll mess around with that eventually. Like regular controller input, it'll be up to the user to manually configure stuff (Up motion, down motion, left motion, right motion), so it shouldn't be hard to support a wide range of gyro controllers.

Of course, I have never dealt with gyro controls before, so I can't say for sure how it'll go. Definitely want to look into it more.

shonumi commented 2 years ago

This is mostly done as of aab1761b5a68cfd086d17706da6d6f57f1e15ee8. Tested with my PS4 controller on the MBC7 (Kirby Tilt & Tumble), GBA Tilt games, and GBA Gyro (WarioWare: Twisted!).

Configuration isn't exposed via the Qt user interface just yet. Right now, configuration is restricted to the .ini file. Needs calibration based on what game is played and what kind of controller the user has, but it's basically a simple "deadzone" value for motion along with a sensitivity value. Requires a somewhat recent version of SDL2 (2.0.14 I believe) for anyone looking to compile it themselves.