From 533722456b0ce33cfa9339ab477e437b7e4079f4 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 7 Oct 2020 17:58:11 +1000 Subject: [PATCH] Android: Fix logo not displaying during loading --- android/app/src/cpp/android_host_interface.cpp | 16 ++++++++++++++++ .../duckstation/AndroidHostInterface.java | 2 ++ .../stenzek/duckstation/EmulationActivity.java | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index 1bf479e96..37c8a1dc0 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -366,16 +366,26 @@ bool AndroidHostInterface::AcquireHostDisplay() !display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device)) { ReportError("Failed to acquire host display."); + display->DestroyRenderDevice(); return false; } m_display = std::move(display); + + if (!CreateHostDisplayResources()) + { + ReportError("Failed to create host display resources"); + ReleaseHostDisplay(); + return false; + } + ImGui::NewFrame(); return true; } void AndroidHostInterface::ReleaseHostDisplay() { + ReleaseHostDisplayResources(); m_display->DestroyRenderDevice(); m_display.reset(); } @@ -830,3 +840,9 @@ DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_setCheatEnabled, jobject obj, AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj); hi->RunOnEmulationThread([index, enabled, hi]() { hi->SetCheatCodeState(static_cast(index), enabled, true); }); } + +DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_addOSDMessage, jobject obj, jstring message, jfloat duration) +{ + AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj); + hi->AddOSDMessage(AndroidHelpers::JStringToString(env, message), duration); +} diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java b/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java index 9e93f1c49..d4bda0643 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java @@ -74,6 +74,8 @@ public class AndroidHostInterface { public native CheatCode[] getCheatList(); public native void setCheatEnabled(int index, boolean enabled); + public native void addOSDMessage(String message, float duration); + static { System.loadLibrary("duckstation-native"); } diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java index b9374bcaf..f83c646a0 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java @@ -372,7 +372,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde private void showCheatsMenu() { final CheatCode[] cheats = AndroidHostInterface.getInstance().getCheatList(); if (cheats == null) { - Toast.makeText(this, "No cheats are loaded.", Toast.LENGTH_LONG); + AndroidHostInterface.getInstance().addOSDMessage("No cheats are loaded.", 5.0f); return; }