[mupen64plus-input-sdl] 59/196: Add mouse sensitivity

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:00:16 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 8bd833f37b46612d38b4670ac6a13d472528fed3
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Jul 24 08:59:26 2011 +0200

    Add mouse sensitivity
---
 debian/changelog                       |   1 +
 debian/patches/mouse_sensitivity.patch | 126 +++++++++++++++++++++++++++++++++
 debian/patches/series                  |   1 +
 3 files changed, 128 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index c3e660c..12df4ec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ mupen64plus-input-sdl (1.99.4-3) UNRELEASED; urgency=low
     - Remove obsolete default-optimisations.patch, hurd_os.patch
     - Add rewrite_makefile.patch, Rewrite Makefile to fix flags and linking
     - Add inputautocfg.patch, Update InputAutoCfg.ini from mercurial
+    - Add mouse_sensitivity.patch, Add mouse sensitivity
 
  -- Sven Eckelmann <sven at narfation.org>  Sat, 23 Jul 2011 16:42:44 +0200
 
diff --git a/debian/patches/mouse_sensitivity.patch b/debian/patches/mouse_sensitivity.patch
new file mode 100644
index 0000000..7afed2f
--- /dev/null
+++ b/debian/patches/mouse_sensitivity.patch
@@ -0,0 +1,126 @@
+Description: Add mouse sensitivity
+Origin: upstream, https://bitbucket.org/richard42/mupen64plus-input-sdl/changeset/4840628890ed
+Author: Richard Goedeken <Richard at fascinationsoftware.com>
+
+---
+diff --git a/src/config.c b/src/config.c
+index 86aa513079f586abb8c6f56961cd4e30c9253626..301b4f09c0c37fd4112ceb6f5eca1b5f857eb2f1 100644
+--- a/src/config.c
++++ b/src/config.c
+@@ -94,6 +94,7 @@ static void clear_controller(int iCtrlIdx)
+     }
+     for( b = 0; b < 2; b++ )
+     {
++        controller[iCtrlIdx].mouse_sens[b] = 2.0;
+         controller[iCtrlIdx].axis_deadzone[b] = 4096;
+         controller[iCtrlIdx].axis_peak[b] = 32768;
+         controller[iCtrlIdx].axis[b].button_a = controller[iCtrlIdx].axis[b].button_b = -1;
+@@ -168,6 +169,11 @@ static int load_controller_config(const char *SectionName, int i)
+             break;
+         /* then do the optional parameters */
+         ConfigGetParameter(pConfig, "mouse", M64TYPE_BOOL, &controller[i].mouse, sizeof(int));
++        if (ConfigGetParameter(pConfig, "MouseSensitivity", M64TYPE_STRING, input_str, 256) == M64ERR_SUCCESS)
++        {
++            if (sscanf(input_str, "%f,%f", &controller[i].mouse_sens[0], &controller[i].mouse_sens[1]) != 2)
++                DebugMessage(M64MSG_WARNING, "parsing error in MouseSensitivity parameter for controller %i", i + 1);
++        }
+         if (ConfigGetParameter(pConfig, "AnalogDeadzone", M64TYPE_STRING, input_str, 256) == M64ERR_SUCCESS)
+         {
+             if (sscanf(input_str, "%i,%i", &controller[i].axis_deadzone[0], &controller[i].axis_deadzone[1]) != 2)
+@@ -274,6 +280,8 @@ void save_controller_config(int iCtrlIdx)
+     ConfigSetDefaultBool(pConfig, "mouse", controller[iCtrlIdx].mouse, "If True, then mouse buttons may be used with this controller");
+     ConfigSetDefaultInt(pConfig, "device", controller[iCtrlIdx].device, "Specifies which joystick is bound to this controller: -2=Keyboard/mouse, -1=Auto config, 0 or more= SDL Joystick number");
+ 
++    sprintf(Param, "%.2f,%.2f", controller[iCtrlIdx].mouse_sens[0], controller[iCtrlIdx].mouse_sens[1]);
++    ConfigSetDefaultString(pConfig, "MouseSensitivity", Param, "Scaling factor for mouse movements.  For X, Y axes.");
+     sprintf(Param, "%i,%i", controller[iCtrlIdx].axis_deadzone[0], controller[iCtrlIdx].axis_deadzone[1]);
+     ConfigSetDefaultString(pConfig, "AnalogDeadzone", Param, "The minimum absolute value of the SDL analog joystick axis to move the N64 controller axis value from 0.  For X, Y axes.");
+     sprintf(Param, "%i,%i", controller[iCtrlIdx].axis_peak[0], controller[iCtrlIdx].axis_peak[1]);
+diff --git a/src/plugin.c b/src/plugin.c
+index 0bdfcc9127bdb6cf0387495c1dd244508932b630..5f4a9367534931e6c9c9ddd9776c09e3cad49156 100644
+--- a/src/plugin.c
++++ b/src/plugin.c
+@@ -428,6 +428,8 @@ EXPORT void CALL ControllerCommand(int Control, unsigned char *Command)
+ *******************************************************************/
+ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+ {
++    static int mousex_residual = 0;
++    static int mousey_residual = 0;
+     int b, axis_val;
+     SDL_Event event;
+     unsigned char mstate;
+@@ -532,30 +534,43 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+             controller[Control].buttons.Value |= button_bits[b];
+     }
+ 
+-    if (controller[Control].mouse && SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
++    if (controller[Control].mouse)
+     {
+-        SDL_PumpEvents();
+-        while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
++        if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
+         {
+-            if (event.motion.xrel)
++            SDL_PumpEvents();
++            while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
+             {
+-                axis_val = (event.motion.xrel * 10);
+-                if (axis_val < -80)
+-                    axis_val = -80;
+-                else if (axis_val > 80)
+-                    axis_val = 80;
+-                controller[Control].buttons.X_AXIS = axis_val;
+-            }
+-            if (event.motion.yrel)
+-            {
+-                axis_val = (event.motion.yrel * 10);
+-                if (axis_val < -80)
+-                    axis_val = -80;
+-                else if (axis_val > 80)
+-                    axis_val = 80;
+-                controller[Control].buttons.Y_AXIS = -axis_val;
++                if (event.motion.xrel)
++                {
++                    mousex_residual += (int) (event.motion.xrel * controller[Control].mouse_sens[0]);
++                }
++                if (event.motion.yrel)
++                {
++                    mousey_residual += (int) (event.motion.yrel * controller[Control].mouse_sens[1]);
++                }
+             }
+         }
++        else
++        {
++            mousex_residual = 0;
++            mousey_residual = 0;
++        }
++        axis_val = mousex_residual;
++        if (axis_val < -80)
++            axis_val = -80;
++        else if (axis_val > 80)
++            axis_val = 80;
++        controller[Control].buttons.X_AXIS = axis_val;
++        axis_val = mousey_residual;
++        if (axis_val < -80)
++            axis_val = -80;
++        else if (axis_val > 80)
++            axis_val = 80;
++        controller[Control].buttons.Y_AXIS = -axis_val;
++        /* the mouse x/y values decay exponentially */
++        mousex_residual = (mousex_residual * 224) / 256;
++        mousey_residual = (mousey_residual * 224) / 256;
+     }
+ 
+ #ifdef _DEBUG
+diff --git a/src/plugin.h b/src/plugin.h
+index e64aa0dbc27587ff021bbf195ad121181430532c..c0b81d1a55f8df00a21baa9ad24d9bd693ff2984 100644
+--- a/src/plugin.h
++++ b/src/plugin.h
+@@ -99,6 +99,7 @@ typedef struct
+     int           event_joystick;   // the /dev/input/eventX device for force feeback
+     int           axis_deadzone[2]; // minimum absolute value before analog movement is recognized
+     int           axis_peak[2];     // highest analog value returned by SDL, used for scaling
++    float         mouse_sens[2];    // mouse sensitivity
+ } SController;
+ 
+ /* global data definitions */
diff --git a/debian/patches/series b/debian/patches/series
index ca5ea08..095e4d1 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 rewrite_makefile.patch
 2controllers-per-usb-device.patch
 inputautocfg.patch
+mouse_sensitivity.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