From a6430ff0ffa748134945967fcc57e1866c572511 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 15 Sep 2020 21:12:32 +0200 Subject: [PATCH] Moved the input debug logging to a more appropriate location. This also fixes the issue where some input was not being logged correctly. --- NEWS.md | 1 + es-app/src/views/UIModeController.cpp | 19 ++----------------- es-app/src/views/UIModeController.h | 4 ++-- es-core/src/Window.cpp | 20 ++++++++++++++++++++ es-core/src/Window.h | 4 ++++ 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/NEWS.md b/NEWS.md index a6a06a9f4..75726d916 100644 --- a/NEWS.md +++ b/NEWS.md @@ -82,6 +82,7 @@ Many bugs have been fixed, and numerous features that were only partially implem * Hidden files still showed up if they had a gamelist.xml entry * Fixed an annoying gamelist issue that caused the game images and data to be updated and rendered up to six times every time the list was scrolled * VRAM statistics overlay was somewhat broken and incorrectly displayed numbers in megabytes instead of mebibytes +* Not all input events were logged when running with debug logging activated * On Unix, adding a hidden folder with a game in it crashed the application on startup * If the user tried to enter a blank game name in the metadata editor, the application would crash upon saving * The SliderComponent knob position was set incorrectly if the minimum value was not zero diff --git a/es-app/src/views/UIModeController.cpp b/es-app/src/views/UIModeController.cpp index 29502f2ae..0f6fcb93c 100644 --- a/es-app/src/views/UIModeController.cpp +++ b/es-app/src/views/UIModeController.cpp @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // UIModeController.cpp // // Handling of application user interface modes (full, kiosk and kid). @@ -43,9 +45,6 @@ bool UIModeController::listen(InputConfig* config, Input input) { // Reads the current input to listen for the passkey sequence to unlock // the UI mode. The progress is saved in mPassKeyCounter. - if (Settings::getInstance()->getBool("Debug")) - logInput(config, input); - if ((Settings::getInstance()->getString("UIMode") == "full") || !isValidInput(config, input)) return false; // Already unlocked, or invalid input, nothing to do here. @@ -136,20 +135,6 @@ std::string UIModeController::getFormattedPassKeyStr() return out; } -void UIModeController::logInput(InputConfig* config, Input input) -{ - std::string mapname = ""; - std::vector maps = config->getMappedTo(input); - - for (auto mn : maps) { - mapname += mn; - mapname += ", "; - } - - LOG(LogDebug) << "UIModeController::logInput(" << config->getDeviceName() << "): " << - input.string() << ", isMappedTo=" << mapname << ", value=" << input.value; -} - bool UIModeController::isValidInput(InputConfig* config, Input input) { if ((config->getMappedTo(input).size() == 0) || // Not a mapped input, so ignore.. diff --git a/es-app/src/views/UIModeController.h b/es-app/src/views/UIModeController.h index 64c76dcd1..7314e0c77 100644 --- a/es-app/src/views/UIModeController.h +++ b/es-app/src/views/UIModeController.h @@ -1,11 +1,12 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // UIModeController.h // // Handling of application user interface modes (full, kiosk and kid). // This includes switching the mode when the UI mode passkey is used. // -#pragma once #ifndef ES_APP_VIEWS_UI_MODE_CONTROLLER_H #define ES_APP_VIEWS_UI_MODE_CONTROLLER_H @@ -42,7 +43,6 @@ private: UIModeController(); bool inputIsMatch(InputConfig * config, Input input); bool isValidInput(InputConfig * config, Input input); - void logInput(InputConfig * config, Input input); // Return UI mode to 'full'. void unlockUIMode(); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 71b4c3b48..0f45508d9 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -1,7 +1,10 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // Window.cpp // // Window management, screensaver and help prompts. +// The input stack starts here as well, as this is the first instance called by InputManager. // #include "Window.h" @@ -132,6 +135,9 @@ void Window::textInput(const char* text) void Window::input(InputConfig* config, Input input) { + if (Settings::getInstance()->getBool("Debug")) + logInput(config, input); + if (mScreenSaver) { if (mScreenSaver->isScreenSaverActive() && Settings::getInstance()->getBool("ScreenSaverControls") && @@ -198,6 +204,20 @@ void Window::input(InputConfig* config, Input input) } } +void Window::logInput(InputConfig* config, Input input) +{ + std::string mapname = ""; + std::vector maps = config->getMappedTo(input); + + for (auto mn : maps) { + mapname += mn; + mapname += ", "; + } + + LOG(LogDebug) << "Window::logInput(" << config->getDeviceName() << "): " << + input.string() << ", isMappedTo=" << mapname << ", value=" << input.value; +} + void Window::update(int deltaTime) { if (mNormalizeNextUpdate) { diff --git a/es-core/src/Window.h b/es-core/src/Window.h index 84efedf55..0b0e3f1c2 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -1,7 +1,10 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // Window.h // // Window management, screensaver and help prompts. +// The input stack starts here as well, as this is the first instance called by InputManager. // #ifndef ES_CORE_WINDOW_H @@ -61,6 +64,7 @@ public: void textInput(const char* text); void input(InputConfig* config, Input input); + void logInput(InputConfig * config, Input input); void update(int deltaTime); void render();