Skip to content

Commit

Permalink
Merge pull request #11876 from AreaScout/master
Browse files Browse the repository at this point in the history
Fix: touchscreen evens on upcomming SDL2 versions which includes the …
  • Loading branch information
hrydgard authored May 17, 2020
2 parents 0692b6d + e673d74 commit 2b605f1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ int main(int argc, char *argv[]) {
printf("DEBUG: Vulkan is not available, not using Vulkan.\n");
}

SDL_version compiled;
SDL_version linked;
int set_xres = -1;
int set_yres = -1;
int w = 0, h = 0;
Expand Down Expand Up @@ -536,6 +538,15 @@ int main(int argc, char *argv[]) {
}
}

SDL_VERSION(&compiled);
SDL_GetVersion(&linked);
printf("Info: We compiled against SDL version %d.%d.%d", compiled.major, compiled.minor, compiled.patch);
if (compiled.minor != linked.minor || compiled.patch != linked.patch) {
printf(", but we are linking against SDL version %d.%d.%d., be aware that this can lead to unexpected behaviors\n", linked.major, linked.minor, linked.patch);
} else {
printf(" and we are linking against SDL version %d.%d.%d. :)\n", linked.major, linked.minor, linked.patch);
}

// Get the video info before doing anything else, so we don't get skewed resolution results.
// TODO: support multiple displays correctly
SDL_DisplayMode displayMode;
Expand Down Expand Up @@ -847,6 +858,7 @@ int main(int argc, char *argv[]) {
NativeKey(key);
break;
}
#if !SDL_VERSION_ATLEAST(2, 0, 10)
// This behavior doesn't feel right on a macbook with a touchpad.
#if !PPSSPP_PLATFORM(MAC)
case SDL_FINGERMOTION:
Expand All @@ -856,7 +868,6 @@ int main(int argc, char *argv[]) {
touchEvent.motion.type = SDL_MOUSEMOTION;
touchEvent.motion.timestamp = event.tfinger.timestamp;
touchEvent.motion.windowID = SDL_GetWindowID(window);
touchEvent.motion.which = SDL_TOUCH_MOUSEID;
touchEvent.motion.state = SDL_GetMouseState(NULL, NULL);
touchEvent.motion.x = event.tfinger.x * w;
touchEvent.motion.y = event.tfinger.y * h;
Expand All @@ -873,7 +884,6 @@ int main(int argc, char *argv[]) {
touchEvent.button.type = SDL_MOUSEBUTTONDOWN;
touchEvent.button.timestamp = SDL_GetTicks();
touchEvent.button.windowID = SDL_GetWindowID(window);
touchEvent.button.which = SDL_TOUCH_MOUSEID;
touchEvent.button.button = SDL_BUTTON_LEFT;
touchEvent.button.state = SDL_PRESSED;
touchEvent.button.clicks = 1;
Expand All @@ -883,7 +893,6 @@ int main(int argc, char *argv[]) {
touchEvent.motion.type = SDL_MOUSEMOTION;
touchEvent.motion.timestamp = SDL_GetTicks();
touchEvent.motion.windowID = SDL_GetWindowID(window);
touchEvent.motion.which = SDL_TOUCH_MOUSEID;
touchEvent.motion.x = event.tfinger.x * w;
touchEvent.motion.y = event.tfinger.y * h;
// Any real mouse cursor should also move
Expand All @@ -902,7 +911,6 @@ int main(int argc, char *argv[]) {
touchEvent.button.type = SDL_MOUSEBUTTONUP;
touchEvent.button.timestamp = SDL_GetTicks();
touchEvent.button.windowID = SDL_GetWindowID(window);
touchEvent.button.which = SDL_TOUCH_MOUSEID;
touchEvent.button.button = SDL_BUTTON_LEFT;
touchEvent.button.state = SDL_RELEASED;
touchEvent.button.clicks = 1;
Expand All @@ -911,6 +919,7 @@ int main(int argc, char *argv[]) {
SDL_PushEvent(&touchEvent);
break;
}
#endif
#endif
case SDL_MOUSEBUTTONDOWN:
switch (event.button.button) {
Expand Down

0 comments on commit 2b605f1

Please sign in to comment.