MCPcopy Create free account
hub / github.com/Pulse-Eight/libcec / AddKey

Method AddKey

src/libcec/CECClient.cpp:1030–1069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1028}
1029
1030void CCECClient::AddKey(bool bSendComboKey /* = false */, bool bButtonRelease /* = false */)
1031{
1032 cec_keypress key;
1033 key.keycode = CEC_USER_CONTROL_CODE_UNKNOWN;
1034
1035 {
1036 CLockObject lock(m_mutex);
1037 if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN)
1038 {
1039 unsigned int duration = (unsigned int) (GetTimeMs() - m_updateButtontime);
1040 key.duration = (unsigned int) (GetTimeMs() - m_initialButtontime);
1041
1042 if (duration > m_configuration.iComboKeyTimeoutMs ||
1043 m_configuration.iComboKeyTimeoutMs == 0 ||
1044 m_iCurrentButton != m_configuration.comboKey ||
1045 bSendComboKey)
1046 {
1047 key.keycode = m_iCurrentButton;
1048
1049 m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN;
1050 m_initialButtontime = 0;
1051 m_updateButtontime = 0;
1052 m_repeatButtontime = 0;
1053 m_releaseButtontime = 0;
1054 m_pressedButtoncount = 0;
1055 m_releasedButtoncount = 0;
1056 }
1057 }
1058 }
1059
1060 // we don't forward releases when supporting repeating keys
1061 if (bButtonRelease && m_configuration.iButtonRepeatRateMs)
1062 return;
1063
1064 if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN)
1065 {
1066 LIB_CEC->AddLog(CEC_LOG_DEBUG, "key released: %s (%1x) D:%dms", ToString(key.keycode), key.keycode, key.duration);
1067 QueueAddKey(key);
1068 }
1069}
1070
1071void CCECClient::AddKey(const cec_keypress &key)
1072{

Calls 2

ToStringFunction · 0.85
AddLogMethod · 0.45

Tested by

no test coverage detected