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:
Philippe Houdoin 2010-07-25 20:54:03 +00:00
parent 0f75e967c8
commit aacfa4790d
5 changed files with 37 additions and 2 deletions

View File

@ -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")) {

View File

@ -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;
}
};

View File

@ -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

View File

@ -92,6 +92,7 @@ public:
int menuNumber; // for menu and status callbacks
int menuValue; // for menu callback
bool visible; // for visibility callback
bool ignoreKeyRepeat;
};
/***********************************************************

View File

@ -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 },