From ee0b0869278ec325d6f31ef51666fa61dd417b8e Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 28 Oct 2017 09:30:49 +1100 Subject: [PATCH] [client] only send one in every 100 key down messages --- client/main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/main.c b/client/main.c index e053b18e..44409403 100644 --- a/client/main.c +++ b/client/main.c @@ -382,8 +382,9 @@ static inline const uint32_t mapScancode(SDL_Scancode scancode) int eventThread(void * arg) { - int mouseX = 0; - int mouseY = 0; + int mouseX = 0; + int mouseY = 0; + int repeatCount = 0; // ensure mouse acceleration is identical in server mode SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1", SDL_HINT_OVERRIDE); @@ -407,8 +408,16 @@ int eventThread(void * arg) case SDL_KEYDOWN: { SDL_Scancode sc = event.key.keysym.scancode; + if (event.key.repeat) + ++repeatCount; + else + repeatCount = 0; + if (sc == SDL_SCANCODE_SCROLLLOCK) { + if (event.key.repeat) + break; + serverMode = !serverMode; spice_mouse_mode(serverMode); SDL_SetRelativeMouseMode(serverMode); @@ -432,6 +441,10 @@ int eventThread(void * arg) break; } + if (repeatCount != 0 && repeatCount != 100) + break; + + repeatCount = 0; uint32_t scancode = mapScancode(sc); if (scancode == 0) break;