mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-26 22:31:10 +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;
|
||||
|
||||
// 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])
|
||||
consdown = false;
|
||||
|
@ -964,7 +964,7 @@ boolean CON_Responder(event_t *ev)
|
|||
// check other keys only if console prompt is active
|
||||
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("\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
|
||||
if (key == KEY_LSHIFT || key == KEY_RSHIFT
|
||||
|| key == KEY_LCTRL || key == KEY_RCTRL
|
||||
|
@ -1295,21 +1301,12 @@ boolean CON_Responder(event_t *ev)
|
|||
else if (key == KEY_KPADSLASH)
|
||||
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
|
||||
if (key < 32 || key > 127)
|
||||
return true;
|
||||
|
||||
if (input_sel != input_cur)
|
||||
CON_InputDelSelection();
|
||||
CON_InputAddChar(key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ typedef enum
|
|||
{
|
||||
ev_keydown,
|
||||
ev_keyup,
|
||||
ev_text,
|
||||
ev_console,
|
||||
ev_mouse,
|
||||
ev_joystick,
|
||||
|
|
|
@ -192,19 +192,19 @@ void D_ProcessEvents(void)
|
|||
ev = &events[eventtail];
|
||||
|
||||
// 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
|
||||
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);
|
||||
else
|
||||
mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1));
|
||||
}
|
||||
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);
|
||||
else
|
||||
mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1));
|
||||
|
|
|
@ -79,6 +79,7 @@ patch_t *nto_font[NT_FONTSIZE];
|
|||
|
||||
static player_t *plr;
|
||||
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 size_t c_input = 0; // let's try to make the chat input less shitty.
|
||||
static boolean headsupactive = false;
|
||||
|
@ -1039,7 +1040,7 @@ boolean HU_Responder(event_t *ev)
|
|||
{
|
||||
INT32 c=0;
|
||||
|
||||
if (ev->type != ev_keydown)
|
||||
if (ev->type != ev_keydown && ev->type != ev_text)
|
||||
return false;
|
||||
|
||||
// only KeyDown events now...
|
||||
|
@ -1068,11 +1069,15 @@ boolean HU_Responder(event_t *ev)
|
|||
|
||||
if (!chat_on)
|
||||
{
|
||||
if (ev->type == ev_text)
|
||||
return false;
|
||||
|
||||
// enter chat mode
|
||||
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.
|
||||
{
|
||||
chat_on = true;
|
||||
chat_on_first_event = false;
|
||||
w_chat[0] = 0;
|
||||
teamtalk = false;
|
||||
chat_scrollmedown = true;
|
||||
|
@ -1083,6 +1088,7 @@ boolean HU_Responder(event_t *ev)
|
|||
&& netgame && !OLD_MUTE)
|
||||
{
|
||||
chat_on = true;
|
||||
chat_on_first_event = false;
|
||||
w_chat[0] = 0;
|
||||
teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams.
|
||||
chat_scrollmedown = true;
|
||||
|
@ -1092,6 +1098,31 @@ boolean HU_Responder(event_t *ev)
|
|||
}
|
||||
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
|
||||
// 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)
|
||||
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 :(
|
||||
if ((c == 'v' || c == 'V') && ctrldown)
|
||||
if (c == 'v' && ctrldown)
|
||||
{
|
||||
const char *paste;
|
||||
size_t chatlen;
|
||||
|
@ -1185,16 +1201,6 @@ boolean HU_Responder(event_t *ev)
|
|||
else
|
||||
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)
|
||||
{
|
||||
if (CHAT_MUTE || c_input <= 0)
|
||||
|
|
18
src/m_menu.c
18
src/m_menu.c
|
@ -3177,11 +3177,12 @@ boolean M_Responder(event_t *ev)
|
|||
}
|
||||
else if (menuactive)
|
||||
{
|
||||
if (ev->type == ev_keydown || ev->type == ev_text)
|
||||
{
|
||||
ch = ev->key;
|
||||
if (ev->type == ev_keydown)
|
||||
{
|
||||
keydown++;
|
||||
ch = ev->key;
|
||||
|
||||
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
||||
switch (ch)
|
||||
{
|
||||
|
@ -3213,6 +3214,7 @@ boolean M_Responder(event_t *ev)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ev->type == ev_joystick && ev->key == 0 && joywait < I_GetTime())
|
||||
{
|
||||
const INT32 jdeadzone = (JOYAXISRANGE * cv_digitaldeadzone.value) / FRACUNIT;
|
||||
|
@ -3372,8 +3374,11 @@ boolean M_Responder(event_t *ev)
|
|||
// Handle menuitems which need a specific key handling
|
||||
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
|
||||
{
|
||||
if (shiftdown && ch >= 32 && ch <= 127)
|
||||
ch = shiftxform[ch];
|
||||
// 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 true;
|
||||
|
||||
routine(ch);
|
||||
return true;
|
||||
}
|
||||
|
@ -3415,6 +3420,11 @@ boolean M_Responder(event_t *ev)
|
|||
{
|
||||
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))
|
||||
return true;
|
||||
else
|
||||
|
|
|
@ -652,6 +652,7 @@ void I_GetConsoleEvents(void)
|
|||
else if (tty_con.cursor < sizeof (tty_con.buffer))
|
||||
{
|
||||
// push regular character
|
||||
ev.type = ev_text;
|
||||
ev.key = tty_con.buffer[tty_con.cursor] = key;
|
||||
tty_con.cursor++;
|
||||
// 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);
|
||||
}
|
||||
|
||||
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 boolean firstmove = true;
|
||||
|
@ -941,6 +954,9 @@ void I_GetEvent(void)
|
|||
case SDL_KEYDOWN:
|
||||
Impl_HandleKeyboardEvent(evt.key, evt.type);
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
Impl_HandleTextEvent(evt.text);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
//if (!mouseMotionOnce)
|
||||
Impl_HandleMouseMotionEvent(evt.motion);
|
||||
|
|
Loading…
Reference in a new issue