libretro / snes9x

Snes9x - Portable Super Nintendo Entertainment System (TM) emulator
http://www.snes9x.com
Other
47 stars 56 forks source link

Dynamically build a controller info table based on connected devices #215

Closed hiddenasbestos closed 5 years ago

hiddenasbestos commented 5 years ago

Currently the table sent via RETRO_ENVIRONMENT_SET_CONTROLLER_INFO is fixed and offers all possible combinations of devices. Because of this, it is not possible for the front-end to know how many controller ports are being emulated.

I've changed the code so that the table is built dynamically based on whether a multi-tap or Justifier is plugged into the second SNES controller port, and if so additional table entries are added to raise the total number of ports to 5 or 3 respectively.

I've tested with NBA Live '98 and five controllers are still functioning.

NOTE: This patch removes the ability to add a multitap into the first controller port. Not something required for commercial software, but apparently some homebrew may use it (https://nintendo.fandom.com/wiki/Super_Multitap)

andres-asm commented 5 years ago

I had to the something similar for dosbox, and dolphin does need something like this too. Actually setting a controller in port 2 in dolphin clears the descriptors for P1 (or used to at least)

Honestly it's pointless, I think the current API to set controllers should be deprecated in favor of something that sets the descriptors for a single gamepad.