Skip to content

Commit 2889c12

Browse files
committed
fixed repeated key inputs duration=0, Pulse-Eight#326 by reverting ef8bc8e
1 parent 3bbd432 commit 2889c12

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/libcec/CECClient.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ CCECClient::CCECClient(CCECProcessor *processor, const libcec_configuration &con
6060
m_releaseButtontime(0),
6161
m_pressedButtoncount(0),
6262
m_releasedButtoncount(0),
63-
m_iPreventForwardingPowerOffCommand(0)
64-
{
65-
m_configuration.Clear();
63+
m_iPreventForwardingPowerOffCommand(0),
64+
m_iLastKeypressTime(0)
65+
{
66+
m_lastKeypress.keycode = CEC_USER_CONTROL_CODE_UNKNOWN;
67+
m_lastKeypress.duration = 0;
68+
m_configuration.Clear();
6669
// set the initial configuration
6770
SetConfiguration(configuration);
6871
CreateThread(false);
@@ -1650,7 +1653,20 @@ void CCECClient::CallbackAddKey(const cec_keypress &key)
16501653
{
16511654
CLockObject lock(m_cbMutex);
16521655
if (m_configuration.callbacks && !!m_configuration.callbacks->keyPress)
1653-
m_configuration.callbacks->keyPress(m_configuration.callbackParam, &key);
1656+
{
1657+
// prevent double taps
1658+
int64_t now = GetTimeMs();
1659+
if (m_lastKeypress.keycode != key.keycode ||
1660+
key.duration > 0 ||
1661+
now - m_iLastKeypressTime >= DoubleTapTimeoutMS())
1662+
{
1663+
// no double tap
1664+
if (key.duration == 0)
1665+
m_iLastKeypressTime = now;
1666+
m_lastKeypress = key;
1667+
m_configuration.callbacks->keyPress(m_configuration.callbackParam, &key);
1668+
}
1669+
}
16541670
}
16551671

16561672
void CCECClient::CallbackAddLog(const cec_log_message_cpp &message)

src/libcec/CECClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ namespace CEC
459459
int32_t m_pressedButtoncount; /**< the number of times a button released message has been seen for this press. */
460460
int32_t m_releasedButtoncount; /**< the number of times a button pressed message has been seen for this press. */
461461
int64_t m_iPreventForwardingPowerOffCommand; /**< prevent forwarding standby commands until this time */
462+
int64_t m_iLastKeypressTime; /**< last time a key press was sent to the client */
463+
cec_keypress m_lastKeypress; /**< the last key press that was sent to the client */
462464
P8PLATFORM::SyncedBuffer<CCallbackWrap*> m_callbackCalls;
463465
};
464466
}

0 commit comments

Comments
 (0)