[SDL] SDL - using keyboard with focus on another window (or console)

Bob Pendleton bob at pendleton.com
Thu Nov 20 14:52:01 PST 2003

On Thu, 2003-11-20 at 14:04, Jeremy Smith wrote:
> I have a quick question...
> I have written a program (called Zigzag, not designed by me) which uses the console-based Curses as its user interface OR OpenGL. The problem is that the keyboard library
> on Curses is actually better than OpenGL's, and I need platform-independent keyboard code for Linux, MacOSX and Windows (the program runs on all these platforms).

Are you asking about ncurses and glut, by any chance? I ask because I
believe that curses has been pretty much replaced by ncurses and OpenGL
does not have any keyboard support.

> A friend recommended SDL for this, and it looks like an excellent library, but... It seems I have to have the window focus on an SDL video window. The problem here is that
> Curses is not compatible with a 2d framebuffer, and OpenGL definitely isn't! I need keyup/keydown and modifiers such as Ctrl, Alt, etc and OpenGL doesn't support Alt, etc.
> So my question is, can I use SDL to intercept keystrokes without having to use an SDL window to capture them?

The way you do it is to use OpenGL *in* an SDL window. Then you can use
SDL to capture all the input information you want and use it with
OpenGL. Look at testgl.c in the SDL source code and at
http://linux.oreillynet.com/pub/a/linux/2003/10/23/sdl_anim.html, also
the SDL documentation is at  http://sdldoc.csn.ul.ie/ the part that
applies most directly to your problem is at

		Bob Pendleton

> Cheers,
> Jeremy.
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
+ Bob Pendleton: writer and programmer. +
+ email: Bob at Pendleton.com              +
+ web:   www.GameProgrammer.com         +

More information about the SDL mailing list