summaryrefslogtreecommitdiffstats
path: root/src/glut/fbdev
diff options
context:
space:
mode:
authorSean D'Epagnier <[email protected]>2006-09-24 10:57:26 +0000
committerSean D'Epagnier <[email protected]>2006-09-24 10:57:26 +0000
commite184bd861c0b3023c5fd5596083e12aaedb2d5e2 (patch)
treeb6f14a2e00b8d21e610933f55bc986d23b12805e /src/glut/fbdev
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')
-rw-r--r--src/glut/fbdev/cursor.c6
-rw-r--r--src/glut/fbdev/fbdev.c71
-rw-r--r--src/glut/fbdev/gamemode.c1
-rw-r--r--src/glut/fbdev/input.c125
4 files changed, 129 insertions, 74 deletions
diff --git a/src/glut/fbdev/cursor.c b/src/glut/fbdev/cursor.c
index 9254e125593..88386956a44 100644
--- a/src/glut/fbdev/cursor.c
+++ b/src/glut/fbdev/cursor.c
@@ -257,8 +257,12 @@ void glutSetCursor(int cursor)
{
if(cursor == GLUT_CURSOR_FULL_CROSSHAIR)
cursor = GLUT_CURSOR_CROSSHAIR;
+
+ if(CurrentCursor >= 0 && CurrentCursor < NUM_CURSORS)
+ EraseCursor();
+
CurrentCursor = cursor;
+
MouseEnabled = 1;
- EraseCursor();
SwapCursor();
}
diff --git a/src/glut/fbdev/fbdev.c b/src/glut/fbdev/fbdev.c
index 1c6cea0434e..ce6419816dd 100644
--- a/src/glut/fbdev/fbdev.c
+++ b/src/glut/fbdev/fbdev.c
@@ -103,6 +103,9 @@ void TestVisible(void) {
static void Cleanup(void)
{
+ /* do not handle this signal when cleaning up */
+ signal(SIGWINCH, SIG_IGN);
+
if(GameMode)
glutLeaveGameMode();
@@ -236,6 +239,7 @@ void glutInit (int *argcp, char **argv)
signal(SIGSEGV, CrashHandler);
signal(SIGINT, CrashHandler);
signal(SIGTERM, CrashHandler);
+ signal(SIGABRT, CrashHandler);
if(nomouse == 0)
InitializeMouse();
@@ -271,7 +275,7 @@ void glutInit (int *argcp, char **argv)
exit(0);
}
- /* Get the fixed screen info */
+ /* get the fixed screen info */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
@@ -410,10 +414,10 @@ void glutInitWindowSize (int width, int height)
static void ProcessTimers(void)
{
- if(GlutTimers && GlutTimers->time < glutGet(GLUT_ELAPSED_TIME)) {
+ while(GlutTimers && GlutTimers->time <= glutGet(GLUT_ELAPSED_TIME)) {
struct GlutTimer *timer = GlutTimers;
- timer->func(timer->value);
GlutTimers = timer->next;
+ timer->func(timer->value);
free(timer);
}
}
@@ -669,6 +673,47 @@ void CreateVisual(void)
}
}
+static void ResizeVisual(void)
+{
+ if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
+ sprintf(exiterror, "Failure to Make Current\n");
+ exit(0);
+ }
+
+ InitializeMenus();
+
+ if(ReshapeFunc)
+ ReshapeFunc(VarInfo.xres, VarInfo.yres);
+ Redisplay = 1;
+}
+
+static void SignalWinch(int arg)
+{
+ /* we can't change bitdepth without destroying the visual */
+ int bits_per_pixel = VarInfo.bits_per_pixel;
+ struct fb_bitfield red = VarInfo.red, green = VarInfo.green,
+ blue = VarInfo.blue, transp = VarInfo.transp;
+
+ /* get the variable screen info */
+ if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &VarInfo)) {
+ sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ exit(0);
+ }
+
+ /* restore bitdepth and color masks only */
+ VarInfo.bits_per_pixel = bits_per_pixel;
+ VarInfo.red = red;
+ VarInfo.green = green;
+ VarInfo.blue = blue;
+ VarInfo.transp = transp;
+
+ SetVideoMode();
+ CreateBuffer();
+
+ ResizeVisual();
+}
+
int glutCreateWindow (const char *title)
{
if(Initialized == 0) {
@@ -713,6 +758,8 @@ int glutCreateWindow (const char *title)
glutSetWindowTitle(title);
+ signal(SIGWINCH, SignalWinch);
+
Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
@@ -787,19 +834,13 @@ void glutReshapeWindow(int width, int height)
if(!ParseFBModes(width, width, height, height, 0, MAX_VSYNC))
return;
+ signal(SIGWINCH, SIG_IGN);
+
SetVideoMode();
CreateBuffer();
-
- if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
- sprintf(exiterror, "Failure to Make Current\n");
- exit(0);
- }
- InitializeMenus();
-
- if(ReshapeFunc)
- ReshapeFunc(VarInfo.xres, VarInfo.yres);
- Redisplay = 1;
+ ResizeVisual();
+ signal(SIGWINCH, SignalWinch);
}
void glutFullScreen(void)
@@ -836,6 +877,9 @@ static void UnIconifyWindow(int sig)
strerror(errno));
exit(0);
}
+
+ RestoreColorMap();
+
Redisplay = 1;
VisibleSwitch = 1;
Visible = 1;
@@ -848,6 +892,7 @@ void glutIconifyWindow(void)
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
+
raise(SIGSTOP);
}
diff --git a/src/glut/fbdev/gamemode.c b/src/glut/fbdev/gamemode.c
index f6d6e4044ef..9f32d9d7e82 100644
--- a/src/glut/fbdev/gamemode.c
+++ b/src/glut/fbdev/gamemode.c
@@ -263,7 +263,6 @@ void glutLeaveGameMode(void)
KeyboardFunc = KeyFuncs[0];
KeyboardUpFunc = KeyFuncs[1];
-
DisplayFunc = NormFuncs[0];
ReshapeFunc = NormFuncs[1];
MouseFunc = NormFuncs[2];
diff --git a/src/glut/fbdev/input.c b/src/glut/fbdev/input.c
index b1362245f2f..2528a74a105 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)