I'm with Bram on this. We can do it in X11. We can do it in Windows. (Otherwise CounterStrike would not work) Mac-X is based on FreeBSD and I'd bet you 50$ we can do it there.

Maybe there wasn't an X event back in 1992 (I'm making that date up) when GLUT was first coded up, but there sure is now.

Is there any reason besides stubborness not to send the Meta keys to the user?

Add GLUT_KEY_SHIFT, GLUT_KEY_ALT, GLUT_KEY_META1, GLUT_KEY_META2 or whatever...  ON my Linux box, the "windows" button fires off as keycode=115

This is not all that hard to do.

Larry E. Ramey.

(Hey Bram! Still plugging away at SARA I see.... would you believe I have the performer archives open to one of your old questions about pfTexture? Of course you didn't get an answer either.....)

----- Original Message ----
From: Bram Stolk <bram@sara.nl>
To: FreeGLUT developers list <freeglut-developer@lists.sourceforge.net>
Sent: Wednesday, October 25, 2006 3:01:26 AM
Subject: Re: [Freeglut-developer] Status of modifier keys (shift/ctrl/alt)

steve wrote:
> Bill Kelly wrote:
>> Sorry for my n00b question - but to clarify: Does that mean
>> one can't get an event for the modifier keys themselves?
> Right - there is no X-windows event for one of those keys
> changing state.

Yes there is.
You get a KeyPress/KeyRelease event if you press or release Shift, or Ctrl,
or any other key.

You can test this very easily: start up 'xev' (comes standard with x11)
and press the Shift key. You will see the generated event on stdout.

I once hacked in better key handling support in glut, because I
was annoyed by the fact that I could not, e.g. use the default
Quake key 'Ctrl' which is fire, in my own programs.
Unfortunately, this was a x11-only hack, so completely non-portable.

In short, my hack came down to something like this:
< #ifndef NO_BRAM_HACK
<         /* This section was added by Bram Stolk (bram.s at chello.nl) */
<         /* to accomodate a complete keypress detection of */
<         /* all keys known to x11. We will avoid GLUT_KEY_XXX */
<         /* usage, by using the X11 key description. */
<         if (window->x11_keyboard)
<         {
<           KeySym ks;    /* x11 key symbol */
<           char *desc;   /* a descriptive string for the key */
<           ks = XLookupKeysym((XKeyEvent *) & event, 0);
<           desc = XKeysymToString(ks);
<           window->x11_keyboard(desc, (event.type == KeyPress));
<         }
< #endif

This enabled me to detect a press or release of all 101 keys on my keyboard.
Even the weird windows key, and a 'menu' key :-)


Bram Stolk, VR Engineer SARA, Amsterdam.   tel +31 20 592 3000

"Windows is a 32-bit extension to a 16-bit graphical shell for an 8-bit
operating system originally coded for a 4-bit microprocessor by a 2-bit
company that can't stand 1 bit of competition."

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
Freeglut-developer mailing list