SFML community forums

Help => Window => Topic started by: _darkus on August 17, 2013, 06:57:41 pm

Title: Same effect as KeyPressed with Gamepad
Post by: _darkus on August 17, 2013, 06:57:41 pm
Hi there.
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left)
{
}
 
I use it for navigation in menu, its very easy to handle single key pressures.
But how can i imlement same single pressuers with gamepad?
I can check  "event.type == sf::Event::JoystickMoved" but even with small moving of stick there will be many pressures.
Thanks.
Title: Re: Same effect as KeyPressed with Gamepad
Post by: Laurent on August 17, 2013, 07:06:39 pm
There's no built-in way of doing it directly. You must use a short delay, i.e. ignore all JoystickMoved during X milliseconds after a pressure, until a new one can be triggered again.
Title: Re: Same effect as KeyPressed with Gamepad
Post by: _darkus on August 17, 2013, 07:16:36 pm
I'll try it, thanks for fast answer. ;)