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:
@@ -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
|
* CLASS: GlutWindow
|
||||||
*
|
*
|
||||||
@@ -380,6 +406,10 @@ void GlutWindow::KeyDown(const char *s, int32 slen)
|
|||||||
|
|
||||||
BPoint p;
|
BPoint p;
|
||||||
|
|
||||||
|
if (ignoreKeyRepeat &&
|
||||||
|
Window()->CurrentMessage()->FindInt32("be:key_repeat") > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (aChar) {
|
switch (aChar) {
|
||||||
case B_FUNCTION_KEY:
|
case B_FUNCTION_KEY:
|
||||||
switch(Window()->CurrentMessage()->FindInt32("key")) {
|
switch(Window()->CurrentMessage()->FindInt32("key")) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ struct GlutState {
|
|||||||
GLUTidleCB idle; // idle callback
|
GLUTidleCB idle; // idle callback
|
||||||
GLUTmenuStatusCB menuStatus; // menu status callback
|
GLUTmenuStatusCB menuStatus; // menu status callback
|
||||||
int modifierKeys; // only valid during keyboard callback
|
int modifierKeys; // only valid during keyboard callback
|
||||||
|
int keyRepeatMode; // global repeat
|
||||||
|
|
||||||
bool debug; // call glGetError
|
bool debug; // call glGetError
|
||||||
bool quitAll; // quit
|
bool quitAll; // quit
|
||||||
@@ -61,6 +62,7 @@ struct GlutState {
|
|||||||
idle = 0;
|
idle = 0;
|
||||||
menuStatus = 0;
|
menuStatus = 0;
|
||||||
modifierKeys = ~0;
|
modifierKeys = ~0;
|
||||||
|
keyRepeatMode = GLUT_KEY_REPEAT_DEFAULT;
|
||||||
debug = quitAll = false;
|
debug = quitAll = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ GlutWindow::GlutWindow(GlutWindow *nparent, const char *name,
|
|||||||
statusEvent = 0;
|
statusEvent = 0;
|
||||||
menuEvent = 0;
|
menuEvent = 0;
|
||||||
visible = true;
|
visible = true;
|
||||||
|
ignoreKeyRepeat = (gState.keyRepeatMode == GLUT_KEY_REPEAT_OFF);
|
||||||
|
|
||||||
gBlock.QuickNewEvent();
|
gBlock.QuickNewEvent();
|
||||||
|
|
||||||
// if i'm a subwindow, add me to my parent view
|
// if i'm a subwindow, add me to my parent view
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public:
|
|||||||
int menuNumber; // for menu and status callbacks
|
int menuNumber; // for menu and status callbacks
|
||||||
int menuValue; // for menu callback
|
int menuValue; // for menu callback
|
||||||
bool visible; // for visibility callback
|
bool visible; // for visibility callback
|
||||||
|
bool ignoreKeyRepeat;
|
||||||
};
|
};
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
|
|||||||
@@ -165,8 +165,8 @@ static struct name_address_pair glut_functions[] = {
|
|||||||
{ "glutVideoResize", (const GLUTproc) glutVideoResize },
|
{ "glutVideoResize", (const GLUTproc) glutVideoResize },
|
||||||
{ "glutVideoPan", (const GLUTproc) glutVideoPan },
|
{ "glutVideoPan", (const GLUTproc) glutVideoPan },
|
||||||
{ "glutReportErrors", (const GLUTproc) glutReportErrors },
|
{ "glutReportErrors", (const GLUTproc) glutReportErrors },
|
||||||
// { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
|
{ "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
|
||||||
// { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
|
{ "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
|
||||||
// { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
|
// { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
|
||||||
// { "glutGameModeString", (const GLUTproc) glutGameModeString },
|
// { "glutGameModeString", (const GLUTproc) glutGameModeString },
|
||||||
// { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
|
// { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
|
||||||
|
|||||||
Reference in New Issue
Block a user