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

Author Topic: Key repeat behavior  (Read 3880 times)

0 Members and 1 Guest are viewing this topic.

NON

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Key repeat behavior
« on: November 23, 2012, 01:45:09 pm »
Hi
I have a game (Roguelike) that I'm considering migrating from SDL 1.2 to SFML. I've heard great things about SFML in general, and it seems to suit me perfectly. But there's one thing I'm concerned about that I can't find an answer to.

I want the key repeat to behave just like when typing text in Windows and Linux, i.e. when user holds down a key, there is one "event" (letter typed/player character moves, or whatever), then a small delay before repeating starts. In SDL this is controlled by "SDL_EnableKeyRepeat(int delay, int interval)".

I don't care so much about the specific delay or interval timings, but it's important for me that the behavior of it is such as I described above. I'm hoping I don't have to write my own code to handle this.

So how does it work in SFML? Happy for a fast response as I'm eager to try it! :D

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Key repeat behavior
« Reply #1 on: November 23, 2012, 01:49:46 pm »
Yes, enabling/disabling key repeat is possible: sf::Window::setKeyRepeatEnabled()

By the way, begin with SFML 2 (either RC or GitHub revision), not an old SFML 1.x version.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

NON

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Key repeat behavior
« Reply #2 on: November 23, 2012, 01:55:31 pm »
Yes, enabling/disabling key repeat is possible: sf::Window::setKeyRepeatEnabled()
Yeah but that doesn't answer my question. What I need to know is, is the behavior like this:

A) <User holds down key> - <one event> - <short delay> - <events repeating quickly>

-or like this:

B) <User holds down key> - <events repeating quickly>

By the way, begin with SFML 2 (either RC or GitHub revision), not an old SFML 1.x version.
Thanks, that was my plan :)
« Last Edit: November 23, 2012, 01:57:17 pm by NON »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Key repeat behavior
« Reply #3 on: November 23, 2012, 02:06:18 pm »
Yeah but that doesn't answer my question.
Next time, write the question down, instead of having it in mind ;)

The behavior is as you described in A).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

NON

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Key repeat behavior
« Reply #4 on: November 23, 2012, 02:14:20 pm »
Next time, write the question down, instead of having it in mind ;)
I did write it down in my original post didn't I? I assumed this was clear enough:

Quote from: Me
I want the key repeat to behave just like when typing text in Windows and Linux, i.e. when user holds down a key, there is one "event" (letter typed/player character moves, or whatever), then a small delay before repeating starts.

The behavior is as you described in A).
Excellent.