From 349e64fe3111f6370a2b54831f54c11ad0704ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 3 Oct 2019 18:31:20 +0200 Subject: [PATCH] Improve the touchscreen test screen with some numbers. Getting closer to finding out what's wrong on the MOQI I7S when using the system fullscreen button... --- UI/ControlMappingScreen.cpp | 34 +++++++++++++++++++++++++++++++--- UI/ControlMappingScreen.h | 4 ++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index eefb18a231..4300729285 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -21,6 +21,7 @@ #include "base/colorutil.h" #include "base/logging.h" +#include "base/display.h" #include "i18n/i18n.h" #include "input/keycodes.h" #include "input/input_state.h" @@ -637,13 +638,40 @@ void TouchTestScreen::CreateViews() { void TouchTestScreen::render() { UIDialogScreenWithBackground::render(); - screenManager()->getUIContext()->BeginNoTex(); + UIContext *ui_context = screenManager()->getUIContext(); + ui_context->BeginNoTex(); for (int i = 0; i < MAX_TOUCH_POINTS; i++) { if (touches_[i].id != -1) { - screenManager()->getUIContext()->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0); + ui_context->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0); } } - screenManager()->getUIContext()->Flush(); + ui_context->Flush(); + + ui_context->Begin(); + + char buffer[1024]; + for (int i = 0; i < MAX_TOUCH_POINTS; i++) { + if (touches_[i].id != -1) { + ui_context->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0); + snprintf(buffer, sizeof(buffer), "%0.1fx%0.1f", touches_[i].x, touches_[i].y); + ui_context->DrawText(buffer, touches_[i].x, touches_[i].y + (touches_[i].y > dp_yres - 100.0f ? -135.0f : 95.0f), 0xFFFFFFFF, ALIGN_HCENTER | FLAG_DYNAMIC_ASCII); + } + } + + snprintf(buffer, sizeof(buffer), + "dp_res: %dx%d\n" + "pixel_res: %dx%d\n" + "g_dpi: %f\n" + "g_dpi_scale: %0.3fx%0.3f\n" + "g_dpi_scale_real: %0.3fx%0.3f\n", + dp_xres, dp_yres, + pixel_xres, pixel_yres, + g_dpi, + g_dpi_scale_x, g_dpi_scale_y, + g_dpi_scale_real_x, g_dpi_scale_real_y); + + ui_context->DrawTextShadow(buffer, 20.0f, dp_yres / 2.0f, 0xFFFFFFFF, ALIGN_VCENTER | FLAG_DYNAMIC_ASCII); + ui_context->Flush(); } void RecreateActivity(); diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index ed58f65fd9..77f5c90df5 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -123,8 +123,8 @@ public: protected: struct TrackedTouch { int id; - int x; - int y; + float x; + float y; }; enum { MAX_TOUCH_POINTS = 10,