mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
Use callbacks for key repeat control.
This commit is contained in:
parent
cf0729c818
commit
2a3986368e
2 changed files with 23 additions and 20 deletions
|
@ -45,7 +45,6 @@
|
||||||
|
|
||||||
cvar_t *in_snd_block;
|
cvar_t *in_snd_block;
|
||||||
|
|
||||||
static keydest_t old_key_dest = key_none;
|
|
||||||
static int have_focus = 1;
|
static int have_focus = 1;
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +70,16 @@ event_focusin (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sdl_keydest_callback (keydest_t key_dest)
|
||||||
|
{
|
||||||
|
if (key_dest == key_game)
|
||||||
|
SDL_EnableKeyRepeat (0, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
|
else
|
||||||
|
SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY,
|
||||||
|
SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IN_LL_ProcessEvents (void)
|
IN_LL_ProcessEvents (void)
|
||||||
{
|
{
|
||||||
|
@ -81,16 +90,6 @@ IN_LL_ProcessEvents (void)
|
||||||
|
|
||||||
|
|
||||||
while (SDL_PollEvent (&event)) {
|
while (SDL_PollEvent (&event)) {
|
||||||
// Ugly key repeat handling. Should use a key_dest callback...
|
|
||||||
if (old_key_dest != key_dest) {
|
|
||||||
old_key_dest = key_dest;
|
|
||||||
if (key_dest == key_game)
|
|
||||||
SDL_EnableKeyRepeat (0, SDL_DEFAULT_REPEAT_INTERVAL);
|
|
||||||
else
|
|
||||||
SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY,
|
|
||||||
SDL_DEFAULT_REPEAT_INTERVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_ACTIVEEVENT:
|
case SDL_ACTIVEEVENT:
|
||||||
if (event.active.state == SDL_APPINPUTFOCUS) {
|
if (event.active.state == SDL_APPINPUTFOCUS) {
|
||||||
|
@ -589,6 +588,7 @@ IN_LL_Init (void)
|
||||||
{
|
{
|
||||||
SDL_EnableUNICODE (1); // Enable UNICODE translation for keyboard input
|
SDL_EnableUNICODE (1); // Enable UNICODE translation for keyboard input
|
||||||
|
|
||||||
|
Key_KeydestCallback (sdl_keydest_callback);
|
||||||
if (COM_CheckParm ("-nomouse"))
|
if (COM_CheckParm ("-nomouse"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,6 @@ cvar_t *in_mouse_accel;
|
||||||
|
|
||||||
static qboolean dga_avail;
|
static qboolean dga_avail;
|
||||||
static qboolean dga_active;
|
static qboolean dga_active;
|
||||||
static keydest_t old_key_dest = key_none;
|
|
||||||
static int p_mouse_x, p_mouse_y;
|
static int p_mouse_x, p_mouse_y;
|
||||||
static int input_grabbed = 0;
|
static int input_grabbed = 0;
|
||||||
|
|
||||||
|
@ -597,20 +596,22 @@ XLateKey (XKeyEvent * ev, int *k, int *u)
|
||||||
*u = unicode;
|
*u = unicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
x11_keydest_callback (keydest_t key_dst)
|
||||||
|
{
|
||||||
|
if (key_dest == key_game) {
|
||||||
|
XAutoRepeatOff (x_disp);
|
||||||
|
} else {
|
||||||
|
XAutoRepeatOn (x_disp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_key (XEvent *event)
|
event_key (XEvent *event)
|
||||||
{
|
{
|
||||||
int key, unicode;
|
int key, unicode;
|
||||||
|
|
||||||
x_time = event->xkey.time;
|
x_time = event->xkey.time;
|
||||||
if (old_key_dest != key_dest) {
|
|
||||||
old_key_dest = key_dest;
|
|
||||||
if (key_dest == key_game) {
|
|
||||||
XAutoRepeatOff (x_disp);
|
|
||||||
} else {
|
|
||||||
XAutoRepeatOn (x_disp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XLateKey (&event->xkey, &key, &unicode);
|
XLateKey (&event->xkey, &key, &unicode);
|
||||||
Key_Event (key, unicode, event->type == KeyPress);
|
Key_Event (key, unicode, event->type == KeyPress);
|
||||||
}
|
}
|
||||||
|
@ -842,6 +843,8 @@ IN_LL_Init (void)
|
||||||
in_mouse_avail = 1;
|
in_mouse_avail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Key_KeydestCallback (x11_keydest_callback);
|
||||||
|
|
||||||
Cmd_AddCommand ("in_paste_buffer", in_paste_buffer_f,
|
Cmd_AddCommand ("in_paste_buffer", in_paste_buffer_f,
|
||||||
"Paste the contents of X's C&P buffer to the console");
|
"Paste the contents of X's C&P buffer to the console");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue