kodi-game / game.libretro

Libretro compatibility layer for the Kodi Game API
GNU General Public License v2.0
37 stars 26 forks source link

Buttonmap v2: Replace mapto names with libretro #defines #19

Closed garbear closed 7 years ago

garbear commented 7 years ago

This updates the buttonmap syntax to use #defines from libretro.h instead of short, easy-to-read names.

The downside of the easy-to-read names was that it introduced another layer. Ultimately, we need to translate the Kodi feature to the constants in libretro.h. By using the #defines directly, there will be less confusion from the unnecessary layer.

Before:

<buttonmap>
  <controller id="game.controller.snes" type="joypad">
    <feature name="a" mapto="a"/>
    <feature name="b" mapto="b"/>
    <feature name="x" mapto="x"/>
    <feature name="y" mapto="y"/>
    <feature name="start" mapto="start"/>
    <feature name="select" mapto="select"/>
    <feature name="up" mapto="up"/>
    <feature name="down" mapto="down"/>
    <feature name="right" mapto="right"/>
    <feature name="left" mapto="left"/>
    <feature name="rightbumper" mapto="r"/>
    <feature name="leftbumper" mapto="l"/>
  </controller>
</buttonmap>

After:

<buttonmap version="2">
  <controller id="game.controller.snes" type="RETRO_DEVICE_JOYPAD">
    <feature name="a" mapto="RETRO_DEVICE_ID_JOYPAD_A"/>
    <feature name="b" mapto="RETRO_DEVICE_ID_JOYPAD_B"/>
    <feature name="x" mapto="RETRO_DEVICE_ID_JOYPAD_B"/>
    <feature name="y" mapto="RETRO_DEVICE_ID_JOYPAD_Y"/>
    <feature name="start" mapto="RETRO_DEVICE_ID_JOYPAD_START"/>
    <feature name="select" mapto="RETRO_DEVICE_ID_JOYPAD_SELECT"/>
    <feature name="up" mapto="RETRO_DEVICE_ID_JOYPAD_UP"/>
    <feature name="down" mapto="RETRO_DEVICE_ID_JOYPAD_DOWN"/>
    <feature name="right" mapto="RETRO_DEVICE_ID_JOYPAD_RIGHT"/>
    <feature name="left" mapto="RETRO_DEVICE_ID_JOYPAD_LEFT"/>
    <feature name="rightbumper" mapto="RETRO_DEVICE_ID_JOYPAD_R"/>
    <feature name="leftbumper" mapto="RETRO_DEVICE_ID_JOYPAD_L"/>
  </controller>
</buttonmap>
garbear commented 7 years ago

@fetzerch Do you have an opinion on this?

fetzerch commented 7 years ago

no objections, sounds like a good idea. i remember debugging something in the mapping and not having to deal with the additional layer makes it probably easier