summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/sdl/window.cpp
diff options
context:
space:
mode:
author Brad Hughes <bradhugh@outlook.com>2016-08-27 14:23:34 -0400
committer Brad Hughes <bradhugh@outlook.com>2016-08-27 14:23:34 -0400
commit9af893666ab69d9d5ea1e97319c5ba7353e8d1bf (patch)
tree938b51ac87b941877592a9c8c2bfcec75a467d71 /src/osd/sdl/window.cpp
parent7df8323c2d6cd291acf5256985c216ee0a9ac8e0 (diff)
Warp mode for relative mouse on OSX SDL 2.0.4
Fixes #1232
Diffstat (limited to 'src/osd/sdl/window.cpp')
-rw-r--r--src/osd/sdl/window.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp
index f878a283748..450b4b59550 100644
--- a/src/osd/sdl/window.cpp
+++ b/src/osd/sdl/window.cpp
@@ -64,6 +64,8 @@
#define WMSZ_RIGHT (7)
#endif
+#define SDL_VERSION_EQUALS(v1, vnum2) (SDL_VERSIONNUM(v1.major, v1.minor, v1.patch) == vnum2)
+
class SDL_DM_Wrapper
{
public:
@@ -714,6 +716,24 @@ int sdl_window_info::complete_create()
*/
#endif
+ // We need to workaround an issue in SDL 2.0.4 for OS X where setting the
+ // relative mode on the mouse in fullscreen mode makes mouse events stop
+ // It is fixed in the latest revisions so we'll assume it'll be fixed
+ // in the next public SDL release as well
+#if defined(SDLMAME_MACOSX) && SDL_VERSION_ATLEAST(2, 0, 2) // SDL_HINT_MOUSE_RELATIVE_MODE_WARP is introduced in 2.0.2
+ SDL_version linked;
+ SDL_GetVersion(&linked);
+ int revision = SDL_GetRevisionNumber();
+
+ // If we're running the exact version of SDL 2.0.4 (revision 10001) from the
+ // SDL web site, we need to work around this issue and send the warp mode hint
+ if (SDL_VERSION_EQUALS(linked, SDL_VERSIONNUM(2, 0, 4)) && revision == 10001)
+ {
+ osd_printf_verbose("Using warp mode for relative mouse in OS X SDL 2.0.4\n");
+ SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1");
+ }
+#endif
+
// create the SDL window
// soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS
m_extra_flags |= (fullscreen() ?