summaryrefslogtreecommitdiff
path: root/src/glut/fbdev/input.c
diff options
context:
space:
mode:
authorSean D'Epagnier <geckosenator@freedesktop.org>2006-09-24 10:57:26 +0000
committerSean D'Epagnier <geckosenator@freedesktop.org>2006-09-24 10:57:26 +0000
commite184bd861c0b3023c5fd5596083e12aaedb2d5e2 (patch)
treeb6f14a2e00b8d21e610933f55bc986d23b12805e /src/glut/fbdev/input.c
parent1ad12874b30dcb2228621da1f519b846b4975fde (diff)
corrected cursor drawing
added handling of SIGWINCH fixed input of recieving SIGIO while handling SIGIO corrected input code for return uncommented normal calculation to models
Diffstat (limited to 'src/glut/fbdev/input.c')
-rw-r--r--src/glut/fbdev/input.c125
1 files changed, 66 insertions, 59 deletions
diff --git a/src/glut/fbdev/input.c b/src/glut/fbdev/input.c
index b1362245f2..2528a74a10 100644
--- a/src/glut/fbdev/input.c
+++ b/src/glut/fbdev/input.c
@@ -90,66 +90,67 @@ static int kbdpipe[2];
vts and kill it without Alt-SysRq hack */
static void KeyboardHandler(int sig)
{
- int release, labelval;
unsigned char code;
- struct kbentry entry;
- static int lalt; /* only left alt does vt switch */
- if(read(ConsoleFD, &code, 1) != 1)
- return;
-
- release = code & 0x80;
-
- entry.kb_index = code & 0x7F;
- entry.kb_table = 0;
-
- if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
- sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
- exit(0);
- }
-
- labelval = entry.kb_value;
-
- switch(labelval) {
- case K_SHIFT:
- case K_SHIFTL:
- MODIFIER(GLUT_ACTIVE_SHIFT);
- return;
- case K_CTRL:
- MODIFIER(GLUT_ACTIVE_CTRL);
- return;
- case K_ALT:
- lalt = !release;
- case K_ALTGR:
- MODIFIER(GLUT_ACTIVE_ALT);
- return;
- }
+ while(read(ConsoleFD, &code, 1) == 1) {
- if(lalt && !release) {
- /* VT switch, we must do it */
- int vt = -1;
- struct vt_stat st;
- if(labelval >= K_F1 && labelval <= K_F12)
- vt = labelval - K_F1 + 1;
+ int release, labelval;
+ struct kbentry entry;
+ static int lalt; /* only left alt does vt switch */
- if(labelval == K_LEFT)
- if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
- vt = st.v_active - 1;
+ release = code & 0x80;
+
+ entry.kb_index = code & 0x7F;
+ entry.kb_table = 0;
+
+ if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
+ sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
+ exit(0);
+ }
- if(labelval == K_RIGHT)
- if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
- vt = st.v_active + 1;
+ labelval = entry.kb_value;
+
+ switch(labelval) {
+ case K_SHIFT:
+ case K_SHIFTL:
+ MODIFIER(GLUT_ACTIVE_SHIFT);
+ continue;
+ case K_CTRL:
+ MODIFIER(GLUT_ACTIVE_CTRL);
+ continue;
+ case K_ALT:
+ lalt = !release;
+ case K_ALTGR:
+ MODIFIER(GLUT_ACTIVE_ALT);
+ continue;
+ }
- if(vt != -1) {
- if(Swapping)
- VTSwitch = vt;
- else
- if(ioctl(ConsoleFD, VT_ACTIVATE, vt) < 0)
- sprintf(exiterror, "Error switching console\n");
- return;
+ if(lalt && !release) {
+ /* VT switch, we must do it */
+ int vt = -1;
+ struct vt_stat st;
+ if(labelval >= K_F1 && labelval <= K_F12)
+ vt = labelval - K_F1 + 1;
+
+ if(labelval == K_LEFT)
+ if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
+ vt = st.v_active - 1;
+
+ if(labelval == K_RIGHT)
+ if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
+ vt = st.v_active + 1;
+
+ if(vt != -1) {
+ if(Swapping)
+ VTSwitch = vt;
+ else
+ if(ioctl(ConsoleFD, VT_ACTIVATE, vt) < 0)
+ sprintf(exiterror, "Error switching console\n");
+ continue;
+ }
}
+ write(kbdpipe[1], &code, 1);
}
- write(kbdpipe[1], &code, 1);
}
static void LedModifier(int led, int release)
@@ -239,7 +240,7 @@ static int ReadKey(void)
goto altset;
}
}
- stdkey:
+
if(specialkey) {
if(SpecialFunc)
SpecialFunc(specialkey, MouseX, MouseY);
@@ -253,6 +254,7 @@ static int ReadKey(void)
|| (code == 95) || (code >= 123 && code <= 126))
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;
+ stdkey:
if(KeyboardFunc)
KeyboardFunc(code, MouseX, MouseY);
}
@@ -341,7 +343,7 @@ static int ReadKey(void)
break;
case K_ENTER:
case K_ENTER - 1: /* keypad enter */
- labelval = '\n'; break;
+ labelval = '\r'; break;
}
/* dispatch callback */
@@ -600,6 +602,10 @@ void InitializeVT(int usestdin)
close(fd);
}
+ /* if we close with the modifier set in glutIconifyWindow, we won't
+ get the signal when they are released, so set to zero here */
+ KeyboardModifiers = 0;
+
/* open the console tty */
sprintf(console, "/dev/tty%d", CurrentVT);
ConsoleFD = open(console, O_RDWR | O_NDELAY, 0);
@@ -660,13 +666,13 @@ void InitializeVT(int usestdin)
if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");
- if (ioctl(ConsoleFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
+ if(ioctl(ConsoleFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
sprintf(exiterror, "ioctl KDSKBMODE failed!\n");
tcsetattr(0, TCSANOW, &OldTermios);
exit(0);
}
- if( ioctl(ConsoleFD, KDGKBLED, &KeyboardLedState) < 0) {
+ if(ioctl(ConsoleFD, KDGKBLED, &KeyboardLedState) < 0) {
sprintf(exiterror, "ioctl KDGKBLED failed!\n");
exit(0);
}
@@ -686,10 +692,8 @@ void RestoreVT(void)
GpmMouse ||
#endif
ConsoleFD == 0)
- if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) {
- sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");
+ if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
goto skipioctl; /* no need to fail twice */
- }
if(ioctl(ConsoleFD, KDSETMODE, OldMode) < 0)
fprintf(stderr, "ioctl KDSETMODE failed!\n");
@@ -707,6 +711,9 @@ void RestoreVT(void)
fprintf(stderr, "ioctl KDSKBMODE failed!\n");
close(ConsoleFD);
+
+ close(kbdpipe[0]);
+ close(kbdpipe[1]);
}
void InitializeMouse(void)