Gamepad "D-pad" (axis) repeat-delay
#1
Running 16.1 on Ubuntu 16.04.

I've got a Logitech gamepad (basic USB gamepad with digital D-pad only)
Code:
Driver version is 2.1.0.
Joystick (Logitech Logitech(R) Precision(TM) Gamepad) has 2 axes (X, Y)
and 10 buttons (Trigger, ThumbBtn, ThumbBtn2, TopBtn, TopBtn2, PinkieBtn, BaseBtn, BaseBtn2, BaseBtn3, BaseBtn4).
Testing ... (interrupt to exit)
Axes:  0:     0  1:     0 Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off

Keymap is set-up as follows:
Code:
<?xml version="1.0" encoding="utf-8"?>
<keymap>
  <global>
    <joystick name="Logitech Logitech(R) Precision(TM) Gamepad">
      <button id="1">Select</button>
      <button id="2">ParentDir</button>
      <button id="3">Pause</button>
      <button id="4">Stop</button>
      <button id="5">skipPrevious</button>
      <button id="6">skipNext</button>
      <button id="7">Rewind</button>
      <button id="8">FastForward</button>
      <button id="9">ContextMenu</button>
      <button id="10">FullScreen</button>
      <axis limit="+1" id="1">Right</axis>
      <axis limit="-1" id="1">Left</axis>
      <axis limit="+1" id="2">Down</axis>
      <axis limit="-1" id="2">Up</axis>
    </joystick>
  </global>
</keymap>

Anyway, the issue I was having was that when I try and use the axis to control Kodi (moving in the menus etc) I get several "presses" even if I tap the d-pad really quickly.

The only solution I could find was running j-hat in the background (to convert the axes into hats). I didn't want to do that for various reasons (didn't play well with emulators mostly).

I "fixed" it with the below hack (applies to 16.1). Hopefully comes in useful for someone else. Perhaps someone can come up with a better solution?

Code:
diff --git a/xbmc/input/SDLJoystick.cpp b/xbmc/input/SDLJoystick.cpp
index b1e71e1..038a958 100644
--- a/xbmc/input/SDLJoystick.cpp
+++ b/xbmc/input/SDLJoystick.cpp
@@ -44,6 +44,7 @@ void CJoystick::Reset()
   m_AxisIdx = -1;
   m_ButtonIdx = -1;
   m_HatIdx = -1;
+  m_lastAxisUpdate = 0;
   m_HatState = SDL_HAT_CENTERED;
   for (std::vector<AxisState>::iterator it = m_Axes.begin(); it != m_Axes.end(); ++it)
     it->reset();
@@ -313,6 +314,8 @@ bool CJoystick::GetAxes(std::list<std::pair<std::string, int> >& axes, bool cons
   SDL_Joystick *joy;
   int axisId;

+  uint32_t nowTicks = SDL_GetTicks();
+  
   for (size_t i = 0; i < m_Axes.size(); ++i)
   {
     int deadzone = m_Axes[i].trigger ? 0 : m_DeadzoneRange;
@@ -323,8 +326,13 @@ bool CJoystick::GetAxes(std::list<std::pair<std::string, int> >& axes, bool cons
       ret.push_back(std::pair<std::string, int>(SDL_JoystickName(joy), axisId));
     }
   }
+  bool result = (nowTicks - m_lastAxisUpdate > 150);
+
+  if (result)
+    m_lastAxisUpdate = nowTicks;
+  
   axes = ret;
-  return true;
+  return result;
}

int CJoystick::GetAxisWithMaxAmount() const
diff --git a/xbmc/input/SDLJoystick.h b/xbmc/input/SDLJoystick.h
index 7faa108..4148229 100644
--- a/xbmc/input/SDLJoystick.h
+++ b/xbmc/input/SDLJoystick.h
@@ -118,6 +118,8 @@ private:
   bool m_joystickEnabled;
   uint32_t m_pressTicksButton;
   uint32_t m_pressTicksHat;
+  uint32_t m_lastAxisUpdate;
+  
   std::map<int, SDL_Joystick*> m_Joysticks;
};


Cheers,
Eddie
Reply
#2
Im having the exact same issue but with a xin-mo arcade controller via USB. Can you provide a step by step on how to fix this.. where do I paste the code?
Reply
#3
+1 Way too sensitive dpad with a SNES SFC30

my xml:
Code:
<joystick>
    <axis id="2" limit="-1">Up</axis>
    <axis id="2" limit="+1">Down</axis>
    <axis id="1" limit="-1">Left</axis>
    <axis id="1" limit="+1">Right</axis>
    <button id="1">Select</button>
    <button id="2">PreviousMenu</button>
    <button id="11">activatewindow(favourites)</button>
</joystick>
Reply

Logout Mark Read Team Forum Stats Members Help
Gamepad "D-pad" (axis) repeat-delay0