소스 검색

Better logging for received inputs.

Daniel requested that we get some more worthwhile logging in
InputComponent
Tobias Hieta 9 년 전
부모
커밋
f46a0124ef
4개의 변경된 파일5개의 추가작업 그리고 12개의 파일을 삭제
  1. 2 1
      src/input/InputComponent.cpp
  2. 0 1
      src/input/InputKeyboard.h
  3. 0 1
      src/input/InputMapping.cpp
  4. 3 9
      src/utils/CachedRegexMatcher.cpp

+ 2 - 1
src/input/InputComponent.cpp

@@ -83,6 +83,8 @@ void InputComponent::remapInput(const QString &source, const QString &keycode, f
   // hide mouse if it's visible.
   SystemComponent::Get().setCursorVisibility(false);
 
+  QLOG_DEBUG() << "Input received: source:" << source << "keycode:" << keycode;
+
   QString action = m_mappings->mapToAction(source, keycode);
   if (!action.isEmpty())
   {
@@ -119,7 +121,6 @@ void InputComponent::remapInput(const QString &source, const QString &keycode, f
     }
     else
     {
-      QLOG_DEBUG() << "Sending action:" << action;
       emit receivedAction(action);
     }
   }

+ 0 - 1
src/input/InputKeyboard.h

@@ -20,7 +20,6 @@ public:
 
   void keyPress(const QKeySequence& sequence)
   {
-    QLOG_DEBUG() << "Input:" << sequence.toString();
     emit receivedInput("Keyboard", sequence.toString());
   }
 

+ 0 - 1
src/input/InputMapping.cpp

@@ -65,7 +65,6 @@ QString InputMapping::mapToAction(const QString& source, const QString& keycode)
     QVariant action = m_inputMatcher.value(sourceName.toString())->match(keycode);
     if (action.isValid())
     {
-      QLOG_DEBUG() << "Mapped:" << keycode << "to action:" << action.toString();
       return action.toString();
     }
   }

+ 3 - 9
src/utils/CachedRegexMatcher.cpp

@@ -24,10 +24,7 @@ QVariant CachedRegexMatcher::match(const QString& input)
 {
   // first we check if this match has already happened before
   if (m_matcherCache.contains(input))
-  {
-    QLOG_DEBUG() << "Found cached match for input:" << input;
     return m_matcherCache.value(input);
-  }
 
   // otherwise try to iterate our list and find a match
   foreach(const MatcherValuePair& matcher, m_matcherList)
@@ -37,21 +34,18 @@ QVariant CachedRegexMatcher::match(const QString& input)
     if (re.indexIn(input) != -1)
     {
       // found match
-      QLOG_DEBUG() << "Matched:" << "to pattern:" << re.pattern();
-
       QVariant returnValue = matcher.second;
 
       if (re.captureCount() > 0 && matcher.second.type() == QVariant::String)
       {
         QString value(matcher.second.toString());
 
-        QLOG_DEBUG() << "Captured:" << re.captureCount();
         for (int i = 0; i < re.captureCount(); i ++)
         {
-          QLOG_DEBUG() << "capture" << i+1 << ":" << re.cap(i+1);
-          value = value.arg(re.cap(i+1));
+          QString argFmt = QString("%%1").arg(i + 1);
+          if (value.contains(argFmt))
+            value = value.arg(re.cap(i + 1));
         }
-        QLOG_DEBUG() << "After captures the final value is:" << value;
         returnValue = QVariant(value);
       }