[mupen64plus-input-sdl] 144/196: upport rumble effects when only a single effect can be registered

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:00:34 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 1a67c2dc53cf58c00128107211c33d6e5668774f
Author: Sven Eckelmann <sven at narfation.org>
Date:   Wed Jun 26 21:24:46 2013 +0200

    upport rumble effects when only a single effect can be registered
---
 debian/changelog                        |  8 ++++
 debian/patches/sdl2_forcefeedback.patch | 73 +++++++++++----------------------
 debian/patches/sdl2_mousemode.patch     | 14 +++----
 3 files changed, 39 insertions(+), 56 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index dde31c1..af08956 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+mupen64plus-input-sdl (2.0~rc2+1+9aaeab081d97-3) UNRELEASED; urgency=low
+
+  * debian/patches:
+    - Update sdl2_forcefeedback.patch, Support rumble effects when only
+      a single effect can be registered
+
+ -- Sven Eckelmann <sven at narfation.org>  Wed, 26 Jun 2013 21:23:41 +0200
+
 mupen64plus-input-sdl (2.0~rc2+1+9aaeab081d97-2) experimental; urgency=low
 
   * debian/rules:
diff --git a/debian/patches/sdl2_forcefeedback.patch b/debian/patches/sdl2_forcefeedback.patch
index db7e523..39f80bf 100644
--- a/debian/patches/sdl2_forcefeedback.patch
+++ b/debian/patches/sdl2_forcefeedback.patch
@@ -3,26 +3,19 @@ Author: Sven Eckelmann <sven at narfation.org>
 
 ---
 diff --git a/src/plugin.c b/src/plugin.c
-index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509e1e544f7 100644
+index 8ce635c592f35d774d0ab8fadd25160328d03796..5adf21a600be08306ad1c9d93df81a2b38f2723b 100644
 --- a/src/plugin.c
 +++ b/src/plugin.c
-@@ -111,7 +111,14 @@ static int romopen = 0;         // is a rom opened
+@@ -111,7 +111,7 @@ static int romopen = 0;         // is a rom opened
  
  static unsigned char myKeyState[SDL_NUM_SCANCODES];
  
 -#ifdef __linux__
-+#if SDL_VERSION_ATLEAST(2,0,0)
-+static SDL_HapticEffect ffeffect[4];
-+static int ffeffect_id[4];
-+static SDL_HapticEffect ffstrong[4];
-+static int ffstrong_id[4];
-+static SDL_HapticEffect ffweak[4];
-+static int ffweak_id[4];
-+#elif __linux__
++#if __linux__ && !SDL_VERSION_ATLEAST(2,0,0)
  static struct ff_effect ffeffect[3];
  static struct ff_effect ffstrong[3];
  static struct ff_effect ffweak[3];
-@@ -402,7 +409,15 @@ EXPORT void CALL ControllerCommand(int Control, unsigned char *Command)
+@@ -402,7 +402,15 @@ EXPORT void CALL ControllerCommand(int Control, unsigned char *Command)
                  unsigned int dwAddress = (Command[3] << 8) + (Command[4] & 0xE0);
                if (dwAddress == PAK_IO_RUMBLE && *Data)
                      DebugMessage(M64MSG_VERBOSE, "Triggering rumble pack.");
@@ -30,16 +23,16 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
 +#if SDL_VERSION_ATLEAST(2,0,0)
 +                if(dwAddress == PAK_IO_RUMBLE && controller[Control].event_joystick) {
 +                    if (*Data) {
-+                        SDL_HapticRunEffect(controller[Control].event_joystick, ffeffect_id[Control], 1);
++                        SDL_HapticRumblePlay(controller[Control].event_joystick, 1, SDL_HAPTIC_INFINITY);
 +                    } else {
-+                        SDL_HapticStopEffect(controller[Control].event_joystick, ffeffect_id[Control]);
++                        SDL_HapticRumbleStop(controller[Control].event_joystick);
 +                    }
 +                }
 +#elif __linux__
                  struct input_event play;
                  if( dwAddress == PAK_IO_RUMBLE && controller[Control].event_joystick != 0)
                  {
-@@ -617,7 +632,29 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+@@ -617,7 +625,30 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
      *Keys = controller[Control].buttons;
  
      /* handle mempack / rumblepak switching (only if rumble is active on joystick) */
@@ -51,17 +44,18 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
 +            SwitchPackTime[Control] = SDL_GetTicks();         // time at which the 'switch pack' command was given
 +            SwitchPackType[Control] = PLUGIN_MEMPAK;          // type of new pack to insert
 +            controller[Control].control->Plugin = PLUGIN_NONE;// remove old pack
-+            SDL_HapticRunEffect(controller[Control].event_joystick, ffweak_id[Control], 1);
++            SDL_HapticRumblePlay(controller[Control].event_joystick, 0.5, 500);
 +        }
 +        if (controller[Control].buttons.Value & button_bits[15]) {
 +            SwitchPackTime[Control] = SDL_GetTicks();         // time at which the 'switch pack' command was given
 +            SwitchPackType[Control] = PLUGIN_RAW;             // type of new pack to insert
 +            controller[Control].control->Plugin = PLUGIN_NONE;// remove old pack
-+            SDL_HapticRunEffect(controller[Control].event_joystick, ffstrong_id[Control], 1);
++            SDL_HapticRumblePlay(controller[Control].event_joystick, 1, 500);
 +        }
 +        // handle inserting new pack if the time has arrived
 +        if (SwitchPackTime[Control] != 0 && (SDL_GetTicks() - SwitchPackTime[Control]) >= 1000)
 +        {
++            SDL_HapticRumbleStop(controller[Control].event_joystick);
 +            controller[Control].control->Plugin = SwitchPackType[Control];
 +            SwitchPackTime[Control] = 0;
 +        }
@@ -70,7 +64,7 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
      if (controller[Control].event_joystick != 0)
      {
          struct input_event play;
-@@ -657,9 +694,82 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+@@ -657,9 +688,66 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
      controller[Control].buttons.Value = 0;
  }
  
@@ -119,42 +113,26 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
 +        return;
 +    }
 +
-+    if ((SDL_HapticQuery(controller[cntrl].event_joystick) & SDL_HAPTIC_SINE) == 0) {
++    if (SDL_HapticRumbleSupported(controller[cntrl].event_joystick) == SDL_FALSE) {
++        SDL_HapticClose(controller[cntrl].event_joystick);
 +        controller[cntrl].event_joystick = NULL;
-+        DebugMessage(M64MSG_WARNING, "Joystick #%i doesn't support sine effect", cntrl + 1);
++        DebugMessage(M64MSG_WARNING, "Joystick #%i doesn't support rumble effect", cntrl + 1);
 +        return;
 +    }
 +
-+    memset(&ffeffect[cntrl], 0, sizeof(SDL_HapticEffect));
-+    ffeffect[cntrl].type = SDL_HAPTIC_SINE;
-+    ffeffect[cntrl].periodic.period = 1000;
-+    ffeffect[cntrl].periodic.magnitude = 0x7FFF;
-+    ffeffect[cntrl].periodic.length = SDL_HAPTIC_INFINITY;
-+
-+    ffeffect_id[cntrl] = SDL_HapticNewEffect(controller[cntrl].event_joystick, &ffeffect[cntrl]);
-+
-+    memset(&ffstrong[cntrl], 0, sizeof(SDL_HapticEffect));
-+    ffstrong[cntrl].type = SDL_HAPTIC_SINE;
-+    ffstrong[cntrl].periodic.period = 1000;
-+    ffstrong[cntrl].periodic.magnitude = 0x7FFF;
-+    ffstrong[cntrl].periodic.length = 500;
-+
-+    ffstrong_id[cntrl] = SDL_HapticNewEffect(controller[cntrl].event_joystick, &ffstrong[cntrl]);
-+
-+    memset(&ffstrong[cntrl], 0, sizeof(SDL_HapticEffect));
-+    ffweak[cntrl].type = SDL_HAPTIC_SINE;
-+    ffweak[cntrl].periodic.period = 1000;
-+    ffweak[cntrl].periodic.magnitude = 0x3FFF;
-+    ffweak[cntrl].periodic.length = 500;
-+
-+    ffweak_id[cntrl] = SDL_HapticNewEffect(controller[cntrl].event_joystick, &ffweak[cntrl]);
++    if (SDL_HapticRumbleInit(controller[cntrl].event_joystick) != 0) {
++        SDL_HapticClose(controller[cntrl].event_joystick);
++        controller[cntrl].event_joystick = NULL;
++        DebugMessage(M64MSG_WARNING, "Rumble initialization failed for Joystick #%i", cntrl + 1);
++        return;
++    }
 +
 +    DebugMessage(M64MSG_INFO, "Rumble activated on N64 joystick #%i", cntrl + 1);
 +#elif __linux__
      DIR* dp;
      struct dirent* ep;
      unsigned long features[4];
-@@ -760,6 +870,19 @@ static void InitiateRumble(int cntrl)
+@@ -760,6 +848,16 @@ static void InitiateRumble(int cntrl)
  #endif /* __linux__ */
  }
  
@@ -162,9 +140,6 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
 +{
 +#if SDL_VERSION_ATLEAST(2,0,0)
 +    if (controller[cntrl].event_joystick) {
-+        SDL_HapticDestroyEffect(controller[cntrl].event_joystick, ffeffect_id[cntrl]);
-+        SDL_HapticDestroyEffect(controller[cntrl].event_joystick, ffstrong_id[cntrl]);
-+        SDL_HapticDestroyEffect(controller[cntrl].event_joystick, ffweak_id[cntrl]);
 +        SDL_HapticClose(controller[cntrl].event_joystick);
 +        controller[cntrl].event_joystick = NULL;
 +    }
@@ -174,7 +149,7 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
  /******************************************************************
    Function: InitiateControllers
    Purpose:  This function initialises how each of the controllers
-@@ -790,10 +913,13 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo)
+@@ -790,10 +888,13 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo)
      for( i = 0; i < 4; i++ )
      {
          // test for rumble support for this joystick
@@ -188,7 +163,7 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
      }
  
      DebugMessage(M64MSG_INFO, "%s version %i.%i.%i initialized.", PLUGIN_NAME, VERSION_PRINTF_SPLIT(PLUGIN_VERSION));
-@@ -830,12 +956,10 @@ EXPORT void CALL RomClosed(void)
+@@ -830,12 +931,10 @@ EXPORT void CALL RomClosed(void)
      int i;
  
      // close joysticks
@@ -205,7 +180,7 @@ index 8ce635c592f35d774d0ab8fadd25160328d03796..0a44f01e501785ed06331f5c0a5ff509
  
      // quit SDL joystick subsystem
      SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
-@@ -871,15 +995,10 @@ EXPORT int CALL RomOpen(void)
+@@ -871,15 +970,10 @@ EXPORT int CALL RomOpen(void)
          }
  
      // open joysticks
diff --git a/debian/patches/sdl2_mousemode.patch b/debian/patches/sdl2_mousemode.patch
index 2b5a9b0..7585b76 100644
--- a/debian/patches/sdl2_mousemode.patch
+++ b/debian/patches/sdl2_mousemode.patch
@@ -3,10 +3,10 @@ Author: Sven Eckelmann <sven at narfation.org>
 
 ---
 diff --git a/src/plugin.c b/src/plugin.c
-index 0a44f01e501785ed06331f5c0a5ff509e1e544f7..341fa767694899773f072be9a96dd23f8ad65713 100644
+index 5adf21a600be08306ad1c9d93df81a2b38f2723b..5f4839247d59c9fce5455e6696d6a2f8e7691ea9 100644
 --- a/src/plugin.c
 +++ b/src/plugin.c
-@@ -313,7 +313,7 @@ doSdlKeys(unsigned char* keystate)
+@@ -306,7 +306,7 @@ doSdlKeys(unsigned char* keystate)
                      grabmouse = !grabmouse;
                      // grab/ungrab mouse
  #if SDL_VERSION_ATLEAST(2,0,0)
@@ -15,7 +15,7 @@ index 0a44f01e501785ed06331f5c0a5ff509e1e544f7..341fa767694899773f072be9a96dd23f
  #else
                      SDL_WM_GrabInput( grabmouse ? SDL_GRAB_ON : SDL_GRAB_OFF );
  #endif
-@@ -582,9 +582,10 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+@@ -575,9 +575,10 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
      if (controller[Control].mouse)
      {
  #if SDL_VERSION_ATLEAST(2,0,0)
@@ -27,7 +27,7 @@ index 0a44f01e501785ed06331f5c0a5ff509e1e544f7..341fa767694899773f072be9a96dd23f
          {
              SDL_PumpEvents();
  #if SDL_VERSION_ATLEAST(1,3,0)
-@@ -593,6 +594,11 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
+@@ -586,6 +587,11 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
              while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
  #endif
              {
@@ -39,7 +39,7 @@ index 0a44f01e501785ed06331f5c0a5ff509e1e544f7..341fa767694899773f072be9a96dd23f
                  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 )
+@@ -594,10 +600,20 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
                  {
                      mousey_residual += (int) (event.motion.yrel * controller[Control].mouse_sens[1]);
                  }
@@ -61,7 +61,7 @@ index 0a44f01e501785ed06331f5c0a5ff509e1e544f7..341fa767694899773f072be9a96dd23f
          {
              mousex_residual = 0;
              mousey_residual = 0;
-@@ -966,7 +982,7 @@ EXPORT void CALL RomClosed(void)
+@@ -941,7 +957,7 @@ EXPORT void CALL RomClosed(void)
  
      // release/ungrab mouse
  #if SDL_VERSION_ATLEAST(2,0,0)
@@ -70,7 +70,7 @@ index 0a44f01e501785ed06331f5c0a5ff509e1e544f7..341fa767694899773f072be9a96dd23f
  #else
      SDL_WM_GrabInput( SDL_GRAB_OFF );
  #endif
-@@ -1003,10 +1019,12 @@ EXPORT int CALL RomOpen(void)
+@@ -978,10 +994,12 @@ EXPORT int CALL RomOpen(void)
      // grab mouse
      if (controller[0].mouse || controller[1].mouse || controller[2].mouse || controller[3].mouse)
      {

-- 
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