Grid Sage Forums

Grid Sage Forums

  • February 22, 2018, 11:43:30 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

LINKS: Website | Steam | Wiki

Author Topic: Experimental Keyboard Layouts and Command Rebinding  (Read 1233 times)

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Experimental Keyboard Layouts and Command Rebinding
« on: July 04, 2017, 07:29:44 PM »

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.
« Last Edit: December 21, 2017, 05:43:28 PM by Kyzrati »
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Pilcrow

  • Unaware
  • *
  • Posts: 8
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #1 on: August 04, 2017, 01:34:00 PM »

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
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #2 on: August 04, 2017, 07:23:27 PM »

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.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Pilcrow

  • Unaware
  • *
  • Posts: 8
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #3 on: August 04, 2017, 09:12:12 PM »

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...
« Last Edit: August 05, 2017, 11:38:41 AM by Pilcrow »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #4 on: August 05, 2017, 04:36:26 AM »

but I have no way of testing that since I don't actually own a non-English keyboard.
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.

I got around this limitation by programming a key command (mapped to Ctrl+Tab IIRC) to toggle the remapping of the other keys...
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.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Pilcrow

  • Unaware
  • *
  • Posts: 8
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #5 on: August 05, 2017, 11:33:54 AM »

Oh, I forgot all about virtual keyboards! I don't actually use Windows (Cogmind works perfectly through Wine in GNU/Linux), but I've got my own virtual keyboard installed and I just checked -- it can also be configured for other layouts.  :D
Logged

DDarkray

  • Cyborg
  • ***
  • Shared a Confirmed Combat Win Shared a Confirmed Stealth Win Wiki Contributor Bug Hunter Weekly Seed Participant
  • Posts: 179
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #6 on: September 28, 2017, 05:04:14 PM »

Just wanting to testify that the keyboard rebinding feature works really well for me! My F2 key (which toggles keyboard mode) doesn't work with my laptop, so I have to switch it with another key. After moving the keyboard mode to the 'P' key, I got it working! I'm pretty happy with the result. :)
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #7 on: September 28, 2017, 06:35:13 PM »

Awesome! This is like... the first report of rebind use in the wild (aside from players I know are using the automatic keyboard layout rebinding, which is a somewhat different thing).

And yeah 'p' is a great key for anyone to replace with something they want to use frequently that may have a harder key combo, since the p key exists purely as an easy way to teach new players in the tutorial how parts need to be activated. Once the autoactivate feature is toggled, after that you never need it again :P

Now you can quickly switch between mouse and dedicated kb mode with ease like the rest of us :D
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

DDarkray

  • Cyborg
  • ***
  • Shared a Confirmed Combat Win Shared a Confirmed Stealth Win Wiki Contributor Bug Hunter Weekly Seed Participant
  • Posts: 179
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #8 on: September 28, 2017, 08:04:09 PM »

Now you can quickly switch between mouse and dedicated kb mode with ease like the rest of us :D

Gone with the habit of pressing Esc, 4, U, Esc just for the keyboard mode! You will not be missed. :P
« Last Edit: September 28, 2017, 10:49:08 PM by DDarkray »
Logged

Shadowfury333

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 42
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #9 on: September 28, 2017, 09:16:05 PM »

Awesome! This is like... the first report of rebind use in the wild (aside from players I know are using the automatic keyboard layout rebinding, which is a somewhat different thing).

I suppose I should have posted my WASD stuff in this thread rather than its own, but meh.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #10 on: September 29, 2017, 12:12:51 AM »

Well you can link to it from your post there, but technically this thread's about Cogmind's own internal rebinding solution, whereas yours is an external one. (Which by the way, thank you for providing that :D) That and you have a dedicated discussion thread for your own in case someone has questions about it, or modifications. I imagine there will be some more users who want to take advantage of it once we have a bigger player base from Steam.

Here, I'll link it for you :)
Shadowfury333's WASD Cogmind solution!
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Sindaleho

  • Unaware
  • *
  • Posts: 2
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #11 on: October 02, 2017, 12:17:59 PM »

I play left-handed, so any type of rebinding updates you do are very well received by me! Thanks
Logged

Shadowfury333

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 42
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #12 on: October 12, 2017, 09:05:46 AM »

There seems to be a bug with transferring a complete commands.cfg from b2.1 to b3. It seems almost centered on a weird name sync bug when generating a new commands.cfg file in b3, starting at line 174:

Code: [Select]
171  CMD_BS_DEFAULT_WAIT                     "Stair/Trap Interaction (2)"    -       -       -       GREATER
172  CMD_BS_DEFAULT_WAIT_M                   "Wait (1)"                      -       -       -       KP5
173  CMD_BS_DEFAULT_WAIT_M                   "Wait (2)"                      -       -       -       PERIOD
174  CMD_BS_DEFAULT_GET_ATTACH               "Get Item"                      -       -       -       g
175  CMD_BS_DEFAULT_DETACH_ALL               "Get Item and Attach"           -       -       -       a
176  CMD_BS_DEFAULT_LOOK                     "Go Naked"                      -       Shift   Alt     p

The thing is that it still works as the descriptions would suggest, rather than the CMD_* string. I'm not even sure how the commands.cfg works anymore.
« Last Edit: October 12, 2017, 09:29:19 AM by Shadowfury333 »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #13 on: October 12, 2017, 09:28:43 AM »

Ah yeah, I put info about this in the Beta 3 release announcement (as a note under the "Update ASAP" section). There was a change in code in Beta 3 that didn't account for people actually using the commands.cfg, and adjustments to some core commands at the top of the file (made for the Steam release) messed up others in the file. And yeah, you're right the underlying cause is a name syncing issue.

It seems there may still be something newly wrong with the commands.cfg, even in Beta 3 with a fresh copy--DDarkRay has encountered an unconfirmed oddity even after making a new set, though I haven't had time to look into that since the build is frozen for Steam release right now.

Either way, start with a fresh commands.cfg and try that.

(This system overall is definitely still experimental since not many people have used it and reported back, though it's possible we do have a new development here which needs to be addressed. Any more information following a reset is welcome!)

Update 171013: It seems to be working fine, although in Beta 3 it may no longer be possible to delete non-rebound commands from commands.cfg and still have it always work. I'll have to test this later and see what's up, but for now at least using a complete copy and doing rebinds seems to be working as expected.
« Last Edit: October 12, 2017, 07:15:26 PM by Kyzrati »
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Shadowfury333

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 42
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #14 on: October 12, 2017, 05:44:07 PM »

Rebuilding from a fresh Beta 3 commands.cfg works (not sure if perfectly, it only modifies movement, pickup, info, and ally order keys), and I've updated the WASD github release with beta 3 compatible keybinds.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #15 on: October 12, 2017, 06:27:32 PM »

Thank you! I should've dropped the update message in this thread as well xD

In the future I'll definitely be more careful about updates that may affect this system.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #16 on: October 17, 2017, 02:26:44 AM »

As Cogmind is now on Steam, we have some more players coming in, and among them are QWERTZ users. Although Cogmind can't fully support foreign keyboards, since the partial binding I included with the game for AZERTY players seems to be useful for some, attached is a new partial QWERTZ layout.

(Again, it's only partial, but better than nothing and worth a shot for those who aren't opting to use a better external solution.)
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #17 on: December 21, 2017, 05:41:59 PM »

By request I've created a simple WASD layout, which only adjusts letter keys to enable WASDQEZC movement for all directions while taking functions originally assigned to those keys and putting them over to the right on HJKLYUBN (vi) movement keys.

This turned out to be not too problematic in terms of understanding, since half of the WASDQEZC keys are occupied by part visualization mode controls, which conveniently appear in the row of buttons at the bottom of the Parts window, so I just moved those (from CEWQ) to HJKL to keep them in the same order as the buttons appear there. Therefore:
Coverage/Vulnerability  C -> H
Energy/Heat             E -> J
Integrity/Mass          W -> K
Info/Matter             Q -> L


The remaining four commands are switched as follows:
Direct Attach  A -> Y
Status         S -> U
Data           D -> B
Intel Mode     Z -> N

Status and Intel Mode aren't used very often anyway--the most commonly used commands here are Data and Direct Attach.

I've tested it a bit and everything seems to be working as a WASD user would expect, though be aware of the following quirks:
  • Cogmind's HJKLYUBN run movement modifier ('r') works with WASD as well, but was originally placed at 'r' because that key is convenient for vi users--it seems quite inconvenient players who want to use WASD. I could change the run modifier to 'p', which is an otherwise unimportant key, moving it to the other side of the keyboard for easier usage, but unfortunately the 'r' modifier is one of the very few hard-coded command modifiers in the game, so it cannot be moved via commands.cfg and I'd have to code a special advanced.cfg setting to enable that adjustment if there is interest in such a change among WASD players.
  • 'd' is also normally used to activate keyboard mode's modal drop mode, so that has moved over to 'b' along with Data. Drop mode is rarely used anyway, being primarily added for a minority of Linux players who don't have access to the Alt key.

Beta 4 includes the relevant commands.cfg file in its /rex/ directory.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Shadowfury333

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 42
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #18 on: December 23, 2017, 02:27:37 PM »

Wait, 'r' is a hardcoded function? I've been using it for player status in my 8-way WASD keybind and hadn't noticed any issues. I suppose I should consider moving self-status to another key to allow running.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #19 on: December 23, 2017, 04:40:24 PM »

'r' is only a hard-coded function when combined with a movement key, which is why you wouldn't have noticed it. I'm pretty sure you can continue to use it as you are if you want, without issue.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Shadowfury333

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 42
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #20 on: December 23, 2017, 10:01:27 PM »

I mean, it doesn't have an effect if it is set to show status, it's more that because shift+w/a/s/d produces the information for the item at slot w/a/s/d I can't use that for running, so having a key that works with wasd for running would be nice.

On the other hand, it would be easier to have something like DoomRL where hitting a key (spacebar in DoomRL by default) makes the next movement action a run.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #21 on: December 24, 2017, 12:42:07 AM »

Ah, yeah I've added a number of modal keyboard commands since the first release but there's no such thing for running yet. The way I implemented it was to just check if 'r' is being held when a movement key is pressed, in order to support vi running.

I can see how a modifier would work... even better, eh?

Then it could become a real key in the normal system that could be reassigned, too. I guess I didn't think about that one enough and wanted to treat 'r' like modifier keys (e.g. Shift) normally behave, and how that is a run modifier, too.

I'll see about changing the implementation. (I guess on the user side the main issue there is if you want to string multiple runs together, you'd have to press the run key each time rather than now where you can just hold it down, as I like to do with the Shift key running. Is that how it works in DoomRL?)
« Last Edit: December 24, 2017, 12:43:38 AM by Kyzrati »
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames

Shadowfury333

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 42
    • View Profile
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #22 on: December 24, 2017, 01:07:00 PM »

Pretty much. DoomRL will automatically stop the player when getting to a doorway or staircase, and IIRC when spotting an enemy, but otherwise you just keep going.

Granted, when playing KB+M with my setup I tend to just tap the keys repeatedly to move quickly, but then again DoomRL is far more combat focused than Cogmind, so I'm usually going tap, tap, RMB (to shoot), tap, tap, tap, RMB,... the whole time, with the run command mostly for quickly getting to a staircase after clearing the level.

In Cogmind I almost always move a few spaces, look around, move a few more, look around, carefully consider what to go to, frantically run across a hall into another room, wait a bit, and so forth. If I have a Sensor Array I'm also often waiting for a bit between every few moves if I see something suspicious outside, so I'm not sure how much I'd even use a run command.
« Last Edit: December 24, 2017, 01:14:16 PM by Shadowfury333 »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2815
    • View Profile
    • Cogmind
Re: Experimental Keyboard Layouts and Command Rebinding
« Reply #23 on: December 24, 2017, 05:34:29 PM »

DoomRL will automatically stop the player when getting to a doorway or staircase, and IIRC when spotting an enemy, but otherwise you just keep going.
Yeah Cogmind already has autostopping on enemies and terrain features, that part of the behavior has been in there for a while. Was just interested in the keyboard modifier specifically.

so I'm not sure how much I'd even use a run command.
Hehe, yeah it's less useful/necessary in a lot of cases compared to other roguelikes, but I use it a fair bit as a combat bot going down hallways. Not like I usually have sensors anyway :P
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames