SFML community forums

Help => General => Topic started by: sdf123 on March 19, 2012, 09:51:03 pm

Title: Customizable controls
Post by: sdf123 on March 19, 2012, 09:51:03 pm
I want to make customizable controls for my game. Currently I'm checking for input in-game using Keyboard::isKeyPressed(). Is it possible to define a Key type variable which would store a keycode defined by the user to use with isKeyPressed() instead of using keycodes like Keyboard::Up, for example? Which function do I use to assign a keycode to that variable? I'm using SFML 2.0.
Title: Customizable controls
Post by: Contadotempo on March 20, 2012, 12:22:43 am
See if this helps you:
http://www.sfml-dev.org/wiki/en/tutoriels/bindevents_en

It's for SFML 1 but the philosophy can be the same for SFML 2.
Title: Customizable controls
Post by: Nexus on March 20, 2012, 12:41:44 pm
You can store entered keys in sf::Keyboard::Key variables.

If you need more flexibility (like dynamic mapping from keys to actions, or combining different keys), you could take a look at my event system here (http://www.bromeon.ch/libraries/thor/v1.1/tutorial-actions.html).