Key press events

I’m using the sample 3-10 program located here:

http://docs.mandragor.org/files/Common_libs_documentation/SDL/SDL_Documentation_project_en/guideinputkeyboard.html

I’m writing a program on top of X Windows and I’m not getting any key
press events apart from the CTRL-C.

If there’s any ideas why there SDL_PollEvent doesn’t return any key
press events, I’d love to hear them!

Thank you!

  • Chris

Does your window have the focus? If not, it won’t get any events at
all. Perhaps the shell still has focus.

Try grabbing the input:

SDL_WM_GrabInput(SDL_GRAB_ON);

in which case you should get everything. Make sure you have a way to
exit the program cleanly :slight_smile:

Stoned koala bears drooled eucalyptus spit in awe as Taylor Chris
Nohara said:> I’m using the sample 3-10 program located here:

http://docs.mandragor.org/files/Common_libs_documentation/SDL/SDL_Documentation_project_en/guideinputkeyboard.html

I’m writing a program on top of X Windows and I’m not getting any key
press events apart from the CTRL-C.

If there’s any ideas why there SDL_PollEvent doesn’t return any key
press events, I’d love to hear them!


William Brodie-Tyrrell

Carpe Diem - fish of the day.

<@William_Brodie-Tyrre>
http://www.brodie-tyrrell.org/

I’m writing a program on top of X Windows and I’m not getting any key
press events apart from the CTRL-C.

SDL catches SIGINT (which is sent when you hit ctrl-c in the terminal
where you launched the program) and sends an SDL_QUIT event in response
to it, to give apps a convenient way to clean up…it makes a
standardish Unix quit request look like they clicked the window
manager’s close button.

So I guess I’m asking: are you sure the SDL window has the focus?

Also, if you’re using Example 3-10, there’s no SDL_Init() or
SDL_SetVideoMode() call there…you won’t get keyboard events unless
there’s a window to get events (which would also explain the ctrl-c
thing)…use the later example code in that article.

–ryan.

What does your code look like?On 10/31/06, Taylor Chris Nohara wrote:

I’m using the sample 3-10 program located here:

http://docs.mandragor.org/files/Common_libs_documentation/SDL/SDL_Documentation_project_en/guideinputkeyboard.html

I’m writing a program on top of X Windows and I’m not getting any key
press events apart from the CTRL-C.

If there’s any ideas why there SDL_PollEvent doesn’t return any key
press events, I’d love to hear them!


E-Mail: Chris Nystrom <@Chris_Nystrom>
http://www.newio.org/
AIM: nystromchris