libretro-mirrors / libretro-arb

For proposed improvements to libretro API.
8 stars 2 forks source link

Ability to map retropad buttons as any key rather than just the default mapped keys #35

Closed gingerbeardman closed 6 years ago

gingerbeardman commented 7 years ago

I make changes on the fMSX core from time to time.

I'd like to add the ability to be able to map any key of the emulated physical keyboard layout to any button on the controller. This is most useful on consoles like my little 3DS.

As of right now, it's only possible to move around the default keys that have been defined against the controller buttons. They are:

keymap_t keybemu1_map[] =
  {
  { RETRO_DEVICE_ID_JOYPAD_UP,       KBD_UP },
  { RETRO_DEVICE_ID_JOYPAD_DOWN,   KBD_DOWN },
  { RETRO_DEVICE_ID_JOYPAD_LEFT,   KBD_LEFT },
  { RETRO_DEVICE_ID_JOYPAD_RIGHT, KBD_RIGHT },
  { RETRO_DEVICE_ID_JOYPAD_B,     KBD_ENTER },
  { RETRO_DEVICE_ID_JOYPAD_A,     KBD_SPACE },
  { RETRO_DEVICE_ID_JOYPAD_X,           'n' },
  { RETRO_DEVICE_ID_JOYPAD_Y,           'm' },
  { RETRO_DEVICE_ID_JOYPAD_SELECT,   KBD_F4 },
  { RETRO_DEVICE_ID_JOYPAD_START,    KBD_F1 },
  { RETRO_DEVICE_ID_JOYPAD_L,        KBD_F2 },
  { RETRO_DEVICE_ID_JOYPAD_R,        KBD_F3 },
  { RETRO_DEVICE_ID_JOYPAD_L2,    KBD_GRAPH },
  { RETRO_DEVICE_ID_JOYPAD_R2,  KBD_CONTROL },
  { RETRO_DEVICE_ID_JOYPAD_L3,       KBD_F5 },
  { RETRO_DEVICE_ID_JOYPAD_R3,   KBD_ESCAPE },
};

So essentially, I'd like the buttons to be mapped as above, from the full set of ~100 keys of the MSX keyboard. Rather than there only being 16 keys available as default/hardcoded mapping. So if I wanted to change 'n' and 'm' to 'z' and 'x' I'd be able to.

My initial thoughts were that I'd be able to assign buttons to phantom control inputs but that'd be a real hack so I thought I'd propose this the official way.

According to @fr500 in the thread below it would require a new API extension: https://forums.libretro.com/t/adding-extra-keys-buttons-to-be-available-for-mapping-through-ui/11032/2

Happy to discuss the implications, pros and cons.

andres-asm commented 7 years ago

sadly the v2 discussion has stagnated and I don't see anyone willing to move it forward this has been discussed a lot along with analog to digital remapping.

Problem is many of the proposed changes may cause an ABI break.

For keyboard mapping a new env to allow keyboard mapping and a menu that implements something similar to what I implemented here should do it: https://github.com/libretro/RetroArch/issues/3028

andres-asm commented 7 years ago

Related https://github.com/libretro/RetroArch/issues/3671

inactive123 commented 7 years ago

We don't want any ABI breaks, yes. I'd like to stick with v1 for as long as possible.

gingerbeardman commented 7 years ago

So is that the end of the discussion? Just so I'm clear that I should cancel my bounty.

inactive123 commented 7 years ago

You don't have to cancel the bounty, however, you should figure out a way to do this without introducing an ABI break, which is something that should be absolutely avoided at all costs UNLESS there is a very, very, very, very good and inavoidable reason for it (and even in that case I will weigh the pros and cons before even signing off on it).

I am very, very flexible when it comes to contributions and PRs, but the ABI stability is a deliberate line in the sand where I have to put my foot down and go against the wisdom of the crowd at times. For anything else, I am your man and I will back anybody's efforts to bring more features/improvements to RA and libretro.

gingerbeardman commented 7 years ago

I'll have to get my head around how the proposed solution breaks the ABI before I can try to think of how to achieve this without breaking the ABI.

where should i start?

andres-asm commented 6 years ago

this s already implemented actually.... I implemented it

gingerbeardman commented 6 years ago

Woohoo! Thanks

andres-asm commented 6 years ago

Ah actually... No

I mean now you can bind any keys to button but my mapper doesn't provide a way to set a default mapping from the core to the frontend realm.

gingerbeardman commented 6 years ago

I'll take a look and see if that's enough for my use

andres-asm commented 6 years ago

I don't think it's hooked in fMSX, I have hooked it up in px68k, bluemsx and dosbox. Only thing you need is a RETRO_DEVICE_KEYBOARD device that IGNORES gamepad inputs internally.