Why no GLUT_KEY_HELP?

Member
Posts: 321
Joined: 2004.10
Post: #1
I find these, but nothing like GLUT_KEY_HELP. Even spotlight didn't
find anything. Is this a compatibility issue with older keyboards or PC keyboards?

#if (GLUT_API_VERSION >= 2)
/* function keys */
#define GLUT_KEY_F1 1
#define GLUT_KEY_F2 2
etc.
#define GLUT_KEY_HOME 106
#define GLUT_KEY_END 107
#define GLUT_KEY_INSERT 108
#endif


Interesting, I set a breakpoint in the function below, thinking I could trap
the value and defind the HELP key for myself. But when I do this, the
cursor just changes to a ? mark and nothing happens. Seems like
glut will not even let me use the HELP key.


void Special( int key, int /*x*/, int /*y*/ )
{
static double delta = .01; // by default use .01
static int granularity = 3;

switch ( key )
{
case GLUT_KEY_UP:
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
GLUT_KEY_INSERT should be the help key, but if it's being caught earlier (by cocoa or something) then you're probably out of luck.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #3
I don't know about Cocoa, but with Carbon you could probably return an eventNotHandledErr in your keyDown event handler... then again, you'd be removing the cross-platformness of GLUT. Then again, you could just add that small bit in, it'd be pretty simple. Although I have no guarentees this would work, it seems like a legitimate approach, give it a try.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #4
Thanks, but I don't even know what an eventNotHandledErr is and I don't use an
event handler Smile I assume I'm just 100% GLUT and I want to keep the KISS principal (for me).
For now, I'll just make my F1 key help.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #5
Initialize...
Code:
pascal OSStatus KeyDown(EventHandlerCallRef inCallRef, EventRef inEvent, void* inUser);
void initKeyboardCallback()
{
       WindowRef ontoThisWindow = FrontWindow();
       EventTypeSpec keyEventType;
    keyEventType.eventClass = kEventClassKeyboard;
    keyEventType.eventKind = kEventRawKeyDown;
    
    InstallWindowEventHandler(ontoThisWindow,
NewEventHandlerUPP(KeyDown),
1,
&keyEventType,
NULL,
NULL);
}

Define it..
Code:
pascal OSStatus KeyDown(EventHandlerCallRef inCallRef, EventRef inEvent, void* inUser)
{
    #pragma unused(inCallRef, inEvent, inUser)
    return eventNotHandledErr;
}

That is keeping it pretty simple. Smile Give it a try, if nothing else, you can figure out if it works.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
GLUT is Cocoa, it seems unlikely that adding a Carbon event handler will work at all, let alone do what's wanted.
Quote this message in a reply
Post Reply