From 356cc64eb5ed555c7cdaf2929438d5280d85b3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Jul 2023 14:56:46 +0200 Subject: [PATCH] Logging improvements, cleanup --- Common/UI/Screen.cpp | 7 +++---- Common/UI/Screen.h | 11 +++++------ UI/ControlMappingScreen.cpp | 6 +++--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index 4e1b736991..ed56879a53 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -11,16 +11,15 @@ #include "Common/Log.h" #include "Common/TimeUtil.h" -ScreenManager::ScreenManager() { - uiContext_ = 0; - dialogFinished_ = 0; -} +#include "Core/KeyMap.h" ScreenManager::~ScreenManager() { shutdown(); } void ScreenManager::switchScreen(Screen *screen) { + // TODO: inputLock_ ? + if (!nextStack_.empty() && screen == nextStack_.front().screen) { ERROR_LOG(SYSTEM, "Already switching to this screen"); return; diff --git a/Common/UI/Screen.h b/Common/UI/Screen.h index 7e9e4f8489..4a45d54186 100644 --- a/Common/UI/Screen.h +++ b/Common/UI/Screen.h @@ -59,9 +59,9 @@ public: virtual void deviceLost() {} virtual void deviceRestored() {} - virtual void UnsyncTouch(const TouchInput &touch) {} - virtual bool UnsyncKey(const KeyInput &touch) { return false; } - virtual void UnsyncAxis(const AxisInput &touch) {} + virtual void UnsyncTouch(const TouchInput &touch) = 0; + virtual bool UnsyncKey(const KeyInput &touch) = 0; + virtual void UnsyncAxis(const AxisInput &touch) = 0; virtual void RecreateViews() {} @@ -98,7 +98,6 @@ typedef void(*PostRenderCallback)(UIContext *ui, void *userdata); class ScreenManager { public: - ScreenManager(); virtual ~ScreenManager(); void switchScreen(Screen *screen); @@ -154,8 +153,8 @@ private: void switchToNext(); void processFinishDialog(); - UIContext *uiContext_; - Draw::DrawContext *thin3DContext_; + UIContext *uiContext_ = nullptr; + Draw::DrawContext *thin3DContext_ = nullptr; PostRenderCallback postRenderCb_ = nullptr; void *postRenderUserdata_ = nullptr; diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 63a45081d5..dea53c39ba 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -688,7 +688,7 @@ void TouchTestScreen::UpdateLogView() { bool TouchTestScreen::key(const KeyInput &key) { UIScreen::key(key); char buf[512]; - snprintf(buf, sizeof(buf), "Keycode: %d Device ID: %d [%s%s%s%s]", key.keyCode, key.deviceId, + snprintf(buf, sizeof(buf), "%s (%d) Device ID: %d [%s%s%s%s]", KeyMap::GetKeyName(key.keyCode).c_str(), key.keyCode, key.deviceId, (key.flags & KEY_IS_REPEAT) ? "REP" : "", (key.flags & KEY_UP) ? "UP" : "", (key.flags & KEY_DOWN) ? "DOWN" : "", @@ -704,8 +704,8 @@ void TouchTestScreen::axis(const AxisInput &axis) { return; char buf[512]; - snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d", - axis.axisId, axis.value, axis.deviceId); + snprintf(buf, sizeof(buf), "Axis: %s (%d) (value %1.3f) Device ID: %d", + KeyMap::GetAxisName(axis.axisId).c_str(), axis.axisId, axis.value, axis.deviceId); keyEventLog_.push_back(buf); if (keyEventLog_.size() > 8) {