I have a Wacom tablet always plugged in. For unrelated asinine reasons,
SDL detects both the pen and the tablet itself as (completely useless)
gamepads, so they always show up in the list first. I also have a Wii U
Bluetooth controller, which shows up third.
When the settings dialog is spawned, selectGamepad is bound to the
currentIndexChanged event, so picking a controller from the combobox
will call it. The current index is initially -1 (because the combobox
is empty), and when updateJoysticks is called to populate it, the index
automatically changes to 0. The event is fired and the current gamepad
is changed to the first one, which in my case is my tablet pen.
updateJoysticks tries to avoid this by explicitly reselecting the active
gamepad after refreshing the combobox, but at this point the "active"
gamepad has already changed.
The upshot of this was that opening the settings dialog for any reason
would disable my controller, unless I remembered to go change it back.
I've also seen the button configuration for the wacom pen or controller
be saved under each others' names.
The fix, which works on my machine™, is to disable signals altogether
while mucking with the contents of the combobox, explicitly reselect the
right gamepad, and then explicitly call selectGamepad. (I dropped the
last two lines because the same thing is already done in refresh, which
is called by selectGamepad.)
Arguably this is still a little wrong:
- If I unplugged my Wacom tablet, my controller would shift upwards to
slot 0. This code would fail to notice and keep trying to use joystick
2. That's a pretty obscure case, though, and maybe difficult to fix
correctly.
- This panel makes changes immediately, but it should wait for OK or Apply.
It was a generous 128, but the inih library has its own maximum length
of 50. Any longer keys were truncated by inih, so they appeared to be
missing when mgba tried to read the longer key again later.
This was causing the configuration for my Nintendo Wii Remote Pro
Controller to be effectively lost; the key name ended up at 53
characters.
Arguably inih should truncate when reading, too, but...