2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
in_dos.c
|
|
|
|
|
|
|
|
@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$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dosisms.h"
|
|
|
|
|
|
|
|
#define AUX_FLAG_FREELOOK 0x00000001
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
typedef struct {
|
|
|
|
long interruptVector;
|
|
|
|
char deviceName[16];
|
|
|
|
long numAxes;
|
|
|
|
long numButtons;
|
|
|
|
long flags;
|
|
|
|
|
|
|
|
vec3_t viewangles;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// intended velocities
|
2001-02-26 06:48:02 +00:00
|
|
|
float forwardmove;
|
|
|
|
float sidemove;
|
|
|
|
float upmove;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
long buttons;
|
2001-02-19 21:15:25 +00:00
|
|
|
} externControl_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
#define AUX_FLAG_FORCEFREELOOK 0x00000001 // r/o
|
|
|
|
#define AUX_FLAG_EXTENDED 0x00000002 // r/o
|
|
|
|
#define AUX_FLAG_RUN 0x00000004 // w/o
|
|
|
|
#define AUX_FLAG_STRAFE 0x00000008 // w/o
|
|
|
|
#define AUX_FLAG_FREELOOK 0x00000010 // w/o
|
|
|
|
|
|
|
|
#define AUX_MAP_UNDEFINED 0
|
|
|
|
#define AUX_MAP_PITCH 1
|
|
|
|
#define AUX_MAP_YAW 2
|
|
|
|
#define AUX_MAP_ROLL 3
|
|
|
|
#define AUX_MAP_FORWARD 4
|
|
|
|
#define AUX_MAP_SIDE 5
|
|
|
|
#define AUX_MAP_UP 6
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
long interruptVector;
|
|
|
|
// r/o
|
|
|
|
char deviceName[16];
|
|
|
|
// r/o
|
|
|
|
long numAxes;
|
|
|
|
// r/o 1-6
|
|
|
|
long numButtons; // r/o 0-32
|
|
|
|
long flags; // see above
|
|
|
|
byte axisMapping[6]; // w/o default = p,y,r,f,s,u
|
|
|
|
float axisValue[6]; // r/w
|
|
|
|
float sensitivity[6]; // w/o default = 1.0
|
|
|
|
long buttons; // r/o
|
|
|
|
float last_frame_time; // w/o
|
|
|
|
} externControl_t;
|
|
|
|
*/
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *m_filter;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean mouse_avail;
|
|
|
|
int mouse_buttons;
|
|
|
|
int mouse_oldbuttonstate;
|
|
|
|
int mouse_buttonstate;
|
|
|
|
float mouse_x, mouse_y;
|
|
|
|
float old_mouse_x, old_mouse_y;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *in_joystick;
|
|
|
|
cvar_t *joy_numbuttons;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean joy_avail;
|
|
|
|
int joy_oldbuttonstate;
|
|
|
|
int joy_buttonstate;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int joyxl, joyxh, joyyl, joyyh;
|
|
|
|
int joystickx, joysticky;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean need_center;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean extern_avail;
|
|
|
|
int extern_buttons;
|
|
|
|
int extern_oldbuttonstate;
|
|
|
|
int extern_buttonstate;
|
|
|
|
cvar_t *aux_look;
|
|
|
|
externControl_t *extern_control;
|
|
|
|
void IN_StartupExternal (void);
|
|
|
|
void IN_ExternalMove (usercmd_t *cmd);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void IN_StartupJoystick (void);
|
|
|
|
qboolean IN_ReadJoystick (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
Toggle_AuxLook_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (aux_look->int_val)
|
2001-02-26 06:48:02 +00:00
|
|
|
Cvar_Set ("auxlook", "0");
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
Cvar_Set ("auxlook", "1");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
Force_CenterView_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
cl.viewangles[PITCH] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_StartupMouse
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_StartupMouse (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
if (COM_CheckParm ("-nomouse"))
|
|
|
|
return;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// check for mouse
|
|
|
|
regs.x.ax = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
dos_int86 (0x33);
|
2001-02-19 21:15:25 +00:00
|
|
|
mouse_avail = regs.x.ax;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!mouse_avail) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("No mouse found\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
mouse_buttons = regs.x.bx;
|
|
|
|
if (mouse_buttons > 3)
|
|
|
|
mouse_buttons = 3;
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_Printf ("%d-button mouse available\n", mouse_buttons);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_Init
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_Init (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None");
|
|
|
|
in_joystick = Cvar_Get ("joystick", "0", CVAR_ARCHIVE, "None");
|
|
|
|
joy_numbuttons = Cvar_Get ("joybuttons", "4", CVAR_ARCHIVE, "None");
|
|
|
|
aux_look = Cvar_Get ("auxlook", "1", CVAR_ARCHIVE, "None");
|
2001-02-21 19:35:06 +00:00
|
|
|
Cmd_AddCommand ("toggle_auxlook", Toggle_AuxLook_f, "No Description");
|
|
|
|
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "No Description");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
IN_StartupMouse ();
|
|
|
|
IN_StartupJoystick ();
|
|
|
|
|
|
|
|
i = COM_CheckParm ("-control");
|
2001-02-26 06:48:02 +00:00
|
|
|
if (i) {
|
|
|
|
extern_control = real2ptr (Q_atoi (com_argv[i + 1]));
|
2001-02-19 21:15:25 +00:00
|
|
|
IN_StartupExternal ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_Shutdown
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_Shutdown (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_Commands
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_Commands (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (mouse_avail) {
|
|
|
|
regs.x.ax = 3; // read buttons
|
|
|
|
dos_int86 (0x33);
|
2001-02-19 21:15:25 +00:00
|
|
|
mouse_buttonstate = regs.x.bx;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
// perform button actions
|
|
|
|
for (i = 0; i < mouse_buttons; i++) {
|
|
|
|
if ((mouse_buttonstate & (1 << i)) &&
|
|
|
|
!(mouse_oldbuttonstate & (1 << i))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Key_Event (K_MOUSE1 + i, true);
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!(mouse_buttonstate & (1 << i)) &&
|
|
|
|
(mouse_oldbuttonstate & (1 << i))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Key_Event (K_MOUSE1 + i, false);
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
mouse_oldbuttonstate = mouse_buttonstate;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (joy_avail) {
|
|
|
|
joy_buttonstate = ((dos_inportb (0x201) >> 4) & 15) ^ 15;
|
|
|
|
// perform button actions
|
|
|
|
for (i = 0; i < joy_numbuttons->int_val; i++) {
|
|
|
|
if ((joy_buttonstate & (1 << i)) &&
|
|
|
|
!(joy_oldbuttonstate & (1 << i))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Key_Event (K_JOY1 + i, true);
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!(joy_buttonstate & (1 << i)) &&
|
|
|
|
(joy_oldbuttonstate & (1 << i))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Key_Event (K_JOY1 + i, false);
|
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
joy_oldbuttonstate = joy_buttonstate;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (extern_avail) {
|
2001-02-19 21:15:25 +00:00
|
|
|
extern_buttonstate = extern_control->buttons;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
// perform button actions
|
|
|
|
for (i = 0; i < extern_buttons; i++) {
|
|
|
|
if ((extern_buttonstate & (1 << i)) &&
|
|
|
|
!(extern_oldbuttonstate & (1 << i))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Key_Event (K_AUX1 + i, true);
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!(extern_buttonstate & (1 << i)) &&
|
|
|
|
(extern_oldbuttonstate & (1 << i))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Key_Event (K_AUX1 + i, false);
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
extern_oldbuttonstate = extern_buttonstate;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_Move
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_MouseMove (usercmd_t *cmd)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int mx, my;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!mouse_avail)
|
|
|
|
return;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
regs.x.ax = 11; // read move
|
|
|
|
dos_int86 (0x33);
|
|
|
|
mx = (short) regs.x.cx;
|
|
|
|
my = (short) regs.x.dx;
|
|
|
|
|
|
|
|
if (m_filter->int_val) {
|
2001-02-19 21:15:25 +00:00
|
|
|
mouse_x = (mx + old_mouse_x) * 0.5;
|
|
|
|
mouse_y = (my + old_mouse_y) * 0.5;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
mouse_x = mx;
|
|
|
|
mouse_y = my;
|
|
|
|
}
|
|
|
|
old_mouse_x = mx;
|
|
|
|
old_mouse_y = my;
|
|
|
|
|
|
|
|
mouse_x *= sensitivity->value;
|
|
|
|
mouse_y *= sensitivity->value;
|
|
|
|
|
|
|
|
// add mouse X/Y movement to cmd
|
2001-02-26 06:48:02 +00:00
|
|
|
if ((in_strafe.state & 1) || (lookstrafe->int_val && (in_mlook.state & 1)))
|
2001-02-19 21:15:25 +00:00
|
|
|
cmd->sidemove += m_side->value * mouse_x;
|
|
|
|
else
|
|
|
|
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (in_mlook.state & 1)
|
|
|
|
V_StopPitchDrift ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
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;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if ((in_strafe.state & 1) && noclip_anglehack)
|
|
|
|
cmd->upmove -= m_forward->value * mouse_y;
|
|
|
|
else
|
|
|
|
cmd->forwardmove -= m_forward->value * mouse_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_JoyMove
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_JoyMove (usercmd_t *cmd)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float speed, aspeed;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!joy_avail || !in_joystick->int_val)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IN_ReadJoystick ();
|
|
|
|
if (joysticky > joyyh * 2 || joystickx > joyxh * 2)
|
|
|
|
return; // assume something jumped in and
|
|
|
|
// messed up the joystick
|
|
|
|
// reading time (win 95)
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (in_speed.state & 1)
|
|
|
|
speed = cl_movespeedkey->value;
|
|
|
|
else
|
|
|
|
speed = 1;
|
2001-02-26 06:48:02 +00:00
|
|
|
aspeed = speed * host_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (in_strafe.state & 1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (joystickx < joyxl)
|
2001-02-26 06:48:02 +00:00
|
|
|
cmd->sidemove -= speed * cl_sidespeed->value;
|
|
|
|
else if (joystickx > joyxh)
|
|
|
|
cmd->sidemove += speed * cl_sidespeed->value;
|
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (joystickx < joyxl)
|
2001-02-26 06:48:02 +00:00
|
|
|
cl.viewangles[YAW] += aspeed * cl_yawspeed->value;
|
|
|
|
else if (joystickx > joyxh)
|
|
|
|
cl.viewangles[YAW] -= aspeed * cl_yawspeed->value;
|
|
|
|
cl.viewangles[YAW] = anglemod (cl.viewangles[YAW]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (in_mlook.state & 1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (m_pitch->value < 0)
|
|
|
|
speed *= -1;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (joysticky < joyyl)
|
|
|
|
cl.viewangles[PITCH] += aspeed * cl_pitchspeed->value;
|
|
|
|
else if (joysticky > joyyh)
|
|
|
|
cl.viewangles[PITCH] -= aspeed * cl_pitchspeed->value;
|
|
|
|
} else {
|
|
|
|
if (joysticky < joyyl)
|
|
|
|
cmd->forwardmove += speed * cl_forwardspeed->value;
|
|
|
|
else if (joysticky > joyyh)
|
|
|
|
cmd->forwardmove -= speed * cl_backspeed->value;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_Move
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_Move (usercmd_t *cmd)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
IN_MouseMove (cmd);
|
|
|
|
IN_JoyMove (cmd);
|
|
|
|
IN_ExternalMove (cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============================================================================
|
|
|
|
|
|
|
|
JOYSTICK
|
|
|
|
|
|
|
|
============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean
|
|
|
|
IN_ReadJoystick (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int b;
|
|
|
|
int count;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
joystickx = 0;
|
|
|
|
joysticky = 0;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
b = dos_inportb (0x201);
|
|
|
|
dos_outportb (0x201, b);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// clear counters
|
2001-02-26 06:48:02 +00:00
|
|
|
while (++count < 10000) {
|
|
|
|
b = dos_inportb (0x201);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
joystickx += b & 1;
|
|
|
|
joysticky += (b & 2) >> 1;
|
|
|
|
if (!(b & 3))
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("IN_ReadJoystick: no response\n");
|
|
|
|
joy_avail = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
WaitJoyButton
|
|
|
|
=============
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean
|
|
|
|
WaitJoyButton (void)
|
|
|
|
{
|
|
|
|
int oldbuttons, buttons;
|
|
|
|
|
|
|
|
oldbuttons = 0;
|
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
key_count = -1;
|
|
|
|
IN_SendKeyEvents ();
|
|
|
|
key_count = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (key_lastpress == K_ESCAPE) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("aborted.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
key_lastpress = 0;
|
|
|
|
SCR_UpdateScreen ();
|
2001-02-26 06:48:02 +00:00
|
|
|
buttons = ((dos_inportb (0x201) >> 4) & 1) ^ 1;
|
|
|
|
if (buttons != oldbuttons) {
|
|
|
|
oldbuttons = buttons;
|
|
|
|
continue;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
} while (!buttons);
|
|
|
|
|
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
key_count = -1;
|
|
|
|
IN_SendKeyEvents ();
|
|
|
|
key_count = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (key_lastpress == K_ESCAPE) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("aborted.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
key_lastpress = 0;
|
|
|
|
SCR_UpdateScreen ();
|
2001-02-26 06:48:02 +00:00
|
|
|
buttons = ((dos_inportb (0x201) >> 4) & 1) ^ 1;
|
|
|
|
if (buttons != oldbuttons) {
|
|
|
|
oldbuttons = buttons;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} while (buttons);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
IN_StartupJoystick
|
|
|
|
===============
|
2001-02-26 06:48:02 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
IN_StartupJoystick (void)
|
|
|
|
{
|
|
|
|
int centerx, centery;
|
|
|
|
|
|
|
|
Con_Printf ("\n");
|
|
|
|
|
|
|
|
joy_avail = false;
|
|
|
|
if (COM_CheckParm ("-nojoy"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!IN_ReadJoystick ()) {
|
|
|
|
joy_avail = false;
|
|
|
|
Con_Printf ("joystick not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("joystick found\n");
|
|
|
|
|
|
|
|
Con_Printf ("CENTER the joystick\nand press button 1 (ESC to skip):\n");
|
|
|
|
if (!WaitJoyButton ())
|
|
|
|
return;
|
|
|
|
IN_ReadJoystick ();
|
|
|
|
centerx = joystickx;
|
|
|
|
centery = joysticky;
|
|
|
|
|
|
|
|
Con_Printf
|
|
|
|
("Push the joystick to the UPPER LEFT\nand press button 1 (ESC to skip):\n");
|
|
|
|
if (!WaitJoyButton ())
|
|
|
|
return;
|
|
|
|
IN_ReadJoystick ();
|
|
|
|
joyxl = (centerx + joystickx) / 2;
|
|
|
|
joyyl = (centerx + joysticky) / 2;
|
|
|
|
|
|
|
|
Con_Printf
|
|
|
|
("Push the joystick to the LOWER RIGHT\nand press button 1 (ESC to skip):\n");
|
|
|
|
if (!WaitJoyButton ())
|
|
|
|
return;
|
|
|
|
IN_ReadJoystick ();
|
|
|
|
joyxh = (centerx + joystickx) / 2;
|
|
|
|
joyyh = (centery + joysticky) / 2;
|
|
|
|
|
|
|
|
joy_avail = true;
|
|
|
|
Con_Printf ("joystick configured.\n");
|
|
|
|
|
|
|
|
Con_Printf ("\n");
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
============================================================================
|
|
|
|
|
|
|
|
EXTERNAL
|
|
|
|
|
|
|
|
============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
IN_StartupExternal
|
|
|
|
===============
|
2001-02-26 06:48:02 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
IN_StartupExternal (void)
|
|
|
|
{
|
2001-02-19 21:15:25 +00:00
|
|
|
if (extern_control->numButtons > 32)
|
|
|
|
extern_control->numButtons = 32;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_Printf ("%s Initialized\n", extern_control->deviceName);
|
|
|
|
Con_Printf (" %u axes %u buttons\n", extern_control->numAxes,
|
|
|
|
extern_control->numButtons);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern_avail = true;
|
|
|
|
extern_buttons = extern_control->numButtons;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
IN_ExternalMove
|
|
|
|
===========
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_ExternalMove (usercmd_t *cmd)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean freelook;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!extern_avail)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
extern_control->viewangles[YAW] = cl.viewangles[YAW];
|
|
|
|
extern_control->viewangles[PITCH] = cl.viewangles[PITCH];
|
|
|
|
extern_control->viewangles[ROLL] = cl.viewangles[ROLL];
|
|
|
|
extern_control->forwardmove = cmd->forwardmove;
|
|
|
|
extern_control->sidemove = cmd->sidemove;
|
|
|
|
extern_control->upmove = cmd->upmove;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_DPrintf ("IN: y:%f p:%f r:%f f:%f s:%f u:%f\n",
|
|
|
|
extern_control->viewangles[YAW],
|
|
|
|
extern_control->viewangles[PITCH],
|
|
|
|
extern_control->viewangles[ROLL], extern_control->forwardmove,
|
|
|
|
extern_control->sidemove, extern_control->upmove);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
dos_int86 (extern_control->interruptVector);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_DPrintf ("OUT: y:%f p:%f r:%f f:%f s:%f u:%f\n",
|
|
|
|
extern_control->viewangles[YAW],
|
|
|
|
extern_control->viewangles[PITCH],
|
|
|
|
extern_control->viewangles[ROLL], extern_control->forwardmove,
|
|
|
|
extern_control->sidemove, extern_control->upmove);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cl.viewangles[YAW] = extern_control->viewangles[YAW];
|
|
|
|
cl.viewangles[PITCH] = extern_control->viewangles[PITCH];
|
|
|
|
cl.viewangles[ROLL] = extern_control->viewangles[ROLL];
|
|
|
|
cmd->forwardmove = extern_control->forwardmove;
|
|
|
|
cmd->sidemove = extern_control->sidemove;
|
|
|
|
cmd->upmove = extern_control->upmove;
|
|
|
|
|
|
|
|
if (cl.viewangles[PITCH] > 80)
|
|
|
|
cl.viewangles[PITCH] = 80;
|
|
|
|
if (cl.viewangles[PITCH] < -70)
|
|
|
|
cl.viewangles[PITCH] = -70;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
freelook = (extern_control->flags & AUX_FLAG_FREELOOK || aux_look->int_val
|
|
|
|
|| in_mlook.state & 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (freelook)
|
|
|
|
V_StopPitchDrift ();
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
IN_HandlePause (qboolean pause)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
}
|