libretro / bsnes-mercury

Fork of bsnes with various performance improvements.
GNU General Public License v3.0
47 stars 39 forks source link

libretro: Don't plug joypads by default #70

Closed Kekun closed 4 years ago

Kekun commented 6 years ago

This avoid assuming what the frontend will plug in anyway.

Similar to https://github.com/libretro/bsnes-libretro/pull/56

inactive123 commented 6 years ago

Just to confirm, the gamepad will still work by default, right?

hizzlekizzle commented 6 years ago

That's going to default to no input, isn't it? If so, that doesn't seem like a good idea to me, as I foresee a lot of "not responding to input" reports.

andres-asm commented 6 years ago

I guess what it's doing is only plug gamepads when input device is gamepad, but some explanation would be nice?

ghost commented 6 years ago

dont think this is necessary as this is immediately overriden in retro_set_controller_port_device()

there are some cases where retro_set_controller_port_device (or something else) fails and defaults to using RETRO_DEVICE_JOYPAD (i still see this sometimes in log that device connected is unknown and defaults to use RETRO_DEVICE_JOYPAD) but without setting input to the main core/emu, input would not work until manually re-setting user input (and hope retro_set_controller_port_device this works).

Kekun commented 6 years ago

You're right my reasoning isn't well conveyed by the PR's message, I'll explicit it. :)

So design-wise I think it's better to have "none" by default for emulators of machines with physical ports. On top of that this caused a bug in retro-gtk that I am going to explain below.

Some cores query various types on the same port and don't use RETRO_ENVIRONMENT_SET_CONTROLLER_INFO to inform the core about anything, for example desmume2015 queries many types on port 0 (which is acceptable as there is no notion of port on the machine, though using SET_CONTROLLER_INFO and multiple ports would be cleaner). To handle these cases, retro-gtk has the notion of default input devices: if the core queries an input on a specific port which is not of a type it handles, retro-gtk will check if a default controller of that type exists and return its value, for example this is used for inputs which can only exist in one instance like the window used as a RETRO_DEVICE_POINTER while a physical gamepad is plugged into port 0.

This created a bug in retro-gtk which is that if the core queries multiple ports for the same type without the frontend to explicitely set them, the same physical device will answer the same inputs. For example this makes Street Fighter II unusable because in menus both ports will press start at the exact same time, start a 2P game with the to characters doing the exact same movements.

To sum things up, either completely ignore retro_set_controller_port_device() and preset the controllers or let the frontend control what's plugged into the core mixing and mashing these two approaches is source of problems because neither the core nor the frontend controls everything.

To be clear, the bug in retro-gtk comes both from retro-gtk trying to be smart to handle complex cases well like desmume2015 where the port just does whatever it want and from bsnes wich only partialy let the frontend in control by having non-empty ports by defaults.

I hope my ideas are more clear. :)

Kekun commented 6 years ago

My problem could be solved by dropping the concept of default controller in retro-gtk and by making desmume2015 use RETRO_ENVIRONMENT_SET_CONTROLLER_INFO and plug one kind of input in different ports, but I still think that cores shouldn't silently set their controller types without the frontend knowing.

inactive123 commented 6 years ago

OK, so to reiterate my question, is the gamepad still plugged in by default when the user first boots up the core or not,?

Because that is where I draw the line. If the enduser at first startup of this core gets into a default state where no gamepads are plugged in at all and he has to specifically set these gamepad ports at first, that is not something I want to happen. Enduser accessibility trumps any API / frontend considerations in that case.

If this is not the case and the user does not have to manually set the controller port to SNES joypad, then I'm more open to this PR.