A good key list for User Rebindability

Started by
4 comments, last by kburkhart84 6 years, 6 months ago

(Note to Mods: Could "Input" or "Peripherals" be a good Tag to add to the tag list? Just a thought.)

Hey, I'm currently working on which keys on a keyboard that a user can rebind their actions to. The trick is that I use a Norwegian keyboard, so it's not obvious which keys correspond to the actual C#/XNA Keys enum values.

Are there any keys from the XNA Keys enum that, in your opinion, I've neglected to add? I don't need all Keys to be bindable, only the "most commonly used keys on a keyboard". Thanks.
https://pastebin.com/n1cz8Y0u

Advertisement

Just FYI, in my code I allow every single key to be assigned.  This includes the famous media keys and things like that, as long as they are found as part of the 256(technically less) possible keycodes.  Now, I of course don't have actual descriptions for all those keys, and I won't ever be able to because I'm sure the more rare ones are going to be different for different keyboards.  The solution is to have a sort of "default" text that works for any undefined descriptions.  The words "Unknown Key" work for me.  This way, the player can still bind any key they want.  I don't think any players are going to care if you don't have a proper description for that really rare key they want to use for whatever reason.



Windows actually provides an API for retrieving the names of keys - GetKeyNameText().

A quick search found some old C++ example code at: http://www.setnode.com/blog/mapvirtualkey-getkeynametext-and-a-story-of-how-to/ - you probably don't need to worry about XP compatibility any more.

To use it from C# you'll probably want something like the example code at: https://stackoverflow.com/questions/38584015/using-getkeynametext-with-special-keys

On 11/19/2017 at 5:38 AM, kburkhart84 said:

I allow every single key to be assigned.

Thanks. Now that I think of it, I'm somewhat conflating what would be smart to default my keys to, with whatever the user might want to rebind them to, which is their responsibility and not my own. So I think I'll just include every key in the rebindable list, and instead just setup the defaults to the more common keys. I'm certainly going to have a "Revert to Default" option anyways.
 

On 11/20/2017 at 10:51 PM, Adam_42 said:

Windows actually provides an API for retrieving the names of keys - GetKeyNameText().

I'm trying to stick with XNA's Keys enum which is (afaik) is higher level and culture independent, but I'll keep your tip in mind and play around with it if needed. Thanks. :)

This is my thoughts on it...I have a default which should be somewhat usable, though not perfect.  I then allow any available keys on the keyboard to be used, whether I have proper names for them or not.  I allow the default to be loaded at any time too.  So what you have described in that last post is basically exactly what I would do.



This topic is closed to new replies.

Advertisement