Key/button repeat

So, I’m currently checking for SDL_KEYDOWN events to navigate around in a menu in my game. If I hold down the ‘down’ key, I can move quickly down through the menu, due to key repeat. This is what I want to happen, but I am curious how exactly key repeat works/is controlled in SDL2.

So, how does it work exactly?

Also, is there any way to enable the same kind of repeating for controller buttons? I looked in the SDL_ControllerButtonEvent struct and didn’t see anything about repeat, which I did see in SDL_KeyboardEvent. I’m guessing there is no such option, but I thought I’d ask. Thanks!

http://sdl.beuc.net/sdl.wiki/SDL_EnableKeyRepeat exaplains a little bit
about it.

not really sure about the delay in repeating in joysticks.

2014-03-21 3:31 GMT-07:00 Dark_Oppressor :> So, I’m currently checking for SDL_KEYDOWN events to navigate around in

a menu in my game. If I hold down the ‘down’ key, I can move quickly down
through the menu, due to key repeat. This is what I want to happen, but I
am curious how exactly key repeat works/is controlled in SDL2.

So, how does it work exactly?

Also, is there any way to enable the same kind of repeating for controller
buttons? I looked in the SDL_ControllerButtonEvent struct and didn’t see
anything about repeat, which I did see in SDL_KeyboardEvent. I’m guessing
there is no such option, but I thought I’d ask. Thanks!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Javier Flores

But that is for SDL 1.2, isn’t it? I’m working with SDL2, which doesn’t seem to have SDL_EnableKeyRepeat. Unless I’m missing something?

javierecf wrote:> http://sdl.beuc.net/sdl.wiki/SDL_EnableKeyRepeat (http://sdl.beuc.net/sdl.wiki/SDL_EnableKeyRepeat) exaplains a little bit about it.

not really sure about the delay in repeating in joysticks.

2014-03-21 3:31 GMT-07:00 Dark_Oppressor <DarkOppressor at gmail.com (DarkOppressor at gmail.com)>:

  So, I'm currently checking for SDL_KEYDOWN events to navigate around in a menu in my game. If I hold down the 'down' key, I can move quickly down through the menu, due to key repeat. This is what I want to happen, but I am curious how exactly key repeat works/is controlled in SDL2.

So, how does it work exactly?

Also, is there any way to enable the same kind of repeating for controller buttons? I looked in the SDL_ControllerButtonEvent struct and didn’t see anything about repeat, which I did see in SDL_KeyboardEvent. I’m guessing there is no such option, but I thought I’d ask. Thanks!


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)


Javier Flores

oh yes, mmm i guess sdl2 now uses the OS settings?, not sure. or maybe the
holding key is just passed as nothing and always is 0 time between
repeating. so its up to you to code flags and timers along
SDL_GetKeyboardState(). to know the state of the keys… not really sure
tho.

2014-03-21 18:57 GMT-07:00 Dark_Oppressor :> But that is for SDL 1.2, isn’t it? I’m working with SDL2, which doesn’t

seem to have SDL_EnableKeyRepeat. Unless I’m missing something?

javierecf wrote:

http://sdl.beuc.net/sdl.wiki/SDL_EnableKeyRepeat exaplains a little bit
about it.

not really sure about the delay in repeating in joysticks.

2014-03-21 3:31 GMT-07:00 Dark_Oppressor <>:

Quote:

So, I’m currently checking for SDL_KEYDOWN events to navigate around in
a menu in my game. If I hold down the ‘down’ key, I can move quickly down
through the menu, due to key repeat. This is what I want to happen, but I
am curious how exactly key repeat works/is controlled in SDL2.

So, how does it work exactly?

Also, is there any way to enable the same kind of repeating for controller
buttons? I looked in the SDL_ControllerButtonEvent struct and didn’t see
anything about repeat, which I did see in SDL_KeyboardEvent. I’m guessing
there is no such option, but I thought I’d ask. Thanks!


SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Javier Flores


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Javier Flores

But that is for SDL 1.2, isn’t it? I’m working with SDL2, which doesn’t seem to have SDL_EnableKeyRepeat. Unless I’m missing something?

Look in the SDL_KeyboardEvent struct in SDL_events.h:

Uint8 repeat; /**< Non-zero if this is a key repeat */

I haven’t used it myself. Give it a try.–
Terry Welsh
http://www.reallyslick.com

I think it uses the OS settings.
Not sure what you mean with “holding key is just passed as nothing”, but
key repeats do generate multiple SDL_KEYDOWN events and event.key.repeat
is != 0 for the repeated events.
You’ll only get an SDL_KEYUP once (when the key is not pressed anymore),
not for each repeat.

Cheers,
DanielAm 22.03.2014 03:13, schrieb Javier Flores:

oh yes, mmm i guess sdl2 now uses the OS settings?, not sure. or maybe
the holding key is just passed as nothing and always is 0 time between
repeating. so its up to you to code flags and timers along
SDL_GetKeyboardState(). to know the state of the keys… not really
sure tho.

2014-03-21 18:57 GMT-07:00 Dark_Oppressor <DarkOppressor at gmail.com
<mailto:DarkOppressor at gmail.com>>:

__
But that is for SDL 1.2, isn't it? I'm working with SDL2, which
doesn't seem to have SDL_EnableKeyRepeat. Unless I'm missing something?




javierecf wrote:	

http://sdl.beuc.net/sdl.wiki/SDL_EnableKeyRepeat exaplains a little
bit about it.


not really sure about the delay in repeating in joysticks.



2014-03-21 3:31 GMT-07:00 Dark_Oppressor <>:



Quote:	

So, I'm currently checking for SDL_KEYDOWN events to navigate around
in a menu in my game. If I hold down the 'down' key, I can move
quickly down through the menu, due to key repeat. This is what I
want to happen, but I am curious how exactly key repeat works/is
controlled in SDL2.

So, how does it work exactly?

Also, is there any way to enable the same kind of repeating for
controller buttons? I looked in the SDL_ControllerButtonEvent struct
and didn't see anything about repeat, which I did see in
SDL_KeyboardEvent. I'm guessing there is no such option, but I
thought I'd ask. Thanks!


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

	




--
Javier Flores	


_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


/Javier Flores/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

OK, thanks guys!