From e69bfe74d7f887fb516f300f575d43b9903d9ab3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 23 Mar 2002 02:34:07 +0000 Subject: DOS/Mesa driver updates (Daniel Borca) --- src/glut/dos/Makefile.DJ | 20 +++++++++-- src/glut/dos/PC_HW/pc_keyb.c | 13 +++++-- src/glut/dos/PC_HW/pc_mouse.c | 11 ++++-- src/glut/dos/init.c | 83 +++++++++++++++++++------------------------ 4 files changed, 75 insertions(+), 52 deletions(-) (limited to 'src/glut/dos') diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ index 7cacd8d009..7a26eb2d0c 100644 --- a/src/glut/dos/Makefile.DJ +++ b/src/glut/dos/Makefile.DJ @@ -20,7 +20,7 @@ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# DOS/DJGPP glut makefile v0.2 for Mesa 4.0 +# DOS/DJGPP glut makefile v0.4 for Mesa 4.0 # # Copyright (C) 2002 - Borca Daniel # Email : dborca@yahoo.com @@ -36,7 +36,15 @@ AR = ar ARFLAGS = ruv LIBDIR = $(TOP)/lib +ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),) +DXE2GEN = +else +DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH)))) +endif + GLUT_LIB = libglut.a +GLUT_DXE = glut.dxe +GLUT_IMP = libiglut.a CORE_SOURCES = \ callback.c \ @@ -69,11 +77,19 @@ OBJECTS = $(SOURCES:.c=.o) $(PC_HW_OBJECTS) .c.o: gcc -o $@ -c $(CFLAGS) $< -all: $(LIBDIR)/$(GLUT_LIB) +all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP) $(LIBDIR)/$(GLUT_LIB): $(OBJECTS) $(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS) +$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS) +ifeq ($(DXE2GEN),) + @echo Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN + @echo somewhere in PATH, and DXE2.LD in DJGPP/LIB directory. +else + dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -D "DOS Glut" -U +endif + clean: -$(RM) *.o -$(RM) PC_HW\*.o diff --git a/src/glut/dos/PC_HW/pc_keyb.c b/src/glut/dos/PC_HW/pc_keyb.c index f5f4bd8e76..d3987d8e34 100644 --- a/src/glut/dos/PC_HW/pc_keyb.c +++ b/src/glut/dos/PC_HW/pc_keyb.c @@ -1,5 +1,5 @@ /* - * PC/HW routine collection v0.1 for DOS/DJGPP + * PC/HW routine collection v0.4 for DOS/DJGPP * * Copyright (C) 2002 - Borca Daniel * Email : dborca@yahoo.com @@ -32,7 +32,7 @@ static volatile struct { static volatile int key_enhanced, key_pause_loop, key_shifts; static int leds_ok = TRUE; static int in_a_terrupt = FALSE; -volatile char pc_key[KEY_MAX]; +static volatile char pc_key[KEY_MAX]; @@ -400,6 +400,10 @@ static int keyboard () } if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) { + /* Hack alert: + only SIGINT (but not Ctrl-Break) + calls the destructors and will safely clean up + */ __asm__("\n\ movb $0x79, %%al \n\ call ___djgpp_hw_exception \n\ @@ -436,6 +440,11 @@ int pc_readkey (void) } } +int pc_keydown (int code) +{ + return pc_key[code]; +} + void pc_remove_keyb (void) { if (keyboard_installed) { diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c index 2a692eceb6..aa1fbe4da7 100644 --- a/src/glut/dos/PC_HW/pc_mouse.c +++ b/src/glut/dos/PC_HW/pc_mouse.c @@ -1,5 +1,5 @@ /* - * PC/HW routine collection v0.2 for DOS/DJGPP + * PC/HW routine collection v0.4 for DOS/DJGPP * * Copyright (C) 2002 - Borca Daniel * Email : dborca@yahoo.com @@ -29,7 +29,7 @@ static void *mouse_stack; static long mouse_callback; static __dpmi_regs mouse_regs; -volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b; +static volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b; static int minx = 0; static int maxx = 319; @@ -205,6 +205,13 @@ void pc_mouse_speed (int xspeed, int yspeed) ENABLE(); } +int pc_query_mouse (int *x, int *y) +{ + *x = pc_mouse_x; + *y = pc_mouse_y; + return pc_mouse_b; +} + void pc_show_mouse (void) { /* not implemented */ diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c index 41170e37c9..9cda3a8b5b 100644 --- a/src/glut/dos/init.c +++ b/src/glut/dos/init.c @@ -19,7 +19,7 @@ */ /* - * DOS/DJGPP glut driver v0.2 for Mesa 4.0 + * DOS/DJGPP glut driver v0.4 for Mesa 4.0 * * Copyright (C) 2002 - Borca Daniel * Email : dborca@yahoo.com @@ -27,30 +27,13 @@ */ -#include #include "GL/glut.h" #include "internal.h" -static void *old_sig_int = NULL; - - -static void signal_handler (int num) -{ - signal(SIGINT, old_sig_int); - - raise(num); -} - - void APIENTRY glutInit (int *argcp, char **argv) { glutGet(GLUT_ELAPSED_TIME); - /* Hack alert: - only SIGINT (but not Ctrl-Break) - calls the destructors and will safely clean up - */ - old_sig_int = signal(SIGINT, signal_handler); } @@ -133,34 +116,42 @@ void APIENTRY glutMainLoop (void) } } - if (g_mouse && motion_func && ((pc_mouse_x != old_mouse_x) || (pc_mouse_y != old_mouse_y))) { - idle = GL_FALSE; - old_mouse_x = pc_mouse_x; - old_mouse_y = pc_mouse_y; - - motion_func(old_mouse_x, old_mouse_y); - } - - if (g_mouse && mouse_func && (pc_mouse_b != old_mouse_b)) { - int new_mouse_b = pc_mouse_b; - - if ((old_mouse_b & 1) && !(new_mouse_b & 1)) - mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y); - else if (!(old_mouse_b & 1) && (new_mouse_b & 1)) - mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y); - - if ((old_mouse_b & 2) && !(new_mouse_b & 2)) - mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y); - else if (!(old_mouse_b & 2) && (new_mouse_b & 2)) - mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y); - - if ((old_mouse_b & 4) && !(new_mouse_b & 4)) - mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y); - else if (!(old_mouse_b & 3) && (new_mouse_b & 4)) - mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y); - - idle = GL_FALSE; - old_mouse_b = new_mouse_b; + if (g_mouse) { + int mouse_x; + int mouse_y; + int mouse_b; + + mouse_b = pc_query_mouse(&mouse_x, &mouse_y); + + if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) { + idle = GL_FALSE; + old_mouse_x = mouse_x; + old_mouse_y = mouse_y; + + motion_func(old_mouse_x, old_mouse_y); + } + + if (mouse_func && (mouse_b != old_mouse_b)) { + int new_mouse_b = mouse_b; + + if ((old_mouse_b & 1) && !(new_mouse_b & 1)) + mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y); + else if (!(old_mouse_b & 1) && (new_mouse_b & 1)) + mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y); + + if ((old_mouse_b & 2) && !(new_mouse_b & 2)) + mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y); + else if (!(old_mouse_b & 2) && (new_mouse_b & 2)) + mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y); + + if ((old_mouse_b & 4) && !(new_mouse_b & 4)) + mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y); + else if (!(old_mouse_b & 3) && (new_mouse_b & 4)) + mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, mouse_y); + + idle = GL_FALSE; + old_mouse_b = new_mouse_b; + } } if (idle && idle_func) -- cgit v1.2.3