|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
Status of modifier keys (shift/ctrl/alt)Hello!
I am developing a game / navigation framework (*) using GLUT and now FreeGLUT. Everything is fine, there is just an annoying detail: the change of status in modifier keys (shift/ctrl/alt) is noticed only when something else happens (other keys, or mouse event). If I call glutGetModifiers from glutDisplayFunc or glutIdleFunc I get this message on the console (as well as nasty effects): GLUT: Warning in .\GLOBE_3D_Demo.exe: glutCurrentModifiers: do not call outside core input callback. So, my question: how to get a fresh status of these modifier keys, independently of the other keys or the mouse ? Or, is there a new callback function (say, KeyboardModifierFunc) to add to the wish list ? TIA - cheers! Gautier __ (*) It is called GLOBE_3D, URL: http://homepage.sunrise.ch/mysunrise/gdm/g3d.htm _________________________________________________________________ Stay in touch with old friends and meet new ones with Windows Live Spaces http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)Gautier de Montmollin wrote:
> So, my question: how to get a fresh status of these modifier keys, > independently of the other keys or the mouse ? No - you can't. That's actually an operating system restriction under some OS's - so to be portable, GLUT (and therefore freeglut) doesn't let you read the modifier keys outside of the mouse and keyboard callbacks. The reason is that these are MODIFIER keys - they MODIFY the function of other keys or of the mouse - so it doesn't make sense to read them other than when other keys/mouse are doing something. > Or, is there a new callback function (say, KeyboardModifierFunc) to add to > the wish list ? Nope - not going to happen because it's not possible for such functions to be portable. Sorry! ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)From: "steve" <sjbaker1@...>
> > Gautier de Montmollin wrote: > >> So, my question: how to get a fresh status of these modifier keys, >> independently of the other keys or the mouse ? > > No - you can't. That's actually an operating system restriction > under some OS's - so to be portable, GLUT (and therefore freeglut) > doesn't let you read the modifier keys outside of the mouse and > keyboard callbacks. > > The reason is that these are MODIFIER keys - they MODIFY the function > of other keys or of the mouse - so it doesn't make sense to read them > other than when other keys/mouse are doing something. Sorry for my n00b question - but to clarify: Does that mean one can't get an event for the modifier keys themselves? Like, let's say I wanted to bind "left-shift" to make my character walk instead of run while the left shift key is pressed. I want to detect that press/release regardless of whether other keys are pressed. Are you implying that wouldn't be possible, or have I misunderstood? Thanks! Bill ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)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. > Like, let's say I wanted to bind "left-shift" to make my > character walk instead of run while the left shift key > is pressed. You mean that (say) you hold down the left arrow key to make your character walk to the left - then while the arrow key is held down, you push the shift key to turn walking left into running left? If that's what you mean then that's OK because you get an event for the arrow key whenever it is pressed or if it changes from being 'Left arrow' to 'Shifted left arrow'. Once inside the GLUT key event callback, you can test the status of the shift key...no problem there. Ditto with CTRL and ALT. If, however, you wanted to fire a gun every time the shift key was pressed (even when no other keys are held down) then that would be a major problem. > I want to detect that press/release regardless > of whether other keys are pressed. Are you implying that > wouldn't be possible, or have I misunderstood? No - that's impossible (in a portable manner at least). ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)From: "steve" <sjbaker1@...>
> > If, however, you wanted to fire a gun every time the shift > key was pressed (even when no other keys are held down) > then that would be a major problem. > >> I want to detect that press/release regardless >> of whether other keys are pressed. Are you implying that >> wouldn't be possible, or have I misunderstood? > > No - that's impossible (in a portable manner at least). Whoa. I had no idea. Now I wonder how Quake2 is implemented on Linux. I just chatted with a Linux Q2 engine developer, who confirmed that Q2 does run under X, and, it does receive independent events for the shift / alt keys, even if no other keys are pressed. He suggested I run `xev`, an event reporting tool for X, saying that he also gets independent shift and alt key events there. (I don't have a linux box with X installed at present, so I couldn't try it personally.) So I guess the question is, do `xev` and Quake2 get their events in some non-portable fashion... I dunno. :-( (I'll be interested to see what SDL does, as well... I wouldn't harp on the matter, except I was planning to be able to bind the modifier keys in my FreeGLUT app, as they can be in Q2...) Regards, Bill ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)From: "Bill Kelly" <billk@...>
> > Now I wonder how Quake2 is implemented on Linux. > > I just chatted with a Linux Q2 engine developer, who > confirmed that Q2 does run under X, and, it does > receive independent events for the shift / alt keys, > even if no other keys are pressed. Just an addendum, for what it's worth: He pointed me at the code, where the x11 keys are being translated into values quake likes. (Line 436 is handling left/right shift.) http://jdolan.dyndns.org/trac/browser/quetoo/src/vid_glx.c#L436 Regards, Bill ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)Bill Kelly wrote:
> Now I wonder how Quake2 is implemented on Linux. Not portably I suspect! I confess I'm not 100% clear on where the problems lie - but having talked this over with Mark Kilgard (who wrote the original GLUT) some years ago, I was convinced that GLUT's design is good in this regard. At any rate, I'm highly resistant to adding significant features to freeglut. It's supposed to be a GLUT clone and that's that. If you need more features, there are MUCH better libraries out there. Personally - I think that game designers should either go with SDL (if you need more sophistication) - or with something yet simpler and easier to use than GLUT such as the PW library that comes with PLIB. freeglut is here to provide an opensourced way to deliver OpenGL demos and sample programs - and as a lingua franca between developers when providing little programs to show small features or to report bugs. In order to fit into that niche, freeglut needs to be as GLUT-compatible as it can be and adding more features can only make it harder to maintain and risk a loss of that vital compatibility. ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)From: "steve" <sjbaker1@...>
> > At any rate, I'm highly resistant to adding significant > features to freeglut. It's supposed to be a GLUT clone > and that's that. If you need more features, there are > MUCH better libraries out there. > > Personally - I think that game designers should either > go with SDL (if you need more sophistication) - or > with something yet simpler and easier to use than > GLUT such as the PW library that comes with PLIB. I see. OK. Actually I wanted to use SDL, but the problem with SDL (and apparently also PW) is that they allow only a single OpenGL window per process. I'm not writing a game per se; more of a game-flavored peer-to-peer 3D browser of sorts, which will need multiple windows open. Thanks for the pointer to PLIB, though - that looks quite nice! Hmm... Looking at the web page for PLIB::PUI, I see it allows PU_USE_FLTK .... ? It would seem FLTK is likely to allow opening multiple OpenGL windows; however I can't guess yet how it might behave with regard to modifier keys. <grin> Oh well, I'll keep looking. Thanks for the info. Regards, Bill ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: 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 -- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
Re: Status of modifier keys (shift/ctrl/alt)[X-Window - portability - modifier key event]
So there is some hope... Even if it is not portable, why not something like: KeyboardModifierEventsAvailable - gives True or False to inform the program of availability on target system KeyboardModifierFunc - get modifier key events If the KeyboardModifierFunc is erroneously set up on a system where it cannot work, FreeGLUT could issue a warning like the one issued when calling GetModifiers outside input callbacks. And no thank you for SDL... Gautier _________________________________________________________________ Find a local pizza place, music store, museum and moreĀ then map the best route! http://local.live.com?FORM=MGA001 ------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Freeglut-developer mailing list Freeglut-developer@... https://lists.sourceforge.net/lists/listinfo/freeglut-developer |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |