diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index b5575dbcae..eefb18a231 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -570,3 +570,88 @@ void AnalogTestScreen::CreateViews() { root_->Add(new Button(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); } + +bool TouchTestScreen::touch(const TouchInput &touch) { + UIDialogScreenWithBackground::touch(touch); + if (touch.flags & TOUCH_DOWN) { + bool found = false; + for (int i = 0; i < MAX_TOUCH_POINTS; i++) { + if (touches_[i].id == touch.id) { + WLOG("Double touch"); + touches_[i].x = touch.x; + touches_[i].y = touch.y; + found = true; + } + } + if (!found) { + for (int i = 0; i < MAX_TOUCH_POINTS; i++) { + if (touches_[i].id == -1) { + touches_[i].id = touch.id; + touches_[i].x = touch.x; + touches_[i].y = touch.y; + break; + } + } + } + } + if (touch.flags & TOUCH_MOVE) { + bool found = false; + for (int i = 0; i < MAX_TOUCH_POINTS; i++) { + if (touches_[i].id == touch.id) { + touches_[i].x = touch.x; + touches_[i].y = touch.y; + found = true; + } + } + if (!found) { + WLOG("Move without touch down: %d", touch.id); + } + } + if (touch.flags & TOUCH_UP) { + bool found = false; + for (int i = 0; i < MAX_TOUCH_POINTS; i++) { + if (touches_[i].id == touch.id) { + found = true; + touches_[i].id = -1; + break; + } + } + if (!found) { + WLOG("Touch release without touch down"); + } + } + return true; +} + +void TouchTestScreen::CreateViews() { + using namespace UI; + + I18NCategory *di = GetI18NCategory("Dialog"); + I18NCategory *gr = GetI18NCategory("Graphics"); + root_ = new LinearLayout(ORIENT_VERTICAL); + LinearLayout *theTwo = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0f)); + root_->Add(theTwo); + root_->Add(new CheckBox(&g_Config.bImmersiveMode, gr->T("FullScreen", "Full Screen")))->OnClick.Handle(this, &TouchTestScreen::OnImmersiveModeChange); + root_->Add(new Button(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); +} + +void TouchTestScreen::render() { + UIDialogScreenWithBackground::render(); + screenManager()->getUIContext()->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); + } + } + screenManager()->getUIContext()->Flush(); +} + +void RecreateActivity(); + +UI::EventReturn TouchTestScreen::OnImmersiveModeChange(UI::EventParams &e) { + System_SendMessage("immersive", ""); + if (g_Config.iAndroidHwScale != 0) { + RecreateActivity(); + } + return UI::EVENT_DONE; +} diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index a1292548ba..ed58f65fd9 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -105,6 +105,32 @@ public: protected: virtual void CreateViews() override; - UI::TextView *lastKeyEvent_; - UI::TextView *lastLastKeyEvent_; + UI::TextView *lastKeyEvent_ = nullptr; + UI::TextView *lastLastKeyEvent_ = nullptr; +}; + +class TouchTestScreen : public UIDialogScreenWithBackground { +public: + TouchTestScreen() { + for (int i = 0; i < MAX_TOUCH_POINTS; i++) { + touches_[i].id = -1; + } + } + + bool touch(const TouchInput &touch) override; + void render() override; + +protected: + struct TrackedTouch { + int id; + int x; + int y; + }; + enum { + MAX_TOUCH_POINTS = 10, + }; + TrackedTouch touches_[MAX_TOUCH_POINTS]{}; + + virtual void CreateViews() override; + UI::EventReturn OnImmersiveModeChange(UI::EventParams &e); }; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 35f9eb312f..684a293a43 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -42,6 +42,7 @@ #include "GPU/GPUState.h" #include "UI/MiscScreens.h" #include "UI/DevScreens.h" +#include "UI/ControlMappingScreen.h" #include "UI/GameSettingsScreen.h" #ifdef _WIN32 diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index b1bf46f218..7645fc9b7e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -839,7 +839,7 @@ UI::EventReturn GameSettingsScreen::OnScreenRotation(UI::EventParams &e) { return UI::EVENT_DONE; } -static void RecreateActivity() { +void RecreateActivity() { const int SYSTEM_JELLYBEAN = 16; if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= SYSTEM_JELLYBEAN) { ILOG("Sending recreate"); @@ -1342,6 +1342,7 @@ void DeveloperToolsScreen::CreateViews() { if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) { list->Add(new Choice(dev->T("GPU Driver Test")))->OnClick.Handle(this, &DeveloperToolsScreen::OnGPUDriverTest); } + list->Add(new Choice(dev->T("Touchscreen Test")))->OnClick.Handle(this, &DeveloperToolsScreen::OnTouchscreenTest); allowDebugger_ = !WebServerStopped(WebServerFlags::DEBUGGER); canAllowDebugger_ = !WebServerStopping(WebServerFlags::DEBUGGER); @@ -1443,6 +1444,11 @@ UI::EventReturn DeveloperToolsScreen::OnGPUDriverTest(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn DeveloperToolsScreen::OnTouchscreenTest(UI::EventParams &e) { + screenManager()->push(new TouchTestScreen()); + return UI::EVENT_DONE; +} + UI::EventReturn DeveloperToolsScreen::OnJitAffectingSetting(UI::EventParams &e) { NativeMessageReceived("clear jit", ""); return UI::EVENT_DONE; diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 8620336907..cde4e47409 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -173,6 +173,7 @@ private: UI::EventReturn OnJitDebugTools(UI::EventParams &e); UI::EventReturn OnRemoteDebugger(UI::EventParams &e); UI::EventReturn OnGPUDriverTest(UI::EventParams &e); + UI::EventReturn OnTouchscreenTest(UI::EventParams &e); bool allowDebugger_ = false; bool canAllowDebugger_ = true; diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 2a70b05e56..fa3d86f25e 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -578,6 +578,7 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C } Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight + " holder: " + holder.toString() + " or: " + requestedOr); + NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int) densityDpi, refreshRate); getDesiredBackbufferSize(desiredSize); // Note that desiredSize might be 0,0 here - but that's fine when calling setFixedSize! It means auto.