mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 17:21:46 +00:00
Makefile.am: misc. fixes to changelog building.
input.h: Use int_val for freelook cl_input.c: Use freelook macro instead of in_mlook.state in_svgalib.c: freelook support and whitespace in_win.c: whitespace and minor optimization in mouse support in_x11.c: freelook support vid_ggi.c: joystick support and minor opt in mouse support vid_sdl.c: joystick support, freelook support, minor mouse opt, spaces->tabs
This commit is contained in:
parent
40269b2bb5
commit
8903d650d2
8 changed files with 389 additions and 360 deletions
|
@ -10,9 +10,7 @@ EXTRA_DIST = README.WIN newtree.dsw ChangeLog \
|
||||||
tools/gas2masm/gas2masm.mak tools/gas2masm/gas2masm.mdp \
|
tools/gas2masm/gas2masm.mak tools/gas2masm/gas2masm.mdp \
|
||||||
tools/zpak
|
tools/zpak
|
||||||
|
|
||||||
bin_SCRIPTS = ChangeLog
|
changelog::
|
||||||
|
|
||||||
ChangeLog:
|
|
||||||
-touch ChangeLog
|
-touch ChangeLog
|
||||||
-tools/cvs2cl/cvs2cl.pl
|
-tools/cvs2cl/cvs2cl.pl
|
||||||
-rm -f ChangeLog.bak
|
-rm -f ChangeLog.bak
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
|
||||||
#define freelook (in_mlook.state&1 || cl_freelook->value)
|
#define freelook (in_mlook.state&1 || cl_freelook->int_val)
|
||||||
|
|
||||||
void IN_Init (void);
|
void IN_Init (void);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
#include "in_win.h"
|
#include "input.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
@ -145,7 +145,7 @@ void IN_KLookUp (void) {KeyUp(&in_klook);}
|
||||||
void IN_MLookDown (void) {KeyDown(&in_mlook);}
|
void IN_MLookDown (void) {KeyDown(&in_mlook);}
|
||||||
void IN_MLookUp (void) {
|
void IN_MLookUp (void) {
|
||||||
KeyUp(&in_mlook);
|
KeyUp(&in_mlook);
|
||||||
if ( !(in_mlook.state&1 || cl_freelook->value) && lookspring->value)
|
if ( !freelook && lookspring->value)
|
||||||
V_StartPitchDrift();
|
V_StartPitchDrift();
|
||||||
}
|
}
|
||||||
void IN_UpDown(void) {KeyDown(&in_up);}
|
void IN_UpDown(void) {KeyDown(&in_up);}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
|
#include "input.h"
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -102,7 +103,8 @@ void Force_CenterView_f(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int IN_Init(void)
|
void
|
||||||
|
IN_Init (void)
|
||||||
{
|
{
|
||||||
if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
|
if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
|
||||||
if (COM_CheckParm("-nomouse")) UseMouse = 0;
|
if (COM_CheckParm("-nomouse")) UseMouse = 0;
|
||||||
|
@ -115,10 +117,11 @@ int IN_Init(void)
|
||||||
JOY_Init();
|
JOY_Init();
|
||||||
|
|
||||||
in_svgalib_inited = 1;
|
in_svgalib_inited = 1;
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IN_init_kb()
|
static void
|
||||||
|
IN_init_kb (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -232,13 +235,14 @@ static void IN_init_kb()
|
||||||
scantokey[111] = K_DEL;
|
scantokey[111] = K_DEL;
|
||||||
scantokey[119] = K_PAUSE;
|
scantokey[119] = K_PAUSE;
|
||||||
|
|
||||||
if (keyboard_init()) {
|
if (keyboard_init ()) {
|
||||||
Sys_Error("keyboard_init() failed");
|
Sys_Error ("keyboard_init() failed");
|
||||||
}
|
}
|
||||||
keyboard_seteventhandler(keyhandler);
|
keyboard_seteventhandler(keyhandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IN_init_mouse()
|
static void
|
||||||
|
IN_init_mouse()
|
||||||
{
|
{
|
||||||
int mtype;
|
int mtype;
|
||||||
char *mousedev;
|
char *mousedev;
|
||||||
|
@ -339,7 +343,7 @@ void IN_Move(usercmd_t *cmd)
|
||||||
while (mouse_update())
|
while (mouse_update())
|
||||||
;
|
;
|
||||||
|
|
||||||
if (m_filter->value) {
|
if (m_filter->int_val) {
|
||||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||||
mouse_y = (my + old_mouse_y) * 0.5;
|
mouse_y = (my + old_mouse_y) * 0.5;
|
||||||
} else {
|
} else {
|
||||||
|
@ -355,23 +359,18 @@ void IN_Move(usercmd_t *cmd)
|
||||||
mouse_y *= sensitivity->value;
|
mouse_y *= sensitivity->value;
|
||||||
|
|
||||||
/* Add mouse X/Y movement to cmd */
|
/* Add mouse X/Y movement to cmd */
|
||||||
if ( (in_strafe.state & 1) ||
|
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook)) {
|
||||||
(lookstrafe->value && (in_mlook.state & 1) )) {
|
|
||||||
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)) V_StopPitchDrift();
|
if (freelook)
|
||||||
|
V_StopPitchDrift();
|
||||||
|
|
||||||
if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
if (freelook && !(in_strafe.state & 1)) {
|
||||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||||
if (cl.viewangles[PITCH] > 80) {
|
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||||
cl.viewangles[PITCH] = 80;
|
|
||||||
}
|
|
||||||
if (cl.viewangles[PITCH] < -70) {
|
|
||||||
cl.viewangles[PITCH] = -70;
|
|
||||||
}
|
|
||||||
} 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;
|
||||||
|
|
|
@ -717,7 +717,7 @@ void IN_MouseMove (usercmd_t *cmd)
|
||||||
mouse_y *= sensitivity->value;
|
mouse_y *= sensitivity->value;
|
||||||
|
|
||||||
// add mouse X/Y movement to cmd
|
// add mouse X/Y movement to cmd
|
||||||
if ( (in_strafe.state & 1) || (lookstrafe->value && freelook ))
|
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;
|
||||||
|
@ -725,16 +725,10 @@ void IN_MouseMove (usercmd_t *cmd)
|
||||||
if (freelook)
|
if (freelook)
|
||||||
V_StopPitchDrift ();
|
V_StopPitchDrift ();
|
||||||
|
|
||||||
if ( freelook && !(in_strafe.state & 1))
|
if ( freelook && !(in_strafe.state & 1)) {
|
||||||
{
|
|
||||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||||
if (cl.viewangles[PITCH] > 80)
|
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||||
cl.viewangles[PITCH] = 80;
|
} else {
|
||||||
if (cl.viewangles[PITCH] < -70)
|
|
||||||
cl.viewangles[PITCH] = -70;
|
|
||||||
}
|
|
||||||
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;
|
||||||
else
|
else
|
||||||
|
|
|
@ -35,11 +35,18 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
|
@ -59,12 +66,9 @@
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "context_x11.h"
|
#include "context_x11.h"
|
||||||
#include "qargs.h"
|
#include "input.h"
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
|
#include "qargs.h"
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cvar_t *_windowed_mouse;
|
cvar_t *_windowed_mouse;
|
||||||
cvar_t *m_filter;
|
cvar_t *m_filter;
|
||||||
|
@ -302,18 +306,19 @@ void
|
||||||
IN_Commands (void)
|
IN_Commands (void)
|
||||||
{
|
{
|
||||||
JOY_Command ();
|
JOY_Command ();
|
||||||
if (old__windowed_mouse != _windowed_mouse->value) {
|
|
||||||
old__windowed_mouse = _windowed_mouse->value;
|
|
||||||
|
|
||||||
if (!_windowed_mouse->value) {
|
if (old__windowed_mouse != _windowed_mouse->int_val) {
|
||||||
|
old__windowed_mouse = _windowed_mouse->int_val;
|
||||||
|
|
||||||
|
if (!_windowed_mouse->int_val) {
|
||||||
/* ungrab the pointer */
|
/* ungrab the pointer */
|
||||||
XUngrabPointer(x_disp,CurrentTime);
|
XUngrabPointer (x_disp, CurrentTime);
|
||||||
} else {
|
} else {
|
||||||
/* grab the pointer */
|
/* grab the pointer */
|
||||||
XGrabPointer(x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
||||||
GrabModeAsync, x_win, None, CurrentTime);
|
GrabModeAsync, x_win, None, CurrentTime);
|
||||||
//XGrabPointer(x_disp,x_win,True,0,GrabModeAsync,
|
// XGrabPointer (x_disp,x_win,True,0,GrabModeAsync,
|
||||||
// GrabModeAsync,x_win,None,CurrentTime);
|
// GrabModeAsync,x_win,None,CurrentTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,7 +340,7 @@ IN_Move (usercmd_t *cmd)
|
||||||
if (!mouse_avail)
|
if (!mouse_avail)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_filter->value) {
|
if (m_filter->int_val) {
|
||||||
mouse_x = (mouse_x + old_mouse_x) * 0.5;
|
mouse_x = (mouse_x + old_mouse_x) * 0.5;
|
||||||
mouse_y = (mouse_y + old_mouse_y) * 0.5;
|
mouse_y = (mouse_y + old_mouse_y) * 0.5;
|
||||||
}
|
}
|
||||||
|
@ -346,14 +351,15 @@ 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->int_val && 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] += m_pitch->value * mouse_y;
|
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||||
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||||
} else {
|
} else {
|
||||||
|
@ -390,13 +396,14 @@ void
|
||||||
IN_Shutdown (void)
|
IN_Shutdown (void)
|
||||||
{
|
{
|
||||||
JOY_Shutdown ();
|
JOY_Shutdown ();
|
||||||
Con_Printf("IN_Shutdown\n");
|
|
||||||
|
Con_Printf ("IN_Shutdown\n");
|
||||||
mouse_avail = 0;
|
mouse_avail = 0;
|
||||||
if (x_disp) {
|
if (x_disp) {
|
||||||
XAutoRepeatOn(x_disp);
|
XAutoRepeatOn (x_disp);
|
||||||
|
|
||||||
#ifdef HAVE_DGA
|
#ifdef HAVE_DGA
|
||||||
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), 0);
|
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
x11_close_display();
|
x11_close_display();
|
||||||
|
@ -404,7 +411,7 @@ IN_Shutdown (void)
|
||||||
|
|
||||||
extern int scr_width, scr_height;
|
extern int scr_width, scr_height;
|
||||||
|
|
||||||
int
|
void
|
||||||
IN_Init (void)
|
IN_Init (void)
|
||||||
{
|
{
|
||||||
// open the display
|
// open the display
|
||||||
|
@ -433,7 +440,8 @@ IN_Init (void)
|
||||||
|
|
||||||
XAutoRepeatOff(x_disp);
|
XAutoRepeatOff(x_disp);
|
||||||
|
|
||||||
if (COM_CheckParm("-nomouse")) return 1;
|
if (COM_CheckParm("-nomouse"))
|
||||||
|
return;
|
||||||
#ifdef HAVE_DGA
|
#ifdef HAVE_DGA
|
||||||
in_dgamouse = Cvar_Get ("in_dgamouse", "0", CVAR_ROM,
|
in_dgamouse = Cvar_Get ("in_dgamouse", "0", CVAR_ROM,
|
||||||
"1 if you have DGA mouse support");
|
"1 if you have DGA mouse support");
|
||||||
|
@ -473,5 +481,5 @@ IN_Init (void)
|
||||||
x11_add_event(ButtonRelease, &event_button);
|
x11_add_event(ButtonRelease, &event_button);
|
||||||
x11_add_event(MotionNotify, &event_motion);
|
x11_add_event(MotionNotify, &event_motion);
|
||||||
|
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@
|
||||||
#include "d_local.h"
|
#include "d_local.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
|
#include "joystick.h"
|
||||||
|
|
||||||
extern viddef_t vid; // global video state
|
extern viddef_t vid; // global video state
|
||||||
unsigned short d_8to16table[256];
|
unsigned short d_8to16table[256];
|
||||||
|
|
||||||
|
@ -910,6 +912,8 @@ void IN_SendKeyEvents(void)
|
||||||
void
|
void
|
||||||
IN_Init(void)
|
IN_Init(void)
|
||||||
{
|
{
|
||||||
|
JOY_Init ();
|
||||||
|
|
||||||
_windowed_mouse = Cvar_Get("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
|
_windowed_mouse = Cvar_Get("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
|
||||||
old_windowed_mouse = -1; /* Force update */
|
old_windowed_mouse = -1; /* Force update */
|
||||||
m_filter = Cvar_Get("m_filter", "0", CVAR_ARCHIVE, "None");
|
m_filter = Cvar_Get("m_filter", "0", CVAR_ARCHIVE, "None");
|
||||||
|
@ -923,6 +927,9 @@ IN_Init(void)
|
||||||
void
|
void
|
||||||
IN_Shutdown(void)
|
IN_Shutdown(void)
|
||||||
{
|
{
|
||||||
|
JOY_Shutdown ();
|
||||||
|
|
||||||
|
Con_Printf("IN_Shutdown\n");
|
||||||
mouse_avail = 0;
|
mouse_avail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,6 +937,8 @@ IN_Shutdown(void)
|
||||||
void
|
void
|
||||||
IN_Commands (void)
|
IN_Commands (void)
|
||||||
{
|
{
|
||||||
|
JOY_Command ();
|
||||||
|
|
||||||
/* Only supported by LibGII 0.7 or later. */
|
/* Only supported by LibGII 0.7 or later. */
|
||||||
#ifdef GII_CMDCODE_PREFER_RELPTR
|
#ifdef GII_CMDCODE_PREFER_RELPTR
|
||||||
if (old_windowed_mouse != _windowed_mouse->value) {
|
if (old_windowed_mouse != _windowed_mouse->value) {
|
||||||
|
@ -952,9 +961,12 @@ IN_Commands (void)
|
||||||
void
|
void
|
||||||
IN_Move(usercmd_t *cmd)
|
IN_Move(usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
if (!mouse_avail) return;
|
JOY_Move (cmd);
|
||||||
|
|
||||||
if (m_filter->value) {
|
if (!mouse_avail)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_filter->int_val) {
|
||||||
mouse_x = (mouse_x + old_mouse_x) * 0.5;
|
mouse_x = (mouse_x + old_mouse_x) * 0.5;
|
||||||
mouse_y = (mouse_y + old_mouse_y) * 0.5;
|
mouse_y = (mouse_y + old_mouse_y) * 0.5;
|
||||||
}
|
}
|
||||||
|
@ -965,19 +977,16 @@ 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 && freelook ))
|
if ( (in_strafe.state & 1) || (lookstrafe->int_val && 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 (freelook)
|
if (freelook)
|
||||||
V_StopPitchDrift ();
|
V_StopPitchDrift ();
|
||||||
|
|
||||||
if ( freelook && !(in_strafe.state & 1)) {
|
if (freelook && !(in_strafe.state & 1)) {
|
||||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||||
if (cl.viewangles[PITCH] > 80)
|
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||||
cl.viewangles[PITCH] = 80;
|
|
||||||
if (cl.viewangles[PITCH] < -70)
|
|
||||||
cl.viewangles[PITCH] = -70;
|
|
||||||
} 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;
|
||||||
|
|
101
source/vid_sdl.c
101
source/vid_sdl.c
|
@ -57,7 +57,7 @@
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "d_local.h"
|
#include "d_local.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "joystick.h"
|
||||||
|
|
||||||
cvar_t *_windowed_mouse;
|
cvar_t *_windowed_mouse;
|
||||||
|
|
||||||
|
@ -92,13 +92,13 @@ static qboolean mouse_avail;
|
||||||
static float mouse_x, mouse_y;
|
static float mouse_x, mouse_y;
|
||||||
static int mouse_oldbuttonstate = 0;
|
static int mouse_oldbuttonstate = 0;
|
||||||
|
|
||||||
void VID_SetPalette (unsigned char *palette)
|
void
|
||||||
|
VID_SetPalette (unsigned char *palette)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
SDL_Color colors[256];
|
SDL_Color colors[256];
|
||||||
|
|
||||||
for ( i=0; i<256; ++i )
|
for ( i=0; i<256; ++i ) {
|
||||||
{
|
|
||||||
colors[i].r = *palette++;
|
colors[i].r = *palette++;
|
||||||
colors[i].g = *palette++;
|
colors[i].g = *palette++;
|
||||||
colors[i].b = *palette++;
|
colors[i].b = *palette++;
|
||||||
|
@ -106,12 +106,14 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
SDL_SetColors(screen, colors, 0, 256);
|
SDL_SetColors(screen, colors, 0, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_ShiftPalette (unsigned char *palette)
|
void
|
||||||
|
VID_ShiftPalette (unsigned char *palette)
|
||||||
{
|
{
|
||||||
VID_SetPalette(palette);
|
VID_SetPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_Init (unsigned char *palette)
|
void
|
||||||
|
VID_Init (unsigned char *palette)
|
||||||
{
|
{
|
||||||
int pnum, chunk;
|
int pnum, chunk;
|
||||||
byte *cache;
|
byte *cache;
|
||||||
|
@ -122,7 +124,7 @@ void VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
|
|
||||||
// Load the SDL library
|
// Load the SDL library
|
||||||
if (SDL_Init(SDL_INIT_VIDEO)<0) //|SDL_INIT_AUDIO|SDL_INIT_CDROM) < 0)
|
if (SDL_Init (SDL_INIT_VIDEO) < 0) //|SDL_INIT_AUDIO|SDL_INIT_CDROM) < 0)
|
||||||
Sys_Error("VID: Couldn't load SDL: %s", SDL_GetError());
|
Sys_Error("VID: Couldn't load SDL: %s", SDL_GetError());
|
||||||
|
|
||||||
// Set up display mode (width and height)
|
// Set up display mode (width and height)
|
||||||
|
@ -130,8 +132,7 @@ void VID_Init (unsigned char *palette)
|
||||||
vid.height = BASEHEIGHT;
|
vid.height = BASEHEIGHT;
|
||||||
vid.maxwarpwidth = WARP_WIDTH;
|
vid.maxwarpwidth = WARP_WIDTH;
|
||||||
vid.maxwarpheight = WARP_HEIGHT;
|
vid.maxwarpheight = WARP_HEIGHT;
|
||||||
if ((pnum=COM_CheckParm("-winsize")))
|
if ((pnum=COM_CheckParm("-winsize"))) {
|
||||||
{
|
|
||||||
if (pnum >= com_argc-2)
|
if (pnum >= com_argc-2)
|
||||||
Sys_Error("VID: -winsize <width> <height>\n");
|
Sys_Error("VID: -winsize <width> <height>\n");
|
||||||
vid.width = atoi(com_argv[pnum+1]);
|
vid.width = atoi(com_argv[pnum+1]);
|
||||||
|
@ -173,8 +174,7 @@ void VID_Init (unsigned char *palette)
|
||||||
Sys_Error ("Not enough memory for video mode\n");
|
Sys_Error ("Not enough memory for video mode\n");
|
||||||
|
|
||||||
// initialize the cache memory
|
// initialize the cache memory
|
||||||
cache = (byte *) d_pzbuffer
|
cache = (byte *) d_pzbuffer + vid.width * vid.height * sizeof (*d_pzbuffer);
|
||||||
+ vid.width * vid.height * sizeof (*d_pzbuffer);
|
|
||||||
D_InitCaches (cache, cachesize);
|
D_InitCaches (cache, cachesize);
|
||||||
|
|
||||||
// initialize the mouse
|
// initialize the mouse
|
||||||
|
@ -189,12 +189,14 @@ void VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_Shutdown (void)
|
void
|
||||||
|
VID_Shutdown (void)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_Update (vrect_t *rects)
|
void
|
||||||
|
VID_Update (vrect_t *rects)
|
||||||
{
|
{
|
||||||
SDL_Rect *sdlrects;
|
SDL_Rect *sdlrects;
|
||||||
int n, i;
|
int n, i;
|
||||||
|
@ -210,16 +212,17 @@ void VID_Update (vrect_t *rects)
|
||||||
// Second, copy them to SDL rectangles and update
|
// Second, copy them to SDL rectangles and update
|
||||||
if(!(sdlrects=(SDL_Rect *)calloc(1,n*sizeof(SDL_Rect))))
|
if(!(sdlrects=(SDL_Rect *)calloc(1,n*sizeof(SDL_Rect))))
|
||||||
Sys_Error("Out of memory!");
|
Sys_Error("Out of memory!");
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (rect = rects; rect; rect = rect->pnext)
|
|
||||||
{
|
for (rect = rects; rect; rect = rect->pnext) {
|
||||||
sdlrects[i].x = rect->x;
|
sdlrects[i].x = rect->x;
|
||||||
sdlrects[i].y = rect->y;
|
sdlrects[i].y = rect->y;
|
||||||
sdlrects[i].w = rect->width;
|
sdlrects[i].w = rect->width;
|
||||||
sdlrects[i].h = rect->height;
|
sdlrects[i].h = rect->height;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
SDL_UpdateRects(screen, n, sdlrects);
|
SDL_UpdateRects (screen, n, sdlrects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -227,17 +230,20 @@ void VID_Update (vrect_t *rects)
|
||||||
D_BeginDirectRect
|
D_BeginDirectRect
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
void
|
||||||
|
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||||
{
|
{
|
||||||
Uint8 *offset;
|
Uint8 *offset;
|
||||||
|
|
||||||
|
if (!screen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( x < 0 )
|
||||||
|
x = screen->w+x-1;
|
||||||
|
|
||||||
if (!screen) return;
|
|
||||||
if ( x < 0 ) x = screen->w+x-1;
|
|
||||||
offset = (Uint8 *)screen->pixels + y*screen->pitch + x;
|
offset = (Uint8 *)screen->pixels + y*screen->pitch + x;
|
||||||
while ( height-- )
|
while (height--) {
|
||||||
{
|
memcpy (offset, pbitmap, width);
|
||||||
memcpy(offset, pbitmap, width);
|
|
||||||
offset += screen->pitch;
|
offset += screen->pitch;
|
||||||
pbitmap += width;
|
pbitmap += width;
|
||||||
}
|
}
|
||||||
|
@ -249,10 +255,15 @@ void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||||
D_EndDirectRect
|
D_EndDirectRect
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void D_EndDirectRect (int x, int y, int width, int height)
|
void
|
||||||
|
D_EndDirectRect (int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
if (!screen) return;
|
if (!screen)
|
||||||
if (x < 0) x = screen->w+x-1;
|
return;
|
||||||
|
|
||||||
|
if (x < 0)
|
||||||
|
x = screen->w+x-1;
|
||||||
|
|
||||||
SDL_UpdateRect(screen, x, y, width, height);
|
SDL_UpdateRect(screen, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,18 +440,23 @@ void IN_SendKeyEvents (void)
|
||||||
void
|
void
|
||||||
IN_Commands (void)
|
IN_Commands (void)
|
||||||
{
|
{
|
||||||
if (old_windowed_mouse != _windowed_mouse->value)
|
JOY_Command ();
|
||||||
{
|
|
||||||
|
if (old_windowed_mouse != _windowed_mouse->int_val) {
|
||||||
old_windowed_mouse = _windowed_mouse->value;
|
old_windowed_mouse = _windowed_mouse->value;
|
||||||
if (!_windowed_mouse->value)
|
|
||||||
SDL_WM_GrabInput (SDL_GRAB_OFF);
|
if (_windowed_mouse->int_val)
|
||||||
else
|
|
||||||
SDL_WM_GrabInput (SDL_GRAB_ON);
|
SDL_WM_GrabInput (SDL_GRAB_ON);
|
||||||
|
else
|
||||||
|
SDL_WM_GrabInput (SDL_GRAB_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Init (void)
|
void
|
||||||
|
IN_Init (void)
|
||||||
{
|
{
|
||||||
|
JOY_Init ();
|
||||||
|
|
||||||
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
|
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
|
||||||
|
|
||||||
if ( COM_CheckParm("-nomouse") && !_windowed_mouse->value)
|
if ( COM_CheckParm("-nomouse") && !_windowed_mouse->value)
|
||||||
|
@ -450,8 +466,12 @@ void IN_Init (void)
|
||||||
mouse_avail = 1;
|
mouse_avail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Shutdown (void)
|
void
|
||||||
|
IN_Shutdown (void)
|
||||||
{
|
{
|
||||||
|
JOY_Shutdown ();
|
||||||
|
|
||||||
|
Con_Printf ("IN_Shutdown\n");
|
||||||
mouse_avail = 0;
|
mouse_avail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,27 +495,28 @@ void IN_Frame(void)
|
||||||
mouse_oldbuttonstate = mouse_buttonstate;
|
mouse_oldbuttonstate = mouse_buttonstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Move (usercmd_t *cmd)
|
void
|
||||||
|
IN_Move (usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
|
JOY_Move (cmd);
|
||||||
|
|
||||||
if (!mouse_avail)
|
if (!mouse_avail)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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] += m_pitch->value * mouse_y;
|
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||||
if (cl.viewangles[PITCH] > 80)
|
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||||
cl.viewangles[PITCH] = 80;
|
|
||||||
if (cl.viewangles[PITCH] < -70)
|
|
||||||
cl.viewangles[PITCH] = -70;
|
|
||||||
} 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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue