From 721f5877ebe7a5d87c619fe00650487a7e8406b7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Dec 2017 18:30:28 -0800 Subject: [PATCH 1/9] http: Allow sharing automatically on PPSSPP start. Since that might always be something you want, on your desktop. --- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/NativeApp.cpp | 5 +++++ UI/RemoteISOScreen.cpp | 27 ++++++++++++++++++--------- UI/RemoteISOScreen.h | 2 ++ 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 44661820b0..9f6869f757 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -377,6 +377,7 @@ static ConfigSetting generalSettings[] = { ConfigSetting("LastRemoteISOServer", &g_Config.sLastRemoteISOServer, ""), ConfigSetting("LastRemoteISOPort", &g_Config.iLastRemoteISOPort, 0), ConfigSetting("RemoteISOManualConfig", &g_Config.bRemoteISOManual, false), + ConfigSetting("RemoteShareOnStartup", &g_Config.bRemoteShareOnStartup, false), ConfigSetting("RemoteISOSubdir", &g_Config.sRemoteISOSubdir, "/"), #ifdef __ANDROID__ diff --git a/Core/Config.h b/Core/Config.h index 25882624e3..09171057e1 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -143,6 +143,7 @@ public: std::string sLastRemoteISOServer; int iLastRemoteISOPort; bool bRemoteISOManual; + bool bRemoteShareOnStartup; std::string sRemoteISOSubdir; bool bMemStickInserted; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index bd7c165699..a56bebe199 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -92,6 +92,7 @@ #include "UI/HostTypes.h" #include "UI/OnScreenDisplay.h" #include "UI/MiscScreens.h" +#include "UI/RemoteISOScreen.h" #include "UI/TiltEventProcessor.h" #include "UI/BackgroundAudio.h" #include "UI/TextureUtil.h" @@ -544,6 +545,10 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch screenManager->switchScreen(new LogoScreen()); } + if (g_Config.bRemoteShareOnStartup) { + StartRemoteISOSharing(); + } + std::string sysName = System_GetProperty(SYSPROP_NAME); isOuya = KeyMap::IsOuya(sysName); diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 71cf9bf88c..638a93a0db 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -186,6 +186,20 @@ static void ExecuteServer() { UpdateStatus(ServerStatus::STOPPED); } +bool StartRemoteISOSharing() { + std::lock_guard guard(serverStatusLock); + + if (serverStatus != ServerStatus::STOPPED) { + return false; + } + + serverStatus = ServerStatus::STARTING; + serverThread = new std::thread(&ExecuteServer); + serverThread->detach(); + + return true; +} + static bool FindServer(std::string &resultHost, int &resultPort) { http::Client http; Buffer result; @@ -412,16 +426,10 @@ void RemoteISOScreen::CreateViews() { } UI::EventReturn RemoteISOScreen::HandleStartServer(UI::EventParams &e) { - std::lock_guard guard(serverStatusLock); - - if (serverStatus != ServerStatus::STOPPED) { + if (!StartRemoteISOSharing()) { return EVENT_SKIPPED; } - serverStatus = ServerStatus::STARTING; - serverThread = new std::thread(&ExecuteServer); - serverThread->detach(); - return EVENT_DONE; } @@ -651,7 +659,7 @@ void RemoteISOBrowseScreen::CreateViews() { } RemoteISOSettingsScreen::RemoteISOSettingsScreen() { - serverRunning_ = RetrieveStatus() != ServerStatus::STOPPED;; + serverRunning_ = RetrieveStatus() != ServerStatus::STOPPED; } void RemoteISOSettingsScreen::update() { @@ -674,7 +682,8 @@ void RemoteISOSettingsScreen::CreateViews() { remoteisoSettingsScroll->Add(remoteisoSettings); remoteisoSettings->Add(new ItemHeader(ri->T("Remote disc streaming"))); - remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteISOManual, ri->T("Manual Mode Client", "Manual Mode Client"))); + remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteShareOnStartup, ri->T("Share on PPSSPP startup"))); + remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteISOManual, ri->T("Manual Mode Client", "Manually configure client"))); #if !defined(MOBILE_DEVICE) PopupTextInputChoice *remoteServer = remoteisoSettings->Add(new PopupTextInputChoice(&g_Config.sLastRemoteISOServer, ri->T("Remote Server"), "", 255, screenManager())); #else diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index b7f7ff0f5c..a4384d793e 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -25,6 +25,8 @@ #include "UI/MiscScreens.h" #include "UI/MainScreen.h" +bool StartRemoteISOSharing(); + class RemoteISOScreen : public UIScreenWithBackground { public: RemoteISOScreen(); From 522447dca88e8619ddc69b80069808b61893b969 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Dec 2017 23:46:36 -0800 Subject: [PATCH 2/9] GPU: Default to Vulkan if possible. Fall back to Direct3D 11 on Windows 8+ to target Windows 10 most especially. Default vertex cache off everyone except OpenGL where it helps the most. --- Core/Config.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 44661820b0..2b2bd3ffb3 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -31,14 +31,16 @@ #include "net/url.h" #include "Common/CPUDetect.h" -#include "Common/KeyMap.h" #include "Common/FileUtil.h" -#include "Common/StringUtils.h" +#include "Common/KeyMap.h" #include "Common/LogManager.h" +#include "Common/OSVersion.h" +#include "Common/StringUtils.h" +#include "Common/Vulkan/VulkanLoader.h" #include "Core/Config.h" #include "Core/Loaders.h" +#include "Core/HLE/sceUtility.h" #include "GPU/Common/FramebufferCommon.h" -#include "HLE/sceUtility.h" // TODO: Find a better place for this. http::Downloader g_DownloadManager; @@ -477,13 +479,33 @@ static int DefaultAndroidHwScale() { #endif } +static int DefaultGPUBackend() { +#if PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID) + // Where supported, let's use Vulkan. + if (VulkanMayBeAvailable()) { + return GPU_BACKEND_VULKAN; + } +#endif +#if PPSSPP_PLATFORM(WINDOWS) + // If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.) + if (DoesVersionMatchWindows(6, 2, 0, 0, true)) { + return GPU_BACKEND_DIRECT3D11; + } +#endif + return GPU_BACKEND_OPENGL; +} + +static bool DefaultVertexCache() { + return DefaultGPUBackend() == GPU_BACKEND_OPENGL; +} + static ConfigSetting graphicsSettings[] = { ConfigSetting("EnableCardboard", &g_Config.bEnableCardboard, false, true, true), ConfigSetting("CardboardScreenSize", &g_Config.iCardboardScreenSize, 50, true, true), ConfigSetting("CardboardXShift", &g_Config.iCardboardXShift, 0, true, true), ConfigSetting("CardboardYShift", &g_Config.iCardboardXShift, 0, true, true), ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0, true, true), - ReportedConfigSetting("GPUBackend", &g_Config.iGPUBackend, 0), + ReportedConfigSetting("GPUBackend", &g_Config.iGPUBackend, &DefaultGPUBackend), ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), @@ -508,7 +530,7 @@ static ConfigSetting graphicsSettings[] = { #else ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 4, true, true), #endif - ReportedConfigSetting("VertexCache", &g_Config.bVertexCache, true, true, true), + ReportedConfigSetting("VertexCache", &g_Config.bVertexCache, &DefaultVertexCache, true, true), ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, true, true), ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false, true, true), ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, false), From fcdf512ee80685ce8030bf6fd50786edf64dfaa6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 11 Dec 2017 00:01:45 -0800 Subject: [PATCH 3/9] GPU: Rename GPUBackend setting to apply default. --- Core/Config.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 2b2bd3ffb3..665481f34b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -505,7 +505,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("CardboardXShift", &g_Config.iCardboardXShift, 0, true, true), ConfigSetting("CardboardYShift", &g_Config.iCardboardXShift, 0, true, true), ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0, true, true), - ReportedConfigSetting("GPUBackend", &g_Config.iGPUBackend, &DefaultGPUBackend), + ReportedConfigSetting("GraphicsBackend", &g_Config.iGPUBackend, &DefaultGPUBackend), ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), @@ -530,7 +530,7 @@ static ConfigSetting graphicsSettings[] = { #else ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 4, true, true), #endif - ReportedConfigSetting("VertexCache", &g_Config.bVertexCache, &DefaultVertexCache, true, true), + ReportedConfigSetting("VertexDecCache", &g_Config.bVertexCache, &DefaultVertexCache, true, true), ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, true, true), ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false, true, true), ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, false), From 2597ca90f4b2b4849254e1584ab9d41af2a3082d Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Mon, 11 Dec 2017 15:16:00 +0100 Subject: [PATCH 4/9] Improve display layout editor for zooming into corners, also limit the scale to 10 to match slider. --- UI/DisplayLayoutScreen.cpp | 38 +++++++++++++++++++++++++++----------- UI/DisplayLayoutScreen.h | 1 + 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 014df89e60..be5a4419c2 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -81,20 +81,35 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { if (mode == 0) { const Bounds &bounds = picked_->GetBounds(); - int minTouchX = screen_bounds.w / 4; - int maxTouchX = screen_bounds.w - minTouchX; + int limitX = g_Config.fSmallDisplayZoomLevel * 120; + int limitY = g_Config.fSmallDisplayZoomLevel * 68; + if (g_Config.fSmallDisplayZoomLevel < 1) { + limitX = 120; + limitY = 68; + } + if (bRotated) { + //swap X/Y limit for rotated display + int limitTemp = limitX; + limitX = limitY; + limitY = limitTemp; + } - int minTouchY = screen_bounds.h / 4; - int maxTouchY = screen_bounds.h - minTouchY; + int minX = local_dp_xres / 2; + int maxX = local_dp_xres + minX; + int minY = local_dp_yres / 2; + int maxY = local_dp_yres + minY; + // Display visualization disappear outside of those bounds, so we have to limit + if (touchX < -minX) touchX = -minX; + if (touchX > maxX) touchX = maxX; + if (touchY < -minY) touchY = -minY; + if (touchY > maxY) touchY = maxY; int newX = bounds.centerX(), newY = bounds.centerY(); - // we have to handle x and y separately since even if x is blocked, y may not be. - if (touchX > minTouchX && touchX < maxTouchX) { - // if the leftmost point of the control is ahead of the margin, - // move it. Otherwise, don't. + // Allow moving zoomed in display freely as long as at least noticeable portion of the screen is occupied + if (touchX > (local_dp_xres / 2) - limitX - 10 && touchX < (local_dp_xres / 2) + limitX + 10) { newX = touchX; } - if (touchY > minTouchY && touchY < maxTouchY) { + if (touchY > (local_dp_yres / 2) - limitY - 10 && touchY < (local_dp_yres / 2) + limitY + 10) { newY = touchY; } picked_->ReplaceLayoutParams(new UI::AnchorLayoutParams(newX, newY, NONE, NONE, true)); @@ -106,7 +121,8 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { float movementScale = 0.5f; float newScale = startScale_ + diffY * movementScale; - if (newScale > 100.0f) newScale = 100.0f; + // Desired scale * 8.0 since the visualization is tiny size and multiplied by 8. + if (newScale > 80.0f) newScale = 80.0f; if (newScale < 1.0f) newScale = 1.0f; picked_->SetScale(newScale); scaleUpdate_ = picked_->GetScale(); @@ -222,7 +238,7 @@ void DisplayLayoutScreen::CreateViews() { rotation_ = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, previewWidth - 200.0f, 10, NONE, local_dp_yres - 64 - 10)); rotation_->SetEnabledPtr(&displayRotEnable_); displayRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); - bool bRotated = false; + bRotated = false; if (displayRotEnable_ && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) { bRotated = true; } diff --git a/UI/DisplayLayoutScreen.h b/UI/DisplayLayoutScreen.h index e031423535..be7d2b6872 100644 --- a/UI/DisplayLayoutScreen.h +++ b/UI/DisplayLayoutScreen.h @@ -44,6 +44,7 @@ private: UI::PopupMultiChoice *zoom_; UI::PopupMultiChoice *rotation_; bool displayRotEnable_; + bool bRotated; // Touch down state for drag to resize etc float startX_; float startY_; From b0b38078422c1b28aed72f5775e6ca07ef42e4ff Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Mon, 11 Dec 2017 15:50:41 +0100 Subject: [PATCH 5/9] Stick display to edges of the screen/window size --- UI/DisplayLayoutScreen.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index be5a4419c2..d70cb2f016 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -94,6 +94,17 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { limitY = limitTemp; } + // Check where each edge of the screen is + int windowLeftEdge = local_dp_xres / 4; + int windowRightEdge = windowLeftEdge * 3; + int windowUpperEdge = local_dp_yres / 4; + int windowLowerEdge = windowUpperEdge * 3; + // And stick display when close to any edge + if (touchX > windowLeftEdge - 15 + limitX && touchX < windowLeftEdge + 15 + limitX) touchX = windowLeftEdge + limitX; + if (touchX > windowRightEdge - 15 - limitX && touchX < windowRightEdge + 15 - limitX) touchX = windowRightEdge - limitX; + if (touchY > windowUpperEdge - 15 + limitY && touchY < windowUpperEdge + 15 + limitY) touchY = windowUpperEdge + limitY; + if (touchY > windowLowerEdge - 15 - limitY && touchY < windowLowerEdge + 15 - limitY) touchY = windowLowerEdge - limitY; + int minX = local_dp_xres / 2; int maxX = local_dp_xres + minX; int minY = local_dp_yres / 2; @@ -106,10 +117,10 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { int newX = bounds.centerX(), newY = bounds.centerY(); // Allow moving zoomed in display freely as long as at least noticeable portion of the screen is occupied - if (touchX > (local_dp_xres / 2) - limitX - 10 && touchX < (local_dp_xres / 2) + limitX + 10) { + if (touchX > minX - limitX - 10 && touchX < minX + limitX + 10) { newX = touchX; } - if (touchY > (local_dp_yres / 2) - limitY - 10 && touchY < (local_dp_yres / 2) + limitY + 10) { + if (touchY > minY - limitY - 10 && touchY < minY + limitY + 10) { newY = touchY; } picked_->ReplaceLayoutParams(new UI::AnchorLayoutParams(newX, newY, NONE, NONE, true)); From 89be17491babd3e5a0eae9fc668b664f340b25c3 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Mon, 11 Dec 2017 16:10:59 +0100 Subject: [PATCH 6/9] Respect sticky edge by center option and make it stick from smaller range --- UI/DisplayLayoutScreen.cpp | 15 +++++++++------ UI/DisplayLayoutScreen.h | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index d70cb2f016..5fec557786 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -100,10 +100,11 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { int windowUpperEdge = local_dp_yres / 4; int windowLowerEdge = windowUpperEdge * 3; // And stick display when close to any edge - if (touchX > windowLeftEdge - 15 + limitX && touchX < windowLeftEdge + 15 + limitX) touchX = windowLeftEdge + limitX; - if (touchX > windowRightEdge - 15 - limitX && touchX < windowRightEdge + 15 - limitX) touchX = windowRightEdge - limitX; - if (touchY > windowUpperEdge - 15 + limitY && touchY < windowUpperEdge + 15 + limitY) touchY = windowUpperEdge + limitY; - if (touchY > windowLowerEdge - 15 - limitY && touchY < windowLowerEdge + 15 - limitY) touchY = windowLowerEdge - limitY; + stickToEdgeX = false; stickToEdgeY = false; + if (touchX > windowLeftEdge - 8 + limitX && touchX < windowLeftEdge + 8 + limitX) { touchX = windowLeftEdge + limitX; stickToEdgeX = true; } + if (touchX > windowRightEdge - 8 - limitX && touchX < windowRightEdge + 8 - limitX) { touchX = windowRightEdge - limitX; stickToEdgeX = true; } + if (touchY > windowUpperEdge - 8 + limitY && touchY < windowUpperEdge + 8 + limitY) { touchY = windowUpperEdge + limitY; stickToEdgeY = true; } + if (touchY > windowLowerEdge - 8 - limitY && touchY < windowLowerEdge + 8 - limitY) { touchY = windowLowerEdge - limitY; stickToEdgeY = true; } int minX = local_dp_xres / 2; int maxX = local_dp_xres + minX; @@ -167,8 +168,10 @@ void DisplayLayoutScreen::onFinish(DialogResult reason) { } UI::EventReturn DisplayLayoutScreen::OnCenter(UI::EventParams &e) { - g_Config.fSmallDisplayOffsetX = 0.5f; - g_Config.fSmallDisplayOffsetY = 0.5f; + if (!stickToEdgeX || (stickToEdgeX && stickToEdgeY)) + g_Config.fSmallDisplayOffsetX = 0.5f; + if (!stickToEdgeY || (stickToEdgeX && stickToEdgeY)) + g_Config.fSmallDisplayOffsetY = 0.5f; RecreateViews(); return UI::EVENT_DONE; }; diff --git a/UI/DisplayLayoutScreen.h b/UI/DisplayLayoutScreen.h index be7d2b6872..a9d29c19e9 100644 --- a/UI/DisplayLayoutScreen.h +++ b/UI/DisplayLayoutScreen.h @@ -45,6 +45,8 @@ private: UI::PopupMultiChoice *rotation_; bool displayRotEnable_; bool bRotated; + bool stickToEdgeX; + bool stickToEdgeY; // Touch down state for drag to resize etc float startX_; float startY_; From 18d0d45e7fb583d29b39d157f14dccf58e6939be Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Mon, 11 Dec 2017 16:39:01 +0100 Subject: [PATCH 7/9] Limit smallest zoom to match it's slider and well. --- UI/DisplayLayoutScreen.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 5fec557786..7559b78c65 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -83,10 +83,7 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { int limitX = g_Config.fSmallDisplayZoomLevel * 120; int limitY = g_Config.fSmallDisplayZoomLevel * 68; - if (g_Config.fSmallDisplayZoomLevel < 1) { - limitX = 120; - limitY = 68; - } + if (bRotated) { //swap X/Y limit for rotated display int limitTemp = limitX; @@ -135,7 +132,7 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { float newScale = startScale_ + diffY * movementScale; // Desired scale * 8.0 since the visualization is tiny size and multiplied by 8. if (newScale > 80.0f) newScale = 80.0f; - if (newScale < 1.0f) newScale = 1.0f; + if (newScale < 8.0f) newScale = 8.0f; picked_->SetScale(newScale); scaleUpdate_ = picked_->GetScale(); g_Config.fSmallDisplayZoomLevel = scaleUpdate_ / 8.0f; From a931f1c133f9ef57dd3b3ee654db3234ac71afe9 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Mon, 11 Dec 2017 20:54:20 +0100 Subject: [PATCH 8/9] Improve very small display on very large surface, And change some variables to constants. --- UI/DisplayLayoutScreen.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 7559b78c65..f198e18647 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -84,6 +84,9 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { int limitX = g_Config.fSmallDisplayZoomLevel * 120; int limitY = g_Config.fSmallDisplayZoomLevel * 68; + const int quarterResX = local_dp_xres / 4; + const int quarterResY = local_dp_yres / 4; + if (bRotated) { //swap X/Y limit for rotated display int limitTemp = limitX; @@ -92,10 +95,10 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { } // Check where each edge of the screen is - int windowLeftEdge = local_dp_xres / 4; - int windowRightEdge = windowLeftEdge * 3; - int windowUpperEdge = local_dp_yres / 4; - int windowLowerEdge = windowUpperEdge * 3; + const int windowLeftEdge = quarterResX; + const int windowRightEdge = windowLeftEdge * 3; + const int windowUpperEdge = quarterResY; + const int windowLowerEdge = windowUpperEdge * 3; // And stick display when close to any edge stickToEdgeX = false; stickToEdgeY = false; if (touchX > windowLeftEdge - 8 + limitX && touchX < windowLeftEdge + 8 + limitX) { touchX = windowLeftEdge + limitX; stickToEdgeX = true; } @@ -103,16 +106,20 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { if (touchY > windowUpperEdge - 8 + limitY && touchY < windowUpperEdge + 8 + limitY) { touchY = windowUpperEdge + limitY; stickToEdgeY = true; } if (touchY > windowLowerEdge - 8 - limitY && touchY < windowLowerEdge + 8 - limitY) { touchY = windowLowerEdge - limitY; stickToEdgeY = true; } - int minX = local_dp_xres / 2; - int maxX = local_dp_xres + minX; - int minY = local_dp_yres / 2; - int maxY = local_dp_yres + minY; + const int minX = local_dp_xres / 2; + const int maxX = local_dp_xres + minX; + const int minY = local_dp_yres / 2; + const int maxY = local_dp_yres + minY; // Display visualization disappear outside of those bounds, so we have to limit if (touchX < -minX) touchX = -minX; if (touchX > maxX) touchX = maxX; if (touchY < -minY) touchY = -minY; if (touchY > maxY) touchY = maxY; + // Limit small display on much larger output a bit differently + if (quarterResX > limitX) limitX = quarterResX; + if (quarterResY > limitY) limitY = quarterResY; + int newX = bounds.centerX(), newY = bounds.centerY(); // Allow moving zoomed in display freely as long as at least noticeable portion of the screen is occupied if (touchX > minX - limitX - 10 && touchX < minX + limitX + 10) { From f06f9f7246d005350ca3b328c181ee4e732ef1d8 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Mon, 11 Dec 2017 21:02:47 +0100 Subject: [PATCH 9/9] Update bounds in NativeResized as well to fix glitches on layout screens that use it. --- UI/NativeApp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index a56bebe199..6e80ed508c 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1100,6 +1100,10 @@ void NativeResized() { // NativeResized can come from any thread so we just set a flag, then process it later. if (g_graphicsInited) { resized = true; + if (uiContext) { + // Still have to update bounds to avoid problems in display layout and touch controls layout screens + uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres)); + } } else { ILOG("NativeResized ignored, not initialized"); }