2009-11-04, 11:07
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:
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)
{