Grid Sage Forums

Grid Sage Forums

  • October 19, 2017, 09:21:13 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Alpha Access LAUNCHED! Buy Now! (Trailer)

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

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 2532
    • 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/cogmind.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).

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.
« Last Edit: October 12, 2017, 07:12:51 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: 2532
    • 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: 2532
    • 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 Stealth Win Weekly Seed Participant Bug Hunter
  • Posts: 128
    • 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: 2532
    • 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 Stealth Win Weekly Seed Participant Bug Hunter
  • Posts: 128
    • 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: 33
    • 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: 2532
    • 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: 33
    • 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: 2532
    • 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: 33
    • 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: 2532
    • 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: 2532
    • 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