X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrlugburz;a=blobdiff_plain;f=src%2Fminiglut.c;fp=src%2Fminiglut.c;h=c36288250d6e2e15d2d51eb234ca9847508d00fe;hp=bda9491ef644515b3a55536d4142059bc7233c42;hb=60a62013e45b8dd307494b792c48b5fde17d2fdc;hpb=8b4c81041dbf3149c3bbdac08de63524ee2d48b4 diff --git a/src/miniglut.c b/src/miniglut.c index bda9491..c362882 100644 --- a/src/miniglut.c +++ b/src/miniglut.c @@ -88,6 +88,7 @@ static unsigned int init_mode; static struct ctx_info ctx_info; static int cur_cursor = GLUT_CURSOR_INHERIT; +static int ignore_key_repeat; static glut_cb cb_display; static glut_cb cb_idle; @@ -205,6 +206,11 @@ void glutPostRedisplay(void) upd_pending = 1; } +void glutIgnoreKeyRepeat(int ignore) +{ + ignore_key_repeat = ignore; +} + #define UPD_EVMASK(x) \ do { \ if(func) { \ @@ -580,7 +586,22 @@ static void handle_event(XEvent *ev) break; case KeyPress: + if(0) { case KeyRelease: + if(ignore_key_repeat && XEventsQueued(dpy, QueuedAfterReading)) { + XEvent next; + XPeekEvent(dpy, &next); + + if(next.type == KeyPress && next.xkey.keycode == ev->xkey.keycode && + next.xkey.time == ev->xkey.time) { + /* this is a key-repeat event, ignore the release and consume + * the following press + */ + XNextEvent(dpy, &next); + break; + } + } + } modstate = ev->xkey.state & (ShiftMask | ControlMask | Mod1Mask); if(!(sym = XLookupKeysym(&ev->xkey, 0))) { break; @@ -798,6 +819,15 @@ void glutSetCursor(int cidx) cur_cursor = cidx; } +void glutSetKeyRepeat(int repmode) +{ + if(repmode) { + XAutoRepeatOn(dpy); + } else { + XAutoRepeatOff(dpy); + } +} + static XVisualInfo *choose_visual(unsigned int mode) { XVisualInfo *vi; @@ -1229,6 +1259,10 @@ void glutSetCursor(int cidx) } } +void glutSetKeyRepeat(int repmode) +{ +} + #define WGL_DRAW_TO_WINDOW 0x2001 #define WGL_SUPPORT_OPENGL 0x2010 #define WGL_DOUBLE_BUFFER 0x2011