Key remapping
This adds a simple form of action and button remapping by routing calls to wlserver_key and wlserver_mousebutton via actionmap_performkey and actionmap_performbutton which in turn call actionmap_perform that can be used to remap the calls between keyboard and mouse keys and buttons. The actionmap is specified using a simple text file of the form:
srcdev srcid dstdev dstid
where each line specified a mapping from srcdev/srcid to dstdev/dstid. The dev is k, b or n (for keyboard, mouse button and null - used to ignore keys) and id depends on dev. For example:
b 277 k 15 b 274 k 48 b 278 k 33 k 15 n 0
This maps the X1 button to Tab key, the middle button to B key, the X2 button to F key and the Tab key itself to nothing (the 0 is ignored and can be any number).
This functionality can be used with games that have partial or no support for key (re)mapping.
The --actionmap-file CLI parameter can be used to specify an actionmap file and the --report-actionmaps parameter can be used to dump the action mappings to stderr while they happen (which can also be used to find the key and button ids).
I've been using this patch and keeping it alive through the version updates (mostly simple merge conflicts, but I did add support for the Wayland backend). My branch is here for anyone interested: https://github.com/rhendric/gamescope/tree/rhendric/key-remapping-continued.
I've been using this patch and keeping it alive through the version updates (mostly simple merge conflicts, but I did add support for the Wayland backend). My branch is here for anyone interested: https://github.com/rhendric/gamescope/tree/rhendric/key-remapping-continued.
Have you already tried opening a PR so the feature could be merged into gamescope?
It's this PR.
It's this PR.
It's closed, and was initiated by badsectoracula? You have been maintaining another branch since.
The content is the same, and this PR was entirely ignored for three years before it was closed. If you have reason to believe a second PR with the same content would somehow result in a different outcome, let's hear it.
I just noticed the comments. TBH while i think the feature is good, the file was made to be simple before i had any idea how much Valve wanted to put in Gamescope so i kept it simple - perhaps too simple.
Nowadays and considering all the stuff that have been added to Gamescope, i think a better approach would be to use the Lua scripting system to setup the action remapping and add a command-line option in gamescope to allow for running Lua scripts (and expose functions to scripts to run games so that, e.g., one can do gamescope --run-script foo.lua and have a Lua script that setups game-specific settings such as which upscaler to use, fullscreen mode on/off and of course action remappings before calling a function that launches the game itself).