[Ohrrpgce] Multiple joysticks, multiplayer, and control remapping

Ralph Versteegen teeemcee at gmail.com
Fri Apr 16 06:04:30 PDT 2021


I've been working through (especially in gfx_sdl2) gamepad bugs and
unfinished features (none of which made it to github) and now I've only got
handling of multiple gamepads left to improve. For better joystick
numbering I'm thinking forwards to local multiplayer, remappable controls,
ohrkeys joystick support, and even simple remote multiplayer via input
forwarding.

Currently a number of commands (keyval, keyispressed, keypress,
newkeypress, joystickbutton, joystickaxis, getjoystickname,
joystickbuttoncount, joystickaxiscount, joystickhatcount) take the joystick
number as an extra argument. But there are lots of problems with this:
-if there are multiple joysticks on the system you would have to loop
through all of them to figure out which one the player is using
-I added getnumjoysticks recently but it's undocumented
-in gfx_sdl2 and gfx_directx joysticks can get renumbered if any are
removed or even added (not possible in gfx_sdl anyway)
-the joystick number is currently ignored for control keys like usekey
(It's also ignored for keyboard scancodes), instead all inputs joysticks
are OR'd

But I used rpgbatch to scan the gamelists and there was only a single game
that made use of the joystick number arg, Porosis on SS, which erroneously
contains "key is pressed(key:A,true)". "joystick axis" wasn't used either
(though Blood Ledger and inputtest.rpg now use it.)

Further, I want to let people define additional keys to usekey, menukey,
etc. (I think we could break convention and export these to the hsi as
"shootkey", "runkey",  etc. for a form of consistency, since there will be
little difference between builtin and additional controls.) So instead of
hardcoding e.g. a charge-up action to the joy:Y button you'd define a
"charge key" with some default mappings which can then be changed by either
a scripted or future builtin control mapping menu.

SDL2 has functions to get/set the player number for each joystick/gamepad.
At most one joystick can be assigned to a player, which is a reasonable
limitation. On most platforms these functions don't really do anything, but
on consoles they report the actual player number and apparently some
consoles have coloured LED lights to indicate which controller is each
player.

So it occurred to me that we should repurpose the 2nd arg to all those
commands as the *player number* rather than the joystick number. Each
player has at most one joystick and keyboard (and in future mice could also
gain a player number arg) but note that a player might have no joystick,
just a keyboard. I suggest that players are numbered from 1 up, which is
less confusing, and the default player=0 (which is also used by all builtin
controls) can just be all input from all control devices OR'd together so
if you have multiple gamepads all existing games will just work. There
could be a command to instead set a specific player as the default, e.g.
for local or remote multiplayer where you want just one player to control
the hero/menus.

If you want to change which player a device is assigned to that might be
tricky if there are no commands to enumerate joysticks, but we could have a
command such as "swap player gamepads(player A, player B)"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20210417/57b6d4b5/attachment.html>


More information about the Ohrrpgce mailing list