[PATCH] Ignore duplicate remote button presses
#1
I recently bought an OrigenAE remote for the programmable TV power and volume buttons, but after receiving it, I'm finding that it sometimes sends multiple button presses for a single physical press (especially on the OK key). These are showing up in irw as multiple events with 00 sequences, so XBMC is interpreting each one as a separate event. I didn't see any good way to have LIRC drop the double presses, nor did using irrecord to make a new conf file for the remote do anything, so I created this patch for LIRC.cpp/.h and AdvancedSettings.cpp/.h to add a remoteskip tag with skipvalue and skipreset subtags (skipvalue is how long to wait before allowing a new keypress and skipreset is a toggle to determine whether a new keypress resets that timer).

The problem is, while it seems to work for my purposes and does eliminate the double presses, setting it to a long time period like 1500 milliseconds and tapping on a button allows some presses through. Does anybody have any suggestions as to how I might correct that or any suggestions as to how to better accomplish this? Here's what I've done so far:

Code:
Index: trunk/xbmc/AdvancedSettings.cpp
===================================================================
--- trunk/xbmc/AdvancedSettings.cpp    (revision 24272)
+++ trunk/xbmc/AdvancedSettings.cpp    (working copy)
@@ -156,6 +156,8 @@
   m_tvshowMultiPartStackRegExp = "^[-EeXx]+([0-9]+)";

   m_remoteRepeat = 480;
+  m_remoteSkip = 10;
+  m_remoteSkipReset = false;
   m_controllerDeadzone = 0.2f;

   m_playlistAsFolders = true;
@@ -636,6 +638,15 @@
   }

   XMLUtils::GetInt(pRootElement, "remoterepeat", m_remoteRepeat, 1, INT_MAX);
+
+  //Skip multiple quick remote presses
+  pElement = pRootElement->FirstChildElement("remoteskip");
+  if (pElement)
+  {
+    XMLUtils::GetInt(pElement, "skipvalue", m_remoteSkip, 1, INT_MAX);
+    XMLUtils::GetBoolean(pElement, "skipreset", m_remoteSkipReset);
+  }
+  
   XMLUtils::GetFloat(pRootElement, "controllerdeadzone", m_controllerDeadzone, 0.0f, 1.0f);
   XMLUtils::GetInt(pRootElement, "thumbsize", m_thumbSize, 64, 1024);
   XMLUtils::GetBoolean(pRootElement, "useddsfanart", m_useDDSFanart);
Index: trunk/xbmc/AdvancedSettings.h
===================================================================
--- trunk/xbmc/AdvancedSettings.h    (revision 24272)
+++ trunk/xbmc/AdvancedSettings.h    (working copy)
@@ -136,6 +136,8 @@
     CStdString m_tvshowMultiPartStackRegExp;
     CStdStringArray m_pathSubstitutions;
     int m_remoteRepeat;
+    int m_remoteSkip;
+    bool m_remoteSkipReset;
     float m_controllerDeadzone;

     bool m_playlistAsFolders;
Index: trunk/guilib/common/LIRC.h
===================================================================
--- trunk/guilib/common/LIRC.h    (revision 24272)
+++ trunk/guilib/common/LIRC.h    (working copy)
@@ -35,6 +35,7 @@
   bool    m_used;
   bool    m_bLogConnectFailure;
   uint32_t    m_firstClickTime;
+  uint32_t    m_lastClickTime;
   CStdString  m_deviceName;
   bool        CheckDevice();
};
Index: trunk/guilib/common/LIRC.cpp
===================================================================
--- trunk/guilib/common/LIRC.cpp    (revision 24272)
+++ trunk/guilib/common/LIRC.cpp    (working copy)
@@ -31,6 +31,7 @@
   m_bLogConnectFailure = true;
   m_lastInitAttempt = -5000;
   m_initRetryPeriod = 5000;
+  m_lastClickTime = 0;
   Reset();
}

@@ -231,11 +232,22 @@

     if (strcmp(repeatStr, "00") == 0)
     {
-      CLog::Log(LOGDEBUG, "LIRC: %s - NEW at %d:%s (%s)", __FUNCTION__, now, m_buf, buttonName);
-      m_firstClickTime = now;
-      m_isHolding = false;
-      m_skipHold = true;
-      return;
+      if (now - m_lastClickTime >= (uint32_t) g_advancedSettings.m_remoteSkip)
+      {
+        CLog::Log(LOGDEBUG, "LIRC: %s - NEW at %d:%s (%s)", __FUNCTION__, now, m_buf, buttonName);
+        m_firstClickTime = now;
+        m_lastClickTime = now;
+        m_isHolding = false;
+        m_skipHold = true;
+        return;
+      }
+      else
+      {
+        CLog::Log(LOGDEBUG, "LIRC: %s - DUPLICATE button at %d.  Dropping %s (%s)", __FUNCTION__, now, m_buf, buttonName);
+        m_button = 0;
+        if (g_advancedSettings.m_remoteSkipReset)
+          m_lastClickTime = now;
+      }
     }
     else if (now - m_firstClickTime >= (uint32_t) g_advancedSettings.m_remoteRepeat && !m_skipHold)
     {
Reply
#2
Is this a problem with XBMC or the OS ? It looks to be OS is receiving it as two keypresses ...
The normal XBMC log IS NOT a debug log, to enable debug logging you must toggle it on under XBMC Settings - System or in advancedsettings.xml. Use XBMC Debug Log Addon to retrieve it.
Reply
#3
LIRC is receiving it as two keypresses and I'm actually pretty confident that it's sending two, as using irrecord to make a custom remote conf file didn't help things any. It still sent two from time to time, so neither LIRC nor XBMC is doing anything wrong. Both are receiving and processing two keypresses, as they should, but I can't make changes to the remote itself so I need to have one of them account for this.
Reply
#4
lirc is.. we read what lirc says about if a keypress is a repeating keypress or not.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
I know lirc has a parameter (should be "gap") and xbmc also - at least had - one to put in advancedsettings for this. So patching seems overkill to me - and what about buttons that are supposed to be interpreted repeatedly like vol+/vol-? I happen to have a RF-remote here which has such a behaviour: repeats almost every button except volume!! And it's really annoying. But that's a cheap hardware problem in my case...
Reply
#6
elupus Wrote:lirc is.. we read what lirc says about if a keypress is a repeating keypress or not.

I think the major difference is that typically you can use a .lircrc file to help mitigate the issue. Is there any way to do this with XBMC? I have tried a few things here and there and I am having no luck. As of right now my XBMC box is useless
Reply

Logout Mark Read Team Forum Stats Members Help
[PATCH] Ignore duplicate remote button presses0