Sfoglia il codice sorgente

Make sure we handle keys when we get only the up.

This happens on some keys in Sony Bravia. We only get the event on stop with a duration, without getting the first down event with a zero duration.
LongChair 9 anni fa
parent
commit
f7d8936038
1 ha cambiato i file con 10 aggiunte e 2 eliminazioni
  1. 10 2
      src/input/InputCEC.cpp

+ 10 - 2
src/input/InputCEC.cpp

@@ -231,13 +231,15 @@ int InputCEC::CecLogMessage(void* cbParam, const cec_log_message message)
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 int InputCEC::CecKeyPress(void *cbParam, const cec_keypress key)
 {
+  static int lastKeyPressed = -1;
+
   InputCEC *cec = (InputCEC*)cbParam;
   if (cec->m_verboseLogging)
   {
-    QLOG_DEBUG() << "CecKeyPress : Got key" << key.keycode;
+    QLOG_DEBUG() << QString("CecKeyPress : Got key %1 (%2), last was %3").arg(key.keycode).arg(key.duration).arg(lastKeyPressed);
   }
 
-  if (cec)
+  if (cec && lastKeyPressed != key.keycode)
   {
     QString cmdString = cec->getCommandString(key.keycode, key.duration);
 
@@ -245,8 +247,14 @@ int InputCEC::CecKeyPress(void *cbParam, const cec_keypress key)
       cec->sendReceivedInput(CEC_INPUT_NAME, cmdString);
     else
       QLOG_DEBUG() << "Unknown keycode in keypress" << key.keycode;
+
+    lastKeyPressed = key.keycode;
   }
 
+  // reset the last key on a up info (duration > 0)
+  if (key.duration)
+    lastKeyPressed = -1;
+
   return 0;
 }