Implemented glutSetKetRepeat() and glutIgnoreKeyRepeat().
this fix #5330. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37743 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0f75e967c8
commit
aacfa4790d
@ -366,6 +366,32 @@ void glutMainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void glutSetKeyRepeat(int repeatMode)
|
||||
{
|
||||
switch(repeatMode) {
|
||||
case GLUT_KEY_REPEAT_DEFAULT:
|
||||
gState.keyRepeatMode = GLUT_KEY_REPEAT_ON;
|
||||
break;
|
||||
|
||||
case GLUT_KEY_REPEAT_ON:
|
||||
case GLUT_KEY_REPEAT_OFF:
|
||||
gState.keyRepeatMode = repeatMode;
|
||||
break;
|
||||
|
||||
default:
|
||||
__glutWarning("invalid glutSetKeyRepeat mode: %d", repeatMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void glutIgnoreKeyRepeat(int ignore)
|
||||
{
|
||||
if (gState.currentWindow)
|
||||
gState.currentWindow->ignoreKeyRepeat = (ignore != 0);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************
|
||||
* CLASS: GlutWindow
|
||||
*
|
||||
@ -380,6 +406,10 @@ void GlutWindow::KeyDown(const char *s, int32 slen)
|
||||
|
||||
BPoint p;
|
||||
|
||||
if (ignoreKeyRepeat &&
|
||||
Window()->CurrentMessage()->FindInt32("be:key_repeat") > 0)
|
||||
return;
|
||||
|
||||
switch (aChar) {
|
||||
case B_FUNCTION_KEY:
|
||||
switch(Window()->CurrentMessage()->FindInt32("key")) {
|
||||
|
@ -43,6 +43,7 @@ struct GlutState {
|
||||
GLUTidleCB idle; // idle callback
|
||||
GLUTmenuStatusCB menuStatus; // menu status callback
|
||||
int modifierKeys; // only valid during keyboard callback
|
||||
int keyRepeatMode; // global repeat
|
||||
|
||||
bool debug; // call glGetError
|
||||
bool quitAll; // quit
|
||||
@ -61,6 +62,7 @@ struct GlutState {
|
||||
idle = 0;
|
||||
menuStatus = 0;
|
||||
modifierKeys = ~0;
|
||||
keyRepeatMode = GLUT_KEY_REPEAT_DEFAULT;
|
||||
debug = quitAll = false;
|
||||
}
|
||||
};
|
||||
|
@ -131,6 +131,8 @@ GlutWindow::GlutWindow(GlutWindow *nparent, const char *name,
|
||||
statusEvent = 0;
|
||||
menuEvent = 0;
|
||||
visible = true;
|
||||
ignoreKeyRepeat = (gState.keyRepeatMode == GLUT_KEY_REPEAT_OFF);
|
||||
|
||||
gBlock.QuickNewEvent();
|
||||
|
||||
// if i'm a subwindow, add me to my parent view
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
int menuNumber; // for menu and status callbacks
|
||||
int menuValue; // for menu callback
|
||||
bool visible; // for visibility callback
|
||||
bool ignoreKeyRepeat;
|
||||
};
|
||||
|
||||
/***********************************************************
|
||||
|
@ -165,8 +165,8 @@ static struct name_address_pair glut_functions[] = {
|
||||
{ "glutVideoResize", (const GLUTproc) glutVideoResize },
|
||||
{ "glutVideoPan", (const GLUTproc) glutVideoPan },
|
||||
{ "glutReportErrors", (const GLUTproc) glutReportErrors },
|
||||
// { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
|
||||
// { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
|
||||
{ "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
|
||||
{ "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
|
||||
// { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
|
||||
// { "glutGameModeString", (const GLUTproc) glutGameModeString },
|
||||
// { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
|
||||
|
Loading…
Reference in New Issue
Block a user