diff --git a/include/in_win.h b/include/in_win.h index b41383b1d..d1c84124e 100644 --- a/include/in_win.h +++ b/include/in_win.h @@ -28,7 +28,7 @@ #ifndef _IN_WIN_H #define _IN_WIN_H -#include "protocol.h" // FIXME: Do away with this. +#include "QF/qtypes.h" extern qboolean mouseactive; extern float mouse_x, mouse_y; @@ -44,7 +44,7 @@ extern void IN_RestoreOriginalMouseState (void); extern void IN_Init (void); extern void IN_Shutdown (void); extern void IN_MouseEvent (int mstate); -extern void IN_MouseMove (usercmd_t *cmd); +//extern void IN_MouseMove (usercmd_t *cmd); extern void IN_Move (void); extern void IN_Accumulate (void); extern void IN_ClearStates (void); diff --git a/nq/source/Makefile.am b/nq/source/Makefile.am index 03e46bb79..200787cee 100644 --- a/nq/source/Makefile.am +++ b/nq/source/Makefile.am @@ -197,10 +197,10 @@ nq_sgl_DEPENDENCIES=$(client_LIB_DEPS) # # SGI/Microsoft WGL (Windows OpenGL) # -wgl_SOURCES= vid_wgl.c +wgl_SOURCES= vid_wgl.c conproc.c nq_wgl_SOURCES= $(combined_SOURCES) $(ogl_SOURCES) $(wgl_SOURCES) in_win.c -nq_wgl_LDADD= $(client_LIBS) $(GLX_LIBS) -lgdi32 +nq_wgl_LDADD= $(client_LIBS) $(GLX_LIBS) -lgdi32 -lcomctl32 nq_wgl_DEPENDENCIES=$(client_LIB_DEPS) # diff --git a/nq/source/conproc.c b/nq/source/conproc.c index ddb293f15..400be078d 100644 --- a/nq/source/conproc.c +++ b/nq/source/conproc.c @@ -30,10 +30,12 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif - +#include #include #include "conproc.h" +#include "QF/console.h" + HANDLE heventDone; HANDLE hfileBuffer; HANDLE heventChildSend; @@ -56,8 +58,6 @@ void InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild) { DWORD dwID; - CONSOLE_SCREEN_BUFFER_INFO info; - int wheight, wwidth; // ignore if we don't have all the events. if (!hFile || !heventParent || !heventChild) @@ -71,14 +71,14 @@ InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild) heventDone = CreateEvent (NULL, FALSE, FALSE, NULL); if (!heventDone) { - Con_SafePrintf ("Couldn't create heventDone\n"); + Con_Printf ("Couldn't create heventDone\n"); return; } if (!CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) RequestProc, 0, 0, &dwID)) { CloseHandle (heventDone); - Con_SafePrintf ("Couldn't create QHOST thread\n"); + Con_Printf ("Couldn't create QHOST thread\n"); return; } // save off the input/output handles. @@ -120,7 +120,7 @@ RequestProc (DWORD dwNichts) // hfileBuffer is invalid. Just leave. if (!pBuffer) { - Con_SafePrintf ("Invalid hfileBuffer\n"); + Con_Printf ("Invalid hfileBuffer\n"); break; } diff --git a/nq/source/in_win.c b/nq/source/in_win.c index 83c7e3d46..10c94aa71 100644 --- a/nq/source/in_win.c +++ b/nq/source/in_win.c @@ -1,7 +1,7 @@ /* in_win.c - windows 95 mouse and joystick code + windows 95 mouse stuff Copyright (C) 1996-1997 Id Software, Inc. @@ -29,21 +29,20 @@ // 02/21/97 JCB Added extended DirectInput code to support external controllers. #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif -#ifdef __MINGW32__ -# define INITGUID -#endif -#include "quakedef.h" + #include "winquake.h" #include #include "client.h" #include "QF/keys.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/qargs.h" #include "QF/cmd.h" -#include "input.h" -//#include "dosisms.h" +#include "QF/input.h" +#include "view.h" +#include "host.h" #define DINPUT_BUFFERSIZE 16 #define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d) @@ -73,70 +72,11 @@ static qboolean mouseshowtoggle = 1; static qboolean dinput_acquired; static unsigned int mstate_di; -// joystick defines and variables -// where should defines be moved? - -#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick -#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, - // trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V -#define JOY_AXIS_X 0 -#define JOY_AXIS_Y 1 -#define JOY_AXIS_Z 2 -#define JOY_AXIS_R 3 -#define JOY_AXIS_U 4 -#define JOY_AXIS_V 5 - -enum _ControlList { - AxisNada = 0, AxisForward, AxisLook, AxisSide, AxisTurn -}; - -static DWORD dwAxisFlags[JOY_MAX_AXES] = { - JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV -}; - -static DWORD dwAxisMap[JOY_MAX_AXES]; -static DWORD dwControlMap[JOY_MAX_AXES]; -static PDWORD pdwRawValue[JOY_MAX_AXES]; - -// none of these cvars are saved over a session -// this means that advanced controller configuration needs to be executed -// each time. this avoids any problems with getting back to a default usage -// or when changing from one controller to another. this way at least something -// works. -static cvar_t *in_joystick; -static cvar_t *joy_name; -static cvar_t *joy_advanced; -static cvar_t *joy_advaxisx; -static cvar_t *joy_advaxisy; -static cvar_t *joy_advaxisz; -static cvar_t *joy_advaxisr; -static cvar_t *joy_advaxisu; -static cvar_t *joy_advaxisv; -static cvar_t *joy_forwardthreshold; -static cvar_t *joy_sidethreshold; -static cvar_t *joy_pitchthreshold; -static cvar_t *joy_yawthreshold; -static cvar_t *joy_forwardsensitivity; -static cvar_t *joy_sidesensitivity; -static cvar_t *joy_pitchsensitivity; -static cvar_t *joy_yawsensitivity; -static cvar_t *joy_wwhack1; -static cvar_t *joy_wwhack2; - -static qboolean joy_avail, joy_advancedinit, joy_haspov; -static DWORD joy_oldbuttonstate, joy_oldpovstate; -static int joy_id; -static DWORD joy_flags; -static DWORD joy_numbuttons; - // misc locals static LPDIRECTINPUT g_pdi; static LPDIRECTINPUTDEVICE g_pMouse; -static JOYINFOEX ji; - static HINSTANCE hInstDI; static qboolean dinput; @@ -154,13 +94,13 @@ typedef struct MYDATA { static DIOBJECTDATAFORMAT rgodf[] = { {&GUID_XAxis, FIELD_OFFSET (MYDATA, lX), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,}, {&GUID_YAxis, FIELD_OFFSET (MYDATA, lY), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,}, - - {&GUID_ZAxis, FIELD_OFFSET (MYDATA, lZ), + + {&GUID_ZAxis, FIELD_OFFSET (MYDATA, lZ), 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,}, {0, FIELD_OFFSET (MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,}, {0, FIELD_OFFSET (MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,}, - - {0, FIELD_OFFSET (MYDATA, bButtonC), + + {0, FIELD_OFFSET (MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,}, {0, FIELD_OFFSET (MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,}, @@ -177,15 +117,16 @@ static DIDATAFORMAT df = { rgodf, // and here they are }; -// forward-referenced functions, locals -static void IN_StartupJoystick (void); -static void Joy_AdvancedUpdate_f (void); -static void IN_JoyMove (usercmd_t *cmd); +// forward-referenced functions, joy + +extern void JOY_Command(void); +extern void JOY_Init_Cvars(void); +extern void JOY_Init (void); +extern void JOY_AdvancedUpdate_f (void); +extern void JOY_Move (void); /* -=========== -Force_CenterView_f -=========== + Force_CenterView_f */ static void Force_CenterView_f (void) @@ -195,9 +136,7 @@ Force_CenterView_f (void) /* -=========== -IN_UpdateClipCursor -=========== + IN_UpdateClipCursor */ void IN_UpdateClipCursor (void) @@ -210,9 +149,7 @@ IN_UpdateClipCursor (void) /* -=========== -IN_ShowMouse -=========== + IN_ShowMouse */ void IN_ShowMouse (void) @@ -226,9 +163,7 @@ IN_ShowMouse (void) /* -=========== -IN_HideMouse -=========== + IN_HideMouse */ void IN_HideMouse (void) @@ -242,9 +177,7 @@ IN_HideMouse (void) /* -=========== -IN_ActivateMouse -=========== + IN_ActivateMouse */ void IN_ActivateMouse (void) @@ -278,9 +211,7 @@ IN_ActivateMouse (void) /* -=========== -IN_SetQuakeMouseState -=========== + IN_SetQuakeMouseState */ void IN_SetQuakeMouseState (void) @@ -291,9 +222,7 @@ IN_SetQuakeMouseState (void) /* -=========== -IN_DeactivateMouse -=========== + IN_DeactivateMouse */ void IN_DeactivateMouse (void) @@ -323,9 +252,7 @@ IN_DeactivateMouse (void) /* -=========== -IN_RestoreOriginalMouseState -=========== + IN_RestoreOriginalMouseState */ void IN_RestoreOriginalMouseState (void) @@ -342,9 +269,7 @@ IN_RestoreOriginalMouseState (void) /* -=========== -IN_InitDInput -=========== + IN_InitDInput */ static qboolean IN_InitDInput (void) @@ -410,6 +335,7 @@ IN_InitDInput (void) Con_Printf ("Couldn't set DI coop level\n"); return false; } + // set the buffer size to DINPUT_BUFFERSIZE elements. // the buffer size is a DWORD property associated with the device hr = @@ -426,9 +352,7 @@ IN_InitDInput (void) /* -=========== -IN_StartupMouse -=========== + IN_StartupMouse */ static void IN_StartupMouse (void) @@ -481,63 +405,33 @@ IN_StartupMouse (void) /* -=========== -IN_Init -=========== + IN_Init */ void IN_Init (void) { - Cmd_AddCommand ("force_centerview", Force_CenterView_f, "No Description"); - Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f, - "No Description"); + Cmd_AddCommand ("force_centerview", Force_CenterView_f, "Force view of player to center"); uiWheelMessage = RegisterWindowMessage ("MSWHEEL_ROLLMSG"); + IN_StartupMouse (); - IN_StartupJoystick (); + + JOY_Init (); } void IN_Init_Cvars (void) { // mouse variables - m_filter = Cvar_Get ("m_filter", "0", CVAR_NONE, NULL, "None"); + m_filter = Cvar_Get ("m_filter", "0", CVAR_NONE, NULL, + "Toggle mouse input filtering."); - // joystick variables - in_joystick = Cvar_Get ("joystick", "0", CVAR_ARCHIVE, NULL, "None"); - joy_name = Cvar_Get ("joyname", "joystick", CVAR_NONE, NULL, "None"); - joy_advanced = Cvar_Get ("joyadvanced", "0", CVAR_NONE, NULL, "None"); - joy_advaxisx = Cvar_Get ("joyadvaxisx", "0", CVAR_NONE, NULL, "None"); - joy_advaxisy = Cvar_Get ("joyadvaxisy", "0", CVAR_NONE, NULL, "None"); - joy_advaxisz = Cvar_Get ("joyadvaxisz", "0", CVAR_NONE, NULL, "None"); - joy_advaxisr = Cvar_Get ("joyadvaxisr", "0", CVAR_NONE, NULL, "None"); - joy_advaxisu = Cvar_Get ("joyadvaxisu", "0", CVAR_NONE, NULL, "None"); - joy_advaxisv = Cvar_Get ("joyadvaxisv", "0", CVAR_NONE, NULL, "None"); - joy_forwardthreshold = - Cvar_Get ("joyforwardthreshold", "0.15", CVAR_NONE, NULL, "None"); - joy_sidethreshold = - Cvar_Get ("joysidethreshold", "0.15", CVAR_NONE, NULL, "None"); - joy_pitchthreshold = - Cvar_Get ("joypitchthreshold", "0.15", CVAR_NONE, NULL, "None"); - joy_yawthreshold = Cvar_Get ("joyyawthreshold", "0.15", CVAR_NONE, NULL, - "None"); - joy_forwardsensitivity = - Cvar_Get ("joyforwardsensitivity", "-1.0", CVAR_NONE, NULL, "None"); - joy_sidesensitivity = - Cvar_Get ("joysidesensitivity", "-1.0", CVAR_NONE, NULL, "None"); - joy_pitchsensitivity = - Cvar_Get ("joypitchsensitivity", "1.0", CVAR_NONE, NULL, "None"); - joy_yawsensitivity = - Cvar_Get ("joyyawsensitivity", "-1.0", CVAR_NONE, NULL, "None"); - joy_wwhack1 = Cvar_Get ("joywwhack1", "0.0", CVAR_NONE, NULL, "None"); - joy_wwhack2 = Cvar_Get ("joywwhack2", "0.0", CVAR_NONE, NULL, "None"); + JOY_Init_Cvars(); } /* -=========== -IN_Shutdown -=========== + IN_Shutdown */ void IN_Shutdown (void) @@ -559,9 +453,7 @@ IN_Shutdown (void) /* -=========== -IN_MouseEvent -=========== + IN_MouseEvent */ void IN_MouseEvent (int mstate) @@ -572,11 +464,11 @@ IN_MouseEvent (int mstate) // perform button actions for (i = 0; i < mouse_buttons; i++) { if ((mstate & (1 << i)) && !(mouse_oldbuttonstate & (1 << i))) { - Key_Event (K_MOUSE1 + i, true); + Key_Event (K_MOUSE1 + i, -1, true); } if (!(mstate & (1 << i)) && (mouse_oldbuttonstate & (1 << i))) { - Key_Event (K_MOUSE1 + i, false); + Key_Event (K_MOUSE1 + i, -1, false); } } @@ -586,9 +478,7 @@ IN_MouseEvent (int mstate) /* -=========== -IN_MouseMove -=========== + IN_MouseMove */ void IN_MouseMove (void) @@ -630,44 +520,44 @@ IN_MouseMove (void) switch (od.dwOfs) { case DIMOFS_X: - mx += od.dwData; - break; + mx += od.dwData; + break; case DIMOFS_Y: - my += od.dwData; - break; + my += od.dwData; + break; case DIMOFS_BUTTON0: - if (od.dwData & 0x80) - mstate_di |= 1; - else - mstate_di &= ~1; - break; + if (od.dwData & 0x80) + mstate_di |= 1; + else + mstate_di &= ~1; + break; case DIMOFS_BUTTON1: - if (od.dwData & 0x80) - mstate_di |= (1 << 1); - else - mstate_di &= ~(1 << 1); - break; + if (od.dwData & 0x80) + mstate_di |= (1 << 1); + else + mstate_di &= ~(1 << 1); + break; case DIMOFS_BUTTON2: - if (od.dwData & 0x80) - mstate_di |= (1 << 2); - else - mstate_di &= ~(1 << 2); - break; + if (od.dwData & 0x80) + mstate_di |= (1 << 2); + else + mstate_di &= ~(1 << 2); + break; } } // perform button actions for (i = 0; i < mouse_buttons; i++) { if ((mstate_di & (1 << i)) && !(mouse_oldbuttonstate & (1 << i))) { - Key_Event (K_MOUSE1 + i, true); + Key_Event (K_MOUSE1 + i, -1, true); } if (!(mstate_di & (1 << i)) && (mouse_oldbuttonstate & (1 << i))) { - Key_Event (K_MOUSE1 + i, false); + Key_Event (K_MOUSE1 + i, -1, false); } } @@ -704,7 +594,7 @@ IN_MouseMove (void) viewdelta.angles[PITCH] += mouse_y; } else { if ((in_strafe.state & 1) && noclip_anglehack) - viewdelta.position[1] = mouse_y; + viewdelta.position[1] -= mouse_y; else viewdelta.position[2] -= mouse_y; } @@ -717,9 +607,7 @@ IN_MouseMove (void) /* -=========== -IN_Move -=========== + IN_Move */ void IN_Move (void) @@ -727,15 +615,13 @@ IN_Move (void) if (ActiveApp && !Minimized) { IN_MouseMove (); - IN_JoyMove (); + JOY_Move (); } } /* -=========== -IN_Accumulate -=========== + IN_Accumulate */ void IN_Accumulate (void) @@ -743,6 +629,8 @@ IN_Accumulate (void) // int mx, my; // HDC hdc; +// if (dinput) return; // If using dinput we don't probably need this + if (mouseactive) { GetCursorPos (¤t_pos); @@ -756,9 +644,7 @@ IN_Accumulate (void) /* -=================== -IN_ClearStates -=================== + IN_ClearStates */ void IN_ClearStates (void) @@ -771,429 +657,14 @@ IN_ClearStates (void) } } - -/* -=============== -IN_StartupJoystick -=============== -*/ -static void -IN_StartupJoystick (void) -{ - int /* i, */ numdevs; - JOYCAPS jc; - MMRESULT mmr = !JOYERR_NOERROR; - - // assume no joystick - joy_avail = false; - - // abort startup if user requests no joystick - if (COM_CheckParm ("-nojoy")) - return; - - // verify joystick driver is present - if ((numdevs = joyGetNumDevs ()) == 0) { - Con_Printf ("\njoystick not found -- driver not present\n\n"); - return; - } - // cycle through the joystick ids for the first valid one - for (joy_id = 0; joy_id < numdevs; joy_id++) { - memset (&ji, 0, sizeof (ji)); - ji.dwSize = sizeof (ji); - ji.dwFlags = JOY_RETURNCENTERED; - - if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR) - break; - } - - // abort startup if we didn't find a valid joystick - if (mmr != JOYERR_NOERROR) { - Con_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr); - return; - } - // get the capabilities of the selected joystick - // abort startup if command fails - memset (&jc, 0, sizeof (jc)); - if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof (jc))) != JOYERR_NOERROR) { - Con_Printf - ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", - mmr); - return; - } - // save the joystick's number of buttons and POV status - joy_numbuttons = jc.wNumButtons; - joy_haspov = jc.wCaps & JOYCAPS_HASPOV; - - // old button and POV states default to no buttons pressed - joy_oldbuttonstate = joy_oldpovstate = 0; - - // mark the joystick as available and advanced initialization not - // completed - // this is needed as cvars are not available during initialization - - joy_avail = true; - joy_advancedinit = false; - - Con_Printf ("\njoystick detected\n\n"); -} - - /* -=========== -RawValuePointer -=========== -*/ -static PDWORD -RawValuePointer (int axis) -{ - switch (axis) { - case JOY_AXIS_X: - return &ji.dwXpos; - case JOY_AXIS_Y: - return &ji.dwYpos; - case JOY_AXIS_Z: - return &ji.dwZpos; - case JOY_AXIS_R: - return &ji.dwRpos; - case JOY_AXIS_U: - return &ji.dwUpos; - case JOY_AXIS_V: - return &ji.dwVpos; - } - return NULL; -} - -/* -=========== -Joy_AdvancedUpdate_f -=========== -*/ -static void -Joy_AdvancedUpdate_f (void) -{ - - // called once by IN_ReadJoystick and by user whenever an update is - // needed - // cvars are now available - int i; - DWORD dwTemp; - - // initialize all the maps - for (i = 0; i < JOY_MAX_AXES; i++) { - dwAxisMap[i] = AxisNada; - dwControlMap[i] = JOY_ABSOLUTE_AXIS; - pdwRawValue[i] = RawValuePointer (i); - } - - if (joy_advanced->int_val) { - // default joystick initialization - // 2 axes only with joystick control - dwAxisMap[JOY_AXIS_X] = AxisTurn; - // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; - dwAxisMap[JOY_AXIS_Y] = AxisForward; - // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; - } else { - if (strcmp (joy_name->string, "joystick") != 0) { - // notify user of advanced controller - Con_Printf ("\n%s configured\n\n", joy_name->string); - } - // advanced initialization here - // data supplied by user via joy_axisn cvars - dwTemp = joy_advaxisx->int_val; - dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = joy_advaxisy->int_val; - dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = joy_advaxisz->int_val; - dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = joy_advaxisr->int_val; - dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = joy_advaxisu->int_val; - dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = joy_advaxisv->int_val; - dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; - } - - // compute the axes to collect from DirectInput - joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; - for (i = 0; i < JOY_MAX_AXES; i++) { - if (dwAxisMap[i] != AxisNada) { - joy_flags |= dwAxisFlags[i]; - } - } -} - - -/* -=========== -IN_Commands -=========== + IN_Commands */ void IN_Commands (void) { - int i, key_index; - DWORD buttonstate, povstate; - - if (!joy_avail) { - return; - } - // loop through the joystick buttons - // key a joystick event or auxillary event for higher number buttons for - // each state change - buttonstate = ji.dwButtons; - for (i = 0; i < joy_numbuttons; i++) { - if ((buttonstate & (1 << i)) && !(joy_oldbuttonstate & (1 << i))) { - key_index = (i < 4) ? K_JOY1 : K_AUX1; - Key_Event (key_index + i, true); - } - - if (!(buttonstate & (1 << i)) && (joy_oldbuttonstate & (1 << i))) { - key_index = (i < 4) ? K_JOY1 : K_AUX1; - Key_Event (key_index + i, false); - } - } - joy_oldbuttonstate = buttonstate; - - if (joy_haspov) { - // convert POV information into 4 bits of state information - // this avoids any potential problems related to moving from one - // direction to another without going through the center position - povstate = 0; - if (ji.dwPOV != JOY_POVCENTERED) { - if (ji.dwPOV == JOY_POVFORWARD) - povstate |= 0x01; - if (ji.dwPOV == JOY_POVRIGHT) - povstate |= 0x02; - if (ji.dwPOV == JOY_POVBACKWARD) - povstate |= 0x04; - if (ji.dwPOV == JOY_POVLEFT) - povstate |= 0x08; - } - // determine which bits have changed and key an auxillary event for - // each change - for (i = 0; i < 4; i++) { - if ((povstate & (1 << i)) && !(joy_oldpovstate & (1 << i))) { - Key_Event (K_AUX29 + i, true); - } - - if (!(povstate & (1 << i)) && (joy_oldpovstate & (1 << i))) { - Key_Event (K_AUX29 + i, false); - } - } - joy_oldpovstate = povstate; - } -} - - -/* -=============== -IN_ReadJoystick -=============== -*/ -static qboolean -IN_ReadJoystick (void) -{ - - memset (&ji, 0, sizeof (ji)); - ji.dwSize = sizeof (ji); - ji.dwFlags = joy_flags; - - if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR) { - // this is a hack -- there is a bug in the Logitech WingMan Warrior - // DirectInput Driver - // rather than having 32768 be the zero point, they have the zero - // point at 32668 - // go figure -- anyway, now we get the full resolution out of the - // device - if (joy_wwhack1->int_val) { - ji.dwUpos += 100; - } - return true; - } else { - // read error occurred - // turning off the joystick seems too harsh for 1 read error, - // but what should be done? - // Con_Printf ("IN_ReadJoystick: no response\n"); - // joy_avail = false; - return false; - } -} - - -/* -=========== -IN_JoyMove -=========== -*/ -static void -IN_JoyMove (usercmd_t *cmd) -{ - float speed, aspeed; - float fAxisValue, fTemp; - int i; - - // complete initialization if first time in - // this is needed as cvars are not available at initialization time - if (joy_advancedinit != true) { - Joy_AdvancedUpdate_f (); - joy_advancedinit = true; - } - // verify joystick is available and that the user wants to use it - if (!joy_avail || !in_joystick->int_val) { - return; - } - // collect the joystick data, if possible - if (IN_ReadJoystick () != true) { - return; - } - - if (in_speed.state & 1) - speed = cl_movespeedkey->value; - else - speed = 1; - aspeed = speed * host_frametime; - - // loop through the axes - for (i = 0; i < JOY_MAX_AXES; i++) { - // get the floating point zero-centered, potentially-inverted data - // for the current axis - fAxisValue = (float) *pdwRawValue[i]; - // move centerpoint to zero - fAxisValue -= 32768.0; - - if (joy_wwhack2->int_val) { - if (dwAxisMap[i] == AxisTurn) { - // this is a special formula for the Logitech WingMan Warrior - // y=ax^b; where a = 300 and b = 1.3 - // also x values are in increments of 800 (so this is - // factored out) - // then bounds check result to level out excessively high - // spin rates - fTemp = 300.0 * pow (abs (fAxisValue) / 800.0, 1.3); - if (fTemp > 14000.0) - fTemp = 14000.0; - // restore direction information - fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp; - } - } - // convert range from -32768..32767 to -1..1 - fAxisValue /= 32768.0; - - switch (dwAxisMap[i]) { - case AxisForward: - if (!joy_advanced->int_val && freelook) { - // user wants forward control to become look control - if (fabs (fAxisValue) > joy_pitchthreshold->value) { - // if mouse invert is on, invert the joystick pitch value - // only absolute control support here (joy_advanced is - // false) - if (m_pitch->value < 0.0) { - cl.viewangles[PITCH] -= - (fAxisValue * joy_pitchsensitivity->value) * - aspeed * cl_pitchspeed->value; - } else { - cl.viewangles[PITCH] += - (fAxisValue * joy_pitchsensitivity->value) * - aspeed * cl_pitchspeed->value; - } - V_StopPitchDrift (); - } else { - // no pitch movement - // disable pitch return-to-center unless requested by - // user - // *** this code can be removed when the lookspring bug - // is fixed - // *** the bug always has the lookspring feature on - if (!lookspring->int_val) - V_StopPitchDrift (); - } - } else { - // user wants forward control to be forward control - if (fabs (fAxisValue) > joy_forwardthreshold->value) { - cmd->forwardmove += - (fAxisValue * joy_forwardsensitivity->value) * speed * - cl_forwardspeed->value; - } - } - break; - - case AxisSide: - if (fabs (fAxisValue) > joy_sidethreshold->value) { - cmd->sidemove += - (fAxisValue * joy_sidesensitivity->value) * speed * - cl_sidespeed->value; - } - break; - - case AxisTurn: - if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook)) { - // user wants turn control to become side control - if (fabs (fAxisValue) > joy_sidethreshold->value) { - cmd->sidemove -= - (fAxisValue * joy_sidesensitivity->value) * speed * - cl_sidespeed->value; - } - } else { - // user wants turn control to be turn control - if (fabs (fAxisValue) > joy_yawthreshold->value) { - if (dwControlMap[i] == JOY_ABSOLUTE_AXIS) { - cl.viewangles[YAW] += - (fAxisValue * joy_yawsensitivity->value) * aspeed * - cl_yawspeed->value; - } else { - cl.viewangles[YAW] += - (fAxisValue * joy_yawsensitivity->value) * speed * - 180.0; - } - - } - } - break; - - case AxisLook: - if (freelook) { - if (fabs (fAxisValue) > joy_pitchthreshold->value) { - // pitch movement detected and pitch movement desired by - // user - if (dwControlMap[i] == JOY_ABSOLUTE_AXIS) { - cl.viewangles[PITCH] += - (fAxisValue * joy_pitchsensitivity->value) * - aspeed * cl_pitchspeed->value; - } else { - cl.viewangles[PITCH] += - (fAxisValue * joy_pitchsensitivity->value) * speed * - 180.0; - } - V_StopPitchDrift (); - } else { - // no pitch movement - // disable pitch return-to-center unless requested by - // user - // *** this code can be removed when the lookspring bug - // is fixed - // *** the bug always has the lookspring feature on - if (!lookspring->int_val) - V_StopPitchDrift (); - } - } - break; - - default: - break; - } - } - - // bounds check pitch - if (cl.viewangles[PITCH] > 80.0) - cl.viewangles[PITCH] = 80.0; - if (cl.viewangles[PITCH] < -70.0) - cl.viewangles[PITCH] = -70.0; + // Joystick + JOY_Command(); } void diff --git a/nq/source/sys_win.c b/nq/source/sys_win.c index 2c407cf58..af22eed58 100644 --- a/nq/source/sys_win.c +++ b/nq/source/sys_win.c @@ -678,3 +678,8 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, /* return success of application */ return TRUE; } + +void +Sys_DebugLog (char *file, char *fmt, ...) +{ +} diff --git a/nq/source/vid_wgl.c b/nq/source/vid_wgl.c index 55d311d57..4c7cacb14 100644 --- a/nq/source/vid_wgl.c +++ b/nq/source/vid_wgl.c @@ -141,9 +141,6 @@ float gldepthmin, gldepthmax; modestate_t modestate = MS_UNINIT; -void VID_MenuDraw (void); -void VID_MenuKey (int key); - LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void AppActivate (BOOL fActive, BOOL minimize); char *VID_GetModeDescription (int mode); @@ -944,8 +941,6 @@ MAIN WINDOW =================================================================== */ -extern void CL_ClearStates (); - /* ================ ClearAllStates @@ -954,7 +949,6 @@ ClearAllStates void ClearAllStates (void) { - CL_ClearStates (); Key_ClearStates (); IN_ClearStates (); } @@ -1727,7 +1721,7 @@ VID_Init (unsigned char *palette) DestroyWindow (hwnd_dialog); #endif - GL_CheckBrightness (palette); +// GL_CheckBrightness (palette); VID_SetPalette (palette); VID_SetMode (vid_default, palette); @@ -1752,9 +1746,6 @@ VID_Init (unsigned char *palette) // Check for 3DFX Extensions and initialize them. VID_Init8bitPalette (); - vid_menudrawfn = VID_MenuDraw; - vid_menukeyfn = VID_MenuKey; - strcpy (badmode.modedesc, "Bad mode"); vid_canalttab = true; @@ -1774,15 +1765,6 @@ VID_Init_Cvars () // Video menu stuff //======================================================== -extern void M_Menu_Options_f (void); -extern void M_Print (int cx, int cy, char *str); -extern void M_PrintWhite (int cx, int cy, char *str); -extern void M_DrawCharacter (int cx, int line, int num); -extern void M_DrawTransPic (int x, int y, qpic_t *pic); -extern void M_DrawPic (int x, int y, qpic_t *pic); - -static int vid_wmodes; - typedef struct { int modenum; char *desc; @@ -1793,94 +1775,7 @@ typedef struct { #define MODE_AREA_HEIGHT (MAX_COLUMN_SIZE + 2) #define MAX_MODEDESCS (MAX_COLUMN_SIZE*3) -static modedesc_t modedescs[MAX_MODEDESCS]; - -/* -================ -VID_MenuDraw -================ -*/ -void -VID_MenuDraw (void) -{ - qpic_t *p; - char *ptr; - int lnummodes, i, k, column, row; - vmode_t *pv; - - p = Draw_CachePic ("gfx/vidmodes.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - vid_wmodes = 0; - lnummodes = VID_NumModes (); - - for (i = 1; (i < lnummodes) && (vid_wmodes < MAX_MODEDESCS); i++) { - ptr = VID_GetModeDescription (i); - pv = VID_GetModePtr (i); - - k = vid_wmodes; - - modedescs[k].modenum = i; - modedescs[k].desc = ptr; - modedescs[k].iscur = 0; - - if (i == vid_modenum) - modedescs[k].iscur = 1; - - vid_wmodes++; - - } - - if (vid_wmodes > 0) { - M_Print (2 * 8, 36 + 0 * 8, "Fullscreen Modes (WIDTHxHEIGHTxBPP)"); - - column = 8; - row = 36 + 2 * 8; - - for (i = 0; i < vid_wmodes; i++) { - if (modedescs[i].iscur) - M_PrintWhite (column, row, modedescs[i].desc); - else - M_Print (column, row, modedescs[i].desc); - - column += 13 * 8; - - if ((i % VID_ROW_SIZE) == (VID_ROW_SIZE - 1)) { - column = 8; - row += 8; - } - } - } - - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 2, - "Video modes must be set from the"); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 3, - "command line with -width "); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 4, - "and -bpp "); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 6, - "Select windowed mode with -window"); -} - - -/* -================ -VID_MenuKey -================ -*/ -void -VID_MenuKey (int key) -{ - switch (key) { - case K_ESCAPE: - S_LocalSound ("misc/menu1.wav"); - M_Menu_Options_f (); - break; - - default: - break; - } -} +//static modedesc_t modedescs[MAX_MODEDESCS]; void VID_SetCaption (char *text)