[mupen64plus-input-sdl] 139/196: Add support for mouse based analog stick using SDL2
Sven Eckelmann
ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:00:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
ecsv-guest pushed a commit to branch master
in repository mupen64plus-input-sdl.
commit 8af0225df1538e56a816bb9ce93d16c2f1f8dcd9
Author: Sven Eckelmann <sven at narfation.org>
Date: Sun Jun 23 10:20:38 2013 +0200
Add support for mouse based analog stick using SDL2
---
debian/changelog | 2 +
debian/patches/sdl2_mousemode.patch | 88 +++++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 91 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index cd9ab24..ca394d8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ mupen64plus-input-sdl (2.0~rc2+1+9aaeab081d97-2) UNRELEASED; urgency=low
* debian/patches:
- Add sdl2_forcefeedback.patch, Use SDL2 to play force feedback effects
- Add sdl2_keysym.patch, Use SDL1.2 keysym in the config when using SDL2
+ - Add sdl2_mousemode.patch, Add support for mouse based analog stick using
+ SDL2
-- Sven Eckelmann <sven at narfation.org> Sun, 09 Jun 2013 22:36:16 +0200
diff --git a/debian/patches/sdl2_mousemode.patch b/debian/patches/sdl2_mousemode.patch
new file mode 100644
index 0000000..5d024c1
--- /dev/null
+++ b/debian/patches/sdl2_mousemode.patch
@@ -0,0 +1,88 @@
+Description: Add support for mouse based analog stick using SDL2
+Author: Sven Eckelmann <sven at narfation.org>
+
+---
+diff --git a/src/plugin.c b/src/plugin.c
+index e47d1d4411218aa65a6b6ddb4e458d5b2dcc909a..865054c59fb7bb600714fcf8be56145c8638aeac 100644
+--- a/src/plugin.c
++++ b/src/plugin.c
+@@ -313,7 +313,7 @@ doSdlKeys(unsigned char* keystate)
+ grabmouse = !grabmouse;
+ // grab/ungrab mouse
+ #if SDL_VERSION_ATLEAST(2,0,0)
+-#warning SDL mouse grabbing not yet supported with SDL 2.0
++ SDL_SetRelativeMouseMode(grabmouse ? SDL_TRUE : SDL_FALSE);
+ #else
+ SDL_WM_GrabInput( grabmouse ? SDL_GRAB_ON : SDL_GRAB_OFF );
+ #endif
+@@ -582,9 +582,10 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+ if (controller[Control].mouse)
+ {
+ #if SDL_VERSION_ATLEAST(2,0,0)
+-#warning SDL mouse grabbing not yet supported with SDL 2.0
++ if (SDL_GetRelativeMouseMode())
+ #else
+ if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
++#endif
+ {
+ SDL_PumpEvents();
+ #if SDL_VERSION_ATLEAST(1,3,0)
+@@ -593,6 +594,11 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+ while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
+ #endif
+ {
++#if SDL_VERSION_ATLEAST(2,0,0)
++ int w, h;
++ SDL_Window *focus;
++#endif
++
+ if (event.motion.xrel)
+ {
+ mousex_residual += (int) (event.motion.xrel * controller[Control].mouse_sens[0]);
+@@ -601,10 +607,20 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+ {
+ mousey_residual += (int) (event.motion.yrel * controller[Control].mouse_sens[1]);
+ }
++
++#if SDL_VERSION_ATLEAST(2,0,0)
++ focus = SDL_GetKeyboardFocus();
++ if (focus) {
++ SDL_GetWindowSize(focus, &w, &h);
++ SDL_WarpMouseInWindow(focus, w / 2, h / 2);
++ } else {
++ mousex_residual = 0;
++ mousey_residual = 0;
++ }
++#endif
+ }
+ }
+ else
+-#endif
+ {
+ mousex_residual = 0;
+ mousey_residual = 0;
+@@ -965,7 +981,7 @@ EXPORT void CALL RomClosed(void)
+
+ // release/ungrab mouse
+ #if SDL_VERSION_ATLEAST(2,0,0)
+-#warning SDL mouse grabbing not yet supported with SDL 2.0
++ SDL_SetRelativeMouseMode(SDL_FALSE);
+ #else
+ SDL_WM_GrabInput( SDL_GRAB_OFF );
+ #endif
+@@ -1002,10 +1018,12 @@ EXPORT int CALL RomOpen(void)
+ // grab mouse
+ if (controller[0].mouse || controller[1].mouse || controller[2].mouse || controller[3].mouse)
+ {
+-#if SDL_VERSION_ATLEAST(2,0,0)
+-#warning SDL mouse grabbing not yet supported with SDL 2.0
+-#else
+ SDL_ShowCursor( 0 );
++#if SDL_VERSION_ATLEAST(2,0,0)
++ if (SDL_SetRelativeMouseMode(SDL_TRUE) < 0) {
++ DebugMessage(M64MSG_WARNING, "Couldn't grab input! Mouse support won't work!");
++ }
++#else
+ if (SDL_WM_GrabInput( SDL_GRAB_ON ) != SDL_GRAB_ON)
+ {
+ DebugMessage(M64MSG_WARNING, "Couldn't grab input! Mouse support won't work!");
diff --git a/debian/patches/series b/debian/patches/series
index 56bfa6e..33f561e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
sdl2_forcefeedback.patch
sdl2_keysym.patch
+sdl2_mousemode.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-input-sdl.git
More information about the Pkg-games-commits
mailing list