vid_sdl.c: Removed some stupid includes, some whitespace

vid_sgl.c: Added freelook and joystick support.
This commit is contained in:
Jeff Teunissen 2000-10-13 06:16:27 +00:00
parent 8903d650d2
commit fd81937dd9
2 changed files with 62 additions and 56 deletions

View file

@ -30,34 +30,23 @@
#include "config.h" #include "config.h"
#endif #endif
#include "SDL.h" #include <SDL.h>
#include "bothdefs.h" // needed by: common.h, net.h, client. #include "client.h"
#include "quakedef.h"
#include "menu.h"
#include "vid.h"
#include "sys.h"
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
// modelgen.h, glmodel.h
#include "wad.h"
#include "draw.h"
#include "cvar.h"
#include "net.h" // needed by: client.h
#include "protocol.h" // needed by: client.h
#include "cmd.h"
#include "keys.h"
#include "sbar.h"
#include "sound.h"
#include "render.h" // needed by: client.h, gl_model.h, glquake.h
#include "client.h" // need cls in this file
#include "console.h" #include "console.h"
#include "qendian.h" #include "cvar.h"
#include "qargs.h" #include "draw.h"
#include "compat.h" #include "d_iface.h"
#include "d_local.h" #include "d_local.h"
#include "input.h" #include "input.h"
#include "joystick.h" #include "joystick.h"
#include "keys.h"
#include "menu.h"
#include "sys.h"
#include "qargs.h"
#include "qendian.h"
#include "qtypes.h"
#include "quakedef.h"
cvar_t *_windowed_mouse; cvar_t *_windowed_mouse;
@ -443,12 +432,15 @@ IN_Commands (void)
JOY_Command (); JOY_Command ();
if (old_windowed_mouse != _windowed_mouse->int_val) { if (old_windowed_mouse != _windowed_mouse->int_val) {
old_windowed_mouse = _windowed_mouse->value; old_windowed_mouse = _windowed_mouse->int_val;
if (_windowed_mouse->int_val) if (_windowed_mouse->int_val) { // grab the pointer
SDL_ShowCursor (0);
SDL_WM_GrabInput (SDL_GRAB_ON); SDL_WM_GrabInput (SDL_GRAB_ON);
else } else { // ungrab the pointer
SDL_WM_GrabInput (SDL_GRAB_OFF); SDL_WM_GrabInput (SDL_GRAB_OFF);
SDL_ShowCursor (1);
}
} }
} }

View file

@ -36,19 +36,21 @@
#include <signal.h> #include <signal.h>
#include <values.h> #include <values.h>
#include "SDL.h" #include <SDL.h>
#include "qtypes.h"
#include "quakedef.h"
#include "qendian.h"
#include "glquake.h"
#include "cvar.h"
#include "qargs.h"
#include "console.h" #include "console.h"
#include "cvar.h"
#include "draw.h"
#include "glquake.h"
#include "input.h"
#include "joystick.h"
#include "keys.h" #include "keys.h"
#include "menu.h" #include "menu.h"
#include "sys.h" #include "sys.h"
#include "draw.h" #include "qargs.h"
#include "qendian.h"
#include "qtypes.h"
#include "quakedef.h"
#define WARP_WIDTH 320 #define WARP_WIDTH 320
#define WARP_HEIGHT 200 #define WARP_HEIGHT 200
@ -92,7 +94,7 @@ int modestate;
static qboolean mouse_avail; static qboolean mouse_avail;
static float mouse_x, mouse_y; static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y; static float old_mouse_x, old_mouse_y;
static float old__windowed_mouse; static float old_windowed_mouse;
void void
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height) D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
@ -428,7 +430,8 @@ VID_Init (unsigned char *palette)
vid.recalc_refdef = 1; // force a surface cache flush vid.recalc_refdef = 1; // force a surface cache flush
} }
void VID_InitCvars() void
VID_InitCvars ()
{ {
} }
@ -619,6 +622,8 @@ IN_SendKeyEvents (void)
void void
IN_Init (void) IN_Init (void)
{ {
JOY_Init ();
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "Grab mouse and keyboard input"); _windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "Grab mouse and keyboard input");
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None"); m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None");
@ -635,16 +640,21 @@ IN_Init (void)
void void
IN_Shutdown (void) IN_Shutdown (void)
{ {
JOY_Shutdown ();
Con_Printf ("IN_Shutdown\n");
mouse_avail = 0; mouse_avail = 0;
} }
void void
IN_Commands (void) IN_Commands (void)
{ {
if (old__windowed_mouse != _windowed_mouse->value) { JOY_Command ();
old__windowed_mouse = _windowed_mouse->value;
if (_windowed_mouse->value) { // grab the pointer if (old_windowed_mouse != _windowed_mouse->int_val) {
old_windowed_mouse = _windowed_mouse->int_val;
if (_windowed_mouse->int_val) { // grab the pointer
SDL_ShowCursor (0); SDL_ShowCursor (0);
SDL_WM_GrabInput (SDL_GRAB_ON); SDL_WM_GrabInput (SDL_GRAB_ON);
} else { // ungrab the pointer } else { // ungrab the pointer
@ -657,6 +667,8 @@ IN_Commands(void)
void void
IN_Move (usercmd_t *cmd) IN_Move (usercmd_t *cmd)
{ {
JOY_Move (cmd);
if (!mouse_avail) if (!mouse_avail)
return; return;
@ -671,15 +683,17 @@ IN_Move(usercmd_t *cmd)
mouse_x *= sensitivity->value; mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value; mouse_y *= sensitivity->value;
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) if ((in_strafe.state & 1) || (lookstrafe->value && freelook))
cmd->sidemove += m_side->value * mouse_x; cmd->sidemove += m_side->value * mouse_x;
else else
cl.viewangles[YAW] -= m_yaw->value * mouse_x; cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (in_mlook.state & 1)
if (freelook)
V_StopPitchDrift (); V_StopPitchDrift ();
if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) { if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH] + (m_pitch->value * mouse_y), 80); cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
} else { } else {
if ((in_strafe.state & 1) && noclip_anglehack) if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y; cmd->upmove -= m_forward->value * mouse_y;