Fix key-repeats in the console (for instance the backspace key)

This commit is contained in:
svdijk 2014-01-05 20:22:34 +01:00
parent 84a1766702
commit 50e1bf16fe
3 changed files with 25 additions and 9 deletions

View file

@ -41,6 +41,11 @@ typedef struct in_state
int *in_speed_state;
} in_state_t;
/*
* Keyboard initialisation. Called by the client.
*/
void IN_KeyboardInit(Key_Event_fp_t fp);
/*
* Updates the state of the input queue
*/
@ -49,7 +54,7 @@ void IN_Update(void);
/*
* Initializes the input backend
*/
void IN_BackendInit(in_state_t *in_state_p, Key_Event_fp_t fp);
void IN_BackendInit(in_state_t *in_state_p);
/*
* Shuts the backend down

View file

@ -178,10 +178,7 @@ VID_LoadRefresh(void)
in_state.in_speed_state = &in_speed.state;
// Initiate the input backend
IN_BackendInit (&in_state, Do_Key_Event);
// Initiate keyboard at the input backend
Key_ClearStates();
IN_BackendInit (&in_state);
// Declare the refresher as active
ref_active = true;
@ -193,6 +190,10 @@ VID_LoadRefresh(void)
return false;
}
// Initiate keyboard at the input backend
IN_KeyboardInit(Do_Key_Event);
Key_ClearStates();
Com_Printf("------------------------------------\n\n");
return true;
}

View file

@ -560,15 +560,15 @@ IN_MLookUp(void)
/* ------------------------------------------------------------------ */
/*
* Initializes the backend
* Keyboard initialisation. Called by the client.
*/
void
IN_BackendInit(in_state_t *in_state_p, Key_Event_fp_t fp)
IN_KeyboardInit(Key_Event_fp_t fp)
{
in_state = in_state_p;
Key_Event_fp = fp;
mouse_x = mouse_y = 0;
/* SDL stuff. Moved here from IN_BackendInit because
* this must be done after video is initialized. */
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_SetRelativeMouseMode(SDL_TRUE);
have_grab = GLimp_InputIsGrabbed();
@ -577,6 +577,16 @@ IN_BackendInit(in_state_t *in_state_p, Key_Event_fp_t fp)
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
have_grab = (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
#endif
}
/*
* Initializes the backend
*/
void
IN_BackendInit(in_state_t *in_state_p)
{
in_state = in_state_p;
mouse_x = mouse_y = 0;
exponential_speedup = Cvar_Get("exponential_speedup", "0", CVAR_ARCHIVE);
freelook = Cvar_Get("freelook", "1", 0);