Disclaimer: I'm using SFML 2.0...
I'm very confused. I'm trying to implement a way for the player of my game to customize their controls.
Basically, they highlight the action they want to change, let's say, "Jump." They press A, which indicates that the game should now "listen" for a button press and set whatever button to be the "Jump" button. Just like any game you've ever played that allowed custom controls.
However, if I set my bool _listening to true and then move the joystick, it's recognizing the joystick having been moved as a "button press" and sets the button value to either 0 for the x axis or 1 for the y axis.
How the heck do I fix this? I really feel like moving the joystick should not be triggering a button pressed event. The offending code:
else if (_controlsSetup && _listening)
{
// leaving this code here just in case it's a matter
// of {'s or }'s
if (event.type == sf::Event::KeyPressed)
{
if(event.key.code == sf::Keyboard::Return)
{
_keyToStore = ""; // Indicates what action (jump, shoot) the key press is for
_buttonToStore = ""; // ditto for controller buttons.
_listening = false;
}
else if(_keyboardSettings)
{
game()->settings()->keyIs(_keyToStore, event.key.code);
_keyToStore = "";
_listening = false;
}
}
if (event.type = sf::Event::JoystickButtonPressed)
{
// SOMEHOW we are arriving here despite no buttons being pressed, only the joystick being moved.
if(_controllerSettings)
{
_listening = false;
game()->settings()->buttonIs(_buttonToStore, event.joystickButton.button);
_buttonToStore = "";
}
}
}
As always, any help is deeply appreciated. I imagine it's something dumb but...