cli frontend: fix mouse input

there were 2 logical issues which caused reproducible misbehaviour.
for example when starting up pokemon soulsilver, one can click away
the intro, but it's not possible to click on the "load savegame"
icon.
the issues were:

1) failure to record whether the down event has been
passed to the emulator before abandoning it and turning it into
a click event (on a fast click, both events would happen during
the same SDL_Pollevent loop), and
2) mouse coordinates were discarded and unless the mouse down
event was registered. that means if the down and up events happen
on the exact same coordinate, the .x and .y of the mouse weren't
updated at all.
This commit is contained in:
rofl0r 2021-10-25 01:02:04 +00:00
parent 086112c4b5
commit a2c6a789ad
3 changed files with 15 additions and 12 deletions

View File

@ -481,11 +481,14 @@ static void desmume_cycle(struct ctrls_event_config * cfg)
}
/* Update mouse position and click */
if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y);
if(mouse.down) {
NDS_setTouchPos(mouse.x, mouse.y);
mouse.down = 2;
}
if(mouse.click)
{
NDS_releaseTouch();
mouse.click = FALSE;
mouse.click = 0;
}
update_keypad(cfg->keypad); /* Update keypad */

View File

@ -576,14 +576,12 @@ process_ctrls_event( SDL_Event& event,
break;
case SDL_MOUSEBUTTONDOWN:
if(event.button.button==1)
mouse.down = TRUE;
if(event.button.button==1 && !mouse.down)
mouse.down = 1;
break;
case SDL_MOUSEMOTION:
if(!mouse.down)
break;
else {
{
signed long scaled_x =
screen_to_touch_range( event.button.x,
cfg->nds_screen_size_ratio);
@ -597,8 +595,10 @@ process_ctrls_event( SDL_Event& event,
break;
case SDL_MOUSEBUTTONUP:
if(mouse.down) mouse.click = TRUE;
mouse.down = FALSE;
if(mouse.down) {
mouse.click = 1;
if(mouse.down > 1) mouse.down = 0;
}
break;
case SDL_QUIT:

View File

@ -75,8 +75,8 @@ struct mouse_status
{
signed long x;
signed long y;
BOOL click;
BOOL down;
int click;
int down;
};
extern mouse_status mouse;