[sdl2] long-click sticky key functional
This commit is contained in:
parent
a25ca2de89
commit
2e22cafc03
1 changed files with 9 additions and 6 deletions
|
@ -1042,18 +1042,21 @@ void sdl_get_event( void )
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
hpkey = mouse_click_to_hpkey( event.button.x, event.button.y );
|
hpkey = mouse_click_to_hpkey( event.button.x, event.button.y );
|
||||||
if ( sdl_press_key( hpkey ) != -1 ) {
|
if ( sdl_press_key( hpkey ) != -1 ) {
|
||||||
lasthpkey = hpkey;
|
if ( lasthpkey == -1 ) {
|
||||||
// Start timer
|
lasthpkey = hpkey;
|
||||||
lastticks = SDL_GetTicks();
|
// Start timer
|
||||||
|
lastticks = SDL_GetTicks();
|
||||||
|
} else
|
||||||
|
lasthpkey = lastticks = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
hpkey = mouse_click_to_hpkey( event.button.x, event.button.y );
|
hpkey = mouse_click_to_hpkey( event.button.x, event.button.y );
|
||||||
if ( lasthpkey != hpkey || lastticks == -1 || ( SDL_GetTicks() - lastticks < 750 ) ) {
|
if ( lasthpkey != hpkey || lastticks == -1 || ( SDL_GetTicks() - lastticks < 750 ) )
|
||||||
lasthpkey = lastticks = -1;
|
|
||||||
sdl_release_key( hpkey );
|
sdl_release_key( hpkey );
|
||||||
}
|
|
||||||
|
lasthpkey = lastticks = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
|
Loading…
Reference in a new issue