flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.36k stars 167 forks source link

[Libretro] Add options to manage each expansion slot #1368

Closed bslenul closed 7 months ago

bslenul commented 7 months ago

Hey!

This is a PR for the Libretro core, it adds a "Controller Expansion Slots" category for core options (only shows for Dreamcast games):

image

this will let the user decides what expansion device they want for each slot (currently none/vmu/rumble):

image

The menu refreshes when changing controller type and will only show the slots available, for example having an arcade stick in port A will hide A2 and having a keyboard in port B will hide both B1 and B2:

image

It makes the expansion devices much more "malleable", for example before this PR with the "Controller" device type if the "Purupuru" option was enabled then all the slot 2 VMUs were disabled automatically and it was also impossible to disconnect any slot 1 VMU which has been requested multiple times (especially for Sonic Shuffle, see #723).

By default all slots 1 will be set to VMU and all slots 2 to Purupuru, to match the current core defaults.

I did some kind of a workaround in retro_set_controller_port_device() to avoid input descriptors and core options to be refreshed 4 times on startup, couldn't think of a better way of doing it... basically I don't refresh the first time until all ports are not set to "-1" anymore. If anyone has a better idea I'm all ears! I'm still lacking some "dev logic" :p

The PR does not affect existing VMUs but I'm still nervous with changes related to saves, I really hope everything is OK! I feel a bit more confident with PRs lately but I'm still pretty noobish so if this is not good enough or anything let me know and I'll just close the PR, no hard feelings!