diff --git a/Makefile b/Makefile index c11307f..777ce6b 100644 --- a/Makefile +++ b/Makefile @@ -11,12 +11,12 @@ LIBS = -lMw -lGL -lm OBJS = src/cl_demo.o src/cl_input.o src/cl_main.o src/cl_parse.o src/cl_tent.o src/chase.o src/cmd.o src/common.o src/console.o src/crc.o src/cvar.o src/gl_draw.o src/gl_mesh.o src/gl_model.o src/gl_refrag.o src/gl_rlight.o src/gl_rmain.o src/gl_rmisc.o src/gl_rsurf.o src/gl_screen.o src/gl_test.o src/gl_warp.o src/host.o src/host_cmd.o src/keys.o src/menu.o src/mathlib.o src/net_dgrm.o src/net_loop.o src/net_main.o src/net_vcr.o src/pr_cmds.o src/pr_edict.o src/pr_exec.o src/r_part.o src/sbar.o src/sv_main.o src/sv_phys.o src/sv_move.o src/sv_user.o src/zone.o src/view.o src/wad.o src/world.o src/cd.o src/sound.o src/gl.o src/stb_ds.o src/snd_mem.o src/mix.o src/miniaudio.o src/snd_ma.o src/net_udp.o src/net_bsd.o src/sys.o -all: quake +all: mwquake clean: rm -f $(OBJS) quake -quake: $(OBJS) +mwquake: $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) .c.o: diff --git a/id1/autoexec.cfg b/id1/autoexec.cfg index 2d0bc5d..1262743 100644 --- a/id1/autoexec.cfg +++ b/id1/autoexec.cfg @@ -1,2 +1,3 @@ +mlook joystick 0 +exec contorl.cfg diff --git a/id1/control.cfg b/id1/control.cfg new file mode 100644 index 0000000..440451c --- /dev/null +++ b/id1/control.cfg @@ -0,0 +1,86 @@ +bind "TAB" "+showscores" +bind "ENTER" "+jump" +bind "ESCAPE" "togglemenu" +bind "SPACE" "+jump" +bind "+" "sizeup" +bind "," "+moveleft" +bind "-" "sizedown" +bind "." "+moveright" +bind "/" "impulse 10" +bind "0" "impulse 0" +bind "1" "impulse 1" +bind "2" "impulse 2" +bind "3" "impulse 3" +bind "4" "impulse 4" +bind "5" "impulse 5" +bind "6" "impulse 6" +bind "7" "impulse 7" +bind "8" "impulse 8" +bind "=" "sizeup" +bind "\" "+mlook" +bind "`" "toggleconsole" +bind "a" "+moveleft" +bind "c" "+movedown" +bind "d" "+moveright" +bind "s" "+back" +bind "t" "messagemode" +bind "w" "+forward" +bind "z" "+lookdown" +bind "~" "toggleconsole" +bind "UPARROW" "+forward" +bind "DOWNARROW" "+back" +bind "LEFTARROW" "+left" +bind "RIGHTARROW" "+right" +bind "ALT" "+strafe" +bind "CTRL" "+attack" +bind "SHIFT" "+speed" +bind "F1" "help" +bind "F2" "menu_save" +bind "F3" "menu_load" +bind "F4" "menu_options" +bind "F5" "menu_multiplayer" +bind "F6" "echo Quicksaving...; wait; save quick" +bind "F9" "echo Quickloading...; wait; load quick" +bind "F10" "quit" +bind "F11" "zoom_in" +bind "F12" "screenshot" +bind "INS" "+klook" +bind "DEL" "+lookdown" +bind "PGDN" "+lookup" +bind "END" "centerview" +bind "MOUSE1" "+attack" +bind "MOUSE2" "+forward" +bind "MOUSE3" "+mlook" +bind "PAUSE" "pause" +m_side "0.8" +m_forward "1" +m_yaw "0.022" +m_pitch "0.022" +sensitivity "1.500000" +lookstrafe "0" +lookspring "0.000000" +cl_backspeed "200" +cl_forwardspeed "200" +_cl_color "0" +_cl_name "player" +_snd_mixahead "0.1" +bgmvolume "1" +volume "0.7" +gl_triplebuffer "1" +viewsize "100.000000" +_config_modem_hangup "AT H" +_config_modem_init "" +_config_modem_clear "ATZ" +_config_modem_dialtype "T" +_config_com_modem "1.000000" +_config_com_baud "57600.000000" +_config_com_irq "4.000000" +_config_com_port "1016.000000" +gl_subdivide_size "128" +saved4 "0" +saved3 "0" +saved2 "0" +saved1 "0" +savedgamecfg "0" +gamma "1.000000" +crosshair "0" diff --git a/src/gl.c b/src/gl.c index ed51572..51563a4 100644 --- a/src/gl.c +++ b/src/gl.c @@ -99,6 +99,9 @@ void D_EndDirectRect (int x, int y, int width, int height) static void install_grabs(void) { + MwFocus(opengl); + MwHideCursor(opengl); + MwGrabPointer(opengl, 1); mouse_active = true; } @@ -107,12 +110,20 @@ static void uninstall_grabs(void) if (!win) return; - /* TODO */ + MwGrabPointer(opengl, 0); mouse_active = false; } static int MilskoToQuakeKey(int key){ + if(key == MwLLKeyEnter) key = K_ENTER; + if(key == MwLLKeyEscape) key = K_ESCAPE; + if(key == MwLLKeyBackSpace) key = K_BACKSPACE; + if(key == MwLLKeyLeft) key = K_LEFTARROW; + if(key == MwLLKeyRight) key = K_RIGHTARROW; + if(key == MwLLKeyUp) key = K_UPARROW; + if(key == MwLLKeyDown) key = K_DOWNARROW; + return key; } @@ -121,22 +132,21 @@ static int MilskoToQuakeMouse(int btn){ if(btn == MwLLMouseLeft) b = 0; if(btn == MwLLMouseMiddle) b = 2; if(btn == MwLLMouseRight) b = 1; + if(btn == MwLLMouseWheelUp) return K_MWHEELUP; + if(btn == MwLLMouseWheelDown) return K_MWHEELDOWN; return K_MOUSE1 + b; } -MwPoint mouse; void mousemove(MwWidget handle, void* user, void* call) { MwPoint* p = call; - int vecX = p->x - mouse.x; - int vecY = p->y - mouse.y; + int vecX = p->x; + int vecY = p->y; if (mouse_active) { mx += vecX * 2; my += vecY * 2; } - - mouse = *p; } void key(MwWidget handle, void* user, void* call){ @@ -159,6 +169,17 @@ void mouseup(MwWidget handle, void* user, void* call){ Key_Event(MilskoToQuakeMouse(m->button), 0); } +void focusin(MwWidget handle, void* user, void* call){ + if(mouse_active){ + MwGrabPointer(opengl, 0); + MwGrabPointer(opengl, 1); + } +} + +void focusout(MwWidget handle, void* user, void* call){ + MwGrabPointer(opengl, 0); +} + static void HandleEvents(void) { int b; @@ -406,9 +427,6 @@ void VID_Init(unsigned char *palette) mouse_avail = 1; - mouse.x = 0; - mouse.y = 0; - vid.maxwarpwidth = WARP_WIDTH; vid.maxwarpheight = WARP_HEIGHT; vid.colormap = host_colormap; @@ -465,6 +483,10 @@ void VID_Init(unsigned char *palette) MwAddUserHandler(opengl, MwNkeyReleaseHandler, keyrelease, NULL); MwAddUserHandler(opengl, MwNmouseDownHandler, mousedown, NULL); MwAddUserHandler(opengl, MwNmouseUpHandler, mouseup, NULL); + MwAddUserHandler(opengl, MwNfocusInHandler, focusin, NULL); + MwAddUserHandler(opengl, MwNfocusOutHandler, focusout, NULL); + + MwFocus(opengl); if(fullscreen){ /* todo */ @@ -487,7 +509,7 @@ void VID_Init(unsigned char *palette) GL_Init(); - sprintf (gldir, "%s/glquake", com_gamedir); + sprintf (gldir, "%s/mwquake", com_gamedir); Sys_mkdir (gldir); VID_SetPalette(palette);