Jump to content
  • Advertisement
Sign in to follow this  
Zipster

Consistent handling of hotkeys in other languages

This topic is 1132 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently came across an interesting issue with how we handle hotkey mapping under international keyboard layouts, as was wondering if others have encountered a similar issue and how they dealt with it.

 

Right now we use some common hotkey groupings as defaults in our game (WASD, QWERTY, etc.). However we noticed that if the user changes their active keyboard layout to something else, like Turkish, these defaults no longer work that well because we map from virtual keys, and these virtual keys are only physically grouped together on a handful of keyboard layouts (U.S. in our case).

 

The user can always remap their keys, but I'm hoping to come up with some sort of solution to automatically map the default virtual key assignments from the assumed U.S. keyboard layout to the active keyboard layout, at the very least to preserve the usefulness of the defaults for as many players as possible. However the more I look into it, the less feasible it seems.

 

Does anyone have any experience with this issue? Did you find a solution/workaround, or did you just accept that your default keyboard bindings might suck for some international users and have them re-bind their keys?

Share this post


Link to post
Share on other sites
Advertisement

Virtual keys have the same physical position in every keyboard layout. So the WASD virtual keys will be on the upper left part on every keyboard. However the text on the actual keys will be different. This is ideal for game control keys, because their position is important, not the text on them. And virtual keys can handle special keys like shift, ctrl etc too.

 

Off course on the keyboard binding screen you have to translate the name of the virtual key based on the actual keyboard layout with the OS.

 

If you want to use a textual input, you shouldn't use virtual keys at all. There are many different input methods in different languages that you probably don't want handle. You should use the unicode character codes from the windows messages.

 

Share this post


Link to post
Share on other sites

Virtual keys have the same physical position in every keyboard layout.

 

I was initially under this impression as well, but unfortunately it doesn't appear to be the case. It's easy enough to demonstrate, just breakpoint your WM_KEYDOWN handler and press a key -- such as 'Q' -- with an 'English - US' keyboard set. The virtual key code is 0x51, as you'd expect. Now use the language bar to switch the keyboard to something like 'Turkish (Turkey) - Turkish F'. The same 'Q' key now has a virtual key code of 0x46, which is what you'd expect from the 'F' key. The OEM codes can get especially jumbled.

Share this post


Link to post
Share on other sites


The user can always remap their keys, but I'm hoping to come up with some sort of solution to automatically map the default virtual key assignments from the assumed U.S. keyboard layout to the active keyboard layout

^^ You already have the best solution.

 

Assuming you've got a global audience you should have people familiar with that region who can inform you about common shortcuts. Assuming Windows, you can look at Windows keyboard layouts to see what they are mapped to physically, and you can use GetKeyboardLayout() to see what is currently in use.  

 

If the result of GetKeyboardLayout() is one you recognize then default to that layout.  Otherwise, use your game's default.

 

After you've picked your default, allow the user to remap their keys to anything they want, or to switch between any of the prebuilt defaults you have created.

Share this post


Link to post
Share on other sites


...you can look at Windows keyboard layouts to see what they are mapped to physically...

Thanks for the reference!

 

I figured that we might just have to set up a few common defaults for our core supported languages, but just wanted to do my due diligence first and see if we couldn't make it easier and more automated for our designers and users :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!