Cogmind > General Discussion

Experimental Keyboard Layouts and Command Rebinding

(1/7) > >>

Kyzrati:
As of Beta 2, Cogmind comes with a way to use some non-QWERTY keyboards as well as rebind specific commands if necessary.

However, the system is currently considered experimental because although I've tested it pretty thoroughly, no one else has used it yet, nor does it live up to the user-friendly standards you'd expect from a Cogmind UI feature.

It's also pretty limited: 1) The settings are only accessible via external text files, 2) alternative US101 keyboard layouts work well but foreign keyboards are not fully supported, and 3) the underlying key labeling system is not 100% intuitive (I based it on the way SDL keycodes work).

As such, to prevent inexperienced players from running into too many issues (or thinking it's better than it is) and getting frustrated, even exposing the bindings requires setting a config option: open /user/advanced.cfg and set exposeKeybinds to 1.

The next time you run the game it will create two files:

* /user/keyboard.cfg lists the result of pressing each physical key on the keyboard, in terms of letters, numbers, punctuation, etc. It is referenced when entering text in game (e.g. typing hacking commands) and also used to automatically generate the next file below by converting the internal command defaults over to the alternative keyboard layout.
* /user/commands.cfg lists all commands recognized by the game, and the key combinations to trigger them. Technically the contents of this file simply override the defaults, so individual lines of unimportant commands can be freely removed to leave only the commands you care about changing.* Notice that the commands are divided into multiple groups ("domains")--a single domain cannot contain more than one command with the same definition, e.g. CMD_DOMAIN_COMMANDS cannot also assign the '5' key to access the gallery, because it already accesses the game menu (the latter would have to be changed to something else first). (*however, do not remove the domain header line for any domains which contain modified commands, otherwise the game will not know which domain they belong to)
Because you probably don't want to mess with all the little details, I've included presets for the most common use case that works nicely: switching to an alternative US101 layout. In the /rex/ directory you'll find Dvorak and Colemak presets. Delete any existing keyboard.cfg/commands.cfg in the /user/ directory, and copy the preset you want to /user/. Rename the preset file to "keyboard.cfg" and start the game, which will automatically create a commands.cfg based on that keyboard. No more configuration necessary (although again, be sure to set exposeKeybinds=1 first! otherwise it ignores these files).

Other notes:

* Changes to default commands are not currently reflected in the in-game help.
* To avoid conflicts, remember that if you bind a command to a new key, you'll want to also rebind the other command in the same domain that was originally bound to that same key (if there is one).
* Deleting both/either file will cause the game to recreate them with defaults again (QWERTY w/the usual commands).
* If you'd like to make changes in the keyboard file itself (such as describing a custom keyboard) and have those changes applied automatically to all appropriate commands, you'll want to delete the commands.cfg file and have the game generate it based on the new keyboard layout.
* This system only supports keyboard commands; mouse commands cannot be changed.
* SDL keycodes are kinda weird, so things like Shift-3 are actually represented by a single "HASH" (#), without the Shift modifier in the commands.cfg file... (this won't matter if we eventually have an in-game rebinding system, since that'll take care of these odd conversions automatically, but if you want to edit some commands you'll need to be aware of it)
* Unfortunately I don't think foreign/non-English keyboards can be perfectly supported by this system, nor would Cogmind be able to display the non-ASCII characters necessary to describe a command in the game itself (due to how its bitmap-based ASCII fonts work).
So... yeah :P. I'm glad to have finally gotten somewhere with keybinds, though having already put a lot of work into the system so far and seeing how much more would be necessary (a lot!) even though it would never be perfect, makes me unsure of whether or not it'll be revisited later. There are a number of factors suggesting it wouldn't be worth the huge amount of work required (like probably porting to a more modern engine) to go further:

* Cogmind is an English-only game, so non-US101 users are a small minority
* Lots of foreign/non-QWERTY users already have their own external keyboard solutions
* Cogmind cannot display non-ASCII characters
* All UI features are mouse-accessible, and three-quarters of players use the mouse
Anyway, we'll see what happens, but hopefully those who can already take full advantage of the system (Dvorak/Colemak users) will enjoy this new feature!

Feel free to ask any questions or leave any feedback on rebinding here in this thread.


Addendum:

* If you're looking for a WASD layout, Shadowfury333 has shared one here if you're a keyboard + mouse user.
* And I've created a WASDQEZC layout here for pure keyboard users.

Pilcrow:
I know this topic's a month old already, but it's a great idea and I have a question that is sort of related: is there a list of all keyboard commands available in the old 7DRL prototype?

I was actually thinking about making my own wrapper/launcher using AutoIt or AutoHotkey to add a key remapping ability to the prototype (with a full configuration window), and it would help to have a full list instead of having to hop back and forth between manual2.txt and the in-game commands/help screen, if such a list already exists (but if it doesn't, don't bother making one just for me; I can do that myself and don't need to tie up anyone else's time ;)).

Since those languages can also send a series of virtual keypresses, I was also considering adding the functionality to set a 'default' font/size which the wrapper/launcher would switch to on startup using the appropriate amount of Ctrl+PageUp keypresses (that would play nicely with my recent tilesets, and could even be made to check the user's resolution and send an Alt+Enter command to put the game in fullscreen mode at startup -- probably a tick box in the launcher if I decide to do that)... :P

Kyzrati:
Nope, in the 7DRL those two places are the only way to find them all (it's just two lists! pull up the manual2 list next to a copy of the game and that's everything).

That sounds like a really cool project though!

I wonder if an external solution like that would be feasible for modern Cogmind players using non-English keyboards, since I probably won't be able to support all of them internally.

Pilcrow:
Ah, that's fine then. As long as those two lists contain everything, I can easily make my program without feeling like I'm missing anything.   ;)

The way these languages work (one was originally a fork of the other, so they are similar), I think I can make them save to and read from a key config file that will handle remapping similar to Brogue. That is, one key will be interpreted as another when the game window is in focus. For example, if the config file contains a line that says a=b and the user presses the a key, the wrapper will interrupt the keycode and send the one for b instead. I've used these languages before for other games and know they work well (though I've only ever used hard-coded keycodes rather than configurable ones), plus I'd release the source so people could use it without any qualms, but some users may be weary of it anyway: reading and intercepting keycodes sounds an awful lot like what a keylogger does (and may even trigger a false positive in certain virus/malware scanners)...  :/

And yes, an external solution like that would probably work for non-English keyboards too, but I have no way of testing that since I don't actually own a non-English keyboard. Plus, the possibility of certain scanners throwing a false-positive about it being a keylogger means it might not be the most professional solution for your commercial game either...  :/

Another limitation that can be kind of annoying for certain games is that AutoIt/AutoHotkey programs usually can't distinguish between in-game dialog windows, so a "what is your name" screen would have some very strange behavior, lol. When I made a remapping program for the PC version of Phantasy Star Online, I got around this limitation by programming a key command (mapped to Ctrl+Tab IIRC) to toggle the remapping of the other keys...

Kyzrati:

--- Quote from: Pilcrow on August 04, 2017, 09:12:12 PM ---but I have no way of testing that since I don't actually own a non-English keyboard.

--- End quote ---
On Windows at least you don't actually need a real keyboard--you can use the virtual keyboard, which can be set to any of the common ones fairly easily. Like I don't have a French keyboard, but I was able to pull up an AZERTY keyboard on screen and click keys to test out the system. It's how I tested this rebinding system (with Dvorak, too), the development of which I wrote more about here.


--- Quote from: Pilcrow on August 04, 2017, 09:12:12 PM --- I got around this limitation by programming a key command (mapped to Ctrl+Tab IIRC) to toggle the remapping of the other keys...

--- End quote ---
Ah yeah, that would be important :P. In Cogmind there's the manual hacking interface (and name/seed entry), which the 7DRL didn't have.

Navigation

[0] Message Index

[#] Next page

Go to full version