ok, nq compiles again

This commit is contained in:
Bill Currie 2001-02-21 21:44:57 +00:00
parent de96c6c3b8
commit 10b8c5e8ad
13 changed files with 1588 additions and 1540 deletions

View file

@ -1,183 +0,0 @@
/*
keys.h
Key definitions and 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
$Id$
*/
#ifndef _KEYS_H
#define _KEYS_H
#include "quakeio.h"
#include "qtypes.h"
// these are the key numbers that should be passed to Key_Event
typedef enum {
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
// normal keys should be passed as lowercased ascii
K_BACKSPACE = 127,
K_CAPSLOCK,
K_PRNTSCR,
K_SCRLCK,
K_PAUSE,
K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_ALT,
K_CTRL,
K_SHIFT,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
//
// Keypad stuff..
//
KP_NUMLCK,
KP_DIVIDE,
KP_MULTIPLY,
KP_HOME,
KP_UPARROW,
KP_PGUP,
KP_MINUS,
KP_LEFTARROW,
KP_5,
KP_RIGHTARROW,
KP_PLUS,
KP_END,
KP_DOWNARROW,
KP_PGDN,
KP_INS,
KP_DEL,
KP_ENTER,
//
// mouse buttons generate virtual keys
//
K_MOUSE1 = 200,
K_MOUSE2,
K_MOUSE3,
//
// joystick buttons
//
K_JOY1,
K_JOY2,
K_JOY3,
K_JOY4,
//
// aux keys are for multi-buttoned joysticks to generate so they can use
// the normal binding process
//
K_AUX1,
K_AUX2,
K_AUX3,
K_AUX4,
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_AUX15,
K_AUX16,
K_AUX17,
K_AUX18,
K_AUX19,
K_AUX20,
K_AUX21,
K_AUX22,
K_AUX23,
K_AUX24,
K_AUX25,
K_AUX26,
K_AUX27,
K_AUX28,
K_AUX29,
K_AUX30,
K_AUX31,
K_AUX32,
// JACK: Intellimouse(c) Mouse Wheel Support
K_MWHEELUP,
K_MWHEELDOWN
} keynum_t;
typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
extern keydest_t key_dest;
extern char *keybindings[256];
extern int key_repeats[256];
extern int key_count; // incremented every key event
extern int key_lastpress;
extern char chat_buffer[];
extern int chat_bufferlen;
extern qboolean chat_team;
void Key_Event (int key, qboolean down);
void Key_Init (void);
void Key_WriteBindings (QFile *f);
void Key_SetBinding (int keynum, char *binding);
void Key_ClearStates (void);
#endif // _KEYS_H

View file

@ -1,7 +1,7 @@
/*
console.c
@description@
(description)
Copyright (C) 1996-1997 Id Software, Inc.
@ -29,167 +29,169 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef NeXT
#include <libc.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifndef _MSC_VER
#include <unistd.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <fcntl.h>
#include "va.h"
#include <stdarg.h>
#include "client.h"
#include "cmd.h"
#include "console.h"
#include "draw.h"
#include "host.h"
#include "sys.h"
#include "qargs.h"
#include "client.h"
#include "console.h"
#include "input.h"
#include "screen.h"
#include "keys.h"
#include "qargs.h"
#include "screen.h"
#include "sys.h"
#include "va.h"
int con_linewidth;
int con_ormask;
console_t con_main;
console_t con_chat;
console_t *con; // point to either con_main or con_chat
float con_cursorspeed = 4;
int con_linewidth; // characters across screen
int con_totallines; // total lines in console scrollback
#define CON_TEXTSIZE 16384
float con_cursorspeed = 4;
qboolean con_forcedup; // because no entities to refresh
int con_totallines; // total lines in console scrollback
int con_backscroll; // lines up from bottom to display
int con_current; // where next message will be printed
int con_x; // offset in current line for next print
char *con_text=0;
cvar_t *con_notifytime;
cvar_t *con_notifytime; // seconds
#define NUM_CON_TIMES 4
float con_times[NUM_CON_TIMES]; // realtime time the line was generated
// for transparent notify lines
float con_times[NUM_CON_TIMES]; // realtime time the line was generated
// for transparent notify lines
int con_vislines;
int con_vislines;
int con_notifylines; // scan lines to clear for notify lines
qboolean con_debuglog;
qboolean con_debuglog;
#define MAXCMDLINE 256
extern char key_lines[32][MAXCMDLINE];
extern int edit_line;
extern int key_linepos;
extern char key_lines[32][MAXCMDLINE];
extern int edit_line;
extern int key_linepos;
qboolean con_initialized;
int con_notifylines; // scan lines to clear for notify lines
qboolean con_initialized;
extern void M_Menu_Main_f (void);
void
Key_ClearTyping (void)
{
key_lines[edit_line][1] = 0; // clear any typing
key_linepos = 1;
}
/*
================
Con_ToggleConsole_f
================
Con_ToggleConsole_f
*/
void Con_ToggleConsole_f (void)
void
Con_ToggleConsole_f (void)
{
if (key_dest == key_console)
{
Key_ClearTyping ();
if (key_dest == key_console) {
if (cls.state == ca_connected)
{
key_dest = key_game;
key_lines[edit_line][1] = 0; // clear any typing
key_linepos = 1;
}
else
{
M_Menu_Main_f ();
}
}
else
} else
key_dest = key_console;
memset (con_times, 0, sizeof(con_times));
Con_ClearNotify ();
}
/*
================
Con_Clear_f
================
Con_ToggleChat_f
*/
void Con_Clear_f (void)
void
Con_ToggleChat_f (void)
{
if (con_text)
memset (con_text, ' ', CON_TEXTSIZE);
Key_ClearTyping ();
if (key_dest == key_console) {
if (cls.state == ca_connected)
key_dest = key_game;
} else
key_dest = key_console;
Con_ClearNotify ();
}
/*
================
Con_ClearNotify
================
Con_Clear_f
*/
void Con_ClearNotify (void)
void
Con_Clear_f (void)
{
int i;
for (i=0 ; i<NUM_CON_TIMES ; i++)
con_main.numlines = 0;
con_chat.numlines = 0;
memset (con_main.text, ' ', CON_TEXTSIZE);
memset (con_chat.text, ' ', CON_TEXTSIZE);
con_main.display = con_main.current;
}
/*
Con_ClearNotify
*/
void
Con_ClearNotify (void)
{
int i;
for (i = 0; i < NUM_CON_TIMES; i++)
con_times[i] = 0;
}
/*
================
Con_MessageMode_f
================
*/
extern qboolean team_message;
void Con_MessageMode_f (void)
/*
Con_MessageMode_f
*/
void
Con_MessageMode_f (void)
{
if (cls.state != ca_connected)
return;
chat_team = false;
key_dest = key_message;
team_message = false;
}
/*
================
Con_MessageMode2_f
================
Con_MessageMode2_f
*/
void Con_MessageMode2_f (void)
void
Con_MessageMode2_f (void)
{
if (cls.state != ca_connected)
return;
chat_team = true;
key_dest = key_message;
team_message = true;
}
/*
================
Con_CheckResize
If the line width has changed, reformat the buffer.
================
Con_Resize
*/
void Con_CheckResize (void)
void
Con_Resize (console_t *con)
{
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
char tbuf[CON_TEXTSIZE];
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
char tbuf[CON_TEXTSIZE];
width = (vid.width >> 3) - 2;
if (width == con_linewidth)
return;
if (width < 1) // video hasn't been initialized yet
{
if (width < 1) { // video hasn't been initialized yet
width = 38;
con_linewidth = width;
con_totallines = CON_TEXTSIZE / con_linewidth;
memset (con_text, ' ', CON_TEXTSIZE);
}
else
{
memset (con->text, ' ', CON_TEXTSIZE);
} else {
oldwidth = con_linewidth;
con_linewidth = width;
oldtotallines = con_totallines;
@ -200,354 +202,274 @@ void Con_CheckResize (void)
numlines = con_totallines;
numchars = oldwidth;
if (con_linewidth < numchars)
numchars = con_linewidth;
memcpy (tbuf, con_text, CON_TEXTSIZE);
memset (con_text, ' ', CON_TEXTSIZE);
memcpy (tbuf, con->text, CON_TEXTSIZE);
memset (con->text, ' ', CON_TEXTSIZE);
for (i=0 ; i<numlines ; i++)
{
for (j=0 ; j<numchars ; j++)
{
con_text[(con_totallines - 1 - i) * con_linewidth + j] =
tbuf[((con_current - i + oldtotallines) %
oldtotallines) * oldwidth + j];
for (i = 0; i < numlines; i++) {
for (j = 0; j < numchars; j++) {
con->text[(con_totallines - 1 - i) * con_linewidth + j] =
tbuf[((con->current - i + oldtotallines) %
oldtotallines) * oldwidth + j];
}
}
Con_ClearNotify ();
}
con_backscroll = 0;
con_current = con_totallines - 1;
con->current = con_totallines - 1;
con->display = con->current;
}
/*
================
Con_Init
================
Con_CheckResize
If the line width has changed, reformat the buffer.
*/
void Con_Init (void)
void
Con_CheckResize (void)
{
#define MAXGAMEDIRLEN 1000
char temp[MAXGAMEDIRLEN+1];
char *t2 = "/qconsole.log";
Con_Resize (&con_main);
Con_Resize (&con_chat);
}
con_debuglog = COM_CheckParm("-condebug");
if (con_debuglog)
{
if (strlen (com_gamedir) < (MAXGAMEDIRLEN - strlen (t2)))
{
snprintf (temp, sizeof(temp), "%s%s", com_gamedir, t2);
unlink (temp);
}
}
/*
Con_Init
*/
void
Con_Init (void)
{
con_debuglog = COM_CheckParm ("-condebug");
con_text = Hunk_AllocName (CON_TEXTSIZE, "context");
memset (con_text, ' ', CON_TEXTSIZE);
con = &con_main;
con_linewidth = -1;
Con_CheckResize ();
Con_Printf ("Console initialized.\n");
//
// register our commands
//
con_notifytime = Cvar_Get("con_notifytime", "3", CVAR_NONE, "seconds");
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f, "No Description");
Cmd_AddCommand ("messagemode", Con_MessageMode_f, "No Description");
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "No Description");
Cmd_AddCommand ("clear", Con_Clear_f, "No Description");
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f, "Toggle the console up and down");
Cmd_AddCommand ("togglechat", Con_ToggleChat_f, "Toggle the console up and down");
Cmd_AddCommand ("messagemode", Con_MessageMode_f, "Prompt to send a message to everyone");
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "Prompt to send a message to only people on your team");
Cmd_AddCommand ("clear", Con_Clear_f, "Clear the console");
con_initialized = true;
}
void
Con_Init_Cvars (void)
{
con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, "How long in seconds messages are displayed on screen");
}
/*
===============
Con_Linefeed
===============
Con_Linefeed
*/
void Con_Linefeed (void)
void
Con_Linefeed (void)
{
con_x = 0;
con_current++;
memset (&con_text[(con_current%con_totallines)*con_linewidth]
, ' ', con_linewidth);
con->x = 0;
if (con->display == con->current)
con->display++;
con->current++;
if (con->numlines < con_totallines)
con->numlines++;
memset (&con->text[(con->current % con_totallines) * con_linewidth]
, ' ', con_linewidth);
}
/*
================
Con_Print
Con_Print
Handles cursor positioning, line wrapping, etc
All console printing must go through this in order to be logged to disk
If no console is visible, the notify window will pop up.
================
Handles cursor positioning, line wrapping, etc
All console printing must go through this in order to be logged to disk
If no console is visible, the notify window will pop up.
*/
void Con_Print (char *txt)
void
Con_Print (char *txt)
{
int y;
int c, l;
static int cr;
int mask;
con_backscroll = 0;
int y;
int c, l;
static int cr;
int mask;
if (txt[0] == 1)
{
mask = 128; // go to colored text
S_LocalSound ("misc/talk.wav");
// play talk wav
if (txt[0] == 1 || txt[0] == 2) {
mask = 128; // go to colored text
txt++;
}
else if (txt[0] == 2)
{
mask = 128; // go to colored text
txt++;
}
else
} else
mask = 0;
while ( (c = *txt) )
{
// count word length
for (l=0 ; l< con_linewidth ; l++)
if ( txt[l] <= ' ')
while ((c = *txt)) {
// count word length
for (l = 0; l < con_linewidth; l++)
if (txt[l] <= ' ')
break;
// word wrap
if (l != con_linewidth && (con_x + l > con_linewidth) )
con_x = 0;
// word wrap
if (l != con_linewidth && (con->x + l > con_linewidth))
con->x = 0;
txt++;
if (cr)
{
con_current--;
if (cr) {
con->current--;
cr = false;
}
if (!con_x)
{
if (!con->x) {
Con_Linefeed ();
// mark time for transparent overlay
if (con_current >= 0)
con_times[con_current % NUM_CON_TIMES] = realtime;
// mark time for transparent overlay
if (con->current >= 0)
con_times[con->current % NUM_CON_TIMES] = realtime;
}
switch (c)
{
case '\n':
con_x = 0;
break;
switch (c) {
case '\n':
con->x = 0;
break;
case '\r':
con_x = 0;
cr = 1;
break;
case '\r':
con->x = 0;
cr = 1;
break;
default: // display character and advance
y = con_current % con_totallines;
con_text[y*con_linewidth+con_x] = c | mask;
con_x++;
if (con_x >= con_linewidth)
con_x = 0;
break;
default: // display character and advance
y = con->current % con_totallines;
con->text[y * con_linewidth + con->x] = c | mask | con_ormask;
con->x++;
if (con->x >= con_linewidth)
con->x = 0;
break;
}
}
}
/*
================
Con_DebugLog
================
*/
void Con_DebugLog(char *file, char *fmt, ...)
{
va_list argptr;
static char data[1024];
int fd;
va_start(argptr, fmt);
vsnprintf (data, sizeof(data), fmt, argptr);
va_end(argptr);
fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666);
write(fd, data, strlen(data));
close(fd);
}
Con_Printf
/*
================
Con_Printf
Handles cursor positioning, line wrapping, etc
================
Handles cursor positioning, line wrapping, etc
*/
#define MAXPRINTMSG 4096
void Con_Printf (char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
static qboolean inupdate;
va_start (argptr,fmt);
vsnprintf (msg, sizeof(msg), fmt,argptr);
va_end (argptr);
// also echo to debugging console
Sys_Printf ("%s", msg); // also echo to debugging console
// log all messages to file
void
Con_Printf (char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
va_start (argptr, fmt);
vsnprintf (msg, sizeof (msg), fmt, argptr);
va_end (argptr);
// also echo to debugging console
Sys_Printf ("%s", msg); // also echo to debugging console
// log all messages to file
if (con_debuglog)
Con_DebugLog(va("%s/qconsole.log",com_gamedir), "%s", msg);
Sys_DebugLog (va ("%s/qconsole.log", com_gamedir), "%s", msg);
if (!con_initialized)
return;
if (cls.state == ca_dedicated)
return; // no graphics mode
// write it to the scrollable buffer
// write it to the scrollable buffer
Con_Print (msg);
// update the screen if the console is displayed
if (cls.signon != SIGNONS && !scr_disabled_for_loading )
{
// protect against infinite loop if something in SCR_UpdateScreen calls
// Con_Printd
if (!inupdate)
{
inupdate = true;
SCR_UpdateScreen ();
inupdate = false;
}
}
}
/*
================
Con_DPrintf
Con_DPrintf
A Con_Printf that only shows up if the "developer" cvar is set
================
A Con_Printf that only shows up if the "developer" cvar is set
*/
void Con_DPrintf (char *fmt, ...)
void
Con_DPrintf (char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
va_list argptr;
char msg[MAXPRINTMSG];
if (!developer->int_val)
return; // don't confuse non-developers with techie stuff...
return; // don't confuse non-developers with
// techie stuff...
va_start (argptr,fmt);
vsnprintf (msg, sizeof(msg), fmt,argptr);
va_start (argptr, fmt);
vsnprintf (msg, sizeof (msg), fmt, argptr);
va_end (argptr);
Con_Printf ("%s", msg);
}
/*
DRAWING
*/
/*
==================
Con_SafePrintf
Con_DrawInput
Okay to call even when the screen can't be updated
==================
The input line scrolls horizontally if typing goes beyond the right edge
*/
void Con_SafePrintf (char *fmt, ...)
void
Con_DrawInput (void)
{
va_list argptr;
char msg[1024];
int temp;
va_start (argptr,fmt);
vsnprintf (msg, sizeof(msg), fmt,argptr);
va_end (argptr);
int y;
int i;
char *text;
char temp[MAXCMDLINE];
temp = scr_disabled_for_loading;
scr_disabled_for_loading = true;
Con_Printf ("%s", msg);
scr_disabled_for_loading = temp;
}
if (key_dest != key_console && cls.state == ca_connected)
return; // don't draw anything (allways draw
// if not active)
text = strcpy (temp, key_lines[edit_line]);
/*
==============================================================================
DRAWING
==============================================================================
*/
/*
================
Con_DrawInput
The input line scrolls horizontally if typing goes beyond the right edge
================
*/
void Con_DrawInput (void)
{
int y;
int i;
char *text;
if (key_dest != key_console && !con_forcedup)
return; // don't draw anything
text = key_lines[edit_line];
// add the cursor frame
text[key_linepos] = 10+((int)(realtime*con_cursorspeed)&1);
// fill out remainder with spaces
for (i=key_linepos+1 ; i< con_linewidth ; i++)
for (i = strlen (text); i < MAXCMDLINE; i++)
text[i] = ' ';
// prestep if horizontally scrolling
// add the cursor frame
if ((int) (realtime * con_cursorspeed) & 1)
text[key_linepos] = 11;
// prestep if horizontally scrolling
if (key_linepos >= con_linewidth)
text += 1 + key_linepos - con_linewidth;
// draw it
y = con_vislines-16;
y = con_vislines - 22;
for (i=0 ; i<con_linewidth ; i++)
Draw_Character8 ( (i+1)<<3, con_vislines - 16, text[i]);
// remove cursor
key_lines[edit_line][key_linepos] = 0;
for (i = 0; i < con_linewidth; i++)
Draw_Character8 ((i + 1) << 3, con_vislines - 22, text[i]);
}
/*
================
Con_DrawNotify
Con_DrawNotify
Draws the last few lines of output transparently over the game top
================
Draws the last few lines of output transparently over the game top
*/
void Con_DrawNotify (void)
void
Con_DrawNotify (void)
{
int x, v;
char *text;
int i;
float time;
extern char chat_buffer[];
int x, v;
char *text;
int i;
float time;
char *s;
int skip;
v = 0;
for (i= con_current-NUM_CON_TIMES+1 ; i<=con_current ; i++)
{
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
if (i < 0)
continue;
time = con_times[i % NUM_CON_TIMES];
@ -556,54 +478,60 @@ void Con_DrawNotify (void)
time = realtime - time;
if (time > con_notifytime->value)
continue;
text = con_text + (i % con_totallines)*con_linewidth;
text = con->text + (i % con_totallines) * con_linewidth;
clearnotify = 0;
scr_copytop = 1;
for (x = 0 ; x < con_linewidth ; x++)
Draw_Character8 ( (x+1)<<3, v, text[x]);
for (x = 0; x < con_linewidth; x++)
Draw_Character8 ((x + 1) << 3, v, text[x]);
v += 8;
}
if (key_dest == key_message)
{
if (key_dest == key_message) {
clearnotify = 0;
scr_copytop = 1;
if (chat_team) {
Draw_String8 (8, v, "say_team:");
skip = 11;
} else {
Draw_String8 (8, v, "say:");
skip = 5;
}
s = chat_buffer;
if (chat_bufferlen > (vid.width >> 3) - (skip + 1))
s += chat_bufferlen - ((vid.width >> 3) - (skip + 1));
x = 0;
Draw_String8 (8, v, "say:");
while(chat_buffer[x])
{
Draw_Character8 ( (x+5)<<3, v, chat_buffer[x]);
while (s[x]) {
Draw_Character8 ((x + skip) << 3, v, s[x]);
x++;
}
Draw_Character8 ( (x+5)<<3, v, 10+((int)(realtime*con_cursorspeed)&1));
Draw_Character8 ((x + skip) << 3, v,
10 + ((int) (realtime * con_cursorspeed) & 1));
v += 8;
}
if (v > con_notifylines)
con_notifylines = v;
}
/*
================
Con_DrawConsole
Con_DrawConsole
Draws the console with the solid background
The typing input line at the bottom should only be drawn if typing is allowed
================
Draws the console with the solid background
*/
void Con_DrawConsole (int lines)//, qboolean drawinput)
void
Con_DrawConsole (int lines)
{
int i, x, y;
int rows;
char *text;
int j;
int i, x, y;
int rows;
char *text;
int row;
if (lines <= 0)
return;
@ -613,57 +541,34 @@ void Con_DrawConsole (int lines)//, qboolean drawinput)
// draw the text
con_vislines = lines;
rows = (lines-16)>>3; // rows of text to draw
y = lines - 16 - (rows<<3); // may start slightly negative
// changed to line things up better
rows = (lines - 22) >> 3; // rows of text to draw
for (i= con_current - rows + 1 ; i<=con_current ; i++, y+=8 )
{
j = i - con_backscroll;
if (j<0)
j = 0;
text = con_text + (j % con_totallines)*con_linewidth;
y = lines - 30;
for (x=0 ; x<con_linewidth ; x++)
Draw_Character8 ( (x+1)<<3, y, text[x]);
// draw from the bottom up
if (con->display != con->current) {
// draw arrows to show the buffer is backscrolled
for (x = 0; x < con_linewidth; x += 4)
Draw_Character8 ((x + 1) << 3, y, '^');
y -= 8;
rows--;
}
row = con->display;
for (i = 0; i < rows; i++, y -= 8, row--) {
if (row < 0)
break;
if (con->current - row >= con_totallines)
break; // past scrollback wrap point
text = con->text + (row % con_totallines) * con_linewidth;
for (x = 0; x < con_linewidth; x++)
Draw_Character8 ((x + 1) << 3, y, text[x]);
}
// draw the input prompt, user text, and cursor if desired
// if (drawinput)
Con_DrawInput ();
Con_DrawInput ();
}
/*
==================
Con_NotifyBox
==================
*/
void Con_NotifyBox (char *text)
{
double t1, t2;
// during startup for sound / cd warnings
Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n");
Con_Printf (text);
Con_Printf ("Press a key.\n");
Con_Printf("\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n");
key_count = -2; // wait for a key down and up
key_dest = key_console;
do
{
t1 = Sys_DoubleTime ();
SCR_UpdateScreen ();
IN_SendKeyEvents ();
t2 = Sys_DoubleTime ();
realtime += t2-t1; // make the cursor blink
} while (key_count < 0);
Con_Printf ("\n");
key_dest = key_game;
realtime = 0; // put the cursor back to invisible
}

View file

@ -608,9 +608,7 @@ void SCR_SetUpToDrawConsole (void)
return; // never a console with loading plaque
// decide on the height of the console
con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;
if (con_forcedup)
if (!cl.worldmodel || cls.signon != SIGNONS)
{
scr_conlines = vid.height; // full screen
scr_con_current = scr_conlines;
@ -850,7 +848,7 @@ int SCR_ModalMessage (char *text)
do
{
key_count = -1; // wait for a key down and up
//key_count = -1; // wait for a key down and up
IN_SendKeyEvents ();
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);

View file

@ -149,7 +149,7 @@ extern vrect_t scr_vrect;
void
V_RenderView (void)
{
if (con_forcedup)
if (!cl.worldmodel || cls.signon != SIGNONS)
return;
// don't allow cheats in multiplayer

View file

@ -26,13 +26,12 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif
#include <SDL.h>
#include "client.h"
#include "compat.h"
#include "console.h"
#include "cvar.h"
#include "draw.h"
@ -49,180 +48,276 @@
#ifdef WIN32
// fixme: this is evil...
#include <windows.h>
HWND mainwindow;
# include <windows.h>
HWND mainwindow;
#endif
cvar_t *_windowed_mouse;
int old_windowed_mouse;
cvar_t *_windowed_mouse;
int old_windowed_mouse;
int modestate; // fixme: just to avoid cross-comp. errors - remove later
int modestate; // fixme: just to avoid cross-comp.
// errors - remove later
static qboolean mouse_avail;
static float mouse_x, mouse_y;
static int mouse_oldbuttonstate = 0;
static float mouse_x, mouse_y;
static int mouse_oldbuttonstate = 0;
extern viddef_t vid; // global video state
extern viddef_t vid; // global video state
/*
================
IN_SendKeyEvents
================
IN_SendKeyEvents
*/
void
IN_SendKeyEvents (void)
{
SDL_Event event;
int sym, state, but;
int modstate;
SDL_Event event;
int sym, state, but;
int modstate;
while (SDL_PollEvent(&event)) {
while (SDL_PollEvent (&event)) {
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
sym = event.key.keysym.sym;
state = event.key.state;
modstate = SDL_GetModState();
switch(sym) {
case SDLK_DELETE: sym = K_DEL; break;
case SDLK_BACKSPACE: sym = K_BACKSPACE; break;
case SDLK_F1: sym = K_F1; break;
case SDLK_F2: sym = K_F2; break;
case SDLK_F3: sym = K_F3; break;
case SDLK_F4: sym = K_F4; break;
case SDLK_F5: sym = K_F5; break;
case SDLK_F6: sym = K_F6; break;
case SDLK_F7: sym = K_F7; break;
case SDLK_F8: sym = K_F8; break;
case SDLK_F9: sym = K_F9; break;
case SDLK_F10: sym = K_F10; break;
case SDLK_F11: sym = K_F11; break;
case SDLK_F12: sym = K_F12; break;
case SDLK_BREAK:
case SDLK_PAUSE: sym = K_PAUSE; break;
case SDLK_UP: sym = K_UPARROW; break;
case SDLK_DOWN: sym = K_DOWNARROW; break;
case SDLK_RIGHT: sym = K_RIGHTARROW; break;
case SDLK_LEFT: sym = K_LEFTARROW; break;
case SDLK_INSERT: sym = K_INS; break;
case SDLK_HOME: sym = K_HOME; break;
case SDLK_END: sym = K_END; break;
case SDLK_PAGEUP: sym = K_PGUP; break;
case SDLK_PAGEDOWN: sym = K_PGDN; break;
case SDLK_RSHIFT:
case SDLK_LSHIFT: sym = K_SHIFT; break;
case SDLK_RCTRL:
case SDLK_LCTRL: sym = K_CTRL; break;
case SDLK_RALT:
case SDLK_LALT: sym = K_ALT; break;
case SDLK_CAPSLOCK: sym = K_CAPSLOCK; break;
case SDLK_KP0:
if(modstate & KMOD_NUM) sym = K_INS;
else sym = SDLK_0;
break;
case SDLK_KP1:
if(modstate & KMOD_NUM) sym = K_END;
else sym = SDLK_1;
break;
case SDLK_KP2:
if(modstate & KMOD_NUM) sym = K_DOWNARROW;
else sym = SDLK_2;
break;
case SDLK_KP3:
if(modstate & KMOD_NUM) sym = K_PGDN;
else sym = SDLK_3;
break;
case SDLK_KP4:
if(modstate & KMOD_NUM) sym = K_LEFTARROW;
else sym = SDLK_4;
break;
case SDLK_KP5: sym = SDLK_5; break;
case SDLK_KP6:
if(modstate & KMOD_NUM) sym = K_RIGHTARROW;
else sym = SDLK_6;
break;
case SDLK_KP7:
if(modstate & KMOD_NUM) sym = K_HOME;
else sym = SDLK_7;
break;
case SDLK_KP8:
if(modstate & KMOD_NUM) sym = K_UPARROW;
else sym = SDLK_8;
break;
case SDLK_KP9:
if(modstate & KMOD_NUM) sym = K_PGUP;
else sym = SDLK_9;
break;
case SDLK_KP_PERIOD:
if(modstate & KMOD_NUM) sym = K_DEL;
else sym = SDLK_PERIOD;
break;
case SDLK_KP_DIVIDE: sym = SDLK_SLASH; break;
case SDLK_KP_MULTIPLY: sym = SDLK_ASTERISK; break;
case SDLK_KP_MINUS: sym = SDLK_MINUS; break;
case SDLK_KP_PLUS: sym = SDLK_PLUS; break;
case SDLK_KP_ENTER: sym = SDLK_RETURN; break;
case SDLK_KP_EQUALS: sym = SDLK_EQUALS; break;
}
// If we're not directly handled and still above 255
// just force it to 0
if(sym > 255) sym = 0;
Key_Event(sym, state);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
but = event.button.button;
if (but == 2)
but = 3;
else if (but == 3)
but = 2;
switch (but) {
case 1:
case 2:
case 3:
Key_Event(K_MOUSE1 + but - 1, event.type
== SDL_MOUSEBUTTONDOWN);
break;
case 4:
Key_Event(K_MWHEELUP, 1);
Key_Event(K_MWHEELUP, 0);
break;
case 5:
Key_Event(K_MWHEELDOWN, 1);
Key_Event(K_MWHEELDOWN, 0);
break;
}
break;
case SDL_MOUSEMOTION:
if (_windowed_mouse->value) {
if ((event.motion.x != (vid.width/2))
|| (event.motion.y != (vid.height/2)) ) {
// *2 for vid_sdl.c, *10 for vid_sgl.c.
mouse_x = event.motion.xrel*2;
mouse_y = event.motion.yrel*2;
if ((event.motion.x < ((vid.width/2)-(vid.width/4))) ||
(event.motion.x > ((vid.width/2)+(vid.width/4))) ||
(event.motion.y < ((vid.height/2)-(vid.height/4))) ||
(event.motion.y > ((vid.height/2)+(vid.height/4))) )
SDL_WarpMouse(vid.width/2, vid.height/2);
case SDL_KEYDOWN:
case SDL_KEYUP:
sym = event.key.keysym.sym;
state = event.key.state;
modstate = SDL_GetModState ();
switch (sym) {
case SDLK_DELETE:
sym = K_DEL;
break;
case SDLK_BACKSPACE:
sym = K_BACKSPACE;
break;
case SDLK_F1:
sym = K_F1;
break;
case SDLK_F2:
sym = K_F2;
break;
case SDLK_F3:
sym = K_F3;
break;
case SDLK_F4:
sym = K_F4;
break;
case SDLK_F5:
sym = K_F5;
break;
case SDLK_F6:
sym = K_F6;
break;
case SDLK_F7:
sym = K_F7;
break;
case SDLK_F8:
sym = K_F8;
break;
case SDLK_F9:
sym = K_F9;
break;
case SDLK_F10:
sym = K_F10;
break;
case SDLK_F11:
sym = K_F11;
break;
case SDLK_F12:
sym = K_F12;
break;
case SDLK_BREAK:
case SDLK_PAUSE:
sym = K_PAUSE;
break;
case SDLK_UP:
sym = K_UPARROW;
break;
case SDLK_DOWN:
sym = K_DOWNARROW;
break;
case SDLK_RIGHT:
sym = K_RIGHTARROW;
break;
case SDLK_LEFT:
sym = K_LEFTARROW;
break;
case SDLK_INSERT:
sym = K_INS;
break;
case SDLK_HOME:
sym = K_HOME;
break;
case SDLK_END:
sym = K_END;
break;
case SDLK_PAGEUP:
sym = K_PGUP;
break;
case SDLK_PAGEDOWN:
sym = K_PGDN;
break;
case SDLK_RSHIFT:
case SDLK_LSHIFT:
sym = K_SHIFT;
break;
case SDLK_RCTRL:
case SDLK_LCTRL:
sym = K_CTRL;
break;
case SDLK_RALT:
case SDLK_LALT:
sym = K_ALT;
break;
case SDLK_CAPSLOCK:
sym = K_CAPSLOCK;
break;
case SDLK_KP0:
if (modstate & KMOD_NUM)
sym = K_INS;
else
sym = SDLK_0;
break;
case SDLK_KP1:
if (modstate & KMOD_NUM)
sym = K_END;
else
sym = SDLK_1;
break;
case SDLK_KP2:
if (modstate & KMOD_NUM)
sym = K_DOWNARROW;
else
sym = SDLK_2;
break;
case SDLK_KP3:
if (modstate & KMOD_NUM)
sym = K_PGDN;
else
sym = SDLK_3;
break;
case SDLK_KP4:
if (modstate & KMOD_NUM)
sym = K_LEFTARROW;
else
sym = SDLK_4;
break;
case SDLK_KP5:
sym = SDLK_5;
break;
case SDLK_KP6:
if (modstate & KMOD_NUM)
sym = K_RIGHTARROW;
else
sym = SDLK_6;
break;
case SDLK_KP7:
if (modstate & KMOD_NUM)
sym = K_HOME;
else
sym = SDLK_7;
break;
case SDLK_KP8:
if (modstate & KMOD_NUM)
sym = K_UPARROW;
else
sym = SDLK_8;
break;
case SDLK_KP9:
if (modstate & KMOD_NUM)
sym = K_PGUP;
else
sym = SDLK_9;
break;
case SDLK_KP_PERIOD:
if (modstate & KMOD_NUM)
sym = K_DEL;
else
sym = SDLK_PERIOD;
break;
case SDLK_KP_DIVIDE:
sym = SDLK_SLASH;
break;
case SDLK_KP_MULTIPLY:
sym = SDLK_ASTERISK;
break;
case SDLK_KP_MINUS:
sym = SDLK_MINUS;
break;
case SDLK_KP_PLUS:
sym = SDLK_PLUS;
break;
case SDLK_KP_ENTER:
sym = SDLK_RETURN;
break;
case SDLK_KP_EQUALS:
sym = SDLK_EQUALS;
break;
}
} else {
// following are *2 in vid_sdl.c, vid_sgl.c is *10
mouse_x = event.motion.xrel*10;
mouse_y = event.motion.yrel*10;
}
break;
// If we're not directly handled and still above 255
// just force it to 0
if (sym > 255)
sym = 0;
Key_Event (sym, -1, state);
break;
case SDL_QUIT:
CL_Disconnect ();
Sys_Quit ();
break;
default:
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
but = event.button.button;
if (but == 2)
but = 3;
else if (but == 3)
but = 2;
switch (but) {
case 1:
case 2:
case 3:
Key_Event (K_MOUSE1 + but - 1, 0, event.type
== SDL_MOUSEBUTTONDOWN);
break;
case 4:
Key_Event (K_MWHEELUP, 0,
event.type == SDL_MOUSEBUTTONDOWN);
break;
case 5:
Key_Event (K_MWHEELDOWN, 0,
event.type == SDL_MOUSEBUTTONDOWN);
break;
}
break;
case SDL_MOUSEMOTION:
if (_windowed_mouse->value) {
if ((event.motion.x != (vid.width / 2))
|| (event.motion.y != (vid.height / 2))) {
// *2 for vid_sdl.c, *10 for vid_sgl.c.
mouse_x = event.motion.xrel * 5;
mouse_y = event.motion.yrel * 5;
if (
(event.motion.x <
((vid.width / 2) - (vid.width / 4)))
|| (event.motion.x >
((vid.width / 2) + (vid.width / 4)))
|| (event.motion.y <
((vid.height / 2) - (vid.height / 4)))
|| (event.motion.y >
((vid.height / 2) + (vid.height / 4))))
SDL_WarpMouse (vid.width / 2, vid.height / 2);
}
} else {
// following are *2 in vid_sdl.c, vid_sgl.c is *10
mouse_x = event.motion.xrel * 5;
mouse_y = event.motion.yrel * 5;
}
break;
case SDL_QUIT:
CL_Disconnect ();
Sys_Quit ();
break;
default:
break;
}
}
}
@ -236,11 +331,11 @@ IN_Commands (void)
if (old_windowed_mouse != _windowed_mouse->value) {
old_windowed_mouse = _windowed_mouse->value;
if (!_windowed_mouse->value) {
// SDL_ShowCursor (0);
// SDL_ShowCursor (0);
SDL_WM_GrabInput (SDL_GRAB_OFF);
} else {
SDL_WM_GrabInput (SDL_GRAB_ON);
// SDL_ShowCursor (1);
// SDL_ShowCursor (1);
}
}
}
@ -250,14 +345,14 @@ IN_Init (void)
{
JOY_Init ();
if ( COM_CheckParm("-nomouse") && !_windowed_mouse->value)
if (COM_CheckParm ("-nomouse") && !_windowed_mouse->value)
return;
mouse_x = mouse_y = 0.0;
mouse_avail = 1;
// SDL_ShowCursor (0);
// SDL_WM_GrabInput (SDL_GRAB_ON);
// FIXME: disable DGA if in_dgamouse says to.
// SDL_ShowCursor (0);
// SDL_WM_GrabInput (SDL_GRAB_ON);
// FIXME: disable DGA if in_dgamouse says to.
}
void
@ -265,8 +360,8 @@ IN_Init_Cvars (void)
{
JOY_Init_Cvars ();
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
// m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None");
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "If set to 1, quake will grab the mouse in X");
// m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "Toggle mouse input filtering");
}
void
@ -275,22 +370,26 @@ IN_Shutdown (void)
mouse_avail = 0;
}
void IN_Frame(void)
void
IN_Frame (void)
{
int i;
int mouse_buttonstate;
int i;
int mouse_buttonstate;
if (!mouse_avail) return;
if (!mouse_avail)
return;
i = SDL_GetMouseState(NULL, NULL);
i = SDL_GetMouseState (NULL, NULL);
/* Quake swaps the second and third buttons */
mouse_buttonstate = (i & ~0x06) | ((i & 0x02)<<1) | ((i & 0x04)>>1);
for (i=0 ; i<3 ; i++) {
if ( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) )
Key_Event (K_MOUSE1 + i, true);
mouse_buttonstate = (i & ~0x06) | ((i & 0x02) << 1) | ((i & 0x04) >> 1);
for (i = 0; i < 3; i++) {
if ((mouse_buttonstate & (1 << i))
&& !(mouse_oldbuttonstate & (1 << i))) Key_Event (K_MOUSE1 + i, 0,
true);
if ( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) )
Key_Event (K_MOUSE1 + i, false);
if (!(mouse_buttonstate & (1 << i))
&& (mouse_oldbuttonstate & (1 << i))) Key_Event (K_MOUSE1 + i, 0,
false);
}
mouse_oldbuttonstate = mouse_buttonstate;
}
@ -316,7 +415,7 @@ IN_Move (usercmd_t *cmd)
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
if ((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
cmd->sidemove += m_side->value * mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
@ -324,8 +423,9 @@ IN_Move (usercmd_t *cmd)
if (freelook)
V_StopPitchDrift ();
if ( freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH] + (m_pitch->value * mouse_y), 80);
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] =
bound (-70, cl.viewangles[PITCH] + (m_pitch->value * mouse_y), 80);
} else {
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
@ -334,6 +434,7 @@ IN_Move (usercmd_t *cmd)
}
mouse_x = mouse_y = 0.0;
}
void
IN_HandlePause (qboolean paused)
{

View file

@ -30,22 +30,20 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <vga.h>
#include <vgakeyboard.h>
#include <vgamouse.h>
#include "client.h"
#include "cmd.h"
#include "compat.h"
#include "console.h"
#include "cvar.h"
#include "host.h"
@ -53,56 +51,59 @@
#include "joystick.h"
#include "keys.h"
#include "qargs.h"
#include "qtypes.h"
#include "sys.h"
#include "view.h"
static int UseKeyboard = 1;
static int UseMouse = 1;
static int in_svgalib_inited = 0;
static int UseKeyboard = 1;
static int UseMouse = 1;
static int in_svgalib_inited = 0;
static unsigned char scantokey[128];
static int mouse_buttons;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int mx, my;
static int mouse_buttons;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int mx, my;
static void IN_init_kb();
static void IN_init_mouse();
static void IN_InitKeyboard (void);
static void IN_InitMouse (void);
cvar_t *_windowed_mouse;
cvar_t *m_filter;
cvar_t *_windowed_mouse;
cvar_t *m_filter;
static void keyhandler(int scancode, int state)
static void
keyhandler (int scancode, int state)
{
int sc;
int sc;
sc = scancode & 0x7f;
#if 0
Con_Printf("scancode=%x (%d%s)\n", scancode, sc, scancode&0x80?"+128":"");
Con_Printf ("scancode=%x (%d%s)\n", scancode, sc,
scancode & 0x80 ? "+128" : "");
#endif
Key_Event(scantokey[sc], state == KEY_EVENTPRESS);
Key_Event (scantokey[sc], -1, state == KEY_EVENTPRESS);
}
static void mousehandler(int buttonstate, int dx, int dy, int dz, int drx, int dry, int drz)
static void
mousehandler (int buttonstate, int dx, int dy, int dz, int drx, int dry, int drz)
{
mouse_buttonstate = buttonstate;
mx += dx;
my += dy;
if (drx > 0) {
Key_Event(K_MWHEELUP, 1);
Key_Event(K_MWHEELUP, 0);
Key_Event (K_MWHEELUP, 0, 1);
Key_Event (K_MWHEELUP, 0, 0);
} else if (drx < 0) {
Key_Event(K_MWHEELDOWN, 1);
Key_Event(K_MWHEELDOWN, 0);
Key_Event (K_MWHEELDOWN, 0, 1);
Key_Event (K_MWHEELDOWN, 0, 0);
}
}
void Force_CenterView_f(void)
void
Force_CenterView_f (void)
{
cl.viewangles[PITCH] = 0;
}
@ -111,15 +112,17 @@ void Force_CenterView_f(void)
void
IN_Init (void)
{
if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
if (COM_CheckParm("-nomouse")) UseMouse = 0;
if (COM_CheckParm ("-nokbd"))
UseKeyboard = 0;
if (COM_CheckParm ("-nomouse"))
UseMouse = 0;
if (UseKeyboard)
IN_init_kb();
IN_InitKeyboard ();
if (UseMouse)
IN_init_mouse();
IN_InitMouse ();
JOY_Init();
JOY_Init ();
in_svgalib_inited = 1;
return;
@ -128,113 +131,113 @@ IN_Init (void)
void
IN_Init_Cvars (void)
{
JOY_Init_Cvars();
m_filter = Cvar_Get ("m_filter","0",0,"None");
JOY_Init_Cvars ();
m_filter = Cvar_Get ("m_filter", "0", 0, "Toggle mouse input filtering.");
}
static void
IN_init_kb (void)
IN_InitKeyboard (void)
{
int i;
int i;
for (i=0 ; i<128 ; i++) {
for (i = 0; i < 128; i++) {
scantokey[i] = ' ';
}
scantokey[ 1] = K_ESCAPE;
scantokey[ 2] = '1';
scantokey[ 3] = '2';
scantokey[ 4] = '3';
scantokey[ 5] = '4';
scantokey[ 6] = '5';
scantokey[ 7] = '6';
scantokey[ 8] = '7';
scantokey[ 9] = '8';
scantokey[ 10] = '9';
scantokey[ 11] = '0';
scantokey[ 12] = '-';
scantokey[ 13] = '=';
scantokey[ 14] = K_BACKSPACE;
scantokey[ 15] = K_TAB;
scantokey[ 16] = 'q';
scantokey[ 17] = 'w';
scantokey[ 18] = 'e';
scantokey[ 19] = 'r';
scantokey[ 20] = 't';
scantokey[ 21] = 'y';
scantokey[ 22] = 'u';
scantokey[ 23] = 'i';
scantokey[ 24] = 'o';
scantokey[ 25] = 'p';
scantokey[ 26] = '[';
scantokey[ 27] = ']';
scantokey[ 28] = K_ENTER;
scantokey[ 29] = K_CTRL; /*left */
scantokey[ 30] = 'a';
scantokey[ 31] = 's';
scantokey[ 32] = 'd';
scantokey[ 33] = 'f';
scantokey[ 34] = 'g';
scantokey[ 35] = 'h';
scantokey[ 36] = 'j';
scantokey[ 37] = 'k';
scantokey[ 38] = 'l';
scantokey[ 39] = ';';
scantokey[ 40] = '\'';
scantokey[ 41] = '`';
scantokey[ 42] = K_SHIFT; /*left */
scantokey[ 43] = '\\';
scantokey[ 44] = 'z';
scantokey[ 45] = 'x';
scantokey[ 46] = 'c';
scantokey[ 47] = 'v';
scantokey[ 48] = 'b';
scantokey[ 49] = 'n';
scantokey[ 50] = 'm';
scantokey[ 51] = ',';
scantokey[ 52] = '.';
scantokey[ 53] = '/';
scantokey[ 54] = K_SHIFT; /*right */
scantokey[ 55] = KP_MULTIPLY;
scantokey[ 56] = K_ALT; /*left */
scantokey[ 57] = ' ';
scantokey[ 58] = K_CAPSLOCK;
scantokey[ 59] = K_F1;
scantokey[ 60] = K_F2;
scantokey[ 61] = K_F3;
scantokey[ 62] = K_F4;
scantokey[ 63] = K_F5;
scantokey[ 64] = K_F6;
scantokey[ 65] = K_F7;
scantokey[ 66] = K_F8;
scantokey[ 67] = K_F9;
scantokey[ 68] = K_F10;
scantokey[ 69] = KP_NUMLCK;
scantokey[ 70] = K_SCRLCK;
scantokey[ 71] = KP_HOME;
scantokey[ 72] = KP_UPARROW;
scantokey[ 73] = KP_PGUP;
scantokey[ 74] = KP_MINUS;
scantokey[ 75] = KP_LEFTARROW;
scantokey[ 76] = KP_5;
scantokey[ 77] = KP_RIGHTARROW;
scantokey[ 79] = KP_END;
scantokey[ 78] = KP_PLUS;
scantokey[ 80] = KP_DOWNARROW;
scantokey[ 81] = KP_PGDN;
scantokey[ 82] = KP_INS;
scantokey[ 83] = KP_DEL;
scantokey[1] = K_ESCAPE;
scantokey[2] = '1';
scantokey[3] = '2';
scantokey[4] = '3';
scantokey[5] = '4';
scantokey[6] = '5';
scantokey[7] = '6';
scantokey[8] = '7';
scantokey[9] = '8';
scantokey[10] = '9';
scantokey[11] = '0';
scantokey[12] = '-';
scantokey[13] = '=';
scantokey[14] = K_BACKSPACE;
scantokey[15] = K_TAB;
scantokey[16] = 'q';
scantokey[17] = 'w';
scantokey[18] = 'e';
scantokey[19] = 'r';
scantokey[20] = 't';
scantokey[21] = 'y';
scantokey[22] = 'u';
scantokey[23] = 'i';
scantokey[24] = 'o';
scantokey[25] = 'p';
scantokey[26] = '[';
scantokey[27] = ']';
scantokey[28] = K_ENTER;
scantokey[29] = K_CTRL; /* left */
scantokey[30] = 'a';
scantokey[31] = 's';
scantokey[32] = 'd';
scantokey[33] = 'f';
scantokey[34] = 'g';
scantokey[35] = 'h';
scantokey[36] = 'j';
scantokey[37] = 'k';
scantokey[38] = 'l';
scantokey[39] = ';';
scantokey[40] = '\'';
scantokey[41] = '`';
scantokey[42] = K_SHIFT; /* left */
scantokey[43] = '\\';
scantokey[44] = 'z';
scantokey[45] = 'x';
scantokey[46] = 'c';
scantokey[47] = 'v';
scantokey[48] = 'b';
scantokey[49] = 'n';
scantokey[50] = 'm';
scantokey[51] = ',';
scantokey[52] = '.';
scantokey[53] = '/';
scantokey[54] = K_SHIFT; /* right */
scantokey[55] = KP_MULTIPLY;
scantokey[56] = K_ALT; /* left */
scantokey[57] = ' ';
scantokey[58] = K_CAPSLOCK;
scantokey[59] = K_F1;
scantokey[60] = K_F2;
scantokey[61] = K_F3;
scantokey[62] = K_F4;
scantokey[63] = K_F5;
scantokey[64] = K_F6;
scantokey[65] = K_F7;
scantokey[66] = K_F8;
scantokey[67] = K_F9;
scantokey[68] = K_F10;
scantokey[69] = KP_NUMLCK;
scantokey[70] = K_SCRLCK;
scantokey[71] = KP_HOME;
scantokey[72] = KP_UPARROW;
scantokey[73] = KP_PGUP;
scantokey[74] = KP_MINUS;
scantokey[75] = KP_LEFTARROW;
scantokey[76] = KP_5;
scantokey[77] = KP_RIGHTARROW;
scantokey[79] = KP_END;
scantokey[78] = KP_PLUS;
scantokey[80] = KP_DOWNARROW;
scantokey[81] = KP_PGDN;
scantokey[82] = KP_INS;
scantokey[83] = KP_DEL;
/* 84 to 86 not used */
scantokey[ 87] = K_F11;
scantokey[ 88] = K_F12;
scantokey[87] = K_F11;
scantokey[88] = K_F12;
/* 89 to 95 not used */
scantokey[ 96] = KP_ENTER; /* keypad enter */
scantokey[ 97] = K_CTRL; /* right */
scantokey[ 98] = KP_DIVIDE;
scantokey[ 99] = K_PRNTSCR; /* print screen */
scantokey[100] = K_ALT; /* right */
scantokey[96] = KP_ENTER; /* keypad enter */
scantokey[97] = K_CTRL; /* right */
scantokey[98] = KP_DIVIDE;
scantokey[99] = K_PRNTSCR; /* print screen */
scantokey[100] = K_ALT; /* right */
scantokey[101] = K_PAUSE; /* break */
scantokey[101] = K_PAUSE; /* break */
scantokey[102] = K_HOME;
scantokey[103] = K_UPARROW;
scantokey[104] = K_PGUP;
@ -250,109 +253,116 @@ IN_init_kb (void)
if (keyboard_init ()) {
Sys_Error ("keyboard_init() failed");
}
keyboard_seteventhandler(keyhandler);
keyboard_seteventhandler (keyhandler);
}
static void
IN_init_mouse()
IN_InitMouse (void)
{
int mtype;
char *mousedev;
int mouserate = MOUSE_DEFAULTSAMPLERATE;
int mtype;
char *mousedev;
int mouserate = MOUSE_DEFAULTSAMPLERATE;
Cmd_AddCommand("force_centerview", Force_CenterView_f, "No Description");
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "Force viewpoint of player to center");
mouse_buttons = 3;
mtype = vga_getmousetype();
mtype = vga_getmousetype ();
mousedev = "/dev/mouse";
if (getenv("MOUSEDEV")) mousedev = getenv("MOUSEDEV");
if (COM_CheckParm("-mdev")) {
mousedev = com_argv[COM_CheckParm("-mdev")+1];
if (getenv ("MOUSEDEV"))
mousedev = getenv ("MOUSEDEV");
if (COM_CheckParm ("-mdev")) {
mousedev = com_argv[COM_CheckParm ("-mdev") + 1];
}
if (getenv("MOUSERATE")) mouserate = atoi(getenv("MOUSERATE"));
if (COM_CheckParm("-mrate")) {
mouserate = atoi(com_argv[COM_CheckParm("-mrate")+1]);
if (getenv ("MOUSERATE"))
mouserate = atoi (getenv ("MOUSERATE"));
if (COM_CheckParm ("-mrate")) {
mouserate = atoi (com_argv[COM_CheckParm ("-mrate") + 1]);
}
#if 0
printf("Mouse: dev=%s,type=%s,speed=%d\n",
mousedev, mice[mtype].name, mouserate);
printf ("Mouse: dev=%s,type=%s,speed=%d\n",
mousedev, mice[mtype].name, mouserate);
#endif
if (mouse_init(mousedev, mtype, mouserate)) {
Con_Printf("No mouse found\n");
if (mouse_init (mousedev, mtype, mouserate)) {
Con_Printf ("No mouse found\n");
UseMouse = 0;
} else{
mouse_seteventhandler((void*)mousehandler);
} else {
mouse_seteventhandler ((void *) mousehandler);
}
}
void IN_Shutdown(void)
void
IN_Shutdown (void)
{
JOY_Shutdown ();
Con_Printf("IN_Shutdown\n");
Con_Printf ("IN_Shutdown\n");
if (UseMouse) mouse_close();
if (UseKeyboard) keyboard_close();
if (UseMouse)
mouse_close ();
if (UseKeyboard)
keyboard_close ();
in_svgalib_inited = 0;
}
void IN_SendKeyEvents(void)
void
IN_SendKeyEvents (void)
{
if (!in_svgalib_inited) return;
if (!in_svgalib_inited)
return;
if (UseKeyboard) {
while ((keyboard_update()));
while ((keyboard_update ()));
}
}
void IN_Commands(void)
void
IN_Commands (void)
{
JOY_Command ();
if (UseMouse) {
/* Poll mouse values */
while (mouse_update())
;
while (mouse_update ());
/* Perform button actions */
if ((mouse_buttonstate & MOUSE_LEFTBUTTON) &&
!(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
Key_Event (K_MOUSE1, true);
Key_Event (K_MOUSE1, 0, true);
else if (!(mouse_buttonstate & MOUSE_LEFTBUTTON) &&
(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
Key_Event (K_MOUSE1, false);
(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
Key_Event (K_MOUSE1, 0, false);
if ((mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
!(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
Key_Event (K_MOUSE2, true);
Key_Event (K_MOUSE2, 0, true);
else if (!(mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
Key_Event (K_MOUSE2, false);
(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
Key_Event (K_MOUSE2, 0, false);
if ((mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
!(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
Key_Event (K_MOUSE3, true);
Key_Event (K_MOUSE3, 0, true);
else if (!(mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
Key_Event (K_MOUSE3, false);
(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
Key_Event (K_MOUSE3, 0, false);
mouse_oldbuttonstate = mouse_buttonstate;
}
}
void IN_Move(usercmd_t *cmd)
void
IN_Move (usercmd_t *cmd)
{
JOY_Move (cmd);
if (!UseMouse) return;
if (!UseMouse)
return;
/* Poll mouse values */
while (mouse_update())
;
while (mouse_update ());
if (m_filter->int_val) {
mouse_x = (mx + old_mouse_x) * 0.5;
@ -377,7 +387,7 @@ void IN_Move(usercmd_t *cmd)
}
if (freelook)
V_StopPitchDrift();
V_StopPitchDrift ();
if (freelook && !(in_strafe.state & 1)) {
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
@ -391,7 +401,7 @@ void IN_Move(usercmd_t *cmd)
}
}
void
void
IN_HandlePause (qboolean paused)
{
}

View file

@ -29,186 +29,268 @@
$Id$
*/
#define _BSD
#include <config.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#define _BSD
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <X11/Xlib.h>
#include <X11/keysym.h>
#ifdef HAVE_DGA
#include <X11/extensions/XShm.h>
#include <X11/extensions/xf86dga.h>
# include <X11/extensions/XShm.h>
# include <X11/extensions/xf86dga.h>
#endif
#include "dga_check.h"
#include "d_local.h"
#include "sound.h"
#include "keys.h"
#include "cvar.h"
#include "sys.h"
#include "cmd.h"
#include "draw.h"
#include "compat.h"
#include "console.h"
#include "client.h"
#include "console.h"
#include "context_x11.h"
#include "cmd.h"
#include "cvar.h"
#include "dga_check.h"
#include "host.h"
#include "input.h"
#include "joystick.h"
#include "keys.h"
#include "qargs.h"
#include "sys.h"
#include "view.h"
cvar_t *_windowed_mouse;
cvar_t *m_filter;
cvar_t *_windowed_mouse;
cvar_t *m_filter;
cvar_t *in_dga;
cvar_t *in_dga_mouseaccel;
cvar_t *in_dga;
cvar_t *in_dga_mouseaccel;
static qboolean dga_avail;
static qboolean dga_active;
static qboolean mouse_avail;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int p_mouse_x, p_mouse_y;
static keydest_t old_key_dest = key_none;
static qboolean mouse_avail;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int p_mouse_x, p_mouse_y;
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
#define INPUT_MASK (KEY_MASK | MOUSE_MASK)
static int
XLateKey(XKeyEvent *ev)
XLateKey (XKeyEvent * ev, qboolean modified)
{
int key = 0;
KeySym keysym;
char tmp[2];
int key = 0;
KeySym keysym;
keysym = XLookupKeysym(ev, 0);
if (!modified) {
keysym = XLookupKeysym (ev, 0);
} else {
XLookupString (ev, tmp, 1, &keysym, NULL);
}
switch(keysym) {
case XK_KP_Page_Up: key = KP_PGUP; break;
case XK_Page_Up: key = K_PGUP; break;
switch (keysym) {
case XK_KP_Page_Up:
key = KP_PGUP;
break;
case XK_Page_Up:
key = K_PGUP;
break;
case XK_KP_Page_Down: key = KP_PGDN; break;
case XK_Page_Down: key = K_PGDN; break;
case XK_KP_Page_Down:
key = KP_PGDN;
break;
case XK_Page_Down:
key = K_PGDN;
break;
case XK_KP_Home: key = KP_HOME; break;
case XK_Home: key = K_HOME; break;
case XK_KP_Home:
key = KP_HOME;
break;
case XK_Home:
key = K_HOME;
break;
case XK_KP_End: key = KP_END; break;
case XK_End: key = K_END; break;
case XK_KP_End:
key = KP_END;
break;
case XK_End:
key = K_END;
break;
case XK_KP_Left: key = KP_LEFTARROW; break;
case XK_Left: key = K_LEFTARROW; break;
case XK_KP_Left:
key = KP_LEFTARROW;
break;
case XK_Left:
key = K_LEFTARROW;
break;
case XK_KP_Right: key = KP_RIGHTARROW; break;
case XK_Right: key = K_RIGHTARROW; break;
case XK_KP_Right:
key = KP_RIGHTARROW;
break;
case XK_Right:
key = K_RIGHTARROW;
break;
case XK_KP_Down: key = KP_DOWNARROW; break;
case XK_Down: key = K_DOWNARROW; break;
case XK_KP_Down:
key = KP_DOWNARROW;
break;
case XK_Down:
key = K_DOWNARROW;
break;
case XK_KP_Up: key = KP_UPARROW; break;
case XK_Up: key = K_UPARROW; break;
case XK_KP_Up:
key = KP_UPARROW;
break;
case XK_Up:
key = K_UPARROW;
break;
case XK_Escape: key = K_ESCAPE; break;
case XK_Escape:
key = K_ESCAPE;
break;
case XK_KP_Enter: key = KP_ENTER; break;
case XK_Return: key = K_ENTER; break;
case XK_KP_Enter:
key = KP_ENTER;
break;
case XK_Return:
key = K_ENTER;
break;
case XK_Tab: key = K_TAB; break;
case XK_Tab:
key = K_TAB;
break;
case XK_F1: key = K_F1; break;
case XK_F2: key = K_F2; break;
case XK_F3: key = K_F3; break;
case XK_F4: key = K_F4; break;
case XK_F5: key = K_F5; break;
case XK_F6: key = K_F6; break;
case XK_F7: key = K_F7; break;
case XK_F8: key = K_F8; break;
case XK_F9: key = K_F9; break;
case XK_F10: key = K_F10; break;
case XK_F11: key = K_F11; break;
case XK_F12: key = K_F12; break;
case XK_F1:
key = K_F1;
break;
case XK_F2:
key = K_F2;
break;
case XK_F3:
key = K_F3;
break;
case XK_F4:
key = K_F4;
break;
case XK_F5:
key = K_F5;
break;
case XK_F6:
key = K_F6;
break;
case XK_F7:
key = K_F7;
break;
case XK_F8:
key = K_F8;
break;
case XK_F9:
key = K_F9;
break;
case XK_F10:
key = K_F10;
break;
case XK_F11:
key = K_F11;
break;
case XK_F12:
key = K_F12;
break;
case XK_BackSpace: key = K_BACKSPACE; break;
case XK_BackSpace:
key = K_BACKSPACE;
break;
case XK_KP_Delete: key = KP_DEL; break;
case XK_Delete: key = K_DEL; break;
case XK_KP_Delete:
key = KP_DEL;
break;
case XK_Delete:
key = K_DEL;
break;
case XK_Pause: key = K_PAUSE; break;
case XK_Pause:
key = K_PAUSE;
break;
case XK_Shift_L:
case XK_Shift_R: key = K_SHIFT; break;
case XK_Shift_R:
key = K_SHIFT;
break;
case XK_Execute:
case XK_Control_L:
case XK_Control_R: key = K_CTRL; break;
case XK_Control_R:
key = K_CTRL;
break;
case XK_Mode_switch:
case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R: key = K_ALT; break;
case XK_Meta_R:
key = K_ALT;
break;
case XK_Caps_Lock: key = K_CAPSLOCK; break;
case XK_KP_Begin: key = KP_5; break;
case XK_Caps_Lock:
key = K_CAPSLOCK;
break;
case XK_KP_Begin:
key = KP_5;
break;
case XK_Insert: key = K_INS; break;
case XK_KP_Insert: key = KP_INS; break;
case XK_Insert:
key = K_INS;
break;
case XK_KP_Insert:
key = KP_INS;
break;
case XK_KP_Multiply: key = KP_MULTIPLY; break;
case XK_KP_Add: key = KP_PLUS; break;
case XK_KP_Subtract: key = KP_MINUS; break;
case XK_KP_Divide: key = KP_DIVIDE; break;
case XK_KP_Multiply:
key = KP_MULTIPLY;
break;
case XK_KP_Add:
key = KP_PLUS;
break;
case XK_KP_Subtract:
key = KP_MINUS;
break;
case XK_KP_Divide:
key = KP_DIVIDE;
break;
/* For Sun keyboards */
case XK_F27: key = K_HOME; break;
case XK_F29: key = K_PGUP; break;
case XK_F33: key = K_END; break;
case XK_F35: key = K_PGDN; break;
/* For Sun keyboards */
case XK_F27:
key = K_HOME;
break;
case XK_F29:
key = K_PGUP;
break;
case XK_F33:
key = K_END;
break;
case XK_F35:
key = K_PGDN;
break;
#if 0
case 0x021: key = '1';break;/* [!] */
case 0x040: key = '2';break;/* [@] */
case 0x023: key = '3';break;/* [#] */
case 0x024: key = '4';break;/* [$] */
case 0x025: key = '5';break;/* [%] */
case 0x05e: key = '6';break;/* [^] */
case 0x026: key = '7';break;/* [&] */
case 0x02a: key = '8';break;/* [*] */
case 0x028: key = '9';;break;/* [(] */
case 0x029: key = '0';break;/* [)] */
case 0x05f: key = '-';break;/* [_] */
case 0x02b: key = '=';break;/* [+] */
case 0x07c: key = '\'';break;/* [|] */
case 0x07d: key = '[';break;/* [}] */
case 0x07b: key = ']';break;/* [{] */
case 0x022: key = '\'';break;/* ["] */
case 0x03a: key = ';';break;/* [:] */
case 0x03f: key = '/';break;/* [?] */
case 0x03e: key = '.';break;/* [>] */
case 0x03c: key = ',';break;/* [<] */
#endif
default:
if (keysym < 128) {
/* ASCII keys */
key = keysym;
if (key >= 'A' && key <= 'Z') {
if (!modified && ((key >= 'A') && (key <= 'Z'))) {
key = key + ('a' - 'A');
}
}
@ -220,72 +302,77 @@ XLateKey(XKeyEvent *ev)
static void
event_key (XEvent *event)
event_key (XEvent * event)
{
Key_Event (XLateKey (&event->xkey), event->type == KeyPress);
if (old_key_dest != key_dest) {
old_key_dest = key_dest;
if (key_dest == key_game) {
XAutoRepeatOff (x_disp);
} else {
XAutoRepeatOn (x_disp);
}
}
Key_Event (XLateKey (&event->xkey, 0), XLateKey (&event->xkey, 1),
event->type == KeyPress);
}
static void
event_button (XEvent *event)
event_button (XEvent * event)
{
int but;
int but;
but = event->xbutton.button;
if (but == 2) but = 3;
else if (but == 3) but = 2;
switch(but) {
if (but == 2)
but = 3;
else if (but == 3)
but = 2;
switch (but) {
case 1:
case 2:
case 3:
Key_Event(K_MOUSE1 + but - 1, event->type == ButtonPress);
Key_Event (K_MOUSE1 + but - 1, 0, event->type == ButtonPress);
break;
case 4:
Key_Event(K_MWHEELUP, 1);
Key_Event(K_MWHEELUP, 0);
Key_Event (K_MWHEELUP, 0, event->type == ButtonPress);
break;
case 5:
Key_Event(K_MWHEELDOWN, 1);
Key_Event(K_MWHEELDOWN, 0);
Key_Event (K_MWHEELDOWN, 0, event->type == ButtonPress);
break;
}
}
static void
center_pointer(void)
center_pointer (void)
{
XEvent event;
XEvent event;
event.type = MotionNotify;
event.xmotion.display = x_disp;
event.xmotion.window = x_win;
event.xmotion.x = vid.width / 2;
event.xmotion.y = vid.height / 2;
XSendEvent(x_disp, x_win, False, PointerMotionMask, &event);
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
vid.width / 2, vid.height / 2);
XSendEvent (x_disp, x_win, False, PointerMotionMask, &event);
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0,
vid.width / 2, vid.height / 2);
}
static void
event_motion (XEvent *event)
event_motion (XEvent * event)
{
if (dga_active) {
mouse_x += event->xmotion.x_root * in_dga_mouseaccel->value;
mouse_y += event->xmotion.y_root * in_dga_mouseaccel->value;
} else {
if (!p_mouse_x && !p_mouse_y) {
Con_Printf("event->xmotion.x: %d\n", event->xmotion.x);
Con_Printf("event->xmotion.y: %d\n", event->xmotion.y);
}
if (vid_fullscreen->int_val || _windowed_mouse->int_val) {
if (!event->xmotion.send_event) {
mouse_x += (event->xmotion.x - p_mouse_x);
mouse_y += (event->xmotion.y - p_mouse_y);
if (abs(vid.width/2 - event->xmotion.x) > vid.width / 4
|| abs(vid.height/2 - event->xmotion.y) > vid.height / 4) {
center_pointer();
if (abs (vid.width / 2 - event->xmotion.x) > vid.width / 4
|| abs (vid.height / 2 - event->xmotion.y) > vid.height / 4) {
center_pointer ();
}
}
} else {
@ -301,8 +388,8 @@ event_motion (XEvent *event)
void
IN_Commands (void)
{
static int old_windowed_mouse;
static int old_in_dga;
static int old_windowed_mouse;
static int old_in_dga;
JOY_Command ();
@ -311,9 +398,9 @@ IN_Commands (void)
old_windowed_mouse = _windowed_mouse->int_val;
old_in_dga = in_dga->int_val;
if (_windowed_mouse->int_val) { // grab the pointer
if (_windowed_mouse->int_val) { // grab the pointer
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime);
GrabModeAsync, x_win, None, CurrentTime);
#ifdef HAVE_DGA
if (dga_avail && in_dga->int_val && !dga_active) {
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp),
@ -321,7 +408,7 @@ IN_Commands (void)
dga_active = true;
}
#endif
} else { // ungrab the pointer
} else { // ungrab the pointer
#ifdef HAVE_DGA
if (dga_avail && in_dga->int_val && dga_active) {
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
@ -338,7 +425,7 @@ void
IN_SendKeyEvents (void)
{
/* Get events from X server. */
x11_process_events();
x11_process_events ();
}
@ -346,7 +433,7 @@ void
IN_Move (usercmd_t *cmd)
{
JOY_Move (cmd);
if (!mouse_avail)
return;
@ -365,7 +452,7 @@ IN_Move (usercmd_t *cmd)
cmd->sidemove += m_side->value * mouse_x;
else
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
if (freelook)
V_StopPitchDrift ();
@ -395,10 +482,17 @@ IN_Shutdown (void)
XAutoRepeatOn (x_disp);
#ifdef HAVE_DGA
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
if (dga_avail)
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
#endif
}
x11_close_display();
x11_close_display ();
}
void
Force_CenterView_f (void)
{
cl.viewangles[PITCH] = 0;
}
void
@ -406,29 +500,30 @@ IN_Init (void)
{
// open the display
if (!x_disp)
Sys_Error("IN: No display!!\n");
Sys_Error ("IN: No display!!\n");
if (!x_win)
Sys_Error("IN: No window!!\n");
Sys_Error ("IN: No window!!\n");
x11_open_display (); // call to increment the reference counter
x11_open_display (); // call to increment the reference
// counter
{
int attribmask = CWEventMask;
int attribmask = CWEventMask;
XWindowAttributes attribs_1;
XSetWindowAttributes attribs_2;
XGetWindowAttributes(x_disp, x_win, &attribs_1);
XGetWindowAttributes (x_disp, x_win, &attribs_1);
attribs_2.event_mask = attribs_1.your_event_mask | INPUT_MASK;
XChangeWindowAttributes(x_disp, x_win, attribmask, &attribs_2);
XChangeWindowAttributes (x_disp, x_win, attribmask, &attribs_2);
}
JOY_Init ();
XAutoRepeatOff (x_disp);
if (COM_CheckParm("-nomouse"))
if (COM_CheckParm ("-nomouse"))
return;
dga_avail = VID_CheckDGA (x_disp, NULL, NULL, NULL);
@ -440,27 +535,27 @@ IN_Init (void)
mouse_x = mouse_y = 0.0;
mouse_avail = 1;
x11_add_event(KeyPress, &event_key);
x11_add_event(KeyRelease, &event_key);
x11_add_event(ButtonPress, &event_button);
x11_add_event(ButtonRelease, &event_button);
x11_add_event(MotionNotify, &event_motion);
x11_add_event (KeyPress, &event_key);
x11_add_event (KeyRelease, &event_key);
x11_add_event (ButtonPress, &event_button);
x11_add_event (ButtonRelease, &event_button);
x11_add_event (MotionNotify, &event_motion);
return;
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "Force view of player to center");
}
void
IN_Init_Cvars (void)
{
JOY_Init_Cvars ();
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None");
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "With this set to 1, quake will grab the mouse from X");
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "Toggle mouse input filtering.");
in_dga = Cvar_Get ("in_dga", "1", CVAR_ARCHIVE, "DGA Input support");
in_dga_mouseaccel = Cvar_Get ("in_dga_mouseaccel", "1", CVAR_ARCHIVE,
"None");
"DGA Mouse accelleration multiplier");
}
void
void
IN_HandlePause (qboolean paused)
{
}

View file

@ -35,7 +35,6 @@
#include <fcntl.h>
#include <unistd.h>
#include "compat.h"
#include "console.h"
#include "client.h"
#include "cvar.h"
@ -46,30 +45,30 @@
#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
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;
qboolean joy_found = false;
qboolean joy_active = false;
// Variables and structures for this driver
int joy_handle;
int joy_handle;
typedef struct {
char *name;
char *string;
char *name;
char *string;
} ocvar_t;
struct joy_axis {
cvar_t *axis;
ocvar_t var;
int current;
cvar_t *axis;
ocvar_t var;
int current;
};
struct joy_button {
int old;
int current;
int old;
int current;
};
struct joy_axis joy_axes[JOY_MAX_AXES] = {
@ -93,19 +92,21 @@ JOY_Command (void)
while (read (joy_handle, &event, sizeof (struct js_event)) > -1) {
if (event.type & JS_EVENT_BUTTON) {
if(event.number >= JOY_MAX_BUTTONS)
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, true);
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, false);
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;
joy_buttons[event.number].old = joy_buttons[event.number].current;
} else {
if (event.type & JS_EVENT_AXIS) {
if (event.number >= JOY_MAX_AXES)
@ -119,8 +120,8 @@ JOY_Command (void)
void
JOY_Move (usercmd_t *cmd)
{
int i;
int i;
if (!joy_active || !joy_enable->int_val)
return;
@ -128,19 +129,33 @@ JOY_Move (usercmd_t *cmd)
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)));
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)));
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)));
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);
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;
}
@ -151,13 +166,14 @@ void
JOY_Init (void)
{
// Open joystick device
joy_handle = open (joy_device->string, O_RDONLY|O_NONBLOCK);
joy_handle = open (joy_device->string, O_RDONLY | O_NONBLOCK);
if (joy_handle < 0) {
Con_Printf ("JOY: Joystick not found.\n");
} else {
int i;
int i;
joy_found = true;
if (!joy_enable->int_val) {
Con_Printf ("JOY: Joystick found, but not enabled.\n");
i = close (joy_handle);
@ -179,23 +195,29 @@ JOY_Init (void)
void
JOY_Init_Cvars (void)
{
int i;
int i;
joy_device = Cvar_Get ("joy_device", "/dev/js0", CVAR_NONE|CVAR_ROM, "Joystick device");
joy_enable = Cvar_Get ("joy_enable", "1", CVAR_NONE|CVAR_ARCHIVE, "Joystick enable flag");
joy_sensitivity = Cvar_Get ("joy_sensitivity", "1", CVAR_NONE|CVAR_ARCHIVE, "Joystick sensitivity");
joy_device =
Cvar_Get ("joy_device", "/dev/js0", CVAR_NONE | CVAR_ROM,
"Joystick device");
joy_enable =
Cvar_Get ("joy_enable", "1", CVAR_NONE | CVAR_ARCHIVE,
"Joystick enable flag");
joy_sensitivity =
Cvar_Get ("joy_sensitivity", "1", CVAR_NONE | CVAR_ARCHIVE,
"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, "None");
joy_axes[i].var.string,
CVAR_ARCHIVE, "Set joystick axes");
}
}
void
JOY_Shutdown (void)
{
int i;
int i;
if (!joy_active)
return;

File diff suppressed because it is too large Load diff

View file

@ -919,10 +919,18 @@ COM_CreateGameDirectory (char *gamename)
}
/*
COM_InitFilesystem
COM_Filesystem_Init_Cvars
*/
void
COM_InitFilesystem ( void )
COM_Filesystem_Init_Cvars (void)
{
}
/*
COM_Filesystem_Init
*/
void
COM_Filesystem_Init ( void )
{
int i;

View file

@ -543,9 +543,7 @@ void SCR_SetUpToDrawConsole (void)
return; // never a console with loading plaque
// decide on the height of the console
con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;
if (con_forcedup)
if (!cl.worldmodel || cls.signon != SIGNONS)
{
scr_conlines = vid.height; // full screen
scr_con_current = scr_conlines;
@ -853,7 +851,7 @@ int SCR_ModalMessage (char *text)
do
{
key_count = -1; // wait for a key down and up
//key_count = -1; // wait for a key down and up
IN_SendKeyEvents ();
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);

View file

@ -122,7 +122,7 @@ extern vrect_t scr_vrect;
void V_RenderView (void)
{
if (con_forcedup)
if (!cl.worldmodel || cls.signon != SIGNONS)
return;
// don't allow cheats in multiplayer