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).
@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.").
It is hard to manage the existing buttonmaps.
I've seen that there are maps for non-existing controller profiles (search for game.controller.genesis - there is no such profile, probably was renamed to game.controller.genesis.6button, but it was not updated in all the buttonmaps).
There is no single place to change the default controller to controller mapping.
There is no single place to add a mapping for a new profile (game.controller.genesis.3button).
Adding of a new buttonmap for some obscure controller can change the default behavior for all (because it can suddenly become "the most popular").
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).
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:
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).