From 2e22cafc034cca97f9439a9af05dbf8409b39a05 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sat, 7 Sep 2024 10:37:16 +0200 Subject: [PATCH] [sdl2] long-click sticky key functional --- src/ui_sdl2.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ui_sdl2.c b/src/ui_sdl2.c index 2cf505a..3de1a0e 100644 --- a/src/ui_sdl2.c +++ b/src/ui_sdl2.c @@ -1042,18 +1042,21 @@ void sdl_get_event( void ) case SDL_MOUSEBUTTONDOWN: hpkey = mouse_click_to_hpkey( event.button.x, event.button.y ); if ( sdl_press_key( hpkey ) != -1 ) { - lasthpkey = hpkey; - // Start timer - lastticks = SDL_GetTicks(); + if ( lasthpkey == -1 ) { + lasthpkey = hpkey; + // Start timer + lastticks = SDL_GetTicks(); + } else + lasthpkey = lastticks = -1; } break; case SDL_MOUSEBUTTONUP: hpkey = mouse_click_to_hpkey( event.button.x, event.button.y ); - if ( lasthpkey != hpkey || lastticks == -1 || ( SDL_GetTicks() - lastticks < 750 ) ) { - lasthpkey = lastticks = -1; + if ( lasthpkey != hpkey || lastticks == -1 || ( SDL_GetTicks() - lastticks < 750 ) ) sdl_release_key( hpkey ); - } + + lasthpkey = lastticks = -1; break; case SDL_KEYDOWN: