diff --git a/src/libs/mesa/glut/glutEvent.cpp b/src/libs/mesa/glut/glutEvent.cpp index 4063dfd571..baa93af597 100644 --- a/src/libs/mesa/glut/glutEvent.cpp +++ b/src/libs/mesa/glut/glutEvent.cpp @@ -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")) { diff --git a/src/libs/mesa/glut/glutState.h b/src/libs/mesa/glut/glutState.h index 9c44eb6b53..aaa85cc57a 100644 --- a/src/libs/mesa/glut/glutState.h +++ b/src/libs/mesa/glut/glutState.h @@ -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; } }; diff --git a/src/libs/mesa/glut/glutWindow.cpp b/src/libs/mesa/glut/glutWindow.cpp index 979f39e4d6..033021b122 100644 --- a/src/libs/mesa/glut/glutWindow.cpp +++ b/src/libs/mesa/glut/glutWindow.cpp @@ -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 diff --git a/src/libs/mesa/glut/glutWindow.h b/src/libs/mesa/glut/glutWindow.h index 6a0f66ee29..51fb3ee666 100644 --- a/src/libs/mesa/glut/glutWindow.h +++ b/src/libs/mesa/glut/glutWindow.h @@ -92,6 +92,7 @@ public: int menuNumber; // for menu and status callbacks int menuValue; // for menu callback bool visible; // for visibility callback + bool ignoreKeyRepeat; }; /*********************************************************** diff --git a/src/libs/mesa/glut/glut_ext.c b/src/libs/mesa/glut/glut_ext.c index 2b45ddc5f4..6ce7eaa4b8 100644 --- a/src/libs/mesa/glut/glut_ext.c +++ b/src/libs/mesa/glut/glut_ext.c @@ -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 },