From e2ecf306facd2c6d1ae4461b5ce2082528fdb434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 21:42:07 +0200 Subject: [PATCH 1/5] Android: Be slightly more aggressive at defaulting to Vulkan (from Android 8.1 / 27) --- Core/Config.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index b83d1bc893..814b9fae6f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -575,9 +575,9 @@ static int DefaultGPUBackend() { return (int)GPUBackend::DIRECT3D11; } #elif PPSSPP_PLATFORM(ANDROID) - // Default to Vulkan only on Pie (level 28) devices or newer. Drivers before Pie + // Default to Vulkan only on Oreo 8.1 (level 27) devices or newer. Drivers before // were generally too unreliable to default to (with some exceptions, of course). - if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 28) { + if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 27) { return (int)GPUBackend::VULKAN; } #endif @@ -628,10 +628,14 @@ int Config::NextValidBackend() { } #endif - // They've all failed. Let them try the default. + // They've all failed. Let them try the default - or on Android, OpenGL. sFailedGPUBackends += ",ALL"; ERROR_LOG(LOADER, "All graphics backends failed"); +#if PPSSPP_PLATFORM(ANDROID) + return (int)GPUBackend::OPENGL; +#else return DefaultGPUBackend(); +#endif } return iGPUBackend; From e3a40e9cd794500141c43b8e7c2534a4eacef18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 21:42:49 +0200 Subject: [PATCH 2/5] Remove an old special case --- Core/Config.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 814b9fae6f..ecb3a7612e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -507,15 +507,6 @@ static ConfigSetting cpuSettings[] = { ConfigSetting(false), }; -static int DefaultRenderingMode() { - // Workaround for ancient device. Can probably be removed now as we do no longer - // support Froyo (Android 2.2)... - if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") { - return 0; // Non-buffered - } - return 1; -} - static int DefaultInternalResolution() { // Auto on Windows, 2x on large screens, 1x elsewhere. #if defined(USING_WIN_UI) @@ -714,7 +705,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false), #endif ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), - ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true), + ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), ReportedConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true, true, true), From f57b8b19d27badf153e8dba6c84c579929ea66c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 3 Sep 2019 00:01:37 +0200 Subject: [PATCH 3/5] Windows: Kill the mouse wheel release timer after it's used to prevent spamming keyup events. --- Windows/MainWindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 4dbba48ade..fe66c287c8 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -258,7 +258,7 @@ namespace MainWindow } } - void RelaseMouseWheel() { + void ReleaseMouseWheel() { // For simplicity release both wheel events KeyInput key; key.deviceId = DEVICE_ID_MOUSE; @@ -816,7 +816,8 @@ namespace MainWindow return 0; // Hack: need to release wheel event with a delay for games to register it was "pressed down". case TIMER_WHEELRELEASE: - RelaseMouseWheel(); + ReleaseMouseWheel(); + KillTimer(hWnd, TIMER_WHEELRELEASE); return 0; } break; From 6ff110d0928d684e72ed1c6fa24f13aa6d193121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 3 Sep 2019 00:02:57 +0200 Subject: [PATCH 4/5] Create a default keymap for the MOQI:I7S gamer phone (with builtin controls) --- Common/KeyMap.cpp | 55 +++++++++++++++++++++++++++++++++++++---------- Common/KeyMap.h | 2 ++ 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Common/KeyMap.cpp b/Common/KeyMap.cpp index 737d547b3c..169d7547c2 100644 --- a/Common/KeyMap.cpp +++ b/Common/KeyMap.cpp @@ -15,23 +15,24 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include + #if defined(SDL) #include #elif defined(USING_WIN_UI) #include "CommonWindows.h" #endif -#include #include "base/logging.h" #include "base/NativeApp.h" #include "file/ini_file.h" #include "input/input_state.h" +#include "ppsspp_config.h" #include "KeyMap.h" -#include "../Core/HLE/sceUtility.h" -#include "../Core/Config.h" - -#include +#include "Core/HLE/sceUtility.h" +#include "Core/Config.h" namespace KeyMap { @@ -184,6 +185,27 @@ static const DefMappingStruct defaultShieldKeyMap[] = { {VIRTKEY_PAUSE, NKCODE_BACK }, }; +static const DefMappingStruct defaultMOQI7SKeyMap[] = { + {CTRL_CROSS, NKCODE_BUTTON_A}, + {CTRL_CIRCLE, NKCODE_BUTTON_B}, + {CTRL_SQUARE, NKCODE_BUTTON_X}, + {CTRL_TRIANGLE, NKCODE_BUTTON_Y}, + {CTRL_START, JOYSTICK_AXIS_Z, +1}, + {CTRL_SELECT, JOYSTICK_AXIS_Z, -1}, + {CTRL_LTRIGGER, NKCODE_BUTTON_L1}, + {CTRL_RTRIGGER, NKCODE_BUTTON_R1}, + {VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1}, + {VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1}, + {VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1}, + {VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1}, + {CTRL_LEFT, JOYSTICK_AXIS_HAT_X, -1}, + {CTRL_RIGHT, JOYSTICK_AXIS_HAT_X, +1}, + {CTRL_UP, JOYSTICK_AXIS_HAT_Y, -1}, + {CTRL_DOWN, JOYSTICK_AXIS_HAT_Y, +1}, + {VIRTKEY_UNTHROTTLE, JOYSTICK_AXIS_RZ, +1 }, + {VIRTKEY_PAUSE, NKCODE_BACK }, +}; + static const DefMappingStruct defaultPadMap[] = { #if defined(__ANDROID__) {CTRL_CROSS , NKCODE_BUTTON_A}, @@ -384,6 +406,9 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) { case DEFAULT_MAPPING_SHIELD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace); break; + case DEFAULT_MAPPING_MOQI_I7S: + SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultMOQI7SKeyMap, ARRAY_SIZE(defaultMOQI7SKeyMap), replace); + break; case DEFAULT_MAPPING_PAD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace); break; @@ -853,20 +878,24 @@ void SetAxisMapping(int btn, int deviceId, int axisId, int direction, bool repla // Note that it's easy to add other defaults if desired. void RestoreDefault() { g_controllerMap.clear(); -#if defined(_WIN32) +#if PPSSPP_PLATFORM(WINDOWS) SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true); SetDefaultKeyMap(DEFAULT_MAPPING_X360, false); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false); -#elif defined(__ANDROID__) - // Autodetect a few common devices +#elif PPSSPP_PLATFORM(ANDROID) + // Autodetect a few common (and less common) devices std::string name = System_GetProperty(SYSPROP_NAME); if (IsNvidiaShield(name) || IsNvidiaShieldTV(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_SHIELD, true); - } else if (IsOuya(name)) { // TODO: check! + } else if (IsOuya(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_OUYA, true); } else if (IsXperiaPlay(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_XPERIA_PLAY, true); + } else if (IsMOQII7S(name)) { + ILOG("MOQI pad map"); + SetDefaultKeyMap(DEFAULT_MAPPING_MOQI_I7S, true); } else { + ILOG("Default pad map"); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true); } #else @@ -944,8 +973,12 @@ bool IsXperiaPlay(const std::string &name) { return name == "Sony Ericsson:R800a" || name == "Sony Ericsson:R800i" || name == "Sony Ericsson:R800x" || name == "Sony Ericsson:R800at" || name == "Sony Ericsson:SO-01D" || name == "Sony Ericsson:zeus"; } +bool IsMOQII7S(const std::string &name) { + return name == "MOQI:I7S"; +} + bool HasBuiltinController(const std::string &name) { - return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name); + return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name) || IsMOQII7S(name); } void NotifyPadConnected(const std::string &name) { @@ -953,7 +986,7 @@ void NotifyPadConnected(const std::string &name) { } void AutoConfForPad(const std::string &name) { - ILOG("Autoconfiguring pad for %s", name.c_str()); + ILOG("Autoconfiguring pad for '%s'", name.c_str()); if (name == "Xbox 360 Pad") { SetDefaultKeyMap(DEFAULT_MAPPING_X360, true); } else { diff --git a/Common/KeyMap.h b/Common/KeyMap.h index 15c239c62a..70b6c4f2ea 100644 --- a/Common/KeyMap.h +++ b/Common/KeyMap.h @@ -68,6 +68,7 @@ enum DefaultMaps { DEFAULT_MAPPING_SHIELD, DEFAULT_MAPPING_OUYA, DEFAULT_MAPPING_XPERIA_PLAY, + DEFAULT_MAPPING_MOQI_I7S, }; const float AXIS_BIND_THRESHOLD = 0.75f; @@ -141,6 +142,7 @@ namespace KeyMap { bool IsNvidiaShieldTV(const std::string &name); bool IsXperiaPlay(const std::string &name); bool IsOuya(const std::string &name); + bool IsMOQII7S(const std::string &name); bool HasBuiltinController(const std::string &name); const std::set &GetSeenPads(); From 90de634d1ed203a7064a15fee7cdabd0c205c0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 3 Sep 2019 00:05:18 +0200 Subject: [PATCH 5/5] Analog test screen: Fix drawing of the X marks --- UI/ControlMappingScreen.cpp | 35 +++++++++++++++++------------------ UI/DevScreens.cpp | 3 +++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index edb3f26e2d..f7985ba69b 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -432,9 +432,7 @@ public: JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams), xAxis_(xAxis), xDir_(xDir), - yAxis_(yAxis), yDir_(yDir), - curX_(0.0f), curY_(0.0f), - maxCount_(500) {} + yAxis_(yAxis), yDir_(yDir) {} void Draw(UIContext &dc) override; void Update() override; void Axis(const AxisInput &input) override { @@ -448,8 +446,6 @@ public: private: struct Location { - Location() : x(0.0f), y(0.0f) {} - Location(float xx, float yy) : x(xx), y(yy) {} float x; float y; }; @@ -459,40 +455,44 @@ private: int yAxis_; int yDir_; - float curX_; - float curY_; + float curX_ = 0.0f; + float curY_ = 0.0f; std::deque locations_; - int maxCount_; + int maxCount_ = 500; }; void JoystickHistoryView::Draw(UIContext &dc) { if (xAxis_ > -1 && yAxis_ > -1) { const AtlasImage &image = dc.Draw()->GetAtlas()->images[I_CROSS]; float minRadius = std::min(bounds_.w, bounds_.h) * 0.5f - image.w; - + dc.Begin(); int a = maxCount_ - (int)locations_.size(); for (auto iter = locations_.begin(); iter != locations_.end(); ++iter) { float x = bounds_.centerX() + minRadius * iter->x; float y = bounds_.centerY() - minRadius * iter->y; float alpha = (float)a / maxCount_; - if (alpha < 0.0f) alpha = 0.0f; + if (alpha < 0.0f) { + alpha = 0.0f; + } dc.Draw()->DrawImage(I_CROSS, x, y, 0.8f, colorAlpha(0xFFFFFF, alpha), ALIGN_CENTER); a++; } - dc.BeginNoTex(); - dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2, minRadius * 2, 0x80FFFFFF); dc.Flush(); - dc.Begin(); + dc.BeginNoTex(); + dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2.0f, minRadius * 2.0f, 0x80FFFFFF); + dc.Flush(); } else { dc.DrawText("N/A", bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER); } } void JoystickHistoryView::Update() { - locations_.push_back(Location(curX_, curY_)); - if ((int)locations_.size() > maxCount_) { - locations_.pop_front(); + if (xAxis_ > -1 && yAxis_ > -1) { + locations_.push_back(Location{ curX_, curY_ }); + if ((int)locations_.size() > maxCount_) { + locations_.pop_front(); + } } } @@ -521,12 +521,11 @@ bool AnalogTestScreen::axis(const AxisInput &axis) { // This is mainly to catch axis events that would otherwise get translated // into arrow keys, since seeing keyboard arrow key events appear when using // a controller would be confusing for the user. - char buf[512]; - if (IgnoreAxisForMapping(axis.axisId)) return false; if (axis.value > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) { + char buf[512]; snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d", axis.axisId, axis.value, axis.deviceId); // Null-check just in case they weren't created yet. diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index d3e1d54f5d..35f9eb312f 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -439,6 +439,9 @@ void SystemInfoScreen::CreateViews() { deviceSpecs->Add(new ItemHeader(si->T("System Information"))); deviceSpecs->Add(new InfoItem(si->T("System Name", "Name"), System_GetProperty(SYSPROP_NAME))); +#if PPSSPP_PLATFORM(ANDROID) + deviceSpecs->Add(new InfoItem(si->T("System Version"), StringFromInt(System_GetPropertyInt(SYSPROP_SYSTEMVERSION)))); +#endif deviceSpecs->Add(new InfoItem(si->T("Lang/Region"), System_GetProperty(SYSPROP_LANGREGION))); std::string board = System_GetProperty(SYSPROP_BOARDNAME); if (!board.empty())