Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Same effect as KeyPressed with Gamepad  (Read 2415 times)

0 Members and 1 Guest are viewing this topic.

_darkus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Same effect as KeyPressed with Gamepad
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Same effect as KeyPressed with Gamepad
« Reply #1 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.
Laurent Gomila - SFML developer

_darkus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Same effect as KeyPressed with Gamepad
« Reply #2 on: August 17, 2013, 07:16:36 pm »
I'll try it, thanks for fast answer. ;)