ruffle
ruffle copied to clipboard
desktop: Intoduce generic gamepad remapping support
This is mostly a proof-of-concept, because I totally fail at playing Super Mario without a gamepad. We probably need to do some kind of per-game/swf remapping logic to actually make this useful, considering how peculiar some of those keybinds are.
Doesn't seem to work out of the box for me. I press every button on my gamepad, nothing happens. I'm on Arch Linux, LXQt.
EDIT: Nevermind, yes it does. I pulled the wrong branch.
I've updated my patch to support defining custom remappings via a command line parameter.
Super Mario 63:
-B north=x -B south=up -B west=z -B east=c -B start=p -B d-pad-left=left -B d-pad-right=right -B d-pad-up=up -B d-pad-down=down
Phoenotopia:
-B north=s -B south=z -B west=x -B east=c -B start=space -B d-pad-left=left -B d-pad-right=right -B d-pad-up=up -B d-pad-down=down
That's very nice. I've never found joypad mappings very comfortable for SM63 due to the merging of certain actions. Down being used both for diving and for general downward movement was always a bit awkward. But perhaps with a little mod to the game SWF, this could be made more comfortable?
What are the options for mapping? The examples you've listed have space, left, right, etc. Is there an exhaustive list to reference?
Also, could support be added for ; and '? These can be used in SM63 for swimming/opening doors and entering pipes respectively, which is useful for speedrunning.
What are the options for mapping? The examples you've listed have space, left, right, etc. Is there an exhaustive list to reference?
Everything in the KeyCode enum https://github.com/ruffle-rs/ruffle/blob/b55db7083cad9b7e1276c811ab2d6cc2e185306e/core/src/events.rs#L385 should work. So ; should be semicolon and ' should be apostrophe.
This is one the main aspects that make this awkward to actually land. We would need some simpler way of find out the right names etc.
I made some effort to add a better help message for this feature, including a way of listing all valid buttons/keys. I think that should be good enough to land this. I am also going to look at writing a wiki page for this soon.
--help:
-B, --gamepad-button <GAMEPAD BUTTON>=<KEY NAME>
Remaps a specific button on a gamepad to a keyboard key.
This can be used to add new gamepad support to existing games, for example mapping
the D-pad to the arrow keys with -B d-pad-up=up -B d-pad-down=down etc.
A case-insensitive list of supported gamepad-buttons is:
- north, east, south, west
- d-pad-up, d-pad-down, d-pad-left, d-pad-right
- left-trigger, left-trigger2
- right-trigger, right-trigger2
- select, start
A case-insensitive (non-exhaustive) list of common key-names is:
- a, b, c, ..., z
- up, down, left, right
- return
- space
- comma, semicolon
- key0, key1, ..., key9
The complete list of supported key-names can be found by using -B start=nonexistent.
-B start=nonexistent
error: invalid value 'start=nonexistent' for '--gamepad-button <GAMEPAD BUTTON>=<KEY NAME>': Could not parse <key name>: invalid variant: nonexistent
The possible values are: unknown, mouse-left, mouse-right, mouse-middle, backspace, tab, return, command, shift, control, alt, pause, caps-lock, numpad, escape, space, pg-up, pg-down, end, home, left, up, right, down, insert, delete, key0, key1, key2, key3, key4, key5, key6, key7, key8, key9, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, numpad0, numpad1, numpad2, numpad3, numpad4, numpad5, numpad6, numpad7, numpad8, numpad9, multiply, plus, numpad-enter, numpad-minus, numpad-period, numpad-slash, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, scroll-lock, semicolon, equals, comma, minus, period, slash, grave, l-bracket, backslash, r-bracket, apostrophe