mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-22 12:31:32 +00:00
Organization, some fixes
This commit is contained in:
parent
4302b10e2b
commit
f484cb0d76
7 changed files with 108 additions and 79 deletions
|
@ -1259,26 +1259,31 @@ boolean CON_Responder(event_t *ev)
|
|||
return true;
|
||||
}
|
||||
|
||||
// allow people to use keypad in console (good for typing IP addresses) - Calum
|
||||
if (key >= KEY_KEYPAD7 && key <= KEY_KPADDEL)
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
if (!cv_textinput.value)
|
||||
#endif
|
||||
{
|
||||
char keypad_translation[] = {'7','8','9','-',
|
||||
'4','5','6','+',
|
||||
'1','2','3',
|
||||
'0','.'};
|
||||
// allow people to use keypad in console (good for typing IP addresses) - Calum
|
||||
if (key >= KEY_KEYPAD7 && key <= KEY_KPADDEL)
|
||||
{
|
||||
char keypad_translation[] = {'7','8','9','-',
|
||||
'4','5','6','+',
|
||||
'1','2','3',
|
||||
'0','.'};
|
||||
|
||||
key = keypad_translation[key - KEY_KEYPAD7];
|
||||
}
|
||||
else if (key == KEY_KPADSLASH)
|
||||
key = '/';
|
||||
key = keypad_translation[key - KEY_KEYPAD7];
|
||||
}
|
||||
else if (key == KEY_KPADSLASH)
|
||||
key = '/';
|
||||
|
||||
if (key >= 'a' && key <= 'z')
|
||||
{
|
||||
if (capslock ^ shiftdown)
|
||||
if (key >= 'a' && key <= 'z')
|
||||
{
|
||||
if (capslock ^ shiftdown)
|
||||
key = shiftxform[key];
|
||||
}
|
||||
else if (shiftdown)
|
||||
key = shiftxform[key];
|
||||
}
|
||||
else if (shiftdown)
|
||||
key = shiftxform[key];
|
||||
|
||||
// enter a char into the command prompt
|
||||
if (key < 32 || key > 127)
|
||||
|
|
|
@ -817,6 +817,22 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_joyscale);
|
||||
CV_RegisterVar(&cv_joyscale2);
|
||||
|
||||
// * cv_textinput allows "text input" events from SDL,
|
||||
// so that console and chat is guaranteed to use
|
||||
// the player's keyboard locale reliably
|
||||
// * When disabled, the game will fallback to using
|
||||
// keycode events, still following the player's locale
|
||||
// * If cv_keyboardlocale is disabled, input will default
|
||||
// to using the US keyboard layout
|
||||
// * cv_forceqwerty forces a QWERTY layout, but only
|
||||
// if text input events are disabled
|
||||
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
CV_RegisterVar (&cv_textinput);
|
||||
#endif
|
||||
CV_RegisterVar (&cv_keyboardlocale);
|
||||
CV_RegisterVar (&cv_forceqwerty);
|
||||
|
||||
// Analog Control
|
||||
CV_RegisterVar(&cv_analog[0]);
|
||||
CV_RegisterVar(&cv_analog[1]);
|
||||
|
|
|
@ -629,7 +629,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
|||
#define SECTORSPECIALSAFTERTHINK
|
||||
|
||||
/// Text input events
|
||||
//#define HAVE_TEXTINPUT
|
||||
#define HAVE_TEXTINPUT
|
||||
|
||||
/// Sprite rotation
|
||||
#define ROTSPRITE
|
||||
|
|
|
@ -19,6 +19,18 @@
|
|||
#include "d_net.h"
|
||||
#include "console.h"
|
||||
|
||||
static CV_PossibleValue_t keyboardlocale_cons_t[] = {
|
||||
{0, "Off"},
|
||||
{1, "On"},
|
||||
{2, "Only in text fields"},
|
||||
{0, NULL}};
|
||||
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
consvar_t cv_textinput = CVAR_INIT ("textinput", "On", CV_SAVE, CV_OnOff, NULL);
|
||||
#endif
|
||||
consvar_t cv_keyboardlocale = CVAR_INIT ("keyboardlocale", "Off", CV_SAVE, keyboardlocale_cons_t, NULL);
|
||||
consvar_t cv_forceqwerty = CVAR_INIT ("forceqwerty", "Off", CV_SAVE, CV_OnOff, NULL);
|
||||
|
||||
#define MAXMOUSESENSITIVITY 100 // sensitivity steps
|
||||
|
||||
static CV_PossibleValue_t mousesens_cons_t[] = {{1, "MIN"}, {MAXMOUSESENSITIVITY, "MAX"}, {0, NULL}};
|
||||
|
|
|
@ -111,6 +111,12 @@ typedef enum
|
|||
num_gamecontrolschemes
|
||||
} gamecontrolschemes_e;
|
||||
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
extern consvar_t cv_textinput;
|
||||
#endif
|
||||
extern consvar_t cv_keyboardlocale;
|
||||
extern consvar_t cv_forceqwerty;
|
||||
|
||||
// mouse values are used once
|
||||
extern consvar_t cv_mousesens, cv_mouseysens;
|
||||
extern consvar_t cv_mousesens2, cv_mouseysens2;
|
||||
|
|
|
@ -1167,17 +1167,22 @@ boolean HU_Responder(event_t *ev)
|
|||
|
||||
c = (INT32)ev->data1;
|
||||
|
||||
// I know this looks very messy but this works. If it ain't broke, don't fix it!
|
||||
// shift LETTERS to uppercase if we have capslock or are holding shift
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
if (!cv_textinput.value)
|
||||
#endif
|
||||
{
|
||||
if (shiftdown ^ capslock)
|
||||
c = shiftxform[c];
|
||||
}
|
||||
else // if we're holding shift we should still shift non letter symbols
|
||||
{
|
||||
if (shiftdown)
|
||||
c = shiftxform[c];
|
||||
// I know this looks very messy but this works. If it ain't broke, don't fix it!
|
||||
// shift LETTERS to uppercase if we have capslock or are holding shift
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
{
|
||||
if (shiftdown ^ capslock)
|
||||
c = shiftxform[c];
|
||||
}
|
||||
else // if we're holding shift we should still shift non letter symbols
|
||||
{
|
||||
if (shiftdown)
|
||||
c = shiftxform[c];
|
||||
}
|
||||
}
|
||||
|
||||
// pasting. pasting is cool. chat is a bit limited, though :(
|
||||
|
|
|
@ -107,13 +107,6 @@ static consvar_t cv_alwaysgrabmouse = CVAR_INIT ("alwaysgrabmouse", "Off", CV_SA
|
|||
|
||||
UINT8 graphics_started = 0; // Is used in console.c and screen.c
|
||||
|
||||
// Lactozilla: keyboard input
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
consvar_t cv_textinput = {"textinput", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
consvar_t cv_keyboardlocale = {"keyboardlocale", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_forceqwerty = {"forceqwerty", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// To disable fullscreen at startup; is set in VID_PrepareModeList
|
||||
boolean allow_fullscreen = false;
|
||||
static SDL_bool disable_fullscreen = SDL_FALSE;
|
||||
|
@ -279,16 +272,26 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool
|
|||
}
|
||||
}
|
||||
|
||||
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
||||
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Keysym keysym, Uint32 type)
|
||||
{
|
||||
boolean useqwerty = true;
|
||||
if (cv_keyboardlocale.value)
|
||||
{
|
||||
SDL_Keycode keycode = SDL_GetKeyFromScancode(code);
|
||||
SDL_Scancode scancode = keysym.scancode;
|
||||
SDL_Keycode keycode = keysym.sym;
|
||||
|
||||
// Lactozilla
|
||||
// Use keycodes instead of scancodes,
|
||||
// so that non-US keyboards can work! Wow!
|
||||
boolean useqwerty = true;
|
||||
boolean uselocale = (!!cv_keyboardlocale.value);
|
||||
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
if (cv_textinput.value)
|
||||
uselocale = true;
|
||||
#else
|
||||
if (cv_keyboardlocale.value == 2
|
||||
&& !(CON_AcceptInput() || M_TextInput() || HU_ChatActive()))
|
||||
uselocale = false;
|
||||
#endif
|
||||
|
||||
if (uselocale)
|
||||
{
|
||||
// Lactozilla: Use keycodes instead of scancodes, so that non-US keyboards can work.
|
||||
switch (keycode)
|
||||
{
|
||||
// F11 and F12 are separated from the rest of the function keys
|
||||
|
@ -332,13 +335,13 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
|||
return KEY_F1 + (keycode - SDLK_F1);
|
||||
}
|
||||
|
||||
// Do send keyup events to avoid stuck movement keys
|
||||
// Send key up events to avoid stuck movement keys
|
||||
if (type != SDL_KEYUP && (!ctrldown))
|
||||
{
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
if (cv_textinput.value)
|
||||
{
|
||||
// Lactozilla: console input
|
||||
// console input
|
||||
if (CON_AcceptInput())
|
||||
return 0;
|
||||
// menu text input
|
||||
|
@ -405,17 +408,16 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
|||
case SDLK_QUOTEDBL: return '"';
|
||||
case SDLK_RIGHTPAREN: return ')';
|
||||
case SDLK_UNDERSCORE: return '_';
|
||||
default: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Tested by installing a French keymap
|
||||
if (useqwerty)
|
||||
{
|
||||
if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
|
||||
return code - SDL_SCANCODE_A + 'a';
|
||||
else if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9)
|
||||
return code - SDL_SCANCODE_1 + '1';
|
||||
else if (code == SDL_SCANCODE_0)
|
||||
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z)
|
||||
return scancode - SDL_SCANCODE_A + 'a';
|
||||
else if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9)
|
||||
return scancode - SDL_SCANCODE_1 + '1';
|
||||
else if (scancode == SDL_SCANCODE_0)
|
||||
return '0';
|
||||
}
|
||||
else
|
||||
|
@ -430,7 +432,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
|||
}
|
||||
else
|
||||
{
|
||||
switch (code)
|
||||
switch (scancode)
|
||||
{
|
||||
// F11 and F12 are separated from the rest of the function keys
|
||||
case SDL_SCANCODE_F11: return KEY_F11;
|
||||
|
@ -469,18 +471,18 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
|||
default: break;
|
||||
}
|
||||
|
||||
if (code >= SDL_SCANCODE_F1 && code <= SDL_SCANCODE_F10)
|
||||
if (scancode >= SDL_SCANCODE_F1 && scancode <= SDL_SCANCODE_F10)
|
||||
{
|
||||
return KEY_F1 + (code - SDL_SCANCODE_F1);
|
||||
return KEY_F1 + (scancode - SDL_SCANCODE_F1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
// Do send keyup events to avoid stuck movement keys
|
||||
// Send key up events to avoid stuck movement keys
|
||||
if (type != SDL_KEYUP && (!ctrldown))
|
||||
{
|
||||
if (cv_textinput.value)
|
||||
{
|
||||
// Lactozilla: console input
|
||||
// console input
|
||||
if (CON_AcceptInput())
|
||||
return 0;
|
||||
// menu text input
|
||||
|
@ -493,7 +495,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
|||
}
|
||||
#endif
|
||||
|
||||
switch (code)
|
||||
switch (scancode)
|
||||
{
|
||||
case SDL_SCANCODE_KP_0: return KEY_KEYPAD0;
|
||||
case SDL_SCANCODE_KP_1: return KEY_KEYPAD1;
|
||||
|
@ -529,17 +531,16 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code, Uint32 type)
|
|||
default: break;
|
||||
}
|
||||
|
||||
// cv_forceqwerty assumed on
|
||||
if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
|
||||
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z)
|
||||
{
|
||||
// get lowercase ASCII
|
||||
return code - SDL_SCANCODE_A + 'a';
|
||||
return scancode - SDL_SCANCODE_A + 'a';
|
||||
}
|
||||
if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9)
|
||||
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9)
|
||||
{
|
||||
return code - SDL_SCANCODE_1 + '1';
|
||||
return scancode - SDL_SCANCODE_1 + '1';
|
||||
}
|
||||
else if (code == SDL_SCANCODE_0)
|
||||
else if (scancode == SDL_SCANCODE_0)
|
||||
{
|
||||
return '0';
|
||||
}
|
||||
|
@ -837,7 +838,7 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
|||
{
|
||||
return;
|
||||
}
|
||||
event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode, type);
|
||||
event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym, type);
|
||||
if (event.data1) D_PostEvent(&event);
|
||||
}
|
||||
|
||||
|
@ -1937,22 +1938,6 @@ void I_StartupGraphics(void)
|
|||
disable_mouse = M_CheckParm("-nomouse");
|
||||
disable_fullscreen = M_CheckParm("-win") ? 1 : 0;
|
||||
|
||||
// * cv_textinput allows "text input" events from SDL,
|
||||
// so that console and chat is guaranteed to use
|
||||
// the player's keyboard locale reliably
|
||||
// * When disabled, the game will fallback to using
|
||||
// keycode events, still following the player's locale
|
||||
// * If cv_keyboardlocale is disabled, input will default
|
||||
// to using the US keyboard layout
|
||||
// * cv_forceqwerty forces a QWERTY layout, but only
|
||||
// if text input events are disabled
|
||||
|
||||
#ifdef HAVE_TEXTINPUT
|
||||
CV_RegisterVar (&cv_textinput);
|
||||
#endif
|
||||
CV_RegisterVar (&cv_keyboardlocale);
|
||||
CV_RegisterVar (&cv_forceqwerty);
|
||||
|
||||
keyboard_started = true;
|
||||
|
||||
#if !defined(HAVE_TTF)
|
||||
|
|
Loading…
Reference in a new issue