Solve some layer violations

- Handling of key combinations like Alt + Return or Shift + Escape
  clearly belong into the frontend. Now that the client won't clear
  the keystates any more it's save to handle them there.

- The 'force_centerview' command belongs into the client move stuff.
  I guess it was part of the backend sinces it messes with mouse
  handling. Since the renderer is now part of the client that's not
  necessary anymore.

- One can argue that +mlook and -mlook belong into client move stuff,
  too. But since we need there calculations in the backend anyway,
  leave things like they are.
This commit is contained in:
Yamagi Burmeister 2015-01-18 09:19:23 +01:00
parent 30fa1c5407
commit 59ac327aba
3 changed files with 27 additions and 34 deletions

View file

@ -315,12 +315,6 @@ IN_Update(void)
SDL_Event event;
unsigned int key;
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Keymod modstate;
#else
SDLMod modstate;
#endif
/* Get and process an event */
while (SDL_PollEvent(&event))
{
@ -412,22 +406,6 @@ IN_Update(void)
#endif
case SDL_KEYDOWN:
modstate = SDL_GetModState();
/* Fullscreen switch via Alt-Return */
if ((modstate & KMOD_ALT) && (event.key.keysym.sym == SDLK_RETURN))
{
GLimp_ToggleFullscreen();
break;
}
/* Make Shift+Escape toggle the console. */
if ((modstate & KMOD_SHIFT) && (event.key.keysym.sym == SDLK_ESCAPE))
{
Cbuf_ExecuteText(EXEC_NOW, "toggleconsole");
break;
}
#if !SDL_VERSION_ATLEAST(2, 0, 0)
Char_Event(event.key.keysym.unicode);
#endif
@ -553,15 +531,6 @@ IN_Move(usercmd_t *cmd)
/* ------------------------------------------------------------------ */
/*
* Centers the view
*/
static void
IN_ForceCenterView(void)
{
cl.viewangles[PITCH] = 0;
}
/*
* Look down
*/
@ -609,7 +578,6 @@ IN_Init(void)
Cmd_AddCommand("+mlook", IN_MLookDown);
Cmd_AddCommand("-mlook", IN_MLookUp);
Cmd_AddCommand("force_centerview", IN_ForceCenterView);
have_grab = GLimp_InputIsGrabbed();

View file

@ -612,10 +612,20 @@ IN_CenterView(void)
cl.viewangles[PITCH] = -SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[PITCH]);
}
/*
* Centers the view
*/
static void
IN_ForceCenterView(void)
{
cl.viewangles[PITCH] = 0;
}
void
CL_InitInput(void)
{
Cmd_AddCommand("centerview", IN_CenterView);
Cmd_AddCommand("force_centerview", IN_ForceCenterView);
Cmd_AddCommand("+moveup", IN_UpDown);
Cmd_AddCommand("-moveup", IN_UpUp);

View file

@ -28,6 +28,7 @@
*/
#include "header/client.h"
#include "refresh/header/local.h"
static cvar_t *cfg_unbindall;
@ -933,6 +934,20 @@ Key_Event(int key, qboolean down, qboolean special)
key_repeats[key] = 0;
}
/* Fullscreen switch through Alt + Return */
if (down && keydown[K_ALT] && key == K_ENTER)
{
GLimp_ToggleFullscreen();
return;
}
/* Toogle console though Shift + Escape */
if (down && keydown[K_SHIFT] && key == K_ESCAPE)
{
Con_ToggleConsole_f();
return;
}
/* Key is unbound */
if ((key >= 200) && !keybindings[key] && (cls.key_dest != key_console))
{
@ -1007,7 +1022,7 @@ Key_Event(int key, qboolean down, qboolean special)
if (kb && (kb[0] == '+'))
{
Com_sprintf(cmd, sizeof(cmd), "-%s %i %i\n", kb + 1, key, Sys_Milliseconds);
Com_sprintf(cmd, sizeof(cmd), "-%s %i %i\n", kb + 1, key, Sys_Milliseconds());
Cbuf_AddText(cmd);
}
@ -1025,7 +1040,7 @@ Key_Event(int key, qboolean down, qboolean special)
if (kb[0] == '+')
{
/* button commands add keynum and time as a parm */
Com_sprintf(cmd, sizeof(cmd), "%s %i %i\n", kb, key, Sys_Milliseconds);
Com_sprintf(cmd, sizeof(cmd), "%s %i %i\n", kb, key, Sys_Milliseconds());
Cbuf_AddText(cmd);
}
else