Sign in to follow this  

Custom keybinds/name input?

This topic is 1950 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

Hi there
I've googled this topic for a bit but didn't come up with a good solution yet so I thought I might bring this up here:
Is there a way to write custom keybinds for an options menu (e.g. there is an entry for "Up" in the game and you can then rebind it for whatever key you like: w, t, up, enter etc...). I guess the menu has to check every single key for whether it was pressed during the rebind? (also I'd like to then save each individual bind to a config file but I'm going to read up on how to do that myself ;) ).

The same basically goes for entering a name, right? I mean, it also has to check every key and write the associated letter :S

I've seen people do that by writing out every Key, but I guess thats no graceful solution?
greetings

//EDIT:
Sorry for posting this ^^ I didn't know there was already a thread on this here -.- Edited by fuerchter

Share this post


Link to post
Share on other sites
The key is to [b]define a list of actions [/b]that is needed by your game: up, down, left, right, jump, fire, etc.. and store on these actions the key selected:
[code]
Keys up, down, left, right, jump, fire;
[/code]

Now when you enter your option menu to configure "jump" action (for example) you need to listen for keyboard pressed keys and, when is pressed [b]only one key[/b], you can store jump binding like this:
[code]
jump = Keyboard.GetState().GetPressedKeys()[0];
[/code]

You need to take care to [b]wait the release[/b] of the key used in the option menu to enter the "key selection mode" (if you use Enter you need to wait for Enter release to avoid to bind jump to enter key).

This link can help you (but I don't know your programming level):
[url="http://joecrossdevelopment.wordpress.com/2012/05/17/xna-engine-part-1-input-module-class-layout-and-goals/"]http://joecrossdevel...yout-and-goals/[/url]

Check also this link, is usefull for GamePad/Mouse/Keyboard input design:
[url="http://classes.soe.ucsc.edu/cmps020/Winter08/lectures/controller-keyboard-input.pdf"]http://classes.soe.u...board-input.pdf[/url]

Share this post


Link to post
Share on other sites

This topic is 1950 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this