2001-04-15 04:18:22 +00:00
|
|
|
/*
|
|
|
|
in_sdl.c
|
|
|
|
|
|
|
|
general sdl input driver
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
2002-08-21 06:06:05 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/joystick.h"
|
|
|
|
#include "QF/keys.h"
|
2001-04-16 03:55:44 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/qargs.h"
|
2002-08-21 06:06:05 +00:00
|
|
|
#include "QF/sound.h"
|
2001-08-27 01:00:03 +00:00
|
|
|
#include "QF/sys.h"
|
2001-04-16 03:55:44 +00:00
|
|
|
#include "QF/vid.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-08-27 01:00:03 +00:00
|
|
|
#include "compat.h"
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
int in_snd_block;
|
|
|
|
static cvar_t in_snd_block_cvar = {
|
|
|
|
.name = "in_snd_block",
|
|
|
|
.description =
|
|
|
|
"block sound output on window focus loss",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &in_snd_block },
|
|
|
|
};
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2012-01-20 20:01:05 +00:00
|
|
|
static int have_focus = 1;
|
2002-08-29 04:00:30 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-08-21 06:06:05 +00:00
|
|
|
static void
|
|
|
|
event_focusout (void)
|
|
|
|
{
|
2005-03-06 08:22:15 +00:00
|
|
|
if (have_focus) {
|
|
|
|
have_focus = 0;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (in_snd_block) {
|
2005-03-06 08:22:15 +00:00
|
|
|
S_BlockSound ();
|
|
|
|
CDAudio_Pause ();
|
|
|
|
}
|
2002-08-21 06:06:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
event_focusin (void)
|
|
|
|
{
|
2005-03-06 08:22:15 +00:00
|
|
|
have_focus = 1;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (in_snd_block) {
|
2002-08-21 06:06:05 +00:00
|
|
|
S_UnblockSound ();
|
|
|
|
CDAudio_Resume ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-14 03:53:42 +00:00
|
|
|
static void
|
2021-08-02 05:02:41 +00:00
|
|
|
sdl_keydest_callback (keydest_t key_dest, void *data)
|
2013-01-14 03:53:42 +00:00
|
|
|
{
|
|
|
|
if (key_dest == key_game)
|
|
|
|
SDL_EnableKeyRepeat (0, SDL_DEFAULT_REPEAT_INTERVAL);
|
|
|
|
else
|
|
|
|
SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY,
|
|
|
|
SDL_DEFAULT_REPEAT_INTERVAL);
|
|
|
|
}
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
void
|
2003-04-08 18:45:12 +00:00
|
|
|
IN_LL_ProcessEvents (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
SDL_Event event;
|
|
|
|
int sym, state, but;
|
2001-08-16 09:19:36 +00:00
|
|
|
knum_t ksym;
|
|
|
|
short unicode;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-08-29 04:00:30 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
while (SDL_PollEvent (&event)) {
|
|
|
|
switch (event.type) {
|
2002-08-21 06:06:05 +00:00
|
|
|
case SDL_ACTIVEEVENT:
|
|
|
|
if (event.active.state == SDL_APPINPUTFOCUS) {
|
|
|
|
if (event.active.gain)
|
|
|
|
event_focusin ();
|
|
|
|
else
|
|
|
|
event_focusout ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
case SDL_KEYDOWN:
|
|
|
|
case SDL_KEYUP:
|
|
|
|
sym = event.key.keysym.sym;
|
|
|
|
state = event.key.state;
|
2001-08-16 09:19:36 +00:00
|
|
|
unicode = event.key.keysym.unicode;
|
2001-04-15 04:18:22 +00:00
|
|
|
switch (sym) {
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_UNKNOWN:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_UNKNOWN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_BACKSPACE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_BACKSPACE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_TAB:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_TAB;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_CLEAR:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_CLEAR;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_RETURN:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RETURN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_PAUSE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_PAUSE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_ESCAPE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_ESCAPE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_SPACE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_SPACE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_EXCLAIM:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_EXCLAIM;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_QUOTEDBL:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_QUOTEDBL;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_HASH:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_HASH;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_DOLLAR:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_DOLLAR;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_AMPERSAND:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_AMPERSAND;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_QUOTE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_QUOTE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_LEFTPAREN:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LEFTPAREN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_RIGHTPAREN:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RIGHTPAREN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_ASTERISK:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_ASTERISK;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_PLUS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_PLUS;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_COMMA:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_COMMA;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_MINUS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_MINUS;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_PERIOD:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_PERIOD;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_SLASH:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_SLASH;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_0:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_0;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_1:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_1;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_2:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_2;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_3:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_3;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_4:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_4;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_5:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_5;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_6:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_6;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_7:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_7;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_8:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_8;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_9:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_9;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_COLON:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_COLON;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_SEMICOLON:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_SEMICOLON;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LESS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LESS;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_EQUALS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_EQUALS;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_GREATER:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_GREATER;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_QUESTION:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_QUESTION;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_AT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_AT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LEFTBRACKET:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LEFTBRACKET;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_BACKSLASH:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_BACKSLASH;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_RIGHTBRACKET:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RIGHTBRACKET;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_CARET:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_CARET;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_UNDERSCORE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_UNDERSCORE;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_BACKQUOTE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_BACKQUOTE;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_a:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_a;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_b:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_b;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_c:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_c;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_d:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_d;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_e:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_e;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_f:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_f;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_g:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_g;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_h:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_h;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_i:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_i;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_j:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_j;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_k:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_k;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_l:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_l;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_m:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_m;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_n:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_n;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_o:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_o;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_p:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_p;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_q:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_q;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_r:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_r;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_s:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_s;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_t:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_t;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_u:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_u;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_v:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_v;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_w:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_w;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_x:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_x;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_y:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_y;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_z:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_z;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_DELETE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_DELETE;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
case SDLK_KP0:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP0;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP1:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP1;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP2:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP2;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP3:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP3;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP4:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP4;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP5:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP5;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP6:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP6;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP7:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP7;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP8:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP8;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP9:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP9;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_PERIOD:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_PERIOD;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_DIVIDE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_DIVIDE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_MULTIPLY:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_MULTIPLY;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_MINUS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_MINUS;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_PLUS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_PLUS;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_ENTER:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_ENTER;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case SDLK_KP_EQUALS:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_KP_EQUALS;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_UP:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_UP;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_DOWN:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_DOWN;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_RIGHT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RIGHT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LEFT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LEFT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_INSERT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_INSERT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_HOME:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_HOME;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_END:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_END;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_PAGEUP:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_PAGEUP;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_PAGEDOWN:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_PAGEDOWN;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F1:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F1;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F2:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F2;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F3:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F3;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F4:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F4;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F5:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F5;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F6:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F6;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F7:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F7;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F8:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F8;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F9:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F9;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F10:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F10;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F11:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F11;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F12:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F12;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F13:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F13;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F14:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F14;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_F15:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_F15;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_NUMLOCK:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_NUMLOCK;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_CAPSLOCK:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_CAPSLOCK;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_SCROLLOCK:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_SCROLLOCK;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_RSHIFT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RSHIFT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LSHIFT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LSHIFT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_RCTRL:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RCTRL;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LCTRL:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LCTRL;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_RALT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RALT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LALT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LALT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_RMETA:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RMETA;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_LMETA:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LMETA;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
2012-08-18 12:44:51 +00:00
|
|
|
#ifndef SDLK_LSUPER //FIXME need a better check
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_LSUPER:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_LSUPER;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
2012-08-18 12:44:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef SDLK_RSUPER //FIXME need a better check
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_RSUPER:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_RSUPER;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
2012-08-18 12:44:51 +00:00
|
|
|
#endif
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_MODE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_MODE;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_COMPOSE:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_COMPOSE;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_HELP:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_HELP;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_PRINT:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_PRINT;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_SYSREQ:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_SYSREQ;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_BREAK:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_BREAK;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_MENU:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_MENU;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
|
|
|
case SDLK_POWER:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_POWER;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
2012-08-18 12:44:51 +00:00
|
|
|
#ifndef SDLK_EURO //FIXME need a better check
|
2001-08-16 09:19:36 +00:00
|
|
|
case SDLK_EURO:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_EURO;
|
2001-08-16 09:19:36 +00:00
|
|
|
break;
|
2012-08-18 12:44:51 +00:00
|
|
|
#endif
|
2006-12-01 06:58:23 +00:00
|
|
|
case SDLK_UNDO:
|
|
|
|
ksym = QFK_UNDO;
|
|
|
|
break;
|
2012-08-18 12:44:51 +00:00
|
|
|
// case SDLK_LAST:
|
|
|
|
// ksym = QFK_LAST;
|
|
|
|
// break;
|
2001-08-16 09:19:36 +00:00
|
|
|
default:
|
2001-10-28 04:23:37 +00:00
|
|
|
ksym = QFK_UNKNOWN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-08-16 09:19:36 +00:00
|
|
|
if (unicode > 255)
|
|
|
|
unicode = 0;
|
2002-10-05 02:21:44 +00:00
|
|
|
Key_Event (ksym, unicode, state);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
but = event.button.button;
|
2012-07-02 07:49:23 +00:00
|
|
|
if ((unsigned) but > 32)
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
if (but == 2)
|
|
|
|
but = 3;
|
|
|
|
else if (but == 3)
|
|
|
|
but = 2;
|
|
|
|
|
|
|
|
switch (but) {
|
2012-07-02 07:49:23 +00:00
|
|
|
default:
|
2001-10-28 04:23:37 +00:00
|
|
|
Key_Event (QFM_BUTTON1 + but - 1, 0,
|
2001-08-16 09:19:36 +00:00
|
|
|
event.type == SDL_MOUSEBUTTONDOWN);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2002-08-21 06:06:05 +00:00
|
|
|
Key_Event (QFM_WHEEL_UP, 0,
|
|
|
|
event.type == SDL_MOUSEBUTTONDOWN);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-08-21 06:06:05 +00:00
|
|
|
Key_Event (QFM_WHEEL_DOWN, 0,
|
|
|
|
event.type == SDL_MOUSEBUTTONDOWN);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEMOTION:
|
2001-08-06 00:16:48 +00:00
|
|
|
in_mouse_x += event.motion.xrel;
|
|
|
|
in_mouse_y += event.motion.yrel;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_QUIT:
|
|
|
|
Sys_Quit ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-07 03:55:51 +00:00
|
|
|
void
|
|
|
|
IN_LL_Grab_Input (int grab)
|
2001-08-30 20:04:13 +00:00
|
|
|
{
|
2003-03-07 03:55:51 +00:00
|
|
|
static int input_grabbed = 0;
|
2001-08-30 20:04:13 +00:00
|
|
|
|
2003-03-07 03:55:51 +00:00
|
|
|
if ((input_grabbed && grab) || (!input_grabbed && !grab))
|
|
|
|
return;
|
|
|
|
input_grabbed = (SDL_GRAB_ON == SDL_WM_GrabInput (grab ? SDL_GRAB_ON
|
|
|
|
: SDL_GRAB_OFF));
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-16 03:55:44 +00:00
|
|
|
IN_LL_Init (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
2002-08-21 06:06:05 +00:00
|
|
|
SDL_EnableUNICODE (1); // Enable UNICODE translation for keyboard input
|
2001-08-16 09:19:36 +00:00
|
|
|
|
2021-08-02 05:02:41 +00:00
|
|
|
Key_KeydestCallback (sdl_keydest_callback, 0);
|
2002-08-21 06:06:05 +00:00
|
|
|
if (COM_CheckParm ("-nomouse"))
|
2001-04-15 04:18:22 +00:00
|
|
|
return;
|
|
|
|
|
2001-04-16 03:55:44 +00:00
|
|
|
in_mouse_x = in_mouse_y = 0.0;
|
|
|
|
in_mouse_avail = 1;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-16 03:55:44 +00:00
|
|
|
IN_LL_Init_Cvars (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&in_snd_block_cvar, 0, 0);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-16 03:55:44 +00:00
|
|
|
IN_LL_Shutdown (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
2001-04-16 03:55:44 +00:00
|
|
|
in_mouse_avail = 0;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 15:55:33 +00:00
|
|
|
void
|
|
|
|
IN_LL_ClearStates (void)
|
|
|
|
{
|
|
|
|
}
|