From 376bbf3df7e883a4ff6170befaae5943d88e5121 Mon Sep 17 00:00:00 2001 From: Przemyslaw Brudny Date: Mon, 6 Dec 2021 13:27:58 +0100 Subject: [PATCH] [EGD-7922] Added InputEvents Debug option Added Debug flag for InputEvents in EvtManager and Application. --- module-apps/apps-common/ApplicationCommon.cpp | 19 +++++++++++++++++++ .../service-evtmgr/EventManager.cpp | 16 ++++++++++++++++ module-utils/log/api/log/debug.hpp | 1 + 3 files changed, 36 insertions(+) diff --git a/module-apps/apps-common/ApplicationCommon.cpp b/module-apps/apps-common/ApplicationCommon.cpp index 2280d8a6f88a5b36e36492cf1dec891ece53a0e5..bfd1f86f93118bd0cde82d38b702efcf9b04b13e 100644 --- a/module-apps/apps-common/ApplicationCommon.cpp +++ b/module-apps/apps-common/ApplicationCommon.cpp @@ -62,6 +62,12 @@ #include #include +#if DEBUG_INPUT_EVENTS == 1 +#define debug_input_events(...) LOG_DEBUG(__VA_ARGS__) +#else +#define debug_input_events(...) +#endif + namespace gui { class DrawCommand; @@ -201,6 +207,12 @@ namespace app messageInputEventApplication(this, this->GetName(), iev); keyTranslator->resetPreviousKeyPress(); longPressTimer.stop(); + + debug_input_events("AppInput -> K:|%s|, S:|%s|, App:|%s|, W:|%s|", + magic_enum::enum_name(iev.getKeyCode()).data(), + magic_enum::enum_name(iev.getState()).data(), + GetName().c_str(), + getCurrentWindow()->getName().c_str()); } } @@ -412,6 +424,13 @@ namespace app if (!iev.is(gui::KeyCode::KEY_UNDEFINED)) { messageInputEventApplication(this, this->GetName(), iev); } + + debug_input_events("AppInput -> K:|%s|, S:|%s|, App:|%s|, W:|%s|", + magic_enum::enum_name(iev.getKeyCode()).data(), + magic_enum::enum_name(iev.getState()).data(), + GetName().c_str(), + getCurrentWindow()->getName().c_str()); + return sys::msgHandled(); } diff --git a/module-services/service-evtmgr/EventManager.cpp b/module-services/service-evtmgr/EventManager.cpp index 60341f5c31de30e7f0ae55dd80fd5b65be89f150..ebf8e455df76ee2773bdfdf7adca802d0db4b4ee 100644 --- a/module-services/service-evtmgr/EventManager.cpp +++ b/module-services/service-evtmgr/EventManager.cpp @@ -44,6 +44,12 @@ #include #include +#if DEBUG_INPUT_EVENTS == 1 +#define debug_input_events(...) LOG_DEBUG(__VA_ARGS__) +#else +#define debug_input_events(...) +#endif + namespace { constexpr auto loggerDelayMs = 1000 * 60 * 5; @@ -284,10 +290,20 @@ void EventManagerCommon::handleKeyEvent(sys::Message *msg) auto message = std::make_shared(); message->key = kbdMessage->key; + debug_input_events("EVInput -> K:|%s|, S:|%s|, TP:|%d|, TR:|%d|, App:|%s|", + magic_enum::enum_name(message->key.keyCode).data(), + magic_enum::enum_name(message->key.state).data(), + message->key.timePress, + message->key.timeRelease, + targetApplication.c_str()); + // send key to focused application if (!targetApplication.empty()) { bus.sendUnicast(message, targetApplication); } + else { + debug_input_events("EventManagerInput -> No target Application!"); + } // notify application manager to prevent screen locking app::manager::Controller::preventBlockingDevice(this); } diff --git a/module-utils/log/api/log/debug.hpp b/module-utils/log/api/log/debug.hpp index 0d1e167077e0bb14e903cfe64c9bf5a5593c00ad..598c78005faa5dbf9ee22b3b3c502fc23daeef1a 100644 --- a/module-utils/log/api/log/debug.hpp +++ b/module-utils/log/api/log/debug.hpp @@ -15,6 +15,7 @@ #define DEBUG_GUI_TEXT 0 /// show basic debug messages for gui::Text - warning this can be hard on cpu #define DEBUG_GUI_TEXT_LINES 0 /// show extended debug messages for gui::Text - lines building #define DEBUG_GUI_TEXT_CURSOR 0 /// show extended debug messages for gui::Text - cursor handling +#define DEBUG_INPUT_EVENTS 0 /// show input events prints in system #define DEBUG_TIMER 0 /// debug timers system utility #define DEBUG_SETTINGS_DB 0 /// show extensive settings logs for all applications #define DEBUG_SERVICE_CELLULAR 0 /// show various logs in cellular service