Completely reworked mouse handling - should now be smoother due to there no longer being a multi-layered game of telephone going on with all the various interim coordinate counters, also rewritten the serial mouse emulation ground ground up.

This commit is contained in:
OBattler
2023-08-07 18:49:58 +02:00
parent cdb415ef0f
commit c695cb8ded
25 changed files with 1155 additions and 990 deletions

View File

@@ -699,19 +699,6 @@ typedef struct mouseinputdata {
int mousebuttons;
} mouseinputdata;
SDL_mutex *mousemutex;
static mouseinputdata mousedata;
void
mouse_poll(void)
{
SDL_LockMutex(mousemutex);
mouse_x = mousedata.deltax;
mouse_y = mousedata.deltay;
mouse_z = mousedata.deltaz;
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
mouse_buttons = mousedata.mousebuttons;
SDL_UnlockMutex(mousemutex);
}
int real_sdl_w;
int real_sdl_h;
void
@@ -1182,7 +1169,7 @@ main(int argc, char **argv)
event.wheel.y *= -1;
}
SDL_LockMutex(mousemutex);
mousedata.deltaz = event.wheel.y;
mouse_set_z(event.wheel.y);
SDL_UnlockMutex(mousemutex);
}
break;
@@ -1191,8 +1178,7 @@ main(int argc, char **argv)
{
if (mouse_capture || video_fullscreen) {
SDL_LockMutex(mousemutex);
mousedata.deltax += event.motion.xrel;
mousedata.deltay += event.motion.yrel;
mouse_scale(event.motion.xrel, event.motion.yrel);
SDL_UnlockMutex(mousemutex);
}
break;
@@ -1232,10 +1218,10 @@ main(int argc, char **argv)
break;
}
SDL_LockMutex(mousemutex);
if (event.button.state == SDL_PRESSED) {
mousedata.mousebuttons |= buttonmask;
} else
mousedata.mousebuttons &= ~buttonmask;
if (event.button.state == SDL_PRESSED)
mouse_set_buttons_ex(mouse_get_buttons_ex() | buttonmask);
else
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~buttonmask);
SDL_UnlockMutex(mousemutex);
}
break;