SFML community forums
Help => General => Topic started by: Dschoonmaker on July 16, 2018, 09:41:06 pm
-
Hello, I am making a game and want to add custom keybinds (like in Zloxx II, except with gamepad support).
Currently, I have the game working with my gamepad, but I want users to be able to make it work with custom controls/gamepad.
Thanks in advance.
-
I think you can have the screen tell the player to press a button, save the button they press, and then set that button to be the button that activates something.
-
Have a look at chapter 6 (https://github.com/SFML/SFML-Game-Development-Book) of the SFML Game Development book
-
You might also be interested in this topic: https://en.sfml-dev.org/forums/index.php?topic=23926.0
-
Wow, thanks for the quick replies, guys! :)
verdog, I was thinking something like what you mentioned. Do you know how to save the button they pressed?
-
Do you know how to save the button they pressed?
Store the value of the keycode given in the keypressed event.
-
Hapax what about mouse or joystick events?
-
Hapax what about mouse or joystick events?
For mouse you can use Mouse::Button (Documentation) (https://www.sfml-dev.org/documentation/2.5.0/structsf_1_1Event_1_1MouseButtonEvent.php).
For joystick events you can use button indexes (which are just numbers) (Documentation) (https://www.sfml-dev.org/documentation/2.5.0/structsf_1_1Event_1_1JoystickButtonEvent.php)
-
Hapax what about mouse or joystick events?
My bad. I read it as "keybinds" since the point about wanting to add controllers was within the following brackets (in the first sentence).