1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

Adds a potential workaround for SDL mouse motion.

This commit is contained in:
Thomas Harte 2019-07-09 16:38:16 -04:00
parent 96be1a3f62
commit f73bccfec8

View File

@ -736,7 +736,6 @@ int main(int argc, char *argv[]) {
case SDL_MOUSEBUTTONUP: {
const auto mouse_machine = machine->mouse_machine();
if(mouse_machine) {
printf("%d %s\n", event.button.button, (event.type == SDL_MOUSEBUTTONDOWN) ? "pressed" : "released");
mouse_machine->get_mouse().set_button_pressed(
event.button.button % mouse_machine->get_mouse().get_number_of_buttons(),
event.type == SDL_MOUSEBUTTONDOWN);
@ -745,7 +744,12 @@ int main(int argc, char *argv[]) {
case SDL_MOUSEMOTION: {
if(SDL_GetRelativeMouseMode()) {
printf("-> %d %d (%d %d)\n", event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel);
// This is a workaround; using motion.xrel and motion.yrel from the event doesn't
// appear to work consistently.
int xrel, yrel;
SDL_GetRelativeMouseState(&xrel, &yrel);
printf("-> %d %d (%d %d / %d %d)\n", event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, xrel, yrel);
const auto mouse_machine = machine->mouse_machine();
if(mouse_machine) {
mouse_machine->get_mouse().move(event.motion.xrel, event.motion.yrel);