NOTE! This site uses cookies and similar technologies.

If you not change browser settings, you agree to it.

I understand

Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: [SOLVED] Xbox 360 Wireless Controller Navigation

Re: [SOLVED] Xbox 360 Wireless Controller Navigation 4 years 9 months ago #16

  • Jasjeet
  • Jasjeet's Avatar
Please can I get done help, I'm trying to get the Xbox 360 wireless USB receiver and Wirekess Xbox 360 game pad to work with the Raspberry Pi OpenELEC.

Currently it won't even pair, so I tried your mod, I found the files, copied in your code, replaced the archive, made the md5 checksum in the same directory, then ran the name command.

But it won't compile I get a hash mismatch error.

I didn't clear the cache, would that cause an issue, how do I clear the cache.

When using non modded files it compiles fine.
Last Edit: 4 years 9 months ago by Jasjeet.
The administrator has disabled public write access.

Re: [SOLVED] Xbox 360 Wireless Controller Navigation 4 years 9 months ago #17

  • Jasjeet
  • Jasjeet's Avatar
Ok, im now trying the that was posted in #13
diff -Naur xbmc-rpi-3c5a254/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml xbmc-rpi-3c5a254.patch/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml
--- xbmc-rpi-3c5a254/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml	2012-02-07 12:47:08.000000000 +0100
+++ xbmc-rpi-3c5a254.patch/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml	2012-02-07 16:25:10.091108000 +0100
@@ -1,70 +1,43 @@
-<!-- This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within XBMC -->
-<!-- The <global> section is a fall through - they will only be used if the button is not          -->
-<!-- used in the current window's section.  Note that there is only handling                       -->
-<!-- for a single action per button at this stage.                                                 -->
-<!-- For joystick/gamepad configuration under linux/win32, see below as it differs from xbox       -->
-<!-- gamepads.                                                                                     -->
+<!-- This file is designed to work only with the Xbox 360 Wireless Controller -->
+<!-- It will only work correctly with a modified SDLJoystick.cpp file that    -->
+<!-- has fixes in it for the 360 triggers                                     -->
 
-<!-- The format is:                      -->
-<!--    <device>                         -->
-<!--      <button>action</button>        -->
-<!--    </device>                        -->
-
-<!-- To map keys from other remotes using the RCA protocol, you may add <universalremote> blocks -->
-<!-- In this case, the tags used are <obc#> where # is the original button code (OBC) of the key -->
-<!-- You set it up by adding a <universalremote> block to the window or <global> section:       -->
-<!--    <universalremote>             -->
-<!--       <obc45>Stop</obc45>         -->
-<!--    </universalremote>            -->
-
-<!-- Note that the action can be a built-in function.                 -->
-<!--  eg <B>XBMC.ActivateWindow(MyMusic)</B>                         -->
-<!-- would automatically go to My Music on the press of the B button. -->
-
-<!-- Joysticks / Gamepads:                                                                    -->
-<!--   See the sample PS3 controller configuration below for the format.                      -->
-<!--                                                                                          -->
-<!--  Joystick Name:                                                                          -->
-<!--   Do 'cat /proc/bus/input/devices' or see your xbmc log file  to find the names of       -->
-<!--   detected joysticks. The name used in the configuration should match the detected name. -->
-<!--                                                                                          -->
-<!--  Button Ids:                                                                             -->
-<!--   'id' is the button ID used by SDL. Joystick button ids of connected joysticks appear   -->
-<!--   in xbmc.log when they are pressed. Use your log to map custom buttons to actions.      -->
-<!--                                                                                          -->
-<!--  Axis Ids / Analog Controls                                                              -->
-<!--   Coming soon.                                                                           -->
 <keymap>
   <global>
     <joystick name="Xbox 360 Wireless Receiver">
       <button id="1">Select</button> <!-- A -->
       <button id="2">Back</button> <!-- B -->
-      <button id="3"></button> <!-- X -->
-      <button id="4"></button> <!-- Y -->
-      <button id="5"></button> <!-- LB -->
+      <button id="3">Fullscreen</button> <!-- X -->
+      <button id="4">OSD</button> <!-- Y -->
+      <button id="5">ContextMenu</button> <!-- LB -->
       <button id="6"></button> <!-- RB -->
-      <button id="7"></button> <!-- ? -->
-      <button id="8"></button> <!-- ? -->
-      <button id="9">XBMC.ActivateWindow(PlayerControls)</button>
-      <button id="10"/>
-      <button id="11">Up</button>
-      <button id="12">Down</button>
-      <button id="13">Left</button>
-      <button id="14">Right</button>
-      <button id="15"></button>
-      <button id="16"></button>
-      <button id="17">PreviousMenu</button>
-      <axis limit="-1" id="5">VolumeUp</axis>
-      <axis limit="+1" id="5">VolumeDown</axis>
-      <axis limit="-1" id="4">AnalogSeekBack</axis>
-      <axis limit="+1" id="4">AnalogSeekForward</axis>
-      <axis limit="0" id="3">ScrollUp</axis>
-      <axis limit="0" id="6">ScrollDown</axis>
-    </joystick>
+      <button id="7">Back</button> <!-- Back -->
+      <button id="8"></button> <!-- Start -->
+      <button id="9">XBMC.ActivateWindow(Home)</button>  <!-- Xbox 360 Button -->
+      <button id="10"></button> <!-- Left Tumbstick Click -->
+      <button id="11">Screenshot</button> <!-- Right Thumbstick Click -->
+      <button id="12">Left</button> <!-- Dpad Left -->
+      <button id="13">Right</button> <!-- Dpad Right -->
+      <button id="14">Up</button> <!-- Dpad Up -->
+      <button id="15">Down</button> <!-- Dpad Down -->
+      
+      <axis limit="-1" id="1"></axis> <!-- Left stick, left -->
+	  <axis limit="1" id="1"></axis> <!-- Left stick, right -->
+	  <axis limit="-1" id="2">ScrollUp</axis> <!-- Left stick, up -->
+	  <axis limit="1" id="2">ScrollDown</axis> <!-- Left stick, down -->
+	  
+	  <axis limit="-1" id="4">AnalogSeekBack</axis> <!-- Right stick, left -->
+	  <axis limit="1" id="4">AnalogSeekForward</axis> <!-- Right stick, right -->
+	  <axis limit="-1" id="5">VolumeUp</axis> <!-- Right stick, up -->
+      <axis limit="1" id="5">VolumeDown</axis> <!-- Right stick, down -->
+      	  
+	  <axis limit="1" id="3">ScrollUp</axis> <!-- Left Trigger -->
+	  <axis limit="1" id="6">ScrollDown</axis> <!-- Right Trigger -->
+  </joystick>
   </global>
   <Home>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">XBMC.Skin.ToggleSetting(HomeViewToggle)</button>
+      <!-- <button id="3">XBMC.Skin.ToggleSetting(HomeViewToggle)</button> -->
     </joystick>
   </Home>
   <MyFiles>
@@ -75,19 +48,19 @@
   <MyMusicPlaylist>
     <joystick name="Xbox 360 Wireless Receiver">
       <button id="3">Back</button>
-      <button id="5">Delete</button>
+      <!-- <button id="5">Delete</button> -->
     </joystick>
   </MyMusicPlaylist>
   <MyMusicFiles>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">Playlist</button>
-      <button id="5">Queue</button>
+      <button id="3">FullScreen</button>
+      <button id="5">ContextMenu</button>
     </joystick>
   </MyMusicFiles>
   <MyMusicLibrary>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">Playlist</button>
-      <button id="5">Queue</button>
+      <!-- <button id="3">Playlist</button> -->
+      <button id="5">ContextMenu</button>
     </joystick>
   </MyMusicLibrary>
   <FullscreenVideo>
@@ -98,183 +71,179 @@
       <button id="5">AspectRatio</button>
       <button id="6">Info</button>
       <button id="9">OSD</button>
-      <button id="13">BigStepForward</button>
-      <button id="14">StepForward</button>
+      <button id="14">BigStepForward</button>
+      <button id="13">StepForward</button>
       <button id="15">BigStepBack</button>
-      <button id="16">StepBack</button>
-      <button id="17">SmallStepBack</button>
-      <axis limit="0" id="3">AnalogRewind</axis>
-      <axis limit="0" id="6">AnalogFastForward</axis>
+      <button id="12">StepBack</button>      
+      <axis limit="1" id="3">AnalogRewind</axis>
+      <axis limit="1" id="6">AnalogFastForward</axis>
     </joystick>
   </FullscreenVideo>
   <FullscreenInfo>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">CodecInfo</button>
-      <button id="6">Back</button>
-      <button id="9">OSD</button>
-      <axis limit="0" id="3">AnalogRewind</axis>
-      <axis limit="0" id="6">AnalogFastForward</axis>
+      <!-- <axis limit="1" id="3">AnalogRewind</axis> -->
+      <!-- <axis limit="1" id="6">AnalogFastForward</axis> -->
     </joystick>
   </FullscreenInfo>
   <PlayerControls>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="9">Back</button>
+      <!-- <button id="2">Back</button> -->
     </joystick>
   </PlayerControls>
   <Visualisation>
     <joystick name="Xbox 360 Wireless Receiver">
       <button id="1">Pause</button>
       <button id="2">Stop</button>
-      <button id="3">CodecInfo</button>
+      <button id="3">FullScreen</button>
+	  <button id="4">CodecInfo</button>
       <button id="5">XBMC.ActivateWindow(VisualisationPresetList)</button>
       <button id="6">Info</button>
-      <button id="9">XBMC.ActivateWindow(MusicOSD)</button>
-      <button id="13">NextPreset</button>
-      <button id="14">SkipNext</button>
-      <button id="15">PreviousPreset</button>
-      <button id="16">SkipPrevious</button>
-      <axis limit="0" id="3">AnalogRewind</axis>
-      <axis limit="0" id="6">AnalogFastForward</axis>
+      <button id="4">XBMC.ActivateWindow(MusicOSD)</button>
+      <button id="12">SkipPrevious</button>
+	  <button id="13">SkipNext</button>
+	  <button id="14">PreviousPreset</button>
+	  <button id="15">NextPreset</button>
+      <!-- <axis limit="1" id="3">AnalogRewind</axis> -->
+      <!-- <axis limit="1" id="6">AnalogFastForward</axis> -->
     </joystick>
   </Visualisation>
   <MusicOSD>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="19">Back</button>
-      <button id="3">CodecInfo</button>
-      <button id="6">Info</button>
+      <!-- <button id="2">Back</button> -->
+      <!-- <button id="3">CodecInfo</button> -->
+      <!-- <button id="6">Info</button> -->
     </joystick>
   </MusicOSD>
   <VisualisationSettings>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">Back</button>
-      <button id="9">Back</button>
+      <!-- <button id="2">Back</button> -->
+      <!-- <button id="9">Back</button> -->
     </joystick>
   </VisualisationSettings>
   <VisualisationPresetList>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">Back</button>
-      <button id="5">Back</button>
-      <button id="9">Back</button>
+      <!-- <button id="2">Back</button> -->
+      <!-- <button id="3">Back</button> -->
+      <!-- <button id="9">Back</button> -->
     </joystick>
   </VisualisationPresetList>
   <SlideShow>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="1">Pause</button>
-      <button id="2">Stop</button>
-      <button id="3">CodecInfo</button>
-      <button id="4">ZoomNormal</button>
-      <button id="5">Rotate</button>
-      <button id="6">Info</button>
-      <button id="13">ZoomIn</button>
-      <button id="14">NextPicture</button>
-      <button id="15">ZoomOut</button>
-      <button id="16">PreviousPicture</button>
-      <button id="17">Stop</button>
+      <!-- <button id="1">Pause</button> -->
+      <!-- <button id="2">Stop</button> -->
+      <!-- <button id="10">CodecInfo</button> -->
+      <!-- <button id="9">ZoomNormal</button> -->
+      <!-- <button id="14">Rotate</button> -->
+      <!-- <button id="4">Info</button> -->
+      <!-- <button id="5">ZoomIn</button> -->
+      <!-- <button id="13">NextPicture</button> -->
+      <!-- <button id="6">ZoomOut</button> -->
+      <!-- <button id="12">PreviousPicture</button> -->
     </joystick>
   </SlideShow>
   <ScreenCalibration>
     <joystick name="Xbox 360 Wireless Receiver">
       <button id="1">NextCalibration</button>
       <button id="3">ResetCalibration</button>
-      <button id="6">NextResolution</button>
+      <button id="4">NextResolution</button>
     </joystick>
   </ScreenCalibration>
   <GUICalibration>
     <joystick name="Xbox 360 Wireless Receiver">
       <button id="1">NextCalibration</button>
       <button id="3">ResetCalibration</button>
-      <button id="6">NextResolution</button>
+      <button id="4">NextResolution</button>
     </joystick>
   </GUICalibration>
   <VideoOSD>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="9">Back</button>
+      <!-- <button id="2">Back</button> -->
     </joystick>
   </VideoOSD>
   <VideoMenu>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="5">AspectRatio</button>
-      <button id="2">Stop</button>
-      <button id="9">OSD</button>
-      <button id="6">Info</button>
-      <button id="3">CodecInfo</button>
+      <!-- <button id="5">AspectRatio</button> -->
+      <!-- <button id="2">Stop</button> -->
+      <!-- <button id="9">OSD</button> -->
+      <!-- <button id="4">Info</button> -->
+      <!-- <button id="3">CodecInfo</button> -->
     </joystick>
   </VideoMenu>
   <OSDVideoSettings>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="4"/>
-      <button id="5">AspectRatio</button>
-      <button id="19">Back</button>
+      <!-- <button id="4"/> -->
+      <!-- <button id="5">AspectRatio</button> -->
+      <!-- <button id="19">Back</button> -->
     </joystick>
   </OSDVideoSettings>
   <OSDAudioSettings>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="4"/>
-      <button id="5">AspectRatio</button>
-      <button id="19">Back</button>
+      <!-- <button id="4"/> -->
+      <!-- <button id="5">AspectRatio</button> -->
+      <!-- <button id="7">Back</button> -->
     </joystick>
   </OSDAudioSettings>
   <VideoBookmarks>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="4"/>
-      <button id="5">Delete</button>
-      <button id="19">Back</button>
+      <!-- <button id="4"/> -->
+      <!-- <button id="5">Delete</button> -->
+      <!-- <button id="7">Back</button> -->
     </joystick>
   </VideoBookmarks>
   <MyVideoLibrary>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">Delete</button>
+      <!-- <button id="3">Delete</button> -->
     </joystick>
   </MyVideoLibrary>
   <MyVideoFiles>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="5">Queue</button>
-      <button id="3">Playlist</button>
+      <!-- <button id="5">Queue</button> -->
+      <!-- <button id="3">Playlist</button> -->
     </joystick>
   </MyVideoFiles>
   <MyVideoPlaylist>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="5">Delete</button>
-      <button id="3">Back</button>
+      <!-- <button id="5">Delete</button> -->
+      <!-- <button id="7">Back</button> -->
     </joystick>
   </MyVideoPlaylist>
   <VirtualKeyboard>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="9">Enter</button>
-      <button id="2">BackSpace</button>
+      <button id="8">Enter</button>
+      <button id="3">BackSpace</button>
       <button id="5">Shift</button>
-      <button id="4">Symbols</button>
+      <button id="6">Symbols</button>
     </joystick>
   </VirtualKeyboard>
   <ContextMenu>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="6">Back</button>
+      <button id="7">Back</button> -->
     </joystick>
   </ContextMenu>
   <Scripts>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="3">XBMC.ActivateWindow(ScriptsDebugInfo)</button>
+      <button id="4">XBMC.ActivateWindow(ScriptsDebugInfo)</button>
     </joystick>
   </Scripts>
   <NumericInput>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="2">BackSpace</button>
-      <button id="9">Enter</button>
+      <button id="3">BackSpace</button>
+      <button id="8">Enter</button>
     </joystick>
   </NumericInput>
   <GamepadInput>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="9">Stop</button>      <!-- Enter Password -->
+      <!-- <button id="9">Stop</button> -->
     </joystick>
   </GamepadInput>
   <LockSettings>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="9">Back</button>
+      <!-- <button id="7">Back</button> -->
     </joystick>
   </LockSettings>
   <ProfileSettings>
     <joystick name="Xbox 360 Wireless Receiver">
-      <button id="9">Back</button>
+      <!-- <button id="7">Back</button> -->
     </joystick>
   </ProfileSettings>
-</keymap>
+</keymap>
\ Kein Zeilenumbruch am Dateiende.
diff -Naur xbmc-rpi-3c5a254/xbmc/input/SDLJoystick.cpp xbmc-rpi-3c5a254.patch/xbmc/input/SDLJoystick.cpp
--- xbmc-rpi-3c5a254/xbmc/input/SDLJoystick.cpp	2012-02-07 12:46:48.000000000 +0100
+++ xbmc-rpi-3c5a254.patch/xbmc/input/SDLJoystick.cpp	2012-02-07 16:26:02.181313000 +0100
@@ -18,6 +18,8 @@
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */
+//Modified Nov 18, 2011 by Andrew Lockwood
+//Supports ONLY Xbox 360 Wireless controllers - maybe wired as well.
 
 #include "system.h"
 #include "SDLJoystick.h"
@@ -43,8 +45,11 @@
   m_HatId = 0;
   m_HatState = SDL_HAT_CENTERED;
   m_ActiveFlags = JACTIVE_NONE;
-  for (int i = 0 ; i<MAX_AXES ; i++)
-    m_Amount[i] = 0;
+  is_used = false;
+ for (int i = 0 ; i<MAX_AXES ; i++)
+  {
+   m_Amount[i] = 0;
+  }
   SetDeadzone(0);
 }
 
@@ -75,26 +80,19 @@
     // load joystick names and open all connected joysticks
     for (int i = 0 ; i<SDL_NumJoysticks() ; i++)
     {
-      SDL_Joystick *joy = SDL_JoystickOpen(i);
+      if (i > 0) //Hack to stop extra joysticks from being polled. Controller is always joy 0 on my system but 4 show up...?
+       break;
 
-#ifdef __APPLE__
-      // On OS X, the 360 controllers are handled externally, since the SDL code is
-      // really buggy and doesn't handle disconnects.
-      //
-      if (std::string(SDL_JoystickName(i)).find("360") != std::string::npos)
-      {
-        CLog::Log(LOGNOTICE, "Ignoring joystick: %s", SDL_JoystickName(i));
-        continue;
-      }
-#endif
+      SDL_Joystick *joy = SDL_JoystickOpen(i);
 
       m_Joysticks.push_back(joy);
       if (joy)
       {
         m_JoystickNames.push_back(string(SDL_JoystickName(i)));
-        CLog::Log(LOGNOTICE, "Enabled Joystick: %s", SDL_JoystickName(i));
+        CLog::Log(LOGNOTICE, "Enabled Joystick: %s, Joystick Id: %d", SDL_JoystickName(i), i);
         CLog::Log(LOGNOTICE, "Details: Total Axis: %d Total Hats: %d Total Buttons: %d",
-            SDL_JoystickNumAxes(joy), SDL_JoystickNumHats(joy), SDL_JoystickNumButtons(joy));        
+            SDL_JoystickNumAxes(joy), SDL_JoystickNumHats(joy), SDL_JoystickNumButtons(joy));
+        CLog::Log(LOGNOTICE, "**SUPPORT FOR XBOX 360 CONTROLLER ONLY**");
       }
       else
       {
@@ -123,24 +121,27 @@
 {
   int buttonId    = -1;
   int axisId      = -1;
-  int hatId       = -1;
+  //int hatId       = -1;
   int numj        = m_Joysticks.size();
   if (numj <= 0)
     return;
 
+  numj = 1; //hack to disable needless polling as my system always has the joystick on joystick 0
+  CLog::Log(LOGDEBUG, "Entered CJoystick::Update()...");
+
   // update the state of all opened joysticks
   SDL_JoystickUpdate();
 
   // go through all joysticks
   for (int j = 0; j<numj; j++)
   {
+    CLog::Log(LOGDEBUG, "JoyStick Id = %d", j);
+    
     SDL_Joystick *joy = m_Joysticks[j];
     int numb = SDL_JoystickNumButtons(joy);
-    int numhat = SDL_JoystickNumHats(joy);
     int numax = SDL_JoystickNumAxes(joy);
     numax = (numax>MAX_AXES)?MAX_AXES:numax;
     int axisval;
-    uint8_t hatval;
 
     // get button states first, they take priority over axis
     for (int b = 0 ; b<numb ; b++)
@@ -154,18 +155,7 @@
       }
     }
     
-    for (int h = 0; h < numhat; h++)
-    {
-      hatval = SDL_JoystickGetHat(joy, h);
-      if (hatval != SDL_HAT_CENTERED)
-      {
-        m_JoyId = SDL_JoystickIndex(joy);
-        hatId = h + 1;
-        m_HatState = hatval;
-        j = numj-1;
-        break; 
-      }
-    }
+    //removed hat check
 
     // get axis states
     m_NumAxes = numax;
@@ -179,11 +169,17 @@
       }
       else
       {
-        m_Amount[axisId] = axisval;  //[-32768 to 32767]
+        m_Amount[axisId] = axisval;  //-32768 to 32767
+	
+        if (is_used == false && axisval != 0 && (axisId == 3 || axisId == 6))
+	  is_used = true; //set to true as an axis or button has been touched and it's no longer the default 0 init value
+	CLog::Log(LOGDEBUG, "Axis %d value = %d", axisId, axisval);
       }
     }
+
     m_AxisId = GetAxisWithMaxAmount();
-    if (m_AxisId)
+
+    if (m_AxisId) //if !0 set the joystick index and break out of the loop
     {
       m_JoyId = SDL_JoystickIndex(joy);
       j = numj-1;
@@ -191,24 +187,7 @@
     }
   }
 
-  if(hatId==-1)
-  {
-    if(m_HatId!=0)
-      CLog::Log(LOGDEBUG, "Joystick %d hat %u Centered", m_JoyId, hatId);
-    m_pressTicksHat = 0;
-    SetHatActive(false);
-    m_HatId = 0;
-  }
-  else
-  {
-    if(hatId!=m_HatId)
-    {
-      CLog::Log(LOGDEBUG, "Joystick %d hat %u Down", m_JoyId, hatId);
-      m_HatId = hatId;
-      m_pressTicksHat = SDL_GetTicks();
-    }
-    SetHatActive();
-  }
+  //removed hat code
 
   if (buttonId==-1)
   {
@@ -230,107 +209,18 @@
     }
     SetButtonActive();
   }
-
 }
 
 void CJoystick::Update(SDL_Event& joyEvent)
 {
-  int buttonId = -1;
-  int axisId = -1;
-  int joyId = -1;
-  DECLARE_UNUSED(bool,ignore = false)
-  DECLARE_UNUSED(bool,axis = false);
-
-  switch(joyEvent.type)
-  {
-  case SDL_JOYBUTTONDOWN:
-    m_JoyId = joyId = joyEvent.jbutton.which;
-    m_ButtonId = buttonId = joyEvent.jbutton.button + 1;
-    m_pressTicksButton = SDL_GetTicks();
-    SetButtonActive();
-    CLog::Log(LOGDEBUG, "Joystick %d button %d Down", joyId, buttonId);
-    break;
-
-  case SDL_JOYAXISMOTION:
-    joyId = joyEvent.jaxis.which;
-    axisId = joyEvent.jaxis.axis + 1;
-    m_NumAxes = SDL_JoystickNumAxes(m_Joysticks[joyId]);
-    if (axisId<=0 || axisId>=MAX_AXES)
-    {
-      CLog::Log(LOGERROR, "Axis Id out of range. Maximum supported axis: %d", MAX_AXES);
-      ignore = true;
-      break;
-    }
-    axis = true;
-    m_JoyId = joyId;
-    if (joyEvent.jaxis.value==0)
-    {
-      ignore = true;
-      m_Amount[axisId] = 0;
-    }
-    else
-    {
-      m_Amount[axisId] = joyEvent.jaxis.value; //[-32768 to 32767]
-    }
-    m_AxisId = GetAxisWithMaxAmount();
-    CLog::Log(LOGDEBUG, "Joystick %d Axis %d Amount %d", joyId, axisId, m_Amount[axisId]);
-    break;
-
-  case SDL_JOYHATMOTION:
-    m_JoyId = joyId = joyEvent.jbutton.which;
-    m_HatId = joyEvent.jhat.hat + 1;
-    m_pressTicksHat = SDL_GetTicks();
-    m_HatState = joyEvent.jhat.value;
-    SetHatActive(m_HatState != SDL_HAT_CENTERED);
-    CLog::Log(LOGDEBUG, "Joystick %d Hat %d Down with position %d", joyId, buttonId, m_HatState);
-    break;
-
-  case SDL_JOYBALLMOTION:
-    ignore = true;
-    break;
-    
-  case SDL_JOYBUTTONUP:
-    m_pressTicksButton = 0;
-    SetButtonActive(false);
-    CLog::Log(LOGDEBUG, "Joystick %d button %d Up", joyEvent.jbutton.which, m_ButtonId);
-
-  default:
-    ignore = true;
-    break;
-  }
+  //Stubbed out - never saw this called. Assuming it's used for event based detection. Why is that not the default?
+  //Seems that event based triggering would be more efficient than polling...?
 }
 
 bool CJoystick::GetHat(int &id, int &position,bool consider_repeat) 
 {
-  if (!IsHatActive())
-    return false;
-  position = m_HatState;
-  id = m_HatId;
-  if (!consider_repeat)
-    return true;
-
-  static uint32_t lastPressTicks = 0;
-  static uint32_t lastTicks = 0;
-  static uint32_t nowTicks = 0;
-
-  if ((m_HatId>=0) && m_pressTicksHat)
-  {
-    // return the id if it's the first press
-    if (lastPressTicks!=m_pressTicksHat)
-    {
-      lastPressTicks = m_pressTicksHat;
-      return true;
-    }
-    nowTicks = SDL_GetTicks();
-    if ((nowTicks-m_pressTicksHat)<500) // 500ms delay before we repeat
-      return false;
-    if ((nowTicks-lastTicks)<100) // 100ms delay before successive repeats
-      return false;
-
-    lastTicks = nowTicks;
-  }
-
-  return true;
+  //stubbed out
+  return false;
 } 
 
 bool CJoystick::GetButton(int &id, bool consider_repeat)
@@ -378,26 +268,57 @@
   axis = 0;
   maxAmount = 0;
   int tempf;
+  int tempval;
+
   for (int i = 1 ; i<=m_NumAxes ; i++)
   {
     tempf = abs(m_Amount[i]);
-    if (tempf>m_DeadzoneRange && tempf>maxAmount)
+    tempval = TriggerValue(m_Amount[i]);
+
+    //CLog::Log(LOGDEBUG, "GetAxisWithMaxAmount - tempf = %d, non-abs value = %d,Axis = %d", tempf, tempval, i);
+
+    if ((i == 3 || i == 6) && tempval > 0) //TriggerValue accounts for init =0 case and then scales properly 
+    {
+      maxAmount = (tempval / 2); //divide by 2 as it won't handle > 32768
+      axis = i;
+      CLog::Log(LOGDEBUG, "GetAxisWithMaxAmount_2 - Axis: %d, Value = %d, maxAmount = %d", axis, m_Amount[i], (maxAmount / 2));
+    }
+
+    if (tempf>m_DeadzoneRange && tempf>maxAmount && i != 3 && i != 6)
     {
       maxAmount = tempf;
       axis = i;
+      CLog::Log(LOGDEBUG, "GetAxisWithMaxAmount_3 - Axis: %d, Value = %d, maxAmount = %d", axis, m_Amount[i], maxAmount);
     }
   }
+  
+  CLog::Log(LOGDEBUG, "SetAxisActive? - %d", (0 != maxAmount));
   SetAxisActive(0 != maxAmount);
   return axis;
 }
 
 float CJoystick::GetAmount(int axis)
 {
-  if (m_Amount[axis] > m_DeadzoneRange)
-    return (float)(m_Amount[axis]-m_DeadzoneRange)/(float)(MAX_AXISAMOUNT-m_DeadzoneRange);
-  if (m_Amount[axis] < -m_DeadzoneRange)
-    return (float)(m_Amount[axis]+m_DeadzoneRange)/(float)(MAX_AXISAMOUNT-m_DeadzoneRange);
-  return 0;
+  CLog::Log(LOGDEBUG, "GetAmount - Axis %d, m_Amount = %d, MAX_AXIS = %d, m_Deadzone = %d", axis, m_Amount[axis], MAX_AXISAMOUNT, m_DeadzoneRange);
+  float fval = 0;
+
+  if ((axis == 3 || axis == 6) && TriggerValue(m_Amount[axis]) != 0) //ignore 0
+    fval = (float)(TriggerValue(m_Amount[axis]))/(float)(65535); //trigger is re-scaled to all positive
+  else if ((m_Amount[axis] > m_DeadzoneRange) && axis != 3 && axis != 6)
+    fval = (float)(m_Amount[axis]-m_DeadzoneRange)/(float)(MAX_AXISAMOUNT-m_DeadzoneRange);
+  else if ((m_Amount[axis] < -m_DeadzoneRange) && axis != 3 && axis != 6)
+    fval = (float)(m_Amount[axis]+m_DeadzoneRange)/(float)(MAX_AXISAMOUNT-m_DeadzoneRange);
+
+  CLog::Log(LOGDEBUG, "GetAmount_2 - Axis %d, fval =  %f", axis, fval);
+  return fval;
+}
+
+int CJoystick::TriggerValue(int axisValue)
+{
+  if (is_used == true && axisValue  > -32268) //minimal deadzone (500) due to springs on the triggers
+    return (axisValue + 32768); //scale becomes 0 to 65535 because max positive = 32767
+  else
+    return 0;
 }
 
 
-#endif
+#endif
\ Kein Zeilenumbruch am Dateiende.
diff -Naur xbmc-rpi-3c5a254/xbmc/input/SDLJoystick.h xbmc-rpi-3c5a254.patch/xbmc/input/SDLJoystick.h
--- xbmc-rpi-3c5a254/xbmc/input/SDLJoystick.h	2012-02-07 12:46:48.000000000 +0100
+++ xbmc-rpi-3c5a254.patch/xbmc/input/SDLJoystick.h	2012-02-07 16:26:23.988820000 +0100
@@ -18,7 +18,8 @@
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */
-
+//Modified Nov 18, 2011 by Andrew Lockwood
+//Supports ONLY Xbox 360 Wireless controllers - maybe wired as well.
 #ifndef SDL_JOYSTICK_H
 #define SDL_JOYSTICK_H
 
@@ -43,7 +44,6 @@
 #define MAX_AXES 64
 #define MAX_AXISAMOUNT 32768
 
-
 // Class to manage all connected joysticks
 
 class CJoystick
@@ -72,6 +72,7 @@
   bool IsButtonActive() { return (m_ActiveFlags & JACTIVE_BUTTON) == JACTIVE_BUTTON; }
   bool IsAxisActive() { return (m_ActiveFlags & JACTIVE_AXIS) == JACTIVE_AXIS; }
   bool IsHatActive() { return (m_ActiveFlags & JACTIVE_HAT) == JACTIVE_HAT; }
+  int TriggerValue(int axisValue);
 
   int m_Amount[MAX_AXES];
   int m_AxisId;
@@ -86,10 +87,11 @@
   uint8_t m_ActiveFlags;
   std::vector<SDL_Joystick*> m_Joysticks;
   std::vector<std::string> m_JoystickNames;
+  bool is_used;
 };
 
 extern CJoystick g_Joystick;
 
 #endif
 
-#endif
+#endif
\ Kein Zeilenumbruch am Dateiende.

I changed xbmc-1fef727-982 to xbmc-rpi-3c5a254
and i removed code of line 326 due to error
APPLY PATCH: packages/mediacenter/xbmc/patches/xbmc-11.0.1-982-Enable_xbox360_controller.patch
patching file system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml
patching file xbmc/input/SDLJoystick.cpp
Hunk #10 FAILED at 326.
1 out of 10 hunks FAILED -- saving rejects to file xbmc/input/SDLJoystick.cpp.rej
patching file xbmc/input/SDLJoystick.h
Hunk #3 succeeded at 73 (offset 1 line).
Hunk #4 succeeded at 88 (offset 1 line).
make: *** [release] Error 1

I also put xbox360.xml in \Userdata\keymaps on my Raspberry Pi Storage partition.

Now successfully compiled, moving KERNEL and SYSTEM to Raspberry Pi. After reboot still no control.
The Wireless Receiver stop blinking as if its about to Pair up but the Xbox 360 Wireless Gamepad continues blinking and never connects.

What do i do?
Last Edit: 4 years 9 months ago by Jasjeet.
The administrator has disabled public write access.

Re: [SOLVED] Xbox 360 Wireless Controller Navigation 4 years 8 months ago #18

  • fred0r
  • fred0r's Avatar
It would be really cool if wireless Support of Xbox360-Controller would work as i know it from the xbox1.
The administrator has disabled public write access.

Re: [SOLVED] Xbox 360 Wireless Controller Navigation 4 years 8 months ago #19

  • lrusak
  • lrusak's Avatar
fred0r wrote:
It would be really cool if wireless Support of Xbox360-Controller would work as i know it from the xbox1.

I'm sorry fred but I doubt anyone is familiar with how it was.

I told you in IRC that I would help you remap the current keymaping. You just have to tell me what the original mapping was.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2