xbmc / peripheral.joystick

Kodi joystick support (drivers and button maps)
GNU General Public License v2.0
24 stars 46 forks source link

Swapped buttons in default buttonmaps for NES and SNES #259

Closed KOPRajs closed 1 year ago

KOPRajs commented 1 year ago

For a reference the discussion started here: https://github.com/kodi-game/game.libretro.genplus/issues/12

The problem is that currently when you map a new controller for the Kodi's default controller profile (game.controller.default), the translation to the NES and SNES controllers have swapped buttons (because of the swapped "A"<->"B" on the SNES when compared to the Xbox controller).

After discussing this in the forum, the conclusion is that we should preserve the original ergonomy of the layout rather than preserve button names by default: https://forum.kodi.tv/showthread.php?tid=173361&pid=3138392#pid3138392

@garbear then point me to the right place where the problem comes from:

When a controller is connected, peripheral.joystick loads all button maps. If any button map can provide a mapping between two controllers in either direction, it is used. If there are multiple mappings to choose from, they're sorted and the most popular map is chosen.

After looking through the current maps and playing a little with them, I've found out that the default mapping is currently very chaotic. There is no single place to change the default controller to controller mapping, because all maps affects the behavior. It depends on how many times the specific mapping occurs in the pack of all buttonmaps.

So the first question is: Is this really the best way to do this? (I mean this part: "If there are multiple mappings to choose from, they're sorted and the most popular map is chosen.").

So maybe we could only keep buttonmaps for the game.controller.default (as seen in https://github.com/xbmc/peripheral.joystick/commit/c4efbe2cee4dae3f7a4a1d3dd2af8af7e1bbd233) and then specify only one implicit mapping from the game.controller.default to other profiles? Or maybe we can keep the support for other profiles in the buttonmaps and use it only for some specific controllers, but change the fallback algorithm from finding "the most popular mapping" to "use one specific default mapping from the game.controller.default to all other known profiles"? And then we can remove the other controller profiles from buttonmaps where it is not needed (as seen in https://github.com/xbmc/peripheral.joystick/commit/c4efbe2cee4dae3f7a4a1d3dd2af8af7e1bbd233).