Merged joystick code. Great deal of cleanup in input, reduced bizarre overuse of protocol.h...

Maimed joy_win.c, very likely to get odd behavior there, even if it compiles.
This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-04-11 07:57:08 +00:00
parent 5cd24de097
commit f789b61c56
38 changed files with 282 additions and 775 deletions

View file

@ -1440,6 +1440,8 @@ AC_OUTPUT(
libs/audio/targets/Makefile
libs/gamecode/Makefile
libs/util/Makefile
libs/video/Makefile
libs/video/targets/Makefile
qw/Makefile
qw/quakeforge.lsm

View file

@ -29,10 +29,13 @@
#ifndef _INPUT_H
#define _INPUT_H
#include "client.h"
#include "protocol.h"
#include "QF/cvar.h"
struct {
vec3_t angles;
vec3_t position;
} viewdelta;
#define freelook (in_mlook.state&1 || cl_freelook->int_val)
void IN_Init (void);
@ -46,7 +49,7 @@ void IN_Commands (void);
void IN_SendKeyEvents (void);
// Perform Key_Event () callbacks until the input que is empty
void IN_Move (usercmd_t *cmd);
void IN_Move (void); // FIXME: was cmduser_t?
// add additional movement on top of the keyboard move cmd
void IN_ModeChanged (void);

View file

@ -53,14 +53,14 @@ extern qboolean joy_active; // Joystick in use?
void JOY_Command (void);
/*
JOY_Move (usercmd_t *)
JOY_Move (usercmd_t *) // FIXME: Not anymore!
Use this function to process joystick movements to move the player around.
You should exit this function immediately if either joy_active or
joy_enable->int_val are zero.
*/
void JOY_Move (usercmd_t *);
void JOY_Move (void);
/*
JOY_Init ()

View file

@ -28,7 +28,7 @@
#ifndef _IN_WIN_H
#define _IN_WIN_H
#include "protocol.h"
#include "protocol.h" // FIXME: Do away with this.
extern qboolean mouseactive;
extern float mouse_x, mouse_y;
@ -45,11 +45,9 @@ 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_Move (usercmd_t *cmd);
extern void IN_Move (void);
extern void IN_Accumulate (void);
extern void IN_ClearStates (void);
extern void IN_Commands (void);
#endif // _IN_WIN_H

View file

@ -1,4 +1,4 @@
SUBDIRS= audio gamecode util
SUBDIRS= audio gamecode util video
clean-local:
rm -f *.a

3
libs/video/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.vimrc
Makefile.in
Makefile

4
libs/video/Makefile.am Normal file
View file

@ -0,0 +1,4 @@
SUBDIRS= targets
clean-local:
rm -f *.a

3
libs/video/targets/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.vimrc
Makefile.in
Makefile

View file

@ -0,0 +1,16 @@
lib_LTLIBRARIES = libQFjs.la
libQFjs_la_LDFLAGS = -version-info 1:0:0 $(CD_LIBS)
if JOYTYPE_LINUX
libQFjs_la_SOURCES= joy_linux.c
endif
if JOYTYPE_WIN32
libQFjs_la_SOURCES= joy_win.c
endif
if JOYTYPE_NULL
libQFjs_la_SOURCES= joy_null.c
endif
libQFjs_la_CFLAGS= $(JOY_CFLAGS)
LIBLIST = libQFjs.la @LIBRARY_SEARCH_PATH@

View file

@ -37,11 +37,10 @@
#include "QF/compat.h"
#include "QF/console.h"
#include "client.h"
#include "QF/cvar.h"
#include "QF/input.h"
#include "QF/keys.h"
#include "protocol.h"
#include "view.h"
#include "QF/mathlib.h"
#define JOY_MAX_AXES 6
#define JOY_MAX_BUTTONS 16
@ -119,44 +118,41 @@ JOY_Command (void)
}
void
JOY_Move (usercmd_t *cmd)
JOY_Move (void)
{
int i;
if (!joy_active || !joy_enable->int_val)
return;
Cvar_SetValue (joy_sensitivity, bound (1, joy_sensitivity->value, 25));
Cvar_SetValue (joy_sensitivity, max (0.01, joy_sensitivity->value));
for (i = 0; i < JOY_MAX_AXES; i++) {
switch (joy_axes[i].axis->int_val) {
case 1:
cl.viewangles[YAW] -=
m_yaw->value * (float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
viewdelta.angles[YAW] -=
(float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
break;
case 2:
cmd->forwardmove -=
m_forward->value * (float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
viewdelta.position[2] -=
(float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
break;
case 3:
cmd->sidemove +=
m_side->value * (float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
viewdelta.position[0] +=
(float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
break;
case 4:
if (joy_axes[i].current) {
V_StopPitchDrift ();
cl.viewangles[PITCH] -=
m_pitch->value * (float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value *
4)));
cl.viewangles[PITCH] =
bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] -=
(float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value *
4)));
}
break;
}
@ -199,19 +195,19 @@ JOY_Init_Cvars (void)
int i;
joy_device =
Cvar_Get ("joy_device", "/dev/js0", CVAR_NONE | CVAR_ROM, NULL,
Cvar_Get ("joy_device", "/dev/js0", CVAR_NONE | CVAR_ROM, 0,
"Joystick device");
joy_enable =
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, 0,
"Joystick enable flag");
joy_sensitivity =
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, 0,
"Joystick sensitivity");
for (i = 0; i < JOY_MAX_AXES; i++) {
joy_axes[i].axis = Cvar_Get (joy_axes[i].var.name,
joy_axes[i].var.string,
CVAR_ARCHIVE, NULL, "Set joystick axes");
CVAR_ARCHIVE, 0, "Set joystick axes");
}
}

View file

@ -32,7 +32,6 @@
#include "QF/console.h"
#include "QF/cvar.h"
#include "protocol.h"
#include "QF/qtypes.h"
// Joystick variables and structures
@ -49,7 +48,7 @@ JOY_Command (void)
}
void
JOY_Move (usercmd_t *cmd)
JOY_Move (void)
{
}
@ -63,13 +62,13 @@ void
JOY_Init_Cvars (void)
{
joy_device =
Cvar_Get ("joy_device", "none", CVAR_NONE | CVAR_ROM, NULL,
Cvar_Get ("joy_device", "none", CVAR_NONE | CVAR_ROM, 0,
"Joystick device");
joy_enable =
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, 0,
"Joystick enable flag");
joy_sensitivity =
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, 0,
"Joystick sensitivity");
}

View file

@ -40,8 +40,6 @@
#include <dinput.h>
#undef byte
#include "cl_input.h"
#include "client.h"
#include "QF/cmd.h"
#include "QF/compat.h"
#include "QF/console.h"
@ -49,9 +47,7 @@
#include "host.h"
#include "QF/input.h"
#include "QF/keys.h"
#include "protocol.h"
#include "QF/qargs.h"
#include "view.h"
// Joystick variables and structures
cvar_t *joy_device; // Joystick device name
@ -129,7 +125,7 @@ DWORD joy_numbuttons;
//
void JOY_AdvancedUpdate_f (void);
void JOY_StartupJoystick (void);
void JOY_Move (usercmd_t *cmd);
void JOY_Move (void);
void JOY_Init_Cvars(void);
PDWORD RawValuePointer (int axis);
@ -221,7 +217,7 @@ JOY_Command (void)
}
void
JOY_Move (usercmd_t *cmd)
JOY_Move (void)
{
float speed, aspeed;
float fAxisValue, fTemp;
@ -286,15 +282,14 @@ JOY_Move (usercmd_t *cmd)
// only absolute control support here (joy_advanced
// is false)
if (m_pitch->value < 0.0) {
cl.viewangles[PITCH] -=
viewdelta.angles[PITCH] -=
(fAxisValue * joy_pitchsensitivity->value) *
aspeed * cl_pitchspeed->value;
} else {
cl.viewangles[PITCH] +=
viewdelta.angles[PITCH] +=
(fAxisValue * joy_pitchsensitivity->value) *
aspeed * cl_pitchspeed->value;
}
V_StopPitchDrift ();
} else {
// no pitch movement
// disable pitch return-to-center unless requested by
@ -308,7 +303,7 @@ JOY_Move (usercmd_t *cmd)
} else {
// user wants forward control to be forward control
if (fabs (fAxisValue) > joy_forwardthreshold->value) {
cmd->forwardmove +=
viewdelta.position[0] +=
(fAxisValue * joy_forwardsensitivity->value) *
speed * cl_forwardspeed->value;
}
@ -317,7 +312,7 @@ JOY_Move (usercmd_t *cmd)
case AxisSide:
if (fabs (fAxisValue) > joy_sidethreshold->value) {
cmd->sidemove +=
viewdelta.position[1] +=
(fAxisValue * joy_sidesensitivity->value) * speed *
cl_sidespeed->value;
}
@ -327,7 +322,7 @@ JOY_Move (usercmd_t *cmd)
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 -=
viewdelta.position[0] -=
(fAxisValue * joy_sidesensitivity->value) * speed *
cl_sidespeed->value;
}
@ -335,11 +330,11 @@ JOY_Move (usercmd_t *cmd)
// user wants turn control to be turn control
if (fabs (fAxisValue) > joy_yawthreshold->value) {
if (dwControlMap[i] == JOY_ABSOLUTE_AXIS) {
cl.viewangles[YAW] +=
viewdelta.angles[YAW] +=
(fAxisValue * joy_yawsensitivity->value) *
aspeed * cl_yawspeed->value;
} else {
cl.viewangles[YAW] +=
viewdelta.angles[YAW] +=
(fAxisValue * joy_yawsensitivity->value) *
speed * 180.0;
}
@ -353,15 +348,14 @@ JOY_Move (usercmd_t *cmd)
// pitch movement detected and pitch movement desired
// by user
if (dwControlMap[i] == JOY_ABSOLUTE_AXIS) {
cl.viewangles[PITCH] +=
viewdelta.angles[PITCH] +=
(fAxisValue * joy_pitchsensitivity->value) *
aspeed * cl_pitchspeed->value;
} else {
cl.viewangles[PITCH] +=
viewdelta.angles[PITCH] +=
(fAxisValue * joy_pitchsensitivity->value) *
speed * 180.0;
}
V_StopPitchDrift ();
} else {
// no pitch movement
// disable pitch return-to-center unless requested by
@ -379,9 +373,6 @@ JOY_Move (usercmd_t *cmd)
break;
}
}
// bounds check pitch
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
}
void
@ -555,66 +546,54 @@ void
JOY_Init_Cvars(void)
{
joy_device =
Cvar_Get ("joy_device", "none", CVAR_NONE | CVAR_ROM, NULL,
Cvar_Get ("joy_device", "none", CVAR_NONE | CVAR_ROM, 0,
"Joystick device");
joy_enable =
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, 0,
"Joystick enable flag");
joy_sensitivity =
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, 0,
"Joystick sensitivity");
// joystick variables
in_joystick =
Cvar_Get ("joystick", "0", CVAR_ARCHIVE, NULL, "FIXME: No Description");
Cvar_Get ("joystick", "0", CVAR_ARCHIVE, 0, "FIXME: No Description");
joy_name =
Cvar_Get ("joyname", "joystick", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joyname", "joystick", CVAR_NONE, 0, "FIXME: No Description");
joy_advanced =
Cvar_Get ("joyadvanced", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvanced", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_advaxisx =
Cvar_Get ("joyadvaxisx", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvaxisx", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_advaxisy =
Cvar_Get ("joyadvaxisy", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvaxisy", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_advaxisz =
Cvar_Get ("joyadvaxisz", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvaxisz", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_advaxisr =
Cvar_Get ("joyadvaxisr", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvaxisr", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_advaxisu =
Cvar_Get ("joyadvaxisu", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvaxisu", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_advaxisv =
Cvar_Get ("joyadvaxisv", "0", CVAR_NONE, NULL, "FIXME: No Description");
Cvar_Get ("joyadvaxisv", "0", CVAR_NONE, 0, "FIXME: No Description");
joy_forwardthreshold =
Cvar_Get ("joyforwardthreshold", "0.15", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joyforwardthreshold", "0.15", CVAR_NONE, 0, "FIXME: No Description");
joy_sidethreshold =
Cvar_Get ("joysidethreshold", "0.15", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joysidethreshold", "0.15", CVAR_NONE, 0, "FIXME: No Description");
joy_pitchthreshold =
Cvar_Get ("joypitchthreshold", "0.15", CVAR_NONE, NULL,
"FIXME: No Description");
joy_yawthreshold = Cvar_Get ("joyyawthreshold", "0.15", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joypitchthreshold", "0.15", CVAR_NONE, 0, "FIXME: No Description");
joy_yawthreshold = Cvar_Get ("joyyawthreshold", "0.15", CVAR_NONE, 0, "FIXME: No Description");
joy_forwardsensitivity =
Cvar_Get ("joyforwardsensitivity", "-1.0", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joyforwardsensitivity", "-1.0", CVAR_NONE, 0, "FIXME: No Description");
joy_sidesensitivity =
Cvar_Get ("joysidesensitivity", "-1.0", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joysidesensitivity", "-1.0", CVAR_NONE, 0, "FIXME: No Description");
joy_pitchsensitivity =
Cvar_Get ("joypitchsensitivity", "1.0", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joypitchsensitivity", "1.0", CVAR_NONE, 0, "FIXME: No Description");
joy_yawsensitivity =
Cvar_Get ("joyyawsensitivity", "-1.0", CVAR_NONE, NULL,
"FIXME: No Description");
joy_wwhack1 = Cvar_Get ("joywwhack1", "0.0", CVAR_NONE, NULL,
"FIXME: No Description");
joy_wwhack2 = Cvar_Get ("joywwhack2", "0.0", CVAR_NONE, NULL,
"FIXME: No Description");
Cvar_Get ("joyyawsensitivity", "-1.0", CVAR_NONE, 0, "FIXME: No Description");
joy_wwhack1 = Cvar_Get ("joywwhack1", "0.0", CVAR_NONE, 0, "FIXME: No Description");
joy_wwhack2 = Cvar_Get ("joywwhack2", "0.0", CVAR_NONE, 0, "FIXME: No Description");
joy_debug = Cvar_Get ("joy_debug", "0.0", CVAR_NONE, NULL,
"FIXME: No Description");
joy_debug = Cvar_Get ("joy_debug", "0.0", CVAR_NONE, 0, "FIXME: No Description");
return;
}

View file

@ -224,6 +224,7 @@ extern mplane_t *mirror_plane;
extern float r_world_matrix[16];
extern float bubble_sintable[], bubble_costable[];
extern float v_blend[4];
extern const char *gl_vendor;
extern const char *gl_renderer;

View file

@ -1,64 +0,0 @@
/*
view.h
@description@
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __view_h
#define __view_h
#include "QF/qtypes.h"
#include "QF/cvar.h"
extern byte gammatable[256]; // palette is sent through this
extern byte ramps[3][256];
extern float v_blend[4];
extern cvar_t *brightness;
extern cvar_t *contrast;
extern cvar_t *crosshair;
void V_Init (void);
void V_RenderView (void);
float V_CalcRoll (vec3_t angles, vec3_t velocity);
void V_UpdatePalette (void);
void V_CalcBlend (void);
void V_CalcIntermissionRefdef (void);
void V_CalcRefdef (void);
void V_CalcPowerupCshift (void);
qboolean V_CheckGamma (void);
extern cvar_t *scr_ofsx;
extern cvar_t *scr_ofsy;
extern cvar_t *scr_ofsz;
extern cvar_t *cl_crossx;
extern cvar_t *cl_crossy;
extern cvar_t *gl_cshiftpercent;
extern vec3_t forward, right, up;
#endif // __cvar_h

View file

@ -38,7 +38,7 @@ bin_PROGRAMS = @NQ_TARGETS@
EXTRA_PROGRAMS= nq-3dfx nq-fbdev nq-glx nq-mgl nq-sdl \
nq-sgl nq-svga nq-wgl nq-x11 nq-server
noinst_LIBRARIES= libqfjs.a libqfnet.a
noinst_LIBRARIES= libqfsys.a libqfnet.a
#if ASM_ARCH
math_ASM= cl_math.S
@ -62,18 +62,6 @@ else
qfsys_SRC= sys_unix.c
endif
#
# ... Joystick
#
if JOYTYPE_LINUX
libqfjs_a_SOURCES= joy_linux.c
endif
if JOYTYPE_NULL
libqfjs_a_SOURCES= joy_null.c
endif
libqfjs_a_CFLAGS= $(JOY_CFLAGS)
EXTRA_libqfjs_a_SOURCES= joy_linux.c joy_null.c
#
# ... Networking
#
@ -87,8 +75,9 @@ client_LIBS= $(top_builddir)/libs/gamecode/libQFgamecode.la \
$(top_builddir)/libs/util/libQFutil.la \
$(top_builddir)/libs/audio/cd/libQFcd.la \
$(top_builddir)/libs/audio/targets/libQFsound.la \
-L. -lqfjs -lqfnet $(SOUND_LIBS) $(NET_LIBS)
client_LIB_DEPS= libqfjs.a libqfnet.a
$(top_builddir)/libs/video/targets/libQFjs.la \
-L. -lqfsys -lqfnet $(SOUND_LIBS) $(NET_LIBS)
client_LIB_DEPS= libqfsys.a libqfnet.a
client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \
cl_tent.c console.c keys.c sbar.c r_part.c r_view.c \

View file

@ -34,9 +34,11 @@
#include "QF/msg.h"
#include "host.h"
#include "QF/console.h"
#include "client.h"
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/compat.h"
#include "QF/input.h"
/*
===============================================================================
@ -512,6 +514,25 @@ CL_BaseMove (usercmd_t *cmd)
#ifdef QUAKE2
cmd->lightlevel = cl.light_level;
#endif
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[0] = viewdelta.angles[1] = viewdelta.angles[2] = 0;
viewdelta.position[0] = viewdelta.position[1] = viewdelta.position[2] = 0;
IN_Move ();
cmd->forwardmove += viewdelta.position[2] * m_forward->value;
cmd->sidemove += viewdelta.position[0] * m_side->value;
cmd->upmove += viewdelta.position[1];
cl.viewangles[PITCH] += viewdelta.angles[PITCH] * m_pitch->value;
cl.viewangles[YAW] += viewdelta.angles[YAW] * m_yaw->value;
cl.viewangles[ROLL] += viewdelta.angles[ROLL];
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
}
}

View file

@ -803,12 +803,8 @@ CL_SendCmd (void)
return;
if (cls.signon == SIGNONS) {
// get basic movement from keyboard
CL_BaseMove (&cmd);
// allow mice or other external controllers to add to the move
IN_Move (&cmd);
// send the unreliable message
CL_SendMove (&cmd);

View file

@ -31,11 +31,26 @@
# include "config.h"
#endif
#include "view.h"
#include "client.h"
#include "host.h"
#include "QF/console.h"
#include "QF/compat.h"
#include "glquake.h"
#include "host.h"
#include "view.h"
extern byte gammatable[256];
extern qboolean V_CheckGamma (void);
extern void V_CalcIntermissionRefdef (void);
extern void V_CalcPowerupCshift (void);
extern void V_CalcRefdef (void);
extern cvar_t *crosshair;
extern cvar_t *gl_cshiftpercent;
extern cvar_t *scr_ofsx;
extern cvar_t *scr_ofsy;
extern cvar_t *scr_ofsz;
byte ramps[3][256];
float v_blend[4]; // rgba 0.0 - 1.0

View file

@ -275,7 +275,7 @@ IN_Move
===========
*/
void
IN_MouseMove (usercmd_t *cmd)
IN_MouseMove (void)
{
int mx, my;
@ -306,20 +306,13 @@ IN_MouseMove (usercmd_t *cmd)
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (in_mlook.state & 1)
V_StopPitchDrift ();
if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
if (cl.viewangles[PITCH] > 80)
cl.viewangles[PITCH] = 80;
if (cl.viewangles[PITCH] < -70)
cl.viewangles[PITCH] = -70;
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
}
@ -329,7 +322,7 @@ IN_JoyMove
===========
*/
void
IN_JoyMove (usercmd_t *cmd)
IN_JoyMove (void)
{
float speed, aspeed;
@ -383,10 +376,10 @@ IN_Move
===========
*/
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
IN_MouseMove (cmd);
IN_JoyMove (cmd);
IN_MouseMove ();
IN_JoyMove ();
IN_ExternalMove (cmd);
}

View file

@ -139,7 +139,7 @@ IN_Commands (void)
}
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
}

View file

@ -53,7 +53,7 @@ IN_Commands (void)
}
void
IN_Move (usercmd_t *cmd)
IN_Move (null)
{
}

View file

@ -52,6 +52,7 @@
HWND mainwindow;
#endif
cvar_t *m_filter;
cvar_t *_windowed_mouse;
int old_windowed_mouse;
@ -61,6 +62,7 @@ int modestate; // FIXME: just to avoid cross-comp.
static qboolean mouse_avail;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int mouse_oldbuttonstate = 0;
extern viddef_t vid; // global video state
@ -359,8 +361,7 @@ IN_Init_Cvars (void)
_windowed_mouse =
Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, NULL,
"If set to 1, quake will grab the mouse in X");
// m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, NULL,
// "Toggle mouse input filtering");
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, NULL, "Toggle mouse input filtering");
}
void
@ -394,42 +395,35 @@ IN_Frame (void)
}
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
JOY_Move (cmd);
JOY_Move ();
if (!mouse_avail)
return;
/* from vid_sdl.c
if (m_filter->value) {
mouse_x = (mouse_x + old_mouse_x) * 0.5;
mouse_y = (mouse_y + old_mouse_y) * 0.5;
}
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
*/
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
if ((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= mouse_x;
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] =
bound (-70, cl.viewangles[PITCH] + (m_pitch->value * mouse_y), 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
mouse_x = mouse_y = 0.0;
}

View file

@ -69,6 +69,7 @@ extern int global_dx, global_dy;
// globals
//
cvar_t *m_filter;
cvar_t *_windowed_mouse;
int x_root, y_root;
int x_root_old, y_root_old;
@ -199,7 +200,7 @@ IN_Commands (void)
//
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
static int last_dx, last_dy;
static long long last_movement;
@ -250,24 +251,17 @@ IN_Move (usercmd_t *cmd)
}
// add mouse X/Y movement to cmd
if ((in_strafe.state & 1) || (lookstrafe->int_val && (in_mlook.state & 1)))
cmd->sidemove += m_side->value * dx;
viewdelta.position[0] += dx;
else
cl.viewangles[YAW] -= m_yaw->value * dx;
if (in_mlook.state & 1)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= dx;
if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * dy;
if (cl.viewangles[PITCH] > 80)
cl.viewangles[PITCH] = 80;
if (cl.viewangles[PITCH] < -70)
cl.viewangles[PITCH] = -70;
viewdelta.angles[PITCH] += dy;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * dy;
viewdelta.position[1] -= dy;
else
cmd->forwardmove -= m_forward->value * dy;
viewdelta.position[2] -= dy;
}
}

View file

@ -360,9 +360,10 @@ IN_Commands (void)
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
JOY_Move (cmd);
JOY_Move ();
if (!UseMouse)
return;
@ -378,6 +379,7 @@ IN_Move (usercmd_t *cmd)
}
old_mouse_x = mx;
old_mouse_y = my;
/* Clear for next update */
mx = my = 0;
@ -386,22 +388,18 @@ IN_Move (usercmd_t *cmd)
/* Add mouse X/Y movement to cmd */
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook)) {
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
} else {
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
viewdelta.angles[YAW] -= mouse_x;
}
if (freelook)
V_StopPitchDrift ();
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack) {
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
} else {
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
}
}

View file

@ -591,7 +591,7 @@ IN_MouseMove
===========
*/
void
IN_MouseMove (usercmd_t *cmd)
IN_MouseMove (void)
{
int mx, my;
@ -696,21 +696,17 @@ IN_MouseMove (usercmd_t *cmd)
// add mouse X/Y movement to cmd
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook))
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= mouse_x;
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] = mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
// if the mouse has moved, force it to the center, so there's room to move
@ -726,12 +722,12 @@ IN_Move
===========
*/
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
if (ActiveApp && !Minimized) {
IN_MouseMove (cmd);
IN_JoyMove (cmd);
IN_MouseMove ();
IN_JoyMove ();
}
}

View file

@ -431,9 +431,9 @@ IN_SendKeyEvents (void)
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
JOY_Move (cmd);
JOY_Move ();
if (!mouse_avail)
return;
@ -441,30 +441,25 @@ IN_Move (usercmd_t *cmd)
if (m_filter->int_val) {
mouse_x = (mouse_x + old_mouse_x) * 0.5;
mouse_y = (mouse_y + old_mouse_y) * 0.5;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
}
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook))
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= mouse_x;
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
mouse_x = mouse_y = 0.0;
}

View file

@ -1,231 +0,0 @@
/*
joy_linux.c
Joystick driver for Linux
Copyright (C) 2000 David Jeffery
Copyright (C) 2000 Jeff Teunissen <deek@dusknet.dhs.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <linux/joystick.h>
#include <fcntl.h>
#include <unistd.h>
#include "QF/compat.h"
#include "QF/console.h"
#include "client.h"
#include "QF/cvar.h"
#include "QF/keys.h"
#include "protocol.h"
#include "view.h"
#define JOY_MAX_AXES 6
#define JOY_MAX_BUTTONS 16
cvar_t *joy_device; // Joystick device name
cvar_t *joy_enable; // Joystick enabling flag
cvar_t *joy_sensitivity; // Joystick sensitivity
qboolean joy_found = false;
qboolean joy_active = false;
// Variables and structures for this driver
int joy_handle;
typedef struct {
char *name;
char *string;
} ocvar_t;
struct joy_axis {
cvar_t *axis;
ocvar_t var;
int current;
};
struct joy_button {
int old;
int current;
};
struct joy_axis joy_axes[JOY_MAX_AXES] = {
{NULL, {"joyaxis1", "1"}, 0},
{NULL, {"joyaxis2", "2"}, 0},
{NULL, {"joyaxis3", "3"}, 0},
{NULL, {"joyaxis4", "0"}, 0},
{NULL, {"joyaxis5", "0"}, 0},
{NULL, {"joyaxis6", "0"}, 0}
};
struct joy_button joy_buttons[JOY_MAX_BUTTONS];
void
JOY_Command (void)
{
struct js_event event;
if (!joy_active || !joy_enable->int_val)
return;
while (read (joy_handle, &event, sizeof (struct js_event)) > -1) {
if (event.type & JS_EVENT_BUTTON) {
if (event.number >= JOY_MAX_BUTTONS)
continue;
joy_buttons[event.number].current = event.value;
if (joy_buttons[event.number].current >
joy_buttons[event.number].old) {
Key_Event (K_AUX1 + event.number, 0, true);
} else {
if (joy_buttons[event.number].current <
joy_buttons[event.number].old) {
Key_Event (K_AUX1 + event.number, 0, false);
}
}
joy_buttons[event.number].old = joy_buttons[event.number].current;
} else {
if (event.type & JS_EVENT_AXIS) {
if (event.number >= JOY_MAX_AXES)
continue;
joy_axes[event.number].current = event.value;
}
}
}
}
void
JOY_Move (usercmd_t *cmd)
{
int i;
if (!joy_active || !joy_enable->int_val)
return;
Cvar_SetValue (joy_sensitivity, bound (1, joy_sensitivity->value, 25));
for (i = 0; i < JOY_MAX_AXES; i++) {
switch (joy_axes[i].axis->int_val) {
case 1:
cl.viewangles[YAW] -=
m_yaw->value * (float) (joy_axes[i].current /
(201 - (joy_sensitivity->value * 4)));
break;
case 2:
cmd->forwardmove -=
m_forward->value * (float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
break;
case 3:
cmd->sidemove +=
m_side->value * (float) (joy_axes[i].current /
(201 - (joy_sensitivity->value * 4)));
break;
case 4:
if (joy_axes[i].current) {
V_StopPitchDrift ();
cl.viewangles[PITCH] -=
m_pitch->value * (float) (joy_axes[i].current /
(201 -
(joy_sensitivity->value * 4)));
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
}
break;
}
}
}
void
JOY_Init (void)
{
// Open joystick device
joy_handle = open (joy_device->string, O_RDONLY | O_NONBLOCK);
if (joy_handle < 0) {
Con_Printf ("JOY: Joystick not found.\n");
} else {
int i;
joy_found = true;
if (!joy_enable->int_val) {
Con_Printf ("JOY: Joystick found, but not enabled.\n");
i = close (joy_handle);
if (i) {
Con_Printf ("JOY: Failed to close joystick device!\n");
}
} else {
// Initialize joystick if found and enabled
for (i = 0; i < JOY_MAX_BUTTONS; i++) {
joy_buttons[i].old = 0;
joy_buttons[i].current = 0;
}
joy_active = true;
Con_Printf ("JOY: Joystick found and activated.\n");
}
}
}
void
JOY_Init_Cvars (void)
{
int i;
joy_device =
Cvar_Get ("joy_device", "/dev/js0", CVAR_NONE | CVAR_ROM, NULL,
"Joystick device");
joy_enable =
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
"Joystick enable flag");
joy_sensitivity =
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
"Joystick sensitivity");
for (i = 0; i < JOY_MAX_AXES; i++) {
joy_axes[i].axis = Cvar_Get (joy_axes[i].var.name,
joy_axes[i].var.string,
CVAR_ARCHIVE, NULL, "Set joystick axes");
}
}
void
JOY_Shutdown (void)
{
int i;
if (!joy_active)
return;
i = close (joy_handle);
if (i) {
Con_Printf ("JOY: Failed to close joystick device!\n");
} else {
Con_Printf ("JOY_Shutdown\n");
}
joy_active = false;
joy_found = false;
}

View file

@ -1,82 +0,0 @@
/*
joy_null.c
Joystick device driver template
Copyright (C) 2000 Jeff Teunissen <deek@dusknet.dhs.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/console.h"
#include "QF/cvar.h"
#include "protocol.h"
#include "QF/qtypes.h"
#include "client.h"
// Joystick variables and structures
cvar_t *joy_device; // Joystick device name
cvar_t *joy_enable; // Joystick enabling flag
cvar_t *joy_sensitivity; // Joystick sensitivity
qboolean joy_found = false;
qboolean joy_active = false;
void
JOY_Command (void)
{
}
void
JOY_Move (usercmd_t *cmd)
{
}
void
JOY_Init (void)
{
Con_DPrintf ("This system does not have joystick support.\n");
}
void
JOY_Init_Cvars (void)
{
joy_device =
Cvar_Get ("joy_device", "none", CVAR_NONE | CVAR_ROM, NULL,
"Joystick device");
joy_enable =
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
"Joystick enable flag");
joy_sensitivity =
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE, NULL,
"Joystick sensitivity");
}
void
JOY_Shutdown (void)
{
joy_active = false;
joy_found = false;
}

View file

@ -31,13 +31,26 @@
# include "config.h"
#endif
#include "client.h"
#include "QF/compat.h"
#include "QF/console.h"
#include "draw.h"
#include "host.h"
#include "view.h"
#include "vid.h"
#include "QF/console.h"
#include "host.h"
#include "client.h"
#include "draw.h"
extern byte gammatable[256];
extern qboolean V_CheckGamma (void);
extern void V_CalcIntermissionRefdef (void);
extern void V_CalcPowerupCshift (void);
extern void V_CalcRefdef (void);
extern cvar_t *crosshair;
extern cvar_t *scr_ofsx;
extern cvar_t *scr_ofsy;
extern cvar_t *scr_ofsz;
/*
V_UpdatePalette

View file

@ -1,55 +0,0 @@
/*
in_win.h
Win32 input prototypes
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef _IN_WIN_H
#define _IN_WIN_H
#include "protocol.h"
extern qboolean mouseactive;
extern float mouse_x, mouse_y;
extern unsigned int uiWheelMessage;
extern void IN_UpdateClipCursor (void);
extern void IN_ShowMouse (void);
extern void IN_HideMouse (void);
extern void IN_ActivateMouse (void);
extern void IN_SetQuakeMouseState (void);
extern void IN_DeactivateMouse (void);
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_Move (usercmd_t *cmd);
extern void IN_Accumulate (void);
extern void IN_ClearStates (void);
extern void IN_Commands (void);
#endif // _IN_WIN_H

View file

@ -1,59 +0,0 @@
/*
view.h
(description)
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
// view.h
#ifndef __view_h_
#define __view_h_
#include "QF/mathlib.h"
#include "QF/cvar.h"
extern cvar_t *brightness;
extern cvar_t *contrast;
#define INFO_CSHIFT_BONUS (1 << 0)
#define INFO_CSHIFT_CONTENTS (1 << 1)
#define INFO_CSHIFT_DAMAGE (1 << 2)
#define INFO_CSHIFT_POWERUP (1 << 3)
void V_Init (void);
void V_Init_Cvars (void);
void V_RenderView (void);
float V_CalcRoll (vec3_t angles, vec3_t velocity);
void V_UpdatePalette (void);
void V_StartPitchDrift (void);
void V_StopPitchDrift (void);
void V_RenderView (void);
void V_UpdatePalette (void);
void V_Register (void);
void V_ParseDamage (void);
void V_SetContentsColor (int contents);
void V_CalcBlend (void);
#endif // __view_h_

View file

@ -40,7 +40,7 @@ EXTRA_PROGRAMS= qw-client-3dfx qw-client-fbdev \
qw-client-sgl qw-client-svga qw-client-wgl \
qw-client-x11 qw-server
noinst_LIBRARIES= libqfjs.a libqfnet.a
noinst_LIBRARIES= libqfnet.a
#libqfsys_cl.a libqfsys_sv.a
if PACKETLOG
@ -102,28 +102,14 @@ else
syscl_SRC= cl_sys_unix.c
endif
#
# ... Joystick
#
if JOYTYPE_LINUX
libqfjs_a_SOURCES= joy_linux.c
endif
if JOYTYPE_WIN32
libqfjs_a_SOURCES= joy_win.c
endif
if JOYTYPE_NULL
libqfjs_a_SOURCES= joy_null.c
endif
libqfjs_a_CFLAGS= $(JOY_CFLAGS)
EXTRA_libqfjs_a_SOURCES= joy_linux.c joy_win.c joy_null.c
CLIENT_LIBS= $(top_builddir)/libs/util/libQFutil.la \
$(top_builddir)/libs/gamecode/libQFgamecode.la \
$(top_builddir)/libs/audio/cd/libQFcd.la \
$(top_builddir)/libs/audio/targets/libQFsound.la \
-L. -lqfnet -lqfjs \
$(SOUND_LIBS) $(NET_LIBS) $(JOY_LIBS)
CLIENT_LIB_DEPS= libqfnet.a libqfjs.a
$(top_builddir)/libs/video/targets/libQFjs.la \
-L. -lqfnet \
$(SOUND_LIBS) $(NET_LIBS)
CLIENT_LIB_DEPS= libqfnet.a
if ASM_ARCH
client_ASM= cl_math.S

View file

@ -43,6 +43,7 @@
#include "cl_parse.h"
#include "client.h"
#include "QF/cmd.h"
#include "QF/compat.h"
#include "QF/console.h"
#include "host.h"
#include "QF/input.h"
@ -516,6 +517,25 @@ CL_BaseMove (usercmd_t *cmd)
cmd->sidemove *= cl_movespeedkey->value;
cmd->upmove *= cl_movespeedkey->value;
}
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[0] = viewdelta.angles[1] = viewdelta.angles[2] = 0;
viewdelta.position[0] = viewdelta.position[1] = viewdelta.position[2] = 0;
IN_Move ();
cmd->forwardmove += viewdelta.position[2] * m_forward->value;
cmd->sidemove += viewdelta.position[0] * m_side->value;
cmd->upmove += viewdelta.position[1];
cl.viewangles[PITCH] += viewdelta.angles[PITCH] * m_pitch->value;
cl.viewangles[YAW] += viewdelta.angles[YAW] * m_yaw->value;
cl.viewangles[ROLL] += viewdelta.angles[ROLL];
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
}
}
int
@ -616,7 +636,7 @@ CL_SendCmd (void)
CL_BaseMove (cmd);
// allow mice or other external controllers to add to the move
IN_Move (cmd);
IN_Move (); // FIXME: was cmd, should it even exist at all?
// if we are spectator, try autocam
if (cl.spectator)

View file

@ -139,7 +139,7 @@ IN_Commands (void)
}
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
}

View file

@ -54,6 +54,7 @@
HWND mainwindow;
#endif
cvar_t *m_filter;
cvar_t *_windowed_mouse;
int old_windowed_mouse;
@ -63,6 +64,7 @@ int modestate; // FIXME: just to avoid cross-comp.
static qboolean mouse_avail;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int mouse_oldbuttonstate = 0;
extern viddef_t vid; // global video state
@ -362,9 +364,8 @@ IN_Init_Cvars (void)
{
JOY_Init_Cvars ();
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, NULL,
"If set to 1, quake will grab the mouse in X");
// m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, NULL, "Toggle mouse input filtering");
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, NULL, "If set to 1, quake will grab the mouse in X");
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, NULL, "Toggle mouse input filtering");
}
void
@ -398,42 +399,36 @@ IN_Frame (void)
}
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
JOY_Move (cmd);
JOY_Move ();
if (!mouse_avail)
return;
/* from vid_sdl.c
if (m_filter->value) {
mouse_x = (mouse_x + old_mouse_x) * 0.5;
mouse_y = (mouse_y + old_mouse_y) * 0.5;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
}
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
*/
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
if ((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= mouse_x;
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] =
bound (-70, cl.viewangles[PITCH] + (m_pitch->value * mouse_y), 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
mouse_x = mouse_y = 0.0;
}

View file

@ -358,9 +358,10 @@ IN_Commands (void)
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
JOY_Move (cmd);
JOY_Move ();
if (!UseMouse)
return;
@ -384,22 +385,18 @@ IN_Move (usercmd_t *cmd)
/* Add mouse X/Y movement to cmd */
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook)) {
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
} else {
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
viewdelta.angles[YAW] -= mouse_x;
}
if (freelook)
V_StopPitchDrift ();
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack) {
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
} else {
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
}
}

View file

@ -124,7 +124,7 @@ 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 (usercmd_t *cmd);
extern void JOY_Move (void);
/*
Force_CenterView_f
@ -482,7 +482,7 @@ IN_MouseEvent (int mstate)
IN_MouseMove
*/
void
IN_MouseMove (usercmd_t *cmd)
IN_MouseMove (void)
{
int mx, my;
@ -587,21 +587,17 @@ IN_MouseMove (usercmd_t *cmd)
// add mouse X/Y movement to cmd
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook))
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= mouse_x;
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
// if the mouse has moved, force it to the center, so there's room to move
@ -619,8 +615,8 @@ IN_Move (usercmd_t *cmd)
{
if (ActiveApp && !Minimized) {
IN_MouseMove (cmd);
JOY_Move (cmd);
IN_MouseMove ();
JOY_Move ();
}
}

View file

@ -432,9 +432,9 @@ IN_SendKeyEvents (void)
void
IN_Move (usercmd_t *cmd)
IN_Move (void)
{
JOY_Move (cmd);
JOY_Move ();
if (!mouse_avail)
return;
@ -451,21 +451,17 @@ IN_Move (usercmd_t *cmd)
mouse_y *= sensitivity->value;
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook))
cmd->sidemove += m_side->value * mouse_x;
viewdelta.position[0] += mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
viewdelta.angles[YAW] -= mouse_x;
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
viewdelta.angles[PITCH] += mouse_y;
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
viewdelta.position[1] -= mouse_y;
else
cmd->forwardmove -= m_forward->value * mouse_y;
viewdelta.position[2] -= mouse_y;
}
mouse_x = mouse_y = 0.0;
}