mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-23 12:52:57 +00:00
Revert 6c701a9312
This commit is contained in:
parent
fa0c5cfd04
commit
a266fbb6a0
7 changed files with 105 additions and 74 deletions
|
@ -937,7 +937,7 @@ boolean CON_Responder(event_t *ev)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// let go keyup events, don't eat them
|
// let go keyup events, don't eat them
|
||||||
if (ev->type != ev_keydown && ev->type != ev_console)
|
if (ev->type != ev_keydown && ev->type != ev_text && ev->type != ev_console)
|
||||||
{
|
{
|
||||||
if (ev->key == gamecontrol[GC_CONSOLE][0] || ev->key == gamecontrol[GC_CONSOLE][1])
|
if (ev->key == gamecontrol[GC_CONSOLE][0] || ev->key == gamecontrol[GC_CONSOLE][1])
|
||||||
consdown = false;
|
consdown = false;
|
||||||
|
@ -964,7 +964,7 @@ boolean CON_Responder(event_t *ev)
|
||||||
// check other keys only if console prompt is active
|
// check other keys only if console prompt is active
|
||||||
if (!consoleready && key < NUMINPUTS) // metzgermeister: boundary check!!
|
if (!consoleready && key < NUMINPUTS) // metzgermeister: boundary check!!
|
||||||
{
|
{
|
||||||
if (! menuactive && bindtable[key])
|
if (ev->type == ev_keydown && !menuactive && bindtable[key])
|
||||||
{
|
{
|
||||||
COM_BufAddText(bindtable[key]);
|
COM_BufAddText(bindtable[key]);
|
||||||
COM_BufAddText("\n");
|
COM_BufAddText("\n");
|
||||||
|
@ -981,6 +981,12 @@ boolean CON_Responder(event_t *ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ev->type == ev_text)
|
||||||
|
{
|
||||||
|
CON_InputAddChar(key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Always eat ctrl/shift/alt if console open, so the menu doesn't get ideas
|
// Always eat ctrl/shift/alt if console open, so the menu doesn't get ideas
|
||||||
if (key == KEY_LSHIFT || key == KEY_RSHIFT
|
if (key == KEY_LSHIFT || key == KEY_RSHIFT
|
||||||
|| key == KEY_LCTRL || key == KEY_RCTRL
|
|| key == KEY_LCTRL || key == KEY_RCTRL
|
||||||
|
@ -1295,21 +1301,12 @@ boolean CON_Responder(event_t *ev)
|
||||||
else if (key == KEY_KPADSLASH)
|
else if (key == KEY_KPADSLASH)
|
||||||
key = '/';
|
key = '/';
|
||||||
|
|
||||||
if (key >= 'a' && key <= 'z')
|
|
||||||
{
|
|
||||||
if (capslock ^ shiftdown)
|
|
||||||
key = shiftxform[key];
|
|
||||||
}
|
|
||||||
else if (shiftdown)
|
|
||||||
key = shiftxform[key];
|
|
||||||
|
|
||||||
// enter a char into the command prompt
|
// enter a char into the command prompt
|
||||||
if (key < 32 || key > 127)
|
if (key < 32 || key > 127)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (input_sel != input_cur)
|
if (input_sel != input_cur)
|
||||||
CON_InputDelSelection();
|
CON_InputDelSelection();
|
||||||
CON_InputAddChar(key);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
ev_keydown,
|
ev_keydown,
|
||||||
ev_keyup,
|
ev_keyup,
|
||||||
|
ev_text,
|
||||||
ev_console,
|
ev_console,
|
||||||
ev_mouse,
|
ev_mouse,
|
||||||
ev_joystick,
|
ev_joystick,
|
||||||
|
|
|
@ -192,19 +192,19 @@ void D_ProcessEvents(void)
|
||||||
ev = &events[eventtail];
|
ev = &events[eventtail];
|
||||||
|
|
||||||
// Set mouse buttons early in case event is eaten later
|
// Set mouse buttons early in case event is eaten later
|
||||||
if (ev->type == ev_keydown || ev->type == ev_keyup)
|
if (ev->type == ev_keydown || ev->type == ev_keyup || ev->type == ev_text)
|
||||||
{
|
{
|
||||||
// Mouse buttons
|
// Mouse buttons
|
||||||
if ((UINT32)(ev->key - KEY_MOUSE1) < MOUSEBUTTONS)
|
if ((UINT32)(ev->key - KEY_MOUSE1) < MOUSEBUTTONS)
|
||||||
{
|
{
|
||||||
if (ev->type == ev_keydown)
|
if (ev->type == ev_keydown || ev->type == ev_text)
|
||||||
mouse.buttons |= 1 << (ev->key - KEY_MOUSE1);
|
mouse.buttons |= 1 << (ev->key - KEY_MOUSE1);
|
||||||
else
|
else
|
||||||
mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1));
|
mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1));
|
||||||
}
|
}
|
||||||
else if ((UINT32)(ev->key - KEY_2MOUSE1) < MOUSEBUTTONS)
|
else if ((UINT32)(ev->key - KEY_2MOUSE1) < MOUSEBUTTONS)
|
||||||
{
|
{
|
||||||
if (ev->type == ev_keydown)
|
if (ev->type == ev_keydown || ev->type == ev_text)
|
||||||
mouse2.buttons |= 1 << (ev->key - KEY_2MOUSE1);
|
mouse2.buttons |= 1 << (ev->key - KEY_2MOUSE1);
|
||||||
else
|
else
|
||||||
mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1));
|
mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1));
|
||||||
|
|
|
@ -79,6 +79,7 @@ patch_t *nto_font[NT_FONTSIZE];
|
||||||
|
|
||||||
static player_t *plr;
|
static player_t *plr;
|
||||||
boolean chat_on; // entering a chat message?
|
boolean chat_on; // entering a chat message?
|
||||||
|
boolean chat_on_first_event; // blocker for first chat input event
|
||||||
static char w_chat[HU_MAXMSGLEN + 1];
|
static char w_chat[HU_MAXMSGLEN + 1];
|
||||||
static size_t c_input = 0; // let's try to make the chat input less shitty.
|
static size_t c_input = 0; // let's try to make the chat input less shitty.
|
||||||
static boolean headsupactive = false;
|
static boolean headsupactive = false;
|
||||||
|
@ -1039,7 +1040,7 @@ boolean HU_Responder(event_t *ev)
|
||||||
{
|
{
|
||||||
INT32 c=0;
|
INT32 c=0;
|
||||||
|
|
||||||
if (ev->type != ev_keydown)
|
if (ev->type != ev_keydown && ev->type != ev_text)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// only KeyDown events now...
|
// only KeyDown events now...
|
||||||
|
@ -1068,11 +1069,15 @@ boolean HU_Responder(event_t *ev)
|
||||||
|
|
||||||
if (!chat_on)
|
if (!chat_on)
|
||||||
{
|
{
|
||||||
|
if (ev->type == ev_text)
|
||||||
|
return false;
|
||||||
|
|
||||||
// enter chat mode
|
// enter chat mode
|
||||||
if ((ev->key == gamecontrol[GC_TALKKEY][0] || ev->key == gamecontrol[GC_TALKKEY][1])
|
if ((ev->key == gamecontrol[GC_TALKKEY][0] || ev->key == gamecontrol[GC_TALKKEY][1])
|
||||||
&& netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise.
|
&& netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise.
|
||||||
{
|
{
|
||||||
chat_on = true;
|
chat_on = true;
|
||||||
|
chat_on_first_event = false;
|
||||||
w_chat[0] = 0;
|
w_chat[0] = 0;
|
||||||
teamtalk = false;
|
teamtalk = false;
|
||||||
chat_scrollmedown = true;
|
chat_scrollmedown = true;
|
||||||
|
@ -1083,6 +1088,7 @@ boolean HU_Responder(event_t *ev)
|
||||||
&& netgame && !OLD_MUTE)
|
&& netgame && !OLD_MUTE)
|
||||||
{
|
{
|
||||||
chat_on = true;
|
chat_on = true;
|
||||||
|
chat_on_first_event = false;
|
||||||
w_chat[0] = 0;
|
w_chat[0] = 0;
|
||||||
teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams.
|
teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams.
|
||||||
chat_scrollmedown = true;
|
chat_scrollmedown = true;
|
||||||
|
@ -1092,6 +1098,31 @@ boolean HU_Responder(event_t *ev)
|
||||||
}
|
}
|
||||||
else // if chat_on
|
else // if chat_on
|
||||||
{
|
{
|
||||||
|
if (!chat_on_first_event)
|
||||||
|
{
|
||||||
|
// since the text event is sent immediately after the keydown event,
|
||||||
|
// we need to make sure that nothing is displayed once the chat
|
||||||
|
// opens, otherwise a 't' would be outputted.
|
||||||
|
chat_on_first_event = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev->type == ev_text)
|
||||||
|
{
|
||||||
|
if ((c < HU_FONTSTART || c > HU_FONTEND || !hu_font[c-HU_FONTSTART])
|
||||||
|
&& c != ' ') // Allow spaces, of course
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
|
||||||
|
w_chat[c_input] = c;
|
||||||
|
c_input++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore modifier keys
|
// Ignore modifier keys
|
||||||
// Note that we do this here so users can still set
|
// Note that we do this here so users can still set
|
||||||
|
@ -1101,23 +1132,8 @@ boolean HU_Responder(event_t *ev)
|
||||||
|| ev->key == KEY_LALT || ev->key == KEY_RALT)
|
|| ev->key == KEY_LALT || ev->key == KEY_RALT)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
c = (INT32)ev->key;
|
|
||||||
|
|
||||||
// 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 :(
|
// pasting. pasting is cool. chat is a bit limited, though :(
|
||||||
if ((c == 'v' || c == 'V') && ctrldown)
|
if (c == 'v' && ctrldown)
|
||||||
{
|
{
|
||||||
const char *paste;
|
const char *paste;
|
||||||
size_t chatlen;
|
size_t chatlen;
|
||||||
|
@ -1185,16 +1201,6 @@ boolean HU_Responder(event_t *ev)
|
||||||
else
|
else
|
||||||
c_input++;
|
c_input++;
|
||||||
}
|
}
|
||||||
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font[c-HU_FONTSTART])
|
|
||||||
|| c == ' ') // Allow spaces, of course
|
|
||||||
{
|
|
||||||
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
|
|
||||||
w_chat[c_input] = c;
|
|
||||||
c_input++;
|
|
||||||
}
|
|
||||||
else if (c == KEY_BACKSPACE)
|
else if (c == KEY_BACKSPACE)
|
||||||
{
|
{
|
||||||
if (CHAT_MUTE || c_input <= 0)
|
if (CHAT_MUTE || c_input <= 0)
|
||||||
|
|
76
src/m_menu.c
76
src/m_menu.c
|
@ -3177,40 +3177,42 @@ boolean M_Responder(event_t *ev)
|
||||||
}
|
}
|
||||||
else if (menuactive)
|
else if (menuactive)
|
||||||
{
|
{
|
||||||
if (ev->type == ev_keydown)
|
if (ev->type == ev_keydown || ev->type == ev_text)
|
||||||
{
|
{
|
||||||
keydown++;
|
|
||||||
ch = ev->key;
|
ch = ev->key;
|
||||||
|
if (ev->type == ev_keydown)
|
||||||
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
|
||||||
switch (ch)
|
|
||||||
{
|
{
|
||||||
case KEY_MOUSE1:
|
keydown++;
|
||||||
case KEY_JOY1:
|
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
||||||
ch = KEY_ENTER;
|
switch (ch)
|
||||||
break;
|
{
|
||||||
case KEY_JOY1 + 3:
|
case KEY_MOUSE1:
|
||||||
ch = 'n';
|
case KEY_JOY1:
|
||||||
break;
|
ch = KEY_ENTER;
|
||||||
case KEY_MOUSE1 + 1:
|
break;
|
||||||
case KEY_JOY1 + 1:
|
case KEY_JOY1 + 3:
|
||||||
ch = KEY_ESCAPE;
|
ch = 'n';
|
||||||
break;
|
break;
|
||||||
case KEY_JOY1 + 2:
|
case KEY_MOUSE1 + 1:
|
||||||
ch = KEY_BACKSPACE;
|
case KEY_JOY1 + 1:
|
||||||
break;
|
ch = KEY_ESCAPE;
|
||||||
case KEY_HAT1:
|
break;
|
||||||
ch = KEY_UPARROW;
|
case KEY_JOY1 + 2:
|
||||||
break;
|
ch = KEY_BACKSPACE;
|
||||||
case KEY_HAT1 + 1:
|
break;
|
||||||
ch = KEY_DOWNARROW;
|
case KEY_HAT1:
|
||||||
break;
|
ch = KEY_UPARROW;
|
||||||
case KEY_HAT1 + 2:
|
break;
|
||||||
ch = KEY_LEFTARROW;
|
case KEY_HAT1 + 1:
|
||||||
break;
|
ch = KEY_DOWNARROW;
|
||||||
case KEY_HAT1 + 3:
|
break;
|
||||||
ch = KEY_RIGHTARROW;
|
case KEY_HAT1 + 2:
|
||||||
break;
|
ch = KEY_LEFTARROW;
|
||||||
|
break;
|
||||||
|
case KEY_HAT1 + 3:
|
||||||
|
ch = KEY_RIGHTARROW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ev->type == ev_joystick && ev->key == 0 && joywait < I_GetTime())
|
else if (ev->type == ev_joystick && ev->key == 0 && joywait < I_GetTime())
|
||||||
|
@ -3372,8 +3374,11 @@ boolean M_Responder(event_t *ev)
|
||||||
// Handle menuitems which need a specific key handling
|
// Handle menuitems which need a specific key handling
|
||||||
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
|
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
|
||||||
{
|
{
|
||||||
if (shiftdown && ch >= 32 && ch <= 127)
|
// ignore ev_keydown events if the key maps to a character, since
|
||||||
ch = shiftxform[ch];
|
// the ev_text event will follow immediately after in that case.
|
||||||
|
if (ev->type == ev_keydown && ch >= 32 && ch <= 127)
|
||||||
|
return true;
|
||||||
|
|
||||||
routine(ch);
|
routine(ch);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3415,6 +3420,11 @@ boolean M_Responder(event_t *ev)
|
||||||
{
|
{
|
||||||
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING)
|
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING)
|
||||||
{
|
{
|
||||||
|
// ignore ev_keydown events if the key maps to a character, since
|
||||||
|
// the ev_text event will follow immediately after in that case.
|
||||||
|
if (ev->type == ev_keydown && ch >= 32 && ch <= 127)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (M_ChangeStringCvar(ch))
|
if (M_ChangeStringCvar(ch))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
|
|
@ -652,6 +652,7 @@ void I_GetConsoleEvents(void)
|
||||||
else if (tty_con.cursor < sizeof (tty_con.buffer))
|
else if (tty_con.cursor < sizeof (tty_con.buffer))
|
||||||
{
|
{
|
||||||
// push regular character
|
// push regular character
|
||||||
|
ev.type = ev_text;
|
||||||
ev.key = tty_con.buffer[tty_con.cursor] = key;
|
ev.key = tty_con.buffer[tty_con.cursor] = key;
|
||||||
tty_con.cursor++;
|
tty_con.cursor++;
|
||||||
// print the current line (this is differential)
|
// print the current line (this is differential)
|
||||||
|
|
|
@ -693,6 +693,19 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||||
if (event.key) D_PostEvent(&event);
|
if (event.key) D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Impl_HandleTextEvent(SDL_TextInputEvent evt)
|
||||||
|
{
|
||||||
|
event_t event;
|
||||||
|
event.type = ev_text;
|
||||||
|
if (evt.text[1] != '\0')
|
||||||
|
{
|
||||||
|
// limit ourselves to ASCII for now, we can add UTF-8 support later
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.key = evt.text[0];
|
||||||
|
D_PostEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
{
|
{
|
||||||
static boolean firstmove = true;
|
static boolean firstmove = true;
|
||||||
|
@ -941,6 +954,9 @@ void I_GetEvent(void)
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
Impl_HandleKeyboardEvent(evt.key, evt.type);
|
Impl_HandleKeyboardEvent(evt.key, evt.type);
|
||||||
break;
|
break;
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
Impl_HandleTextEvent(evt.text);
|
||||||
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
//if (!mouseMotionOnce)
|
//if (!mouseMotionOnce)
|
||||||
Impl_HandleMouseMotionEvent(evt.motion);
|
Impl_HandleMouseMotionEvent(evt.motion);
|
||||||
|
|
Loading…
Reference in a new issue