From 469ae2805cc452ce72673eca87d5f042b130ecc8 Mon Sep 17 00:00:00 2001 From: offtkp Date: Tue, 14 Nov 2023 15:30:53 +0200 Subject: [PATCH 01/15] Add initial pandroid files --- CMakeLists.txt | 36 ++-- src/emulator.cpp | 2 + src/jni_driver.cpp | 11 ++ src/pandroid/.gitignore | 15 ++ src/pandroid/app/.gitignore | 1 + src/pandroid/app/build.gradle.kts | 46 +++++ src/pandroid/app/proguard-rules.pro | 21 ++ src/pandroid/app/src/main/AndroidManifest.xml | 26 +++ .../com/panda3ds/pandroid/AlberDriver.java | 10 + .../com/panda3ds/pandroid/MainActivity.java | 16 ++ src/pandroid/app/src/main/jniLibs/.gitignore | 2 + .../app/src/main/jniLibs/arm64-v8a/.gitkeep | 0 .../app/src/main/jniLibs/x86_64/.gitkeep | 0 .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ .../res/drawable/ic_launcher_foreground.xml | 30 +++ .../app/src/main/res/layout/activity_main.xml | 18 ++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 6 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../app/src/main/res/values-night/themes.xml | 7 + .../app/src/main/res/values/colors.xml | 5 + .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/themes.xml | 9 + .../app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ src/pandroid/build.gradle.kts | 4 + src/pandroid/gradle.properties | 21 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + src/pandroid/gradlew | 185 ++++++++++++++++++ src/pandroid/gradlew.bat | 89 +++++++++ src/pandroid/settings.gradle.kts | 17 ++ 41 files changed, 783 insertions(+), 11 deletions(-) create mode 100644 src/jni_driver.cpp create mode 100644 src/pandroid/.gitignore create mode 100644 src/pandroid/app/.gitignore create mode 100644 src/pandroid/app/build.gradle.kts create mode 100644 src/pandroid/app/proguard-rules.pro create mode 100644 src/pandroid/app/src/main/AndroidManifest.xml create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/MainActivity.java create mode 100644 src/pandroid/app/src/main/jniLibs/.gitignore create mode 100644 src/pandroid/app/src/main/jniLibs/arm64-v8a/.gitkeep create mode 100644 src/pandroid/app/src/main/jniLibs/x86_64/.gitkeep create mode 100644 src/pandroid/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 src/pandroid/app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 src/pandroid/app/src/main/res/layout/activity_main.xml create mode 100644 src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 src/pandroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 src/pandroid/app/src/main/res/values-night/themes.xml create mode 100644 src/pandroid/app/src/main/res/values/colors.xml create mode 100644 src/pandroid/app/src/main/res/values/strings.xml create mode 100644 src/pandroid/app/src/main/res/values/themes.xml create mode 100644 src/pandroid/app/src/main/res/xml/backup_rules.xml create mode 100644 src/pandroid/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 src/pandroid/build.gradle.kts create mode 100644 src/pandroid/gradle.properties create mode 100644 src/pandroid/gradle/wrapper/gradle-wrapper.jar create mode 100644 src/pandroid/gradle/wrapper/gradle-wrapper.properties create mode 100755 src/pandroid/gradlew create mode 100644 src/pandroid/gradlew.bat create mode 100644 src/pandroid/settings.gradle.kts diff --git a/CMakeLists.txt b/CMakeLists.txt index c202f80cc..2a80b06aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,16 +184,18 @@ set(APPLET_SOURCE_FILES src/core/applets/applet.cpp src/core/applets/mii_selecto set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp) # Frontend source files -if(ENABLE_QT_GUI) - set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp) - set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp) - - source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES}) - source_group("Header Files\\Qt" FILES ${FRONTEND_HEADER_FILES}) - include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS}) -else() - set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp) - set(FRONTEND_HEADER_FILES "") +if(NOT ANDROID) + if(ENABLE_QT_GUI) + set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp) + set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp) + + source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES}) + source_group("Header Files\\Qt" FILES ${FRONTEND_HEADER_FILES}) + include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS}) + else() + set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp) + set(FRONTEND_HEADER_FILES "") + endif() endif() set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp @@ -378,6 +380,10 @@ if(ENABLE_VULKAN) set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_VK_SOURCE_FILES}) endif() +if(ANDROID) + set(ALL_SOURCES ${ALL_SOURCES} src/jni_driver.cpp) +endif() + if(BUILD_HYDRA_CORE) include_directories(third_party/hydra_core/include) add_library(Alber SHARED ${ALL_SOURCES} src/hydra_core.cpp) @@ -386,11 +392,19 @@ else() add_executable(Alber ${ALL_SOURCES}) endif() +if(ANDROID) + target_link_libraries(Alber PRIVATE log) +endif() + if(ENABLE_LTO OR ENABLE_USER_BUILD) set_target_properties(Alber PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) endif() -target_link_libraries(Alber PRIVATE dynarmic SDL2-static cryptopp glad resources_console_fonts) +target_link_libraries(Alber PRIVATE dynarmic cryptopp glad resources_console_fonts) + +if(NOT ANDROID) + target_link_libraries(Alber PRIVATE SDL2-static) +endif() if(ENABLE_DISCORD_RPC AND NOT ANDROID) target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_DISCORD_RPC=1") diff --git a/src/emulator.cpp b/src/emulator.cpp index 81d3ac5c6..cd6bbdcb6 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -1,6 +1,8 @@ #include "emulator.hpp" +#ifndef __ANDROID__ #include +#endif #include diff --git a/src/jni_driver.cpp b/src/jni_driver.cpp new file mode 100644 index 000000000..c2a00d7b8 --- /dev/null +++ b/src/jni_driver.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "emulator.hpp" + +std::unique_ptr emulator; + +extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Initialize(JNIEnv* env, jobject obj) { + __android_log_print(ANDROID_LOG_INFO, "Panda3DS", "Initializing Alber Driver"); + emulator = std::make_unique(); + __android_log_print(ANDROID_LOG_INFO, "Panda3DS", "Done"); +} \ No newline at end of file diff --git a/src/pandroid/.gitignore b/src/pandroid/.gitignore new file mode 100644 index 000000000..aa724b770 --- /dev/null +++ b/src/pandroid/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/src/pandroid/app/.gitignore b/src/pandroid/app/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/src/pandroid/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/src/pandroid/app/build.gradle.kts b/src/pandroid/app/build.gradle.kts new file mode 100644 index 000000000..ff8debcbd --- /dev/null +++ b/src/pandroid/app/build.gradle.kts @@ -0,0 +1,46 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "com.panda3ds.pandroid" + compileSdk = 33 + + defaultConfig { + applicationId = "com.panda3ds.pandroid" + minSdk = 24 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + ndk { + abiFilters += listOf("x86_64", "arm64-v8a") + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.8.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") +} \ No newline at end of file diff --git a/src/pandroid/app/proguard-rules.pro b/src/pandroid/app/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/src/pandroid/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/src/pandroid/app/src/main/AndroidManifest.xml b/src/pandroid/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8047484ad --- /dev/null +++ b/src/pandroid/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java new file mode 100644 index 000000000..55bcd47ed --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java @@ -0,0 +1,10 @@ +package com.panda3ds.pandroid; + +public class AlberDriver { + + public static native void Initialize(); + + static { + System.loadLibrary("Alber"); + } +} \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/MainActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/MainActivity.java new file mode 100644 index 000000000..e2ab412b3 --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/MainActivity.java @@ -0,0 +1,16 @@ +package com.panda3ds.pandroid; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + AlberDriver.Initialize(); + } +} \ No newline at end of file diff --git a/src/pandroid/app/src/main/jniLibs/.gitignore b/src/pandroid/app/src/main/jniLibs/.gitignore new file mode 100644 index 000000000..0b469178c --- /dev/null +++ b/src/pandroid/app/src/main/jniLibs/.gitignore @@ -0,0 +1,2 @@ +# Prebuilt Alber libraries will be placed in this directory, but we don't want to push them to the repo +libAlber.so \ No newline at end of file diff --git a/src/pandroid/app/src/main/jniLibs/arm64-v8a/.gitkeep b/src/pandroid/app/src/main/jniLibs/arm64-v8a/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/src/pandroid/app/src/main/jniLibs/x86_64/.gitkeep b/src/pandroid/app/src/main/jniLibs/x86_64/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/src/pandroid/app/src/main/res/drawable/ic_launcher_background.xml b/src/pandroid/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 000000000..07d5da9cb --- /dev/null +++ b/src/pandroid/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/pandroid/app/src/main/res/drawable/ic_launcher_foreground.xml b/src/pandroid/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 000000000..2b068d114 --- /dev/null +++ b/src/pandroid/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/layout/activity_main.xml b/src/pandroid/app/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..17eab17ba --- /dev/null +++ b/src/pandroid/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 000000000..6f3b755bf --- /dev/null +++ b/src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 000000000..6f3b755bf --- /dev/null +++ b/src/pandroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..c209e78ecd372343283f4157dcfd918ec5165bb3 GIT binary patch literal 1404 zcmV-?1%vuhNk&F=1pok7MM6+kP&il$0000G0000-002h-06|PpNX!5L00Dqw+t%{r zzW2vH!KF=w&cMnnN@{whkTw+#mAh0SV?YL=)3MimFYCWp#fpdtz~8$hD5VPuQgtcN zXl<@<#Cme5f5yr2h%@8TWh?)bSK`O z^Z@d={gn7J{iyxL_y_%J|L>ep{dUxUP8a{byupH&!UNR*OutO~0{*T4q5R6@ApLF! z5{w?Z150gC7#>(VHFJZ-^6O@PYp{t!jH(_Z*nzTK4 zkc{fLE4Q3|mA2`CWQ3{8;gxGizgM!zccbdQoOLZc8hThi-IhN90RFT|zlxh3Ty&VG z?Fe{#9RrRnxzsu|Lg2ddugg7k%>0JeD+{XZ7>Z~{=|M+sh1MF7~ zz>To~`~LVQe1nNoR-gEzkpe{Ak^7{{ZBk2i_<+`Bq<^GB!RYG+z)h;Y3+<{zlMUYd zrd*W4w&jZ0%kBuDZ1EW&KLpyR7r2=}fF2%0VwHM4pUs}ZI2egi#DRMYZPek*^H9YK zay4Iy3WXFG(F14xYsoDA|KXgGc5%2DhmQ1gFCkrgHBm!lXG8I5h*uf{rn48Z!_@ z4Bk6TJAB2CKYqPjiX&mWoW>OPFGd$wqroa($ne7EUK;#3VYkXaew%Kh^3OrMhtjYN?XEoY`tRPQsAkH-DSL^QqyN0>^ zmC>{#F14jz4GeW{pJoRpLFa_*GI{?T93^rX7SPQgT@LbLqpNA}<@2wH;q493)G=1Y z#-sCiRNX~qf3KgiFzB3I>4Z%AfS(3$`-aMIBU+6?gbgDb!)L~A)je+;fR0jWLL-Fu z4)P{c7{B4Hp91&%??2$v9iRSFnuckHUm}or9seH6 z>%NbT+5*@L5(I9j@06@(!{ZI?U0=pKn8uwIg&L{JV14+8s2hnvbRrU|hZCd}IJu7*;;ECgO%8_*W Kmw_-CKmY()leWbG literal 0 HcmV?d00001 diff --git a/src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000000000000000000000000000000000000..b2dfe3d1ba5cf3ee31b3ecc1ced89044a1f3b7a9 GIT binary patch literal 2898 zcmV-Y3$650Nk&FW3jhFDMM6+kP&il$0000G0000-002h-06|PpNWB9900E$G+qN-D z+81ABX7q?;bwx%xBg?kcwr$(C-Tex-ZCkHUw(Y9#+`E5-zuONG5fgw~E2WDng@Bc@ z24xy+R1n%~6xI#u9vJ8zREI)sb<&Il(016}Z~V1n^PU3-_H17A*Bf^o)&{_uBv}Py z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AlwAYudn0FV~|odGH^05AYPEfR)8p`i{n zwg3zPVp{+wOsxKc>)(pMupKF!Y2HoUqQ3|Yu|8lwR=?5zZuhG6J?H`bSNk_wPoM{u zSL{c@pY7+c2kck>`^q1^^gR0QB7Y?KUD{vz-uVX~;V-rW)PDcI)$_UjgVV?S?=oLR zf4}zz{#*R_{LkiJ#0RdQLNC^2Vp%JPEUvG9ra2BVZ92(p9h7Ka@!yf9(lj#}>+|u* z;^_?KWdzkM`6gqPo9;;r6&JEa)}R3X{(CWv?NvgLeOTq$cZXqf7|sPImi-7cS8DCN zGf;DVt3Am`>hH3{4-WzH43Ftx)SofNe^-#|0HdCo<+8Qs!}TZP{HH8~z5n`ExcHuT zDL1m&|DVpIy=xsLO>8k92HcmfSKhflQ0H~9=^-{#!I1g(;+44xw~=* zxvNz35vfsQE)@)Zsp*6_GjYD};Squ83<_?^SbALb{a`j<0Gn%6JY!zhp=Fg}Ga2|8 z52e1WU%^L1}15Ex0fF$e@eCT(()_P zvV?CA%#Sy08_U6VPt4EtmVQraWJX` zh=N|WQ>LgrvF~R&qOfB$!%D3cGv?;Xh_z$z7k&s4N)$WYf*k=|*jCEkO19{h_(%W4 zPuOqbCw`SeAX*R}UUsbVsgtuG?xs(#Ikx9`JZoQFz0n*7ZG@Fv@kZk`gzO$HoA9kN z8U5{-yY zvV{`&WKU2$mZeoBmiJrEdzUZAv1sRxpePdg1)F*X^Y)zp^Y*R;;z~vOv-z&)&G)JQ{m!C9cmziu1^nHA z`#`0c>@PnQ9CJKgC5NjJD8HM3|KC(g5nnCq$n0Gsu_DXk36@ql%npEye|?%RmG)

FJ$wK}0tWNB{uH;AM~i literal 0 HcmV?d00001 diff --git a/src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..948a3070fe34c611c42c0d3ad3013a0dce358be0 GIT binary patch literal 1900 zcmV-y2b1_xNk&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B;{qfug}O%z@K{EZECu6zl)7CiNi%xti0 zB{OKfAj83~iJvmpTU|&q1^?^cIMn2RQ?jeSB95l}{DrEPTW{_gmU_pqTc)h@4T>~& zluq3)GM=xa(#^VU5}@FNqpc$?#SbVsX!~RH*5p0p@w z;~v{QMX0^bFT1!cXGM8K9FP+=9~-d~#TK#ZE{4umGT=;dfvWi?rYj;^l_Zxywze`W z^Cr{55U@*BalS}K%Czii_80e0#0#Zkhlij4-~I@}`-JFJ7$5{>LnoJSs??J8kWVl6|8A}RCGAu9^rAsfCE=2}tHwl93t0C?#+jMpvr7O3`2=tr{Hg$=HlnjVG^ewm|Js0J*kfPa6*GhtB>`fN!m#9J(sU!?(OSfzY*zS(FJ<-Vb zfAIg+`U)YaXv#sY(c--|X zEB+TVyZ%Ie4L$gi#Fc++`h6%vzsS$pjz9aLt+ZL(g;n$Dzy5=m=_TV(3H8^C{r0xd zp#a%}ht55dOq?yhwYPrtp-m1xXp;4X;)NhxxUpgP%XTLmO zcjaFva^}dP3$&sfFTIR_jC=2pHh9kpI@2(6V*GQo7Ws)`j)hd+tr@P~gR*2gO@+1? zG<`_tB+LJuF|SZ9tIec;h%}}6WClT`L>HSW?E{Hp1h^+mlbf_$9zA>!ug>NALJsO{ mU%z=YwVD?}XMya)Bp;vlyE5&E_6!fzx9pwrdz474!~g(M6R?N? literal 0 HcmV?d00001 diff --git a/src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000000000000000000000000000000000000..1b9a6956b3acdc11f40ce2bb3f6efbd845cc243f GIT binary patch literal 3918 zcmV-U53%r4Nk&FS4*&pHMM6+kP&il$0000G0001A003VA06|PpNSy@$00HoY|G(*G z+qV7x14$dSO^Re!iqt-AAIE9iwr$(CZQJL$blA4B`>;C3fBY6Q8_YSjb2%a=fc}4E zrSzssacq<^nmW|Rs93PJni30R<8w<(bK_$LO4L?!_OxLl$}K$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001=f@-~a#s literal 0 HcmV?d00001 diff --git a/src/pandroid/app/src/main/res/values-night/themes.xml b/src/pandroid/app/src/main/res/values-night/themes.xml new file mode 100644 index 000000000..98dd320a8 --- /dev/null +++ b/src/pandroid/app/src/main/res/values-night/themes.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/values/colors.xml b/src/pandroid/app/src/main/res/values/colors.xml new file mode 100644 index 000000000..c8524cd96 --- /dev/null +++ b/src/pandroid/app/src/main/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/values/strings.xml b/src/pandroid/app/src/main/res/values/strings.xml new file mode 100644 index 000000000..40c0990fe --- /dev/null +++ b/src/pandroid/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + pandroid + \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/values/themes.xml b/src/pandroid/app/src/main/res/values/themes.xml new file mode 100644 index 000000000..812da8ea5 --- /dev/null +++ b/src/pandroid/app/src/main/res/values/themes.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file From c1162678bb5783d4b10b919de86726141019a918 Mon Sep 17 00:00:00 2001 From: offtkp Date: Tue, 28 Nov 2023 13:26:07 +0200 Subject: [PATCH 05/15] Cleanup jni_driver --- patch.patch | 118 ------------------ src/jni_driver.cpp | 76 +++++------ .../panda3ds/pandroid/app/GameActivity.java | 2 +- 3 files changed, 39 insertions(+), 157 deletions(-) delete mode 100644 patch.patch diff --git a/patch.patch b/patch.patch deleted file mode 100644 index 98cad32b7..000000000 --- a/patch.patch +++ /dev/null @@ -1,118 +0,0 @@ -diff --git a/src/host_shaders/opengl_display.frag b/src/host_shaders/opengl_display.frag -index 612671c8..1937f711 100644 ---- a/src/host_shaders/opengl_display.frag -+++ b/src/host_shaders/opengl_display.frag -@@ -1,4 +1,5 @@ --#version 410 core -+#version 300 es -+precision mediump float; - in vec2 UV; - out vec4 FragColor; - -diff --git a/src/host_shaders/opengl_display.vert b/src/host_shaders/opengl_display.vert -index 990e2f80..6917c23c 100644 ---- a/src/host_shaders/opengl_display.vert -+++ b/src/host_shaders/opengl_display.vert -@@ -1,4 +1,4 @@ --#version 410 core -+#version 300 es - out vec2 UV; - - void main() { -diff --git a/src/host_shaders/opengl_fragment_shader.frag b/src/host_shaders/opengl_fragment_shader.frag -index f6fa6c55..b0850438 100644 ---- a/src/host_shaders/opengl_fragment_shader.frag -+++ b/src/host_shaders/opengl_fragment_shader.frag -@@ -1,4 +1,5 @@ --#version 410 core -+#version 300 es -+precision mediump float; - - in vec3 v_tangent; - in vec3 v_normal; -@@ -27,7 +28,7 @@ uniform bool u_depthmapEnable; - uniform sampler2D u_tex0; - uniform sampler2D u_tex1; - uniform sampler2D u_tex2; --uniform sampler1DArray u_tex_lighting_lut; -+// uniform sampler1DArray u_tex_lighting_lut; - - uniform uint u_picaRegs[0x200 - 0x48]; - -@@ -145,9 +146,15 @@ vec4 tevCalculateCombiner(int tev_id) { - #define RR_LUT 6u - - float lutLookup(uint lut, uint light, float value) { -- if (lut >= FR_LUT && lut <= RR_LUT) lut -= 1; -- if (lut == SP_LUT) lut = light + 8; -- return texture(u_tex_lighting_lut, vec2(value, lut)).r; -+ // if (lut >= FR_LUT && lut <= RR_LUT) lut -= 1; -+ // if (lut == SP_LUT) lut = light + 8; -+ // return texture(u_tex_lighting_lut, vec2(value, lut)).r; -+ return 0.0; -+} -+ -+uint bitfieldExtract(uint val, int off, int size) { -+ uint mask = uint((1 << size) - 1); -+ return uint(val >> off) & mask; - } - - vec3 regToColor(uint reg) { -diff --git a/src/host_shaders/opengl_vertex_shader.vert b/src/host_shaders/opengl_vertex_shader.vert -index a25d7a6d..5967ccd6 100644 ---- a/src/host_shaders/opengl_vertex_shader.vert -+++ b/src/host_shaders/opengl_vertex_shader.vert -@@ -1,4 +1,4 @@ --#version 410 core -+#version 300 es - - layout(location = 0) in vec4 a_coords; - layout(location = 1) in vec4 a_quaternion; -@@ -20,7 +20,7 @@ out vec2 v_texcoord2; - flat out vec4 v_textureEnvColor[6]; - flat out vec4 v_textureEnvBufferColor; - --out float gl_ClipDistance[2]; -+// out float gl_ClipDistance[2]; - - // TEV uniforms - uniform uint u_textureEnvColor[6]; -@@ -93,6 +93,6 @@ void main() { - ); - - // There's also another, always-on clipping plane based on vertex z -- gl_ClipDistance[0] = -a_coords.z; -- gl_ClipDistance[1] = dot(clipData, a_coords); -+ // gl_ClipDistance[0] = -a_coords.z; -+ // gl_ClipDistance[1] = dot(clipData, a_coords); - } -diff --git a/third_party/opengl/opengl.hpp b/third_party/opengl/opengl.hpp -index f368f573..5ead7f63 100644 ---- a/third_party/opengl/opengl.hpp -+++ b/third_party/opengl/opengl.hpp -@@ -520,21 +520,21 @@ namespace OpenGL { - static void enableBlend() { glEnable(GL_BLEND); } - static void disableBlend() { glDisable(GL_BLEND); } - static void enableLogicOp() { glEnable(GL_COLOR_LOGIC_OP); } -- static void disableLogicOp() { glDisable(GL_COLOR_LOGIC_OP); } -+ static void disableLogicOp() { /* glDisable(GL_COLOR_LOGIC_OP); */ } - static void enableDepth() { glEnable(GL_DEPTH_TEST); } - static void disableDepth() { glDisable(GL_DEPTH_TEST); } - static void enableStencil() { glEnable(GL_STENCIL_TEST); } - static void disableStencil() { glDisable(GL_STENCIL_TEST); } - -- static void enableClipPlane(GLuint index) { glEnable(GL_CLIP_DISTANCE0 + index); } -- static void disableClipPlane(GLuint index) { glDisable(GL_CLIP_DISTANCE0 + index); } -+ static void enableClipPlane(GLuint index) { /* glEnable(GL_CLIP_DISTANCE0 + index); */ } -+ static void disableClipPlane(GLuint index) { /* glDisable(GL_CLIP_DISTANCE0 + index); */ } - - static void setDepthFunc(DepthFunc func) { glDepthFunc(static_cast(func)); } - static void setColourMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) { glColorMask(r, g, b, a); } - static void setDepthMask(GLboolean mask) { glDepthMask(mask); } - - // TODO: Add a proper enum for this -- static void setLogicOp(GLenum op) { glLogicOp(op); } -+ static void setLogicOp(GLenum op) { /* glLogicOp(op); */ } - - enum Primitives { - Triangle = GL_TRIANGLES, diff --git a/src/jni_driver.cpp b/src/jni_driver.cpp index 5cd519e6d..422096d88 100644 --- a/src/jni_driver.cpp +++ b/src/jni_driver.cpp @@ -1,74 +1,74 @@ +#include +#include #include + #include -#include -#include -#include "renderer_gl/renderer_gl.hpp" + #include "emulator.hpp" +#include "renderer_gl/renderer_gl.hpp" +#include "services/hid.hpp" std::unique_ptr emulator = nullptr; +HIDService* hidService = nullptr; RendererGL* renderer = nullptr; bool romLoaded = false; extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Initialize(JNIEnv* env, jobject obj) { - emulator = std::make_unique(); - if (emulator->getRendererType() != RendererType::OpenGL) { - throw std::runtime_error("Renderer is not OpenGL"); - } - renderer = static_cast(emulator->getRenderer()); - __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES Before %d.%d", GLVersion.major, GLVersion.minor); - if (!gladLoadGLES2Loader(reinterpret_cast(eglGetProcAddress))) { + emulator = std::make_unique(); + + if (emulator->getRendererType() != RendererType::OpenGL) { + throw std::runtime_error("Renderer is not OpenGL"); + } + + renderer = static_cast(emulator->getRenderer()); + hidService = &emulator->getServiceManager().getHID(); + + if (!gladLoadGLES2Loader(reinterpret_cast(eglGetProcAddress))) { throw std::runtime_error("OpenGL ES init failed"); } - __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES %d.%d", GLVersion.major, GLVersion.minor); + + __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES %d.%d", GLVersion.major, GLVersion.minor); emulator->initGraphicsContext(nullptr); } extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_RunFrame(JNIEnv* env, jobject obj, jint fbo) { - renderer->setFBO(fbo); - renderer->resetStateManager(); - emulator->runFrame(); - - emulator->getServiceManager().getHID().updateInputs(emulator->getTicks()); + renderer->setFBO(fbo); + renderer->resetStateManager(); + emulator->runFrame(); + + hidService->updateInputs(emulator->getTicks()); } extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Finalize(JNIEnv* env, jobject obj) { - emulator = nullptr; - renderer = nullptr; + emulator = nullptr; + hidService = nullptr; + renderer = nullptr; } -extern "C" JNIEXPORT jboolean JNICALL Java_com_panda3ds_pandroid_AlberDriver_HasRomLoaded(JNIEnv* env, jobject obj) { - return romLoaded; -} +extern "C" JNIEXPORT jboolean JNICALL Java_com_panda3ds_pandroid_AlberDriver_HasRomLoaded(JNIEnv* env, jobject obj) { return romLoaded; } extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_LoadRom(JNIEnv* env, jobject obj, jstring path) { - const char* pathStr = env->GetStringUTFChars(path, nullptr); - __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s", pathStr); - romLoaded = emulator->loadROM(pathStr); - env->ReleaseStringUTFChars(path, pathStr); + const char* pathStr = env->GetStringUTFChars(path, nullptr); + __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s", pathStr); + romLoaded = emulator->loadROM(pathStr); + env->ReleaseStringUTFChars(path, pathStr); } - - extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenDown(JNIEnv* env, jobject obj, jint x, jint y) { - emulator->getServiceManager().getHID().setTouchScreenPress((u16)x, (u16)y); -} - -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenUp(JNIEnv* env, jobject obj) { - emulator->getServiceManager().getHID().releaseTouchScreen(); + hidService->setTouchScreenPress((u16)x, (u16)y); } +extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenUp(JNIEnv* env, jobject obj) { hidService->releaseTouchScreen(); } extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_KeyUp(JNIEnv* env, jobject obj, jint keyCode) { - emulator->getServiceManager().getHID().releaseKey((u32)keyCode); + hidService->releaseKey((u32)keyCode); } extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_KeyDown(JNIEnv* env, jobject obj, jint keyCode) { - emulator->getServiceManager().getHID().pressKey((u32)keyCode); + hidService->pressKey((u32)keyCode); } extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_SetCirclepadAxis(JNIEnv* env, jobject obj, jint x, jint y) { - emulator->getServiceManager().getHID().setCirclepadX((s16)x); - emulator->getServiceManager().getHID().setCirclepadY((s16)y); + hidService->setCirclepadX((s16)x); + hidService->setCirclepadY((s16)y); } - - diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index 275797fbb..60fe87248 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -38,7 +38,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { return; } - pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH));; + pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH)); setContentView(R.layout.game_activity); From 200a884589238d240c63bb3bdea0632a65300cf2 Mon Sep 17 00:00:00 2001 From: offtkp Date: Tue, 28 Nov 2023 14:05:51 +0200 Subject: [PATCH 06/15] Various cleanups --- .../panda3ds/pandroid/app/GameActivity.java | 2 +- .../com/panda3ds/pandroid/math/Vector2.java | 3 ++ .../panda3ds/pandroid/utils/Constants.java | 3 ++ .../pandroid/view/PandaGlRenderer.java | 29 +++++++++---------- .../pandroid/view/PandaGlSurfaceView.java | 4 --- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index 60fe87248..5c2344239 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -33,7 +33,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { if(!intent.hasExtra(Constants.EXTRA_PATH)){ setContentView(new FrameLayout(this)); - Toast.makeText(this, "INVALID ROM PATH", Toast.LENGTH_LONG).show(); + Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show(); finish(); return; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java index 8d4132032..9c5b45b7e 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java @@ -2,9 +2,11 @@ public class Vector2 { public float x,y; + public Vector2(){ this(0.0f); } + public Vector2(float value){ this(value,value); } @@ -17,6 +19,7 @@ public Vector2(float x, float y){ public float distanceTo(Vector2 vec){ return distance(x,y,vec.x, vec.y); } + public static float distance(float x, float y, float x2, float y2){ return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index c8ba68cd7..2e7065309 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -18,6 +18,9 @@ public class Constants { public static final int INPUT_KEY_START = 1 << 3; public static final int INPUT_KEY_SELECT = 1 << 2; + public static final int N3DS_WIDTH = 400; + public static final int N3DS_HEIGHT = 240; + public static final String EXTRA_PATH = "path"; public static final String LOG_TAG = "Alber"; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index 4adce5758..b6be4df26 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -10,6 +10,7 @@ import android.util.Log; import com.panda3ds.pandroid.AlberDriver; +import com.panda3ds.pandroid.utils.Constants; import java.util.ArrayList; @@ -69,43 +70,41 @@ public void onDrawFrame(GL10 unused) { AlberDriver.RunFrame(screenFbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo); + if (screenWidth > screenHeight) { - int topDisplayWidth = (int) ((screenHeight / 240.0) * 400); + int topDisplayWidth = (int)((screenHeight / (float)Constants.N3DS_HEIGHT) * Constants.N3DS_WIDTH); int topDisplayHeight = screenHeight; - if (topDisplayWidth > (screenWidth*0.7)){ - topDisplayWidth = (int) (screenWidth * 0.7); - topDisplayHeight = (int) ((topDisplayWidth/400.0)*240); + if (topDisplayWidth > screenWidth * 0.7){ + topDisplayWidth = (int)(screenWidth * 0.7); + topDisplayHeight = (int)((topDisplayWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT); } - int bottomDisplayHeight = (int) (((screenWidth-topDisplayWidth)/320)*240); - - int topDisplayY = screenHeight-topDisplayHeight; - int bottomDisplayY = screenHeight-bottomDisplayHeight; + int bottomDisplayHeight = (int)(((screenWidth - topDisplayWidth) / 320) * Constants.N3DS_HEIGHT); + int topDisplayY = screenHeight - topDisplayHeight; + int bottomDisplayY = screenHeight - bottomDisplayHeight; - glBlitFramebuffer(0, 240, - 400, 480, + glBlitFramebuffer(0, Constants.N3DS_HEIGHT, + Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2, 0, topDisplayY, topDisplayWidth,topDisplayY+topDisplayHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); glBlitFramebuffer( 40, 0, - 360, 240, + 360, Constants.N3DS_HEIGHT, topDisplayWidth, bottomDisplayY, screenWidth,bottomDisplayY+bottomDisplayHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); } else { - int h = (int) ((screenWidth / 400.0) * 480); - glBlitFramebuffer(0, 0, 400, 480, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); + int h = (int)((screenWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT * 2); + glBlitFramebuffer(0, 0, Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); } } } public void onSurfaceChanged(GL10 unused, int width, int height) { - glViewport(0, 0, width, height); screenWidth = width; screenHeight = height; - glDisable(GL_SCISSOR_TEST); } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java index 358056575..3b5694edc 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java @@ -13,8 +13,4 @@ public PandaGlSurfaceView(Context context, String romPath) { renderer = new PandaGlRenderer(romPath); setRenderer(renderer); } - - public PandaGlRenderer getRenderer() { - return renderer; - } } \ No newline at end of file From 9aded6e55611cc1d950156c7c4262726465a28ec Mon Sep 17 00:00:00 2001 From: offtkp Date: Tue, 28 Nov 2023 18:45:00 +0200 Subject: [PATCH 07/15] Permissions for older phones --- src/jni_driver.cpp | 2 +- src/pandroid/app/src/main/AndroidManifest.xml | 3 +++ .../main/java/com/panda3ds/pandroid/app/MainActivity.java | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/jni_driver.cpp b/src/jni_driver.cpp index 422096d88..6d3bd104e 100644 --- a/src/jni_driver.cpp +++ b/src/jni_driver.cpp @@ -49,8 +49,8 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_panda3ds_pandroid_AlberDriver_Has extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_LoadRom(JNIEnv* env, jobject obj, jstring path) { const char* pathStr = env->GetStringUTFChars(path, nullptr); - __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s", pathStr); romLoaded = emulator->loadROM(pathStr); + __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s, result: %d", pathStr, (int)romLoaded); env->ReleaseStringUTFChars(path, pathStr); } diff --git a/src/pandroid/app/src/main/AndroidManifest.xml b/src/pandroid/app/src/main/AndroidManifest.xml index 01931edcf..978edcc56 100644 --- a/src/pandroid/app/src/main/AndroidManifest.xml +++ b/src/pandroid/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + Date: Tue, 28 Nov 2023 14:54:10 -0400 Subject: [PATCH 08/15] TouchScreen input (#6) --- .../panda3ds/pandroid/app/GameActivity.java | 20 ++- .../com/panda3ds/pandroid/math/Vector2.java | 14 +- .../pandroid/view/PandaGlRenderer.java | 82 +++++---- .../pandroid/view/PandaGlSurfaceView.java | 36 +++- .../pandroid/view/PandaLayoutController.java | 2 + .../view/controller/ControllerLayout.java | 14 +- .../view/controller/ControllerNode.java | 4 + .../controller/nodes/TouchScreenNodeImpl.java | 39 +++++ .../view/renderer/ConsoleRenderer.java | 9 + .../view/renderer/layout/ConsoleLayout.java | 15 ++ .../renderer/layout/DefaultScreenLayout.java | 81 +++++++++ .../app/src/main/res/layout/game_activity.xml | 157 +++++++++--------- .../app/src/main/res/values/values.xml | 4 + 13 files changed, 349 insertions(+), 128 deletions(-) create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java create mode 100644 src/pandroid/app/src/main/res/values/values.xml diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index 5c2344239..53fb1805b 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -2,24 +2,20 @@ import android.content.Intent; import android.os.Bundle; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; +import android.os.Handler; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.CheckBox; -import android.widget.CompoundButton; import android.widget.FrameLayout; import android.widget.Toast; import androidx.annotation.Nullable; -import com.panda3ds.pandroid.AlberDriver; import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.PandaGlSurfaceView; import com.panda3ds.pandroid.view.PandaLayoutController; -import com.panda3ds.pandroid.view.controller.ControllerLayout; public class GameActivity extends BaseActivity { private PandaGlSurfaceView pandaSurface; @@ -46,11 +42,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { .addView(pandaSurface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); controllerLayout = findViewById(R.id.controller_layout); + controllerLayout.initialize(); ((CheckBox)findViewById(R.id.hide_screen_controller)) .setOnCheckedChangeListener((buttonView, isChecked) -> { - controllerLayout.setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE); + findViewById(R.id.overlay_controller) + .setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE); }); + + } + + @Override + protected void onResume() { + super.onResume(); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java index 9c5b45b7e..541d45e19 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java @@ -2,13 +2,8 @@ public class Vector2 { public float x,y; - - public Vector2(){ - this(0.0f); - } - - public Vector2(float value){ - this(value,value); + public Vector2(Vector2 value){ + this(value.x,value.y); } public Vector2(float x, float y){ @@ -23,4 +18,9 @@ public float distanceTo(Vector2 vec){ public static float distance(float x, float y, float x2, float y2){ return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); } + + public void set(float x, float y) { + this.x = x; + this.y = y; + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index b6be4df26..e6adbd9f4 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -6,17 +6,19 @@ import static android.opengl.GLES32.*; import android.content.res.Resources; +import android.graphics.Rect; import android.opengl.GLSurfaceView; import android.util.Log; import com.panda3ds.pandroid.AlberDriver; -import com.panda3ds.pandroid.utils.Constants; +import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout; +import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; +import com.panda3ds.pandroid.view.renderer.layout.DefaultScreenLayout; -import java.util.ArrayList; - -public class PandaGlRenderer implements GLSurfaceView.Renderer { +public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer { private final String romPath; + private ConsoleLayout displayLayout; private int screenWidth, screenHeight; private int screenTexture; public int screenFbo; @@ -24,6 +26,10 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer { PandaGlRenderer(String romPath) { super(); this.romPath = romPath; + + screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels; + screenHeight = Resources.getSystem().getDisplayMetrics().heightPixels; + setLayout(new DefaultScreenLayout()); } @Override @@ -40,8 +46,6 @@ protected void finalize() throws Throwable { public void onSurfaceCreated(GL10 unused, EGLConfig config) { Log.i("pandroid", glGetString(GL_EXTENSIONS)); Log.w("pandroid", glGetString(GL_VERSION)); - screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels; - screenHeight = Resources.getSystem().getDisplayMetrics().heightPixels; glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -71,40 +75,48 @@ public void onDrawFrame(GL10 unused) { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo); - if (screenWidth > screenHeight) { - int topDisplayWidth = (int)((screenHeight / (float)Constants.N3DS_HEIGHT) * Constants.N3DS_WIDTH); - int topDisplayHeight = screenHeight; - - if (topDisplayWidth > screenWidth * 0.7){ - topDisplayWidth = (int)(screenWidth * 0.7); - topDisplayHeight = (int)((topDisplayWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT); - } - - int bottomDisplayHeight = (int)(((screenWidth - topDisplayWidth) / 320) * Constants.N3DS_HEIGHT); - int topDisplayY = screenHeight - topDisplayHeight; - int bottomDisplayY = screenHeight - bottomDisplayHeight; - - glBlitFramebuffer(0, Constants.N3DS_HEIGHT, - Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2, - 0, topDisplayY, - topDisplayWidth,topDisplayY+topDisplayHeight, - GL_COLOR_BUFFER_BIT, GL_LINEAR); - - glBlitFramebuffer( - 40, 0, - 360, Constants.N3DS_HEIGHT, - topDisplayWidth, bottomDisplayY, - screenWidth,bottomDisplayY+bottomDisplayHeight, - GL_COLOR_BUFFER_BIT, GL_LINEAR); - } else { - int h = (int)((screenWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT * 2); - glBlitFramebuffer(0, 0, Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } + Rect topScreen = displayLayout.getTopDisplayBounds(); + Rect bottomScreen = displayLayout.getBottomDisplayBounds(); + + glBlitFramebuffer( + 0, 480, + 400, 240, + topScreen.left, screenHeight - topScreen.top, + topScreen.right, screenHeight - topScreen.bottom, + GL_COLOR_BUFFER_BIT, GL_LINEAR); + + glBlitFramebuffer( + 40, 240, + 360, 0, + bottomScreen.left, screenHeight - bottomScreen.top, + bottomScreen.right, screenHeight - bottomScreen.bottom, + GL_COLOR_BUFFER_BIT, GL_LINEAR); } } public void onSurfaceChanged(GL10 unused, int width, int height) { screenWidth = width; screenHeight = height; + glDisable(GL_SCISSOR_TEST); + + displayLayout.update(screenWidth, screenHeight); + } + + @Override + public void setLayout(ConsoleLayout layout) { + displayLayout = layout; + displayLayout.setTopDisplaySourceSize(400, 240); + displayLayout.setBottomDisplaySourceSize(320, 240); + displayLayout.update(screenWidth, screenHeight); + } + + @Override + public ConsoleLayout getLayout() { + return displayLayout; + } + + @Override + public String getBackendName() { + return "OpenGL"; } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java index 3b5694edc..9f2803930 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java @@ -1,10 +1,22 @@ package com.panda3ds.pandroid.view; import android.content.Context; +import android.graphics.Canvas; import android.opengl.GLSurfaceView; +import android.util.Log; -public class PandaGlSurfaceView extends GLSurfaceView { +import androidx.annotation.NonNull; + +import com.panda3ds.pandroid.math.Vector2; +import com.panda3ds.pandroid.utils.Constants; +import com.panda3ds.pandroid.view.controller.TouchEvent; +import com.panda3ds.pandroid.view.controller.nodes.TouchScreenNodeImpl; +import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; + +public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl { final PandaGlRenderer renderer; + private int size_width; + private int size_height; public PandaGlSurfaceView(Context context, String romPath) { super(context); @@ -13,4 +25,26 @@ public PandaGlSurfaceView(Context context, String romPath) { renderer = new PandaGlRenderer(romPath); setRenderer(renderer); } + + public ConsoleRenderer getRenderer() { + return renderer; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + size_width = getMeasuredWidth(); + size_height = getMeasuredHeight(); + } + + @NonNull + @Override + public Vector2 getSize() { + return new Vector2(size_width, size_height); + } + + @Override + public void onTouch(TouchEvent event) { + onTouchScreenPress(renderer, event); + } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java index 63f328da0..e7d9438ff 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java @@ -58,5 +58,7 @@ public void initialize(){ .setJoystickListener((joystick, axisX, axisY) -> { AlberDriver.SetCirclepadAxis((int)(axisX*0x9C), (int)(axisY*0x9C)*-1); }); + + refreshChildren(); } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java index 97c8eb120..1ef93c895 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java @@ -2,14 +2,18 @@ import android.content.Context; import android.util.AttributeSet; +import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.panda3ds.pandroid.math.Vector2; +import com.panda3ds.pandroid.utils.Constants; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; public class ControllerLayout extends RelativeLayout { @@ -34,8 +38,14 @@ public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr, i } public void refreshChildren(){ + ArrayList nodes = new ArrayList<>(); + populateNodesArray(this, nodes); + + //Need Reverse: First view is in back and last view is in front for respect android View hierarchy + Collections.reverse(nodes); + controllerNodes.clear(); - populateNodesArray(this, controllerNodes); + controllerNodes.addAll(nodes); } private void populateNodesArray(ViewGroup group, ArrayList list){ @@ -89,7 +99,7 @@ private void processTouch(boolean up, float x, float y, int index){ float cx = (pos.x - globalPosition[0]); float cy = (pos.y - globalPosition[1]); - if( x > cx && x < cx+size.x && y > cy && y < cy+size.y){ + if(item.isVisible() && x > cx && x < cx+size.x && y > cy && y < cy+size.y){ node = item; break; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java index 8b01fa97b..a29d08a4f 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java @@ -18,6 +18,10 @@ default Vector2 getPosition(){ return new Vector2(position[0], position[1]); } + default boolean isVisible(){ + return ((View)this).isShown(); + } + @NonNull Vector2 getSize(); void onTouch(TouchEvent event); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java new file mode 100644 index 000000000..85d1ddd69 --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java @@ -0,0 +1,39 @@ +package com.panda3ds.pandroid.view.controller.nodes; + +import android.graphics.Rect; +import android.util.Log; +import android.view.View; + +import com.panda3ds.pandroid.AlberDriver; +import com.panda3ds.pandroid.R; +import com.panda3ds.pandroid.utils.Constants; +import com.panda3ds.pandroid.view.controller.ControllerNode; +import com.panda3ds.pandroid.view.controller.TouchEvent; +import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; + +public interface TouchScreenNodeImpl extends ControllerNode { + default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event){ + + View me = (View) this; + boolean hasDownEvent = me.getTag(R.id.TagEventHasDown) != null && (boolean) me.getTag(R.id.TagEventHasDown); + + Rect bounds = renderer.getLayout().getBottomDisplayBounds();; + + if (event.getX() >= bounds.left && event.getY() >= bounds.top && event.getX() <= bounds.right && event.getY() <= bounds.bottom){ + int x = (int) (event.getX() - bounds.left); + int y = (int) (event.getY() - bounds.top); + + x = Math.round((x/(float)bounds.width())*320); + y = Math.round((y/(float)bounds.height())*240); + + AlberDriver.TouchScreenDown(x,y); + + me.setTag(R.id.TagEventHasDown, true); + } + + if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP){ + AlberDriver.TouchScreenUp(); + me.setTag(R.id.TagEventHasDown, false); + } + } +} diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java new file mode 100644 index 000000000..13ad4d39f --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java @@ -0,0 +1,9 @@ +package com.panda3ds.pandroid.view.renderer; + +import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout; + +public interface ConsoleRenderer { + void setLayout(ConsoleLayout layout); + ConsoleLayout getLayout(); + String getBackendName(); +} diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java new file mode 100644 index 000000000..781f0abd4 --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java @@ -0,0 +1,15 @@ +package com.panda3ds.pandroid.view.renderer.layout; + +import android.graphics.Rect; + +import com.panda3ds.pandroid.math.Vector2; + +public interface ConsoleLayout { + void update(int screenWidth, int screenHeight); + + void setBottomDisplaySourceSize(int width, int height); + void setTopDisplaySourceSize(int width, int height); + + Rect getBottomDisplayBounds(); + Rect getTopDisplayBounds(); +} diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java new file mode 100644 index 000000000..a54db8f7a --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java @@ -0,0 +1,81 @@ +package com.panda3ds.pandroid.view.renderer.layout; + +import android.graphics.Rect; +import android.util.Size; + +import com.panda3ds.pandroid.math.Vector2; + +public class DefaultScreenLayout implements ConsoleLayout { + private final Rect topDisplay = new Rect(); + private final Rect bottomDisplay = new Rect(); + + private final Vector2 screenSize = new Vector2(1.0F, 1.0F); + private final Vector2 topSourceSize = new Vector2(1.0F, 1.0F); + private final Vector2 bottomSourceSize = new Vector2(1.0F, 1.0F); + + @Override + public void update(int screenWidth, int screenHeight) { + screenSize.set(screenWidth, screenHeight); + updateBounds(); + } + + @Override + public void setBottomDisplaySourceSize(int width, int height) { + bottomSourceSize.set(width,height); + updateBounds(); + } + @Override + public void setTopDisplaySourceSize(int width, int height) { + topSourceSize.set(width,height); + updateBounds(); + } + + private void updateBounds(){ + int screenWidth = (int) screenSize.x; + int screenHeight = (int) screenSize.y; + + if (screenWidth > screenHeight){ + + int topDisplayWidth = (int) ((screenHeight / topSourceSize.y) * topSourceSize.x); + int topDisplayHeight = screenHeight; + + if (topDisplayWidth > (screenWidth*0.7)){ + topDisplayWidth = (int) (screenWidth * 0.7); + topDisplayHeight = (int) ((topDisplayWidth/topSourceSize.x)* topSourceSize.y); + } + + int bottomDisplayHeight = (int) (((screenWidth-topDisplayWidth)/ bottomSourceSize.x)* bottomSourceSize.y); + + + topDisplay.set(0, 0, topDisplayWidth, topDisplayHeight); + bottomDisplay.set(topDisplayWidth, 0, topDisplayWidth+(screenWidth-topDisplayWidth), bottomDisplayHeight); + } else { + int topScreenHeight = (int) ((screenWidth/ topSourceSize.x) * topSourceSize.y); + topDisplay.set(0,0,screenWidth,topScreenHeight); + + int bottomDisplayHeight = (int)((screenWidth/ bottomSourceSize.x) * bottomSourceSize.y); + int bottomDisplayWidth = screenWidth; + int bottomDisplayX = 0; + + if (topScreenHeight + bottomDisplayHeight > screenHeight){ + bottomDisplayHeight = (screenHeight-topScreenHeight); + bottomDisplayWidth = (int) ((bottomDisplayHeight/ bottomSourceSize.y)*bottomSourceSize.x); + bottomDisplayX = (screenWidth-bottomDisplayX)/2; + } + + topDisplay.set(0,0, screenWidth,topScreenHeight); + bottomDisplay.set(bottomDisplayX, topScreenHeight, bottomDisplayX+bottomDisplayWidth,topScreenHeight+bottomDisplayHeight); + } + } + + + @Override + public Rect getBottomDisplayBounds() { + return bottomDisplay; + } + + @Override + public Rect getTopDisplayBounds() { + return topDisplay; + } +} diff --git a/src/pandroid/app/src/main/res/layout/game_activity.xml b/src/pandroid/app/src/main/res/layout/game_activity.xml index 64f067b23..6f6f65d7e 100644 --- a/src/pandroid/app/src/main/res/layout/game_activity.xml +++ b/src/pandroid/app/src/main/res/layout/game_activity.xml @@ -4,105 +4,110 @@ android:layout_height="match_parent" android:background="#000"> - + - + android:layout_height="match_parent"> - - - - - - - - + android:layout_height="match_parent" + android:gravity="bottom" + android:padding="20dp"> - + - - - + android:layout_height="25dp" + android:layout_gravity="left" + style="@style/ControllerSimpleButton" + android:background="@drawable/simple_card_button_left" + android:text="L"/> - + - + - + - + - + - + android:gravity="end|bottom" + android:orientation="vertical" + android:layout_gravity="center"> - + - + - + + + + + + + + + + + + diff --git a/src/pandroid/app/src/main/res/values/values.xml b/src/pandroid/app/src/main/res/values/values.xml new file mode 100644 index 000000000..9a4071c7e --- /dev/null +++ b/src/pandroid/app/src/main/res/values/values.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From a40e74a15d08798ae045bae2b64324949b8e1ac3 Mon Sep 17 00:00:00 2001 From: offtkp Date: Tue, 28 Nov 2023 21:11:58 +0200 Subject: [PATCH 09/15] Remove magic numbers --- .../com/panda3ds/pandroid/utils/Constants.java | 3 ++- .../panda3ds/pandroid/view/PandaGlRenderer.java | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index 2e7065309..14d5c398e 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -19,7 +19,8 @@ public class Constants { public static final int INPUT_KEY_SELECT = 1 << 2; public static final int N3DS_WIDTH = 400; - public static final int N3DS_HEIGHT = 240; + public static final int N3DS_HALF_HEIGHT = 240; + public static final int N3DS_FULL_HEIGHT = 480; public static final String EXTRA_PATH = "path"; public static final String LOG_TAG = "Alber"; diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index e6adbd9f4..0e1826d1c 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -79,15 +79,16 @@ public void onDrawFrame(GL10 unused) { Rect bottomScreen = displayLayout.getBottomDisplayBounds(); glBlitFramebuffer( - 0, 480, - 400, 240, + 0, Constants.N3DS_FULL_HEIGHT, + Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT, topScreen.left, screenHeight - topScreen.top, topScreen.right, screenHeight - topScreen.bottom, GL_COLOR_BUFFER_BIT, GL_LINEAR); + // Remove the black bars on the bottom screen glBlitFramebuffer( - 40, 240, - 360, 0, + 40, Constants.N3DS_HALF_HEIGHT, + Constants.N3DS_WIDTH - 40, 0, bottomScreen.left, screenHeight - bottomScreen.top, bottomScreen.right, screenHeight - bottomScreen.bottom, GL_COLOR_BUFFER_BIT, GL_LINEAR); @@ -97,7 +98,6 @@ public void onDrawFrame(GL10 unused) { public void onSurfaceChanged(GL10 unused, int width, int height) { screenWidth = width; screenHeight = height; - glDisable(GL_SCISSOR_TEST); displayLayout.update(screenWidth, screenHeight); } @@ -105,8 +105,8 @@ public void onSurfaceChanged(GL10 unused, int width, int height) { @Override public void setLayout(ConsoleLayout layout) { displayLayout = layout; - displayLayout.setTopDisplaySourceSize(400, 240); - displayLayout.setBottomDisplaySourceSize(320, 240); + displayLayout.setTopDisplaySourceSize(Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT); + displayLayout.setBottomDisplaySourceSize(Constants.N3DS_WIDTH - 40 - 40, Constants.N3DS_HALF_HEIGHT); displayLayout.update(screenWidth, screenHeight); } From ed0864d24f2f4675275f72beb30a768a1d58c3fb Mon Sep 17 00:00:00 2001 From: offtkp Date: Tue, 28 Nov 2023 21:41:57 +0200 Subject: [PATCH 10/15] Run clang-format on .java files --- src/pandroid/app/.gitignore | 1 - src/pandroid/app/build.gradle.kts | 4 - .../com/panda3ds/pandroid/AlberDriver.java | 29 +- .../panda3ds/pandroid/app/BaseActivity.java | 3 +- .../panda3ds/pandroid/app/GameActivity.java | 62 ++-- .../panda3ds/pandroid/app/MainActivity.java | 90 +++--- .../com/panda3ds/pandroid/math/Vector2.java | 30 +- .../panda3ds/pandroid/utils/Constants.java | 35 ++- .../panda3ds/pandroid/utils/PathUtils.java | 156 +++++----- .../pandroid/view/PandaGlRenderer.java | 210 +++++++------- .../pandroid/view/PandaGlSurfaceView.java | 66 ++--- .../pandroid/view/PandaLayoutController.java | 68 ++--- .../view/controller/ControllerLayout.java | 266 +++++++++--------- .../view/controller/ControllerNode.java | 26 +- .../pandroid/view/controller/TouchEvent.java | 32 +-- .../listeners/ButtonStateListener.java | 2 +- .../listeners/JoystickListener.java | 2 +- .../controller/nodes/BasicControllerNode.java | 14 +- .../view/controller/nodes/Button.java | 86 +++--- .../view/controller/nodes/Joystick.java | 155 +++++----- .../controller/nodes/TouchScreenNodeImpl.java | 37 ++- .../view/renderer/ConsoleRenderer.java | 6 +- .../view/renderer/layout/ConsoleLayout.java | 11 +- .../renderer/layout/DefaultScreenLayout.java | 142 +++++----- 24 files changed, 698 insertions(+), 835 deletions(-) delete mode 100644 src/pandroid/app/.gitignore diff --git a/src/pandroid/app/.gitignore b/src/pandroid/app/.gitignore deleted file mode 100644 index 42afabfd2..000000000 --- a/src/pandroid/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/src/pandroid/app/build.gradle.kts b/src/pandroid/app/build.gradle.kts index ff8debcbd..276eb552e 100644 --- a/src/pandroid/app/build.gradle.kts +++ b/src/pandroid/app/build.gradle.kts @@ -36,11 +36,7 @@ android { } dependencies { - implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.8.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.5") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java index 92d276a2d..81bf29a52 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java @@ -1,24 +1,19 @@ package com.panda3ds.pandroid; public class AlberDriver { + AlberDriver() { super(); } - AlberDriver() { - super(); - } + public static native void Initialize(); + public static native void RunFrame(int fbo); + public static native boolean HasRomLoaded(); + public static native void LoadRom(String path); + public static native void Finalize(); - public static native void Initialize(); - public static native void RunFrame(int fbo); - public static native boolean HasRomLoaded(); - public static native void LoadRom(String path); - public static native void Finalize(); + public static native void KeyDown(int code); + public static native void KeyUp(int code); + public static native void SetCirclepadAxis(int x, int y); + public static native void TouchScreenUp(); + public static native void TouchScreenDown(int x, int y); - public static native void KeyDown(int code); - public static native void KeyUp(int code); - public static native void SetCirclepadAxis(int x, int y); - public static native void TouchScreenUp(); - public static native void TouchScreenDown(int x, int y); - - static { - System.loadLibrary("Alber"); - } + static { System.loadLibrary("Alber"); } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/BaseActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/BaseActivity.java index 597d664bd..72926b076 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/BaseActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/BaseActivity.java @@ -2,5 +2,4 @@ import androidx.appcompat.app.AppCompatActivity; -public class BaseActivity extends AppCompatActivity { -} +public class BaseActivity extends AppCompatActivity {} diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index 53fb1805b..e196d0d10 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -9,54 +9,48 @@ import android.widget.CheckBox; import android.widget.FrameLayout; import android.widget.Toast; - import androidx.annotation.Nullable; - import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.PandaGlSurfaceView; import com.panda3ds.pandroid.view.PandaLayoutController; public class GameActivity extends BaseActivity { - private PandaGlSurfaceView pandaSurface; - private PandaLayoutController controllerLayout; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Intent intent = getIntent(); - if(!intent.hasExtra(Constants.EXTRA_PATH)){ + private PandaGlSurfaceView pandaSurface; + private PandaLayoutController controllerLayout; - setContentView(new FrameLayout(this)); - Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show(); - finish(); - return; - } + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); - pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH)); + Intent intent = getIntent(); + if (!intent.hasExtra(Constants.EXTRA_PATH)) { + setContentView(new FrameLayout(this)); + Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show(); + finish(); + return; + } - setContentView(R.layout.game_activity); + pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH)); - ((FrameLayout)findViewById(R.id.panda_gl_frame)) - .addView(pandaSurface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + setContentView(R.layout.game_activity); - controllerLayout = findViewById(R.id.controller_layout); + ((FrameLayout) findViewById(R.id.panda_gl_frame)) + .addView(pandaSurface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - controllerLayout.initialize(); + controllerLayout = findViewById(R.id.controller_layout); - ((CheckBox)findViewById(R.id.hide_screen_controller)) - .setOnCheckedChangeListener((buttonView, isChecked) -> { - findViewById(R.id.overlay_controller) - .setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE); - }); + controllerLayout.initialize(); - } + ((CheckBox) findViewById(R.id.hide_screen_controller)).setOnCheckedChangeListener((buttonView, isChecked) -> { + findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE); + }); + } - @Override - protected void onResume() { - super.onResume(); - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - } + @Override + protected void onResume() { + super.onResume(); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java index ef0ac63f7..181cfb4ea 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java @@ -1,5 +1,7 @@ package com.panda3ds.pandroid.app; +import static android.Manifest.permission.READ_EXTERNAL_STORAGE; +import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; import static android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION; import android.content.Intent; @@ -7,58 +9,50 @@ import android.os.Bundle; import android.os.Environment; import android.widget.Toast; - import androidx.appcompat.app.AppCompatActivity; - -import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; -import static android.Manifest.permission.READ_EXTERNAL_STORAGE; import androidx.core.app.ActivityCompat; - -import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.R; +import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.utils.PathUtils; public class MainActivity extends BaseActivity { - private static final int PICK_3DS_ROM = 2; - private static final int PERMISSION_REQUEST_CODE = 3; - - private void openFile() { - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); - intent.addCategory(Intent.CATEGORY_OPENABLE); - intent.setType("*/*"); - startActivityForResult(intent, PICK_3DS_ROM); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - if (!Environment.isExternalStorageManager()) { - Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); - startActivity(intent); - } - } else { - ActivityCompat.requestPermissions(this, new String[]{READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); - ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); - } - - setContentView(R.layout.activity_main); - - findViewById(R.id.load_rom).setOnClickListener(v->{ - openFile(); - }); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == PICK_3DS_ROM) { - if (resultCode == RESULT_OK) { - String path = PathUtils.getPath(getApplicationContext(), data.getData()); - Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show(); - startActivity(new Intent(this, GameActivity.class) - .putExtra(Constants.EXTRA_PATH, path)); - } - super.onActivityResult(requestCode, resultCode, data); - } - } + private static final int PICK_3DS_ROM = 2; + private static final int PERMISSION_REQUEST_CODE = 3; + + private void openFile() { + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("*/*"); + startActivityForResult(intent, PICK_3DS_ROM); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if (!Environment.isExternalStorageManager()) { + Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); + startActivity(intent); + } + } else { + ActivityCompat.requestPermissions(this, new String[] {READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); + ActivityCompat.requestPermissions(this, new String[] {WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); + } + + setContentView(R.layout.activity_main); + + findViewById(R.id.load_rom).setOnClickListener(v -> { openFile(); }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == PICK_3DS_ROM) { + if (resultCode == RESULT_OK) { + String path = PathUtils.getPath(getApplicationContext(), data.getData()); + Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show(); + startActivity(new Intent(this, GameActivity.class).putExtra(Constants.EXTRA_PATH, path)); + } + super.onActivityResult(requestCode, resultCode, data); + } + } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java index 541d45e19..4208b6102 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java @@ -1,26 +1,20 @@ package com.panda3ds.pandroid.math; public class Vector2 { - public float x,y; - public Vector2(Vector2 value){ - this(value.x,value.y); - } + public float x, y; + public Vector2(Vector2 value) { this(value.x, value.y); } - public Vector2(float x, float y){ - this.x = x; - this.y = y; - } + public Vector2(float x, float y) { + this.x = x; + this.y = y; + } - public float distanceTo(Vector2 vec){ - return distance(x,y,vec.x, vec.y); - } + public float distanceTo(Vector2 vec) { return distance(x, y, vec.x, vec.y); } - public static float distance(float x, float y, float x2, float y2){ - return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); - } + public static float distance(float x, float y, float x2, float y2) { return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); } - public void set(float x, float y) { - this.x = x; - this.y = y; - } + public void set(float x, float y) { + this.x = x; + this.y = y; + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index 14d5c398e..bc3899877 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -1,27 +1,26 @@ package com.panda3ds.pandroid.utils; public class Constants { + public static final int INPUT_KEY_UP = 1 << 6; + public static final int INPUT_KEY_DOWN = 1 << 7; + public static final int INPUT_KEY_LEFT = 1 << 5; + public static final int INPUT_KEY_RIGHT = 1 << 4; - public static final int INPUT_KEY_UP = 1 << 6; - public static final int INPUT_KEY_DOWN = 1 << 7; - public static final int INPUT_KEY_LEFT = 1 << 5; - public static final int INPUT_KEY_RIGHT = 1 << 4; + public static final int INPUT_KEY_A = 1 << 0; + public static final int INPUT_KEY_B = 1 << 1; + public static final int INPUT_KEY_X = 1 << 10; + public static final int INPUT_KEY_Y = 1 << 11; - public static final int INPUT_KEY_A = 1 << 0; - public static final int INPUT_KEY_B = 1 << 1; - public static final int INPUT_KEY_X = 1 << 10; - public static final int INPUT_KEY_Y = 1 << 11; + public static final int INPUT_KEY_R = 1 << 8; + public static final int INPUT_KEY_L = 1 << 9; - public static final int INPUT_KEY_R = 1 << 8; - public static final int INPUT_KEY_L = 1 << 9; + public static final int INPUT_KEY_START = 1 << 3; + public static final int INPUT_KEY_SELECT = 1 << 2; - public static final int INPUT_KEY_START = 1 << 3; - public static final int INPUT_KEY_SELECT = 1 << 2; + public static final int N3DS_WIDTH = 400; + public static final int N3DS_HALF_HEIGHT = 240; + public static final int N3DS_FULL_HEIGHT = 480; - public static final int N3DS_WIDTH = 400; - public static final int N3DS_HALF_HEIGHT = 240; - public static final int N3DS_FULL_HEIGHT = 480; - - public static final String EXTRA_PATH = "path"; - public static final String LOG_TAG = "Alber"; + public static final String EXTRA_PATH = "path"; + public static final String LOG_TAG = "Alber"; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java index 0a24603cc..ccf655bf2 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java @@ -10,116 +10,92 @@ import android.provider.MediaStore; public class PathUtils { + public static String getPath(final Context context, final Uri uri) { + // DocumentProvider + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) { + if (isExternalStorageDocument(uri)) { // ExternalStorageProvider + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + String storageDefinition; - public static String getPath(final Context context, final Uri uri) { + if ("primary".equalsIgnoreCase(type)) { + return Environment.getExternalStorageDirectory() + "/" + split[1]; - // DocumentProvider - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) { + } else { + if (Environment.isExternalStorageRemovable()) { + storageDefinition = "EXTERNAL_STORAGE"; - if (isExternalStorageDocument(uri)) {// ExternalStorageProvider - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - String storageDefinition; + } else { + storageDefinition = "SECONDARY_STORAGE"; + } + return System.getenv(storageDefinition) + "/" + split[1]; + } - if("primary".equalsIgnoreCase(type)){ + } else if (isDownloadsDocument(uri)) { // DownloadsProvider - return Environment.getExternalStorageDirectory() + "/" + split[1]; + final String id = DocumentsContract.getDocumentId(uri); + final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); - } else { + return getDataColumn(context, contentUri, null, null); - if(Environment.isExternalStorageRemovable()){ - storageDefinition = "EXTERNAL_STORAGE"; + } else if (isMediaDocument(uri)) { // MediaProvider + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; - } else{ - storageDefinition = "SECONDARY_STORAGE"; - } + Uri contentUri = null; + if ("image".equals(type)) { + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; + } else if ("video".equals(type)) { + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; + } else if ("audio".equals(type)) { + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; + } - return System.getenv(storageDefinition) + "/" + split[1]; - } - - } else if (isDownloadsDocument(uri)) {// DownloadsProvider + final String selection = "_id=?"; + final String[] selectionArgs = new String[] {split[1]}; - final String id = DocumentsContract.getDocumentId(uri); - final Uri contentUri = ContentUris.withAppendedId( - Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); + return getDataColumn(context, contentUri, selection, selectionArgs); + } - return getDataColumn(context, contentUri, null, null); + } else if ("content".equalsIgnoreCase(uri.getScheme())) { // MediaStore (and general) - } else if (isMediaDocument(uri)) {// MediaProvider - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; + // Return the remote address + if (isGooglePhotosUri(uri)) return uri.getLastPathSegment(); - Uri contentUri = null; - if ("image".equals(type)) { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; - } else if ("video".equals(type)) { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; - } else if ("audio".equals(type)) { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; - } + return getDataColumn(context, uri, null, null); - final String selection = "_id=?"; - final String[] selectionArgs = new String[]{ - split[1] - }; + } else if ("file".equalsIgnoreCase(uri.getScheme())) { // File + return uri.getPath(); + } - return getDataColumn(context, contentUri, selection, selectionArgs); - } + return null; + } - } else if ("content".equalsIgnoreCase(uri.getScheme())) {// MediaStore (and general) + public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { + Cursor cursor = null; + final String column = "_data"; + final String[] projection = {column}; - // Return the remote address - if (isGooglePhotosUri(uri)) - return uri.getLastPathSegment(); + try { + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); + if (cursor != null && cursor.moveToFirst()) { + final int column_index = cursor.getColumnIndexOrThrow(column); + return cursor.getString(column_index); + } + } finally { + if (cursor != null) cursor.close(); + } + return null; + } - return getDataColumn(context, uri, null, null); + public static boolean isExternalStorageDocument(Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); } - } else if ("file".equalsIgnoreCase(uri.getScheme())) {// File - return uri.getPath(); - } + public static boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); } - return null; - } + public static boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); } - public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { - - Cursor cursor = null; - final String column = "_data"; - final String[] projection = { - column - }; - - try { - cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); - if (cursor != null && cursor.moveToFirst()) { - final int column_index = cursor.getColumnIndexOrThrow(column); - return cursor.getString(column_index); - } - } finally { - if (cursor != null) - cursor.close(); - } - return null; - } - - - public static boolean isExternalStorageDocument(Uri uri) { - return "com.android.externalstorage.documents".equals(uri.getAuthority()); - } - - - public static boolean isDownloadsDocument(Uri uri) { - return "com.android.providers.downloads.documents".equals(uri.getAuthority()); - } - - public static boolean isMediaDocument(Uri uri) { - return "com.android.providers.media.documents".equals(uri.getAuthority()); - } - - public static boolean isGooglePhotosUri(Uri uri) { - return "com.google.android.apps.photos.content".equals(uri.getAuthority()); - } + public static boolean isGooglePhotosUri(Uri uri) { return "com.google.android.apps.photos.content".equals(uri.getAuthority()); } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index 0e1826d1c..b21e33537 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -1,122 +1,116 @@ package com.panda3ds.pandroid.view; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - import static android.opengl.GLES32.*; import android.content.res.Resources; import android.graphics.Rect; import android.opengl.GLSurfaceView; import android.util.Log; - import com.panda3ds.pandroid.AlberDriver; -import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout; +import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; +import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout; import com.panda3ds.pandroid.view.renderer.layout.DefaultScreenLayout; +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer { - - private final String romPath; - private ConsoleLayout displayLayout; - private int screenWidth, screenHeight; - private int screenTexture; - public int screenFbo; - - PandaGlRenderer(String romPath) { - super(); - this.romPath = romPath; - - screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels; - screenHeight = Resources.getSystem().getDisplayMetrics().heightPixels; - setLayout(new DefaultScreenLayout()); - } - - @Override - protected void finalize() throws Throwable { - if (screenTexture != 0) { - glDeleteTextures(1, new int[]{screenTexture}, 0); - } - if (screenFbo != 0) { - glDeleteFramebuffers(1, new int[]{screenFbo}, 0); - } - super.finalize(); - } - - public void onSurfaceCreated(GL10 unused, EGLConfig config) { - Log.i("pandroid", glGetString(GL_EXTENSIONS)); - Log.w("pandroid", glGetString(GL_VERSION)); - - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - int[] generateBuffer = new int[1]; - glGenTextures(1, generateBuffer, 0); - screenTexture = generateBuffer[0]; - glBindTexture(GL_TEXTURE_2D, screenTexture); - glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, screenWidth, screenHeight); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glBindTexture(GL_TEXTURE_2D, 0); - - glGenFramebuffers(1, generateBuffer, 0); - screenFbo = generateBuffer[0]; - glBindFramebuffer(GL_FRAMEBUFFER, screenFbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, screenTexture, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - AlberDriver.Initialize(); - AlberDriver.LoadRom(romPath); - } - - public void onDrawFrame(GL10 unused) { - if (AlberDriver.HasRomLoaded()) { - AlberDriver.RunFrame(screenFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo); - - Rect topScreen = displayLayout.getTopDisplayBounds(); - Rect bottomScreen = displayLayout.getBottomDisplayBounds(); - - glBlitFramebuffer( - 0, Constants.N3DS_FULL_HEIGHT, - Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT, - topScreen.left, screenHeight - topScreen.top, - topScreen.right, screenHeight - topScreen.bottom, - GL_COLOR_BUFFER_BIT, GL_LINEAR); - - // Remove the black bars on the bottom screen - glBlitFramebuffer( - 40, Constants.N3DS_HALF_HEIGHT, - Constants.N3DS_WIDTH - 40, 0, - bottomScreen.left, screenHeight - bottomScreen.top, - bottomScreen.right, screenHeight - bottomScreen.bottom, - GL_COLOR_BUFFER_BIT, GL_LINEAR); - } - } - - public void onSurfaceChanged(GL10 unused, int width, int height) { - screenWidth = width; - screenHeight = height; - - displayLayout.update(screenWidth, screenHeight); - } - - @Override - public void setLayout(ConsoleLayout layout) { - displayLayout = layout; - displayLayout.setTopDisplaySourceSize(Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT); - displayLayout.setBottomDisplaySourceSize(Constants.N3DS_WIDTH - 40 - 40, Constants.N3DS_HALF_HEIGHT); - displayLayout.update(screenWidth, screenHeight); - } - - @Override - public ConsoleLayout getLayout() { - return displayLayout; - } - - @Override - public String getBackendName() { - return "OpenGL"; - } + private final String romPath; + private ConsoleLayout displayLayout; + private int screenWidth, screenHeight; + private int screenTexture; + public int screenFbo; + + PandaGlRenderer(String romPath) { + super(); + this.romPath = romPath; + + screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels; + screenHeight = Resources.getSystem().getDisplayMetrics().heightPixels; + setLayout(new DefaultScreenLayout()); + } + + @Override + protected void finalize() throws Throwable { + if (screenTexture != 0) { + glDeleteTextures(1, new int[] {screenTexture}, 0); + } + if (screenFbo != 0) { + glDeleteFramebuffers(1, new int[] {screenFbo}, 0); + } + super.finalize(); + } + + public void onSurfaceCreated(GL10 unused, EGLConfig config) { + Log.i("pandroid", glGetString(GL_EXTENSIONS)); + Log.w("pandroid", glGetString(GL_VERSION)); + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + int[] generateBuffer = new int[1]; + glGenTextures(1, generateBuffer, 0); + screenTexture = generateBuffer[0]; + glBindTexture(GL_TEXTURE_2D, screenTexture); + glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, screenWidth, screenHeight); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glBindTexture(GL_TEXTURE_2D, 0); + + glGenFramebuffers(1, generateBuffer, 0); + screenFbo = generateBuffer[0]; + glBindFramebuffer(GL_FRAMEBUFFER, screenFbo); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, screenTexture, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + AlberDriver.Initialize(); + AlberDriver.LoadRom(romPath); + } + + public void onDrawFrame(GL10 unused) { + if (AlberDriver.HasRomLoaded()) { + AlberDriver.RunFrame(screenFbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo); + + Rect topScreen = displayLayout.getTopDisplayBounds(); + Rect bottomScreen = displayLayout.getBottomDisplayBounds(); + + glBlitFramebuffer( + 0, Constants.N3DS_FULL_HEIGHT, Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT, topScreen.left, screenHeight - topScreen.top, + topScreen.right, screenHeight - topScreen.bottom, GL_COLOR_BUFFER_BIT, GL_LINEAR + ); + + // Remove the black bars on the bottom screen + glBlitFramebuffer( + 40, Constants.N3DS_HALF_HEIGHT, Constants.N3DS_WIDTH - 40, 0, bottomScreen.left, screenHeight - bottomScreen.top, bottomScreen.right, + screenHeight - bottomScreen.bottom, GL_COLOR_BUFFER_BIT, GL_LINEAR + ); + } + } + + public void onSurfaceChanged(GL10 unused, int width, int height) { + screenWidth = width; + screenHeight = height; + + displayLayout.update(screenWidth, screenHeight); + } + + @Override + public void setLayout(ConsoleLayout layout) { + displayLayout = layout; + displayLayout.setTopDisplaySourceSize(Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT); + displayLayout.setBottomDisplaySourceSize(Constants.N3DS_WIDTH - 40 - 40, Constants.N3DS_HALF_HEIGHT); + displayLayout.update(screenWidth, screenHeight); + } + + @Override + public ConsoleLayout getLayout() { + return displayLayout; + } + + @Override + public String getBackendName() { + return "OpenGL"; + } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java index 9f2803930..f5a19efeb 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java @@ -4,9 +4,7 @@ import android.graphics.Canvas; import android.opengl.GLSurfaceView; import android.util.Log; - import androidx.annotation.NonNull; - import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.controller.TouchEvent; @@ -14,37 +12,35 @@ import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl { - final PandaGlRenderer renderer; - private int size_width; - private int size_height; - - public PandaGlSurfaceView(Context context, String romPath) { - super(context); - setEGLContextClientVersion(3); - setDebugFlags(DEBUG_LOG_GL_CALLS); - renderer = new PandaGlRenderer(romPath); - setRenderer(renderer); - } - - public ConsoleRenderer getRenderer() { - return renderer; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - size_width = getMeasuredWidth(); - size_height = getMeasuredHeight(); - } - - @NonNull - @Override - public Vector2 getSize() { - return new Vector2(size_width, size_height); - } - - @Override - public void onTouch(TouchEvent event) { - onTouchScreenPress(renderer, event); - } + final PandaGlRenderer renderer; + private int size_width; + private int size_height; + + public PandaGlSurfaceView(Context context, String romPath) { + super(context); + setEGLContextClientVersion(3); + setDebugFlags(DEBUG_LOG_GL_CALLS); + renderer = new PandaGlRenderer(romPath); + setRenderer(renderer); + } + + public ConsoleRenderer getRenderer() { return renderer; } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + size_width = getMeasuredWidth(); + size_height = getMeasuredHeight(); + } + + @NonNull + @Override + public Vector2 getSize() { + return new Vector2(size_width, size_height); + } + + @Override + public void onTouch(TouchEvent event) { + onTouchScreenPress(renderer, event); + } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java index e7d9438ff..543ab840d 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java @@ -2,7 +2,6 @@ import android.content.Context; import android.util.AttributeSet; - import com.panda3ds.pandroid.AlberDriver; import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.utils.Constants; @@ -11,54 +10,41 @@ import com.panda3ds.pandroid.view.controller.nodes.Joystick; public class PandaLayoutController extends ControllerLayout { - public PandaLayoutController(Context context) { - super(context); - } + public PandaLayoutController(Context context) { super(context); } - public PandaLayoutController(Context context, AttributeSet attrs) { - super(context, attrs); - } + public PandaLayoutController(Context context, AttributeSet attrs) { super(context, attrs); } - public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } + public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } - public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } + public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } - public void initialize(){ - int[] keyButtonList = { - R.id.button_a, Constants.INPUT_KEY_A, - R.id.button_b, Constants.INPUT_KEY_B, - R.id.button_y, Constants.INPUT_KEY_Y, - R.id.button_x, Constants.INPUT_KEY_X, + public void initialize() { + int[] keyButtonList = {R.id.button_a, Constants.INPUT_KEY_A, R.id.button_b, Constants.INPUT_KEY_B, + R.id.button_y, Constants.INPUT_KEY_Y, R.id.button_x, Constants.INPUT_KEY_X, - R.id.button_left, Constants.INPUT_KEY_LEFT, - R.id.button_right, Constants.INPUT_KEY_RIGHT, - R.id.button_up, Constants.INPUT_KEY_UP, - R.id.button_down, Constants.INPUT_KEY_DOWN, + R.id.button_left, Constants.INPUT_KEY_LEFT, R.id.button_right, Constants.INPUT_KEY_RIGHT, + R.id.button_up, Constants.INPUT_KEY_UP, R.id.button_down, Constants.INPUT_KEY_DOWN, - R.id.button_start, Constants.INPUT_KEY_START, - R.id.button_select, Constants.INPUT_KEY_SELECT, + R.id.button_start, Constants.INPUT_KEY_START, R.id.button_select, Constants.INPUT_KEY_SELECT, - R.id.button_l, Constants.INPUT_KEY_L, - R.id.button_r, Constants.INPUT_KEY_R - }; + R.id.button_l, Constants.INPUT_KEY_L, R.id.button_r, Constants.INPUT_KEY_R}; - for (int i = 0; i < keyButtonList.length; i+=2){ - final int keyCode = keyButtonList[i+1]; - ((Button)findViewById(keyButtonList[i])).setStateListener((btn, pressed)->{ - if (pressed) AlberDriver.KeyDown(keyCode); - else AlberDriver.KeyUp(keyCode); - }); - } + for (int i = 0; i < keyButtonList.length; i += 2) { + final int keyCode = keyButtonList[i + 1]; + ((Button) findViewById(keyButtonList[i])).setStateListener((btn, pressed) -> { + if (pressed) + AlberDriver.KeyDown(keyCode); + else + AlberDriver.KeyUp(keyCode); + }); + } - ((Joystick)findViewById(R.id.left_analog)) - .setJoystickListener((joystick, axisX, axisY) -> { - AlberDriver.SetCirclepadAxis((int)(axisX*0x9C), (int)(axisY*0x9C)*-1); - }); + ((Joystick) findViewById(R.id.left_analog)).setJoystickListener((joystick, axisX, axisY) -> { + AlberDriver.SetCirclepadAxis((int) (axisX * 0x9C), (int) (axisY * 0x9C) * -1); + }); - refreshChildren(); - } + refreshChildren(); + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java index 1ef93c895..137bd3126 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java @@ -7,150 +7,140 @@ import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; - import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.utils.Constants; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; public class ControllerLayout extends RelativeLayout { - - private final HashMap activeTouchEvents = new HashMap<>(); - private final ArrayList controllerNodes = new ArrayList<>(); - - public ControllerLayout(Context context) { - this(context,null); - } - - public ControllerLayout(Context context, AttributeSet attrs) { - this(context, attrs,0); - } - - public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr,0 ); - } - - public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - - public void refreshChildren(){ - ArrayList nodes = new ArrayList<>(); - populateNodesArray(this, nodes); - - //Need Reverse: First view is in back and last view is in front for respect android View hierarchy - Collections.reverse(nodes); - - controllerNodes.clear(); - controllerNodes.addAll(nodes); - } - - private void populateNodesArray(ViewGroup group, ArrayList list){ - for (int i = 0; i < group.getChildCount(); i++){ - View view = group.getChildAt(i); - if(view instanceof ControllerNode){ - list.add((ControllerNode) view); - } else if (view instanceof ViewGroup) { - populateNodesArray((ViewGroup) view, list); - } - } - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - int index = event.getActionIndex(); - - switch (event.getActionMasked()){ - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_POINTER_UP: { - int id = event.getPointerId(index); - processTouch(true, event.getX(index), event.getY(index), id); - }break; - case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_POINTER_DOWN: { - int id = event.getPointerId(index); - processTouch(false, event.getX(index), event.getY(index), id); - }break; - case MotionEvent.ACTION_MOVE: - for (int id = 0; id < event.getPointerCount(); id++){ - processTouch(false, event.getX(id), event.getY(id), id); - } - break; - } - return true; - } - - private void processTouch(boolean up, float x, float y, int index){ - int[] globalPosition = new int[2]; - getLocationInWindow(globalPosition); - - int action = TouchEvent.ACTION_MOVE; - - if ((!activeTouchEvents.containsKey(index))){ - if (up)return; - ControllerNode node = null; - for (ControllerNode item: controllerNodes){ - Vector2 pos = item.getPosition(); - Vector2 size= item.getSize(); - - float cx = (pos.x - globalPosition[0]); - float cy = (pos.y - globalPosition[1]); - if(item.isVisible() && x > cx && x < cx+size.x && y > cy && y < cy+size.y){ - node = item; - break; - } - } - if (node != null){ - activeTouchEvents.put(index, node); - action = TouchEvent.ACTION_DOWN; - } else { - return; - } - } - - if (up) action = TouchEvent.ACTION_UP; - - ControllerNode node = activeTouchEvents.get(index); - Vector2 pos = node.getPosition(); - pos.x -= globalPosition[0]; - pos.y -= globalPosition[1]; - - x -= pos.x; - y -= pos.y; - - node.onTouch(new TouchEvent(x,y,action)); - - if(up){ - activeTouchEvents.remove(index); - } - } - - @Override - public void onViewAdded(View child) { - super.onViewAdded(child); - refreshChildren(); - } - - @Override - public void onViewRemoved(View child) { - super.onViewRemoved(child); - refreshChildren(); - } - - /*@TODO: Need replace that methods for prevent Android send events directly to children*/ - - @Override - public ArrayList getTouchables() { - return new ArrayList<>(); - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - return true; - } - + private final HashMap activeTouchEvents = new HashMap<>(); + private final ArrayList controllerNodes = new ArrayList<>(); + + public ControllerLayout(Context context) { this(context, null); } + + public ControllerLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } + + public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } + + public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public void refreshChildren() { + ArrayList nodes = new ArrayList<>(); + populateNodesArray(this, nodes); + + // Need Reverse: First view is in back and last view is in front for respect android View hierarchy + Collections.reverse(nodes); + + controllerNodes.clear(); + controllerNodes.addAll(nodes); + } + + private void populateNodesArray(ViewGroup group, ArrayList list) { + for (int i = 0; i < group.getChildCount(); i++) { + View view = group.getChildAt(i); + if (view instanceof ControllerNode) { + list.add((ControllerNode) view); + } else if (view instanceof ViewGroup) { + populateNodesArray((ViewGroup) view, list); + } + } + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + int index = event.getActionIndex(); + + switch (event.getActionMasked()) { + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_POINTER_UP: { + int id = event.getPointerId(index); + processTouch(true, event.getX(index), event.getY(index), id); + } break; + case MotionEvent.ACTION_DOWN: + case MotionEvent.ACTION_POINTER_DOWN: { + int id = event.getPointerId(index); + processTouch(false, event.getX(index), event.getY(index), id); + } break; + case MotionEvent.ACTION_MOVE: + for (int id = 0; id < event.getPointerCount(); id++) { + processTouch(false, event.getX(id), event.getY(id), id); + } + break; + } + return true; + } + + private void processTouch(boolean up, float x, float y, int index) { + int[] globalPosition = new int[2]; + getLocationInWindow(globalPosition); + + int action = TouchEvent.ACTION_MOVE; + + if ((!activeTouchEvents.containsKey(index))) { + if (up) return; + ControllerNode node = null; + for (ControllerNode item : controllerNodes) { + Vector2 pos = item.getPosition(); + Vector2 size = item.getSize(); + + float cx = (pos.x - globalPosition[0]); + float cy = (pos.y - globalPosition[1]); + if (item.isVisible() && x > cx && x < cx + size.x && y > cy && y < cy + size.y) { + node = item; + break; + } + } + if (node != null) { + activeTouchEvents.put(index, node); + action = TouchEvent.ACTION_DOWN; + } else { + return; + } + } + + if (up) action = TouchEvent.ACTION_UP; + + ControllerNode node = activeTouchEvents.get(index); + Vector2 pos = node.getPosition(); + pos.x -= globalPosition[0]; + pos.y -= globalPosition[1]; + + x -= pos.x; + y -= pos.y; + + node.onTouch(new TouchEvent(x, y, action)); + + if (up) { + activeTouchEvents.remove(index); + } + } + + @Override + public void onViewAdded(View child) { + super.onViewAdded(child); + refreshChildren(); + } + + @Override + public void onViewRemoved(View child) { + super.onViewRemoved(child); + refreshChildren(); + } + + /*@TODO: Need replace that methods for prevent Android send events directly to children*/ + + @Override + public ArrayList getTouchables() { + return new ArrayList<>(); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return true; + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java index a29d08a4f..e5b8795e1 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java @@ -1,28 +1,22 @@ package com.panda3ds.pandroid.view.controller; - import android.view.View; - import androidx.annotation.NonNull; - import com.panda3ds.pandroid.math.Vector2; public interface ControllerNode { + @NonNull + default Vector2 getPosition() { + View me = (View) this; - @NonNull - default Vector2 getPosition(){ - View me = (View) this; - - int[] position = new int[2]; - me.getLocationInWindow(position); - return new Vector2(position[0], position[1]); - } + int[] position = new int[2]; + me.getLocationInWindow(position); + return new Vector2(position[0], position[1]); + } - default boolean isVisible(){ - return ((View)this).isShown(); - } + default boolean isVisible() { return ((View) this).isShown(); } - @NonNull Vector2 getSize(); + @NonNull Vector2 getSize(); - void onTouch(TouchEvent event); + void onTouch(TouchEvent event); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java index a804cda1d..d3b40db95 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java @@ -1,28 +1,22 @@ package com.panda3ds.pandroid.view.controller; public class TouchEvent { - public static final int ACTION_DOWN = 0; - public static final int ACTION_MOVE = 1; - public static final int ACTION_UP = 2; + public static final int ACTION_DOWN = 0; + public static final int ACTION_MOVE = 1; + public static final int ACTION_UP = 2; - private final int action; - private final float x,y; + private final int action; + private final float x, y; - public float getX() { - return x; - } + public float getX() { return x; } - public float getY() { - return y; - } + public float getY() { return y; } - public int getAction() { - return action; - } + public int getAction() { return action; } - public TouchEvent(float x, float y, int action){ - this.x = x; - this.y = y; - this.action = action; - } + public TouchEvent(float x, float y, int action) { + this.x = x; + this.y = y; + this.action = action; + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/ButtonStateListener.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/ButtonStateListener.java index a658cdc03..eb5a693a5 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/ButtonStateListener.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/ButtonStateListener.java @@ -3,5 +3,5 @@ import com.panda3ds.pandroid.view.controller.nodes.Button; public interface ButtonStateListener { - void onButtonPressedChange(Button button, boolean pressed); + void onButtonPressedChange(Button button, boolean pressed); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/JoystickListener.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/JoystickListener.java index 538e2cd82..772252237 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/JoystickListener.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/listeners/JoystickListener.java @@ -3,5 +3,5 @@ import com.panda3ds.pandroid.view.controller.nodes.Joystick; public interface JoystickListener { - void onJoystickAxisChange(Joystick joystick, float axisX, float axisY); + void onJoystickAxisChange(Joystick joystick, float axisX, float axisY); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java index 90d5f5f7c..224be9a41 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java @@ -2,23 +2,15 @@ import android.content.Context; import android.util.AttributeSet; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; - import com.panda3ds.pandroid.view.controller.ControllerNode; public abstract class BasicControllerNode extends AppCompatTextView implements ControllerNode { - public BasicControllerNode(@NonNull Context context) { - super(context); - } + public BasicControllerNode(@NonNull Context context) { super(context); } - public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - } + public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); } - public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } + public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java index 7e8d4e869..4dadc22ba 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java @@ -5,69 +5,63 @@ import android.graphics.Canvas; import android.util.AttributeSet; import android.view.Gravity; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; - import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; import com.panda3ds.pandroid.view.controller.listeners.ButtonStateListener; public class Button extends BasicControllerNode { - private boolean pressed = false; - private int width,height; + private boolean pressed = false; + private int width, height; - private ButtonStateListener stateListener; + private ButtonStateListener stateListener; - public Button(@NonNull Context context) { - super(context); - init(); - } + public Button(@NonNull Context context) { + super(context); + init(); + } - public Button(@NonNull Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - init(); - } + public Button(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + init(); + } - public Button(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(); - } + public Button(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - width = getWidth(); - height = getHeight(); - } + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + width = getWidth(); + height = getHeight(); + } - private void init(){ - setTextAlignment(TEXT_ALIGNMENT_CENTER); - setGravity(Gravity.CENTER); - } + private void init() { + setTextAlignment(TEXT_ALIGNMENT_CENTER); + setGravity(Gravity.CENTER); + } - public void setStateListener(ButtonStateListener stateListener) { - this.stateListener = stateListener; - } + public void setStateListener(ButtonStateListener stateListener) { this.stateListener = stateListener; } - public boolean isPressed() { - return pressed; - } + public boolean isPressed() { return pressed; } - @NonNull - @Override - public Vector2 getSize() { - return new Vector2(width,height); - } + @NonNull + @Override + public Vector2 getSize() { + return new Vector2(width, height); + } - @Override - public void onTouch(TouchEvent event) { - pressed = event.getAction() != TouchEvent.ACTION_UP; - setAlpha(pressed ? 0.2F : 1.0F); - if (stateListener != null){ - stateListener.onButtonPressedChange(this, pressed); - } - } + @Override + public void onTouch(TouchEvent event) { + pressed = event.getAction() != TouchEvent.ACTION_UP; + setAlpha(pressed ? 0.2F : 1.0F); + if (stateListener != null) { + stateListener.onButtonPressedChange(this, pressed); + } + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java index 757ec3cba..df487bd8d 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java @@ -6,127 +6,110 @@ import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.util.AttributeSet; - import androidx.annotation.NonNull; import androidx.appcompat.widget.AppCompatTextView; - import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; import com.panda3ds.pandroid.view.controller.listeners.JoystickListener; - public class Joystick extends BasicControllerNode implements ControllerNode { - private float stick_x = 0; - private float stick_y = 0; - - private int size_width = 0; - private int size_height= 0; - - private JoystickListener joystickListener; - - public Joystick(Context context) { - this(context,null); - } + private float stick_x = 0; + private float stick_y = 0; - public Joystick(Context context, AttributeSet attrs) { - this(context, attrs,0); - } + private int size_width = 0; + private int size_height = 0; - public Joystick(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); + private JoystickListener joystickListener; - paint.setColor(Color.RED); - invalidate(); - } + public Joystick(Context context) { this(context, null); } - private final Paint paint = new Paint(); + public Joystick(Context context, AttributeSet attrs) { this(context, attrs, 0); } - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - } + public Joystick(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); - @Override - public void onDrawForeground(Canvas canvas) { - size_width = getWidth(); - size_height = getHeight(); + paint.setColor(Color.RED); + invalidate(); + } - int analogIconSize = size_width-getPaddingLeft(); + private final Paint paint = new Paint(); - float middleIconSize = analogIconSize / 2.0F; - float middle = size_width / 2.0F; + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + } - float maxDistance = (middle - middleIconSize) * 0.9F; + @Override + public void onDrawForeground(Canvas canvas) { + size_width = getWidth(); + size_height = getHeight(); - float tx = maxDistance * stick_x; - float ty = maxDistance * stick_y; + int analogIconSize = size_width - getPaddingLeft(); - float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty)); - radius = Math.min(maxDistance, radius); + float middleIconSize = analogIconSize / 2.0F; + float middle = size_width / 2.0F; - double deg = Math.atan2(ty,tx) * (180.0/Math.PI); - float rx = (float) (radius*Math.cos(Math.PI * 2 * deg/360.0)); - float ry = (float) (radius*Math.sin(Math.PI * 2 * deg/360.0)); + float maxDistance = (middle - middleIconSize) * 0.9F; - stick_x = Math.max(-1.0f, Math.min(1.0f, stick_x)); - stick_y = Math.max(-1.0f, Math.min(1.0f, stick_y)); + float tx = maxDistance * stick_x; + float ty = maxDistance * stick_y; + float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty)); + radius = Math.min(maxDistance, radius); - float x = middle-middleIconSize+rx; - float y = middle-middleIconSize+ry; + double deg = Math.atan2(ty, tx) * (180.0 / Math.PI); + float rx = (float) (radius * Math.cos(Math.PI * 2 * deg / 360.0)); + float ry = (float) (radius * Math.sin(Math.PI * 2 * deg / 360.0)); + stick_x = Math.max(-1.0f, Math.min(1.0f, stick_x)); + stick_y = Math.max(-1.0f, Math.min(1.0f, stick_y)); - Drawable foreground = getForeground(); - if (foreground != null){ - foreground.setBounds((int) x, (int) y, (int) (x+analogIconSize), (int) (y+analogIconSize)); - foreground.draw(canvas); - } else { - canvas.drawOval(x, y, x+analogIconSize,y+analogIconSize,paint); - } - } + float x = middle - middleIconSize + rx; + float y = middle - middleIconSize + ry; - public Vector2 getAxis() { - return new Vector2( - Math.max(-1.0F, Math.min(1.0F, stick_x)), - Math.max(-1.0F, Math.min(1.0F, stick_y)) - ); - } + Drawable foreground = getForeground(); + if (foreground != null) { + foreground.setBounds((int) x, (int) y, (int) (x + analogIconSize), (int) (y + analogIconSize)); + foreground.draw(canvas); + } else { + canvas.drawOval(x, y, x + analogIconSize, y + analogIconSize, paint); + } + } - public void setJoystickListener(JoystickListener joystickListener) { - this.joystickListener = joystickListener; - } + public Vector2 getAxis() { return new Vector2(Math.max(-1.0F, Math.min(1.0F, stick_x)), Math.max(-1.0F, Math.min(1.0F, stick_y))); } - @NonNull - @Override - public Vector2 getSize() { - return new Vector2(size_width,size_height); - } + public void setJoystickListener(JoystickListener joystickListener) { this.joystickListener = joystickListener; } - @Override - public void onTouch(TouchEvent event) { + @NonNull + @Override + public Vector2 getSize() { + return new Vector2(size_width, size_height); + } - float middle = size_width/2.0F; + @Override + public void onTouch(TouchEvent event) { + float middle = size_width / 2.0F; - float x = event.getX(); - float y = event.getY(); + float x = event.getX(); + float y = event.getY(); - x = Math.max(0, Math.min(middle*2, x)); - y = Math.max(0, Math.min(middle*2, y)); + x = Math.max(0, Math.min(middle * 2, x)); + y = Math.max(0, Math.min(middle * 2, y)); - stick_x = ((x-middle)/middle); + stick_x = ((x - middle) / middle); - stick_y = ((y-middle)/middle); + stick_y = ((y - middle) / middle); - if (event.getAction() == TouchEvent.ACTION_UP){ - stick_x = 0; - stick_y = 0; - } + if (event.getAction() == TouchEvent.ACTION_UP) { + stick_x = 0; + stick_y = 0; + } - if (joystickListener != null){ - joystickListener.onJoystickAxisChange(this, stick_x, stick_y); - } + if (joystickListener != null) { + joystickListener.onJoystickAxisChange(this, stick_x, stick_y); + } - invalidate(); - } + invalidate(); + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java index 85d1ddd69..1009d29c0 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java @@ -3,7 +3,6 @@ import android.graphics.Rect; import android.util.Log; import android.view.View; - import com.panda3ds.pandroid.AlberDriver; import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.utils.Constants; @@ -12,28 +11,28 @@ import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; public interface TouchScreenNodeImpl extends ControllerNode { - default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event){ - - View me = (View) this; - boolean hasDownEvent = me.getTag(R.id.TagEventHasDown) != null && (boolean) me.getTag(R.id.TagEventHasDown); + default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) { + View me = (View) this; + boolean hasDownEvent = me.getTag(R.id.TagEventHasDown) != null && (boolean) me.getTag(R.id.TagEventHasDown); - Rect bounds = renderer.getLayout().getBottomDisplayBounds();; + Rect bounds = renderer.getLayout().getBottomDisplayBounds(); + ; - if (event.getX() >= bounds.left && event.getY() >= bounds.top && event.getX() <= bounds.right && event.getY() <= bounds.bottom){ - int x = (int) (event.getX() - bounds.left); - int y = (int) (event.getY() - bounds.top); + if (event.getX() >= bounds.left && event.getY() >= bounds.top && event.getX() <= bounds.right && event.getY() <= bounds.bottom) { + int x = (int) (event.getX() - bounds.left); + int y = (int) (event.getY() - bounds.top); - x = Math.round((x/(float)bounds.width())*320); - y = Math.round((y/(float)bounds.height())*240); + x = Math.round((x / (float) bounds.width()) * 320); + y = Math.round((y / (float) bounds.height()) * 240); - AlberDriver.TouchScreenDown(x,y); + AlberDriver.TouchScreenDown(x, y); - me.setTag(R.id.TagEventHasDown, true); - } + me.setTag(R.id.TagEventHasDown, true); + } - if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP){ - AlberDriver.TouchScreenUp(); - me.setTag(R.id.TagEventHasDown, false); - } - } + if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP) { + AlberDriver.TouchScreenUp(); + me.setTag(R.id.TagEventHasDown, false); + } + } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java index 13ad4d39f..d5c99e8d6 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/ConsoleRenderer.java @@ -3,7 +3,7 @@ import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout; public interface ConsoleRenderer { - void setLayout(ConsoleLayout layout); - ConsoleLayout getLayout(); - String getBackendName(); + void setLayout(ConsoleLayout layout); + ConsoleLayout getLayout(); + String getBackendName(); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java index 781f0abd4..dc83c59f0 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java @@ -1,15 +1,14 @@ package com.panda3ds.pandroid.view.renderer.layout; import android.graphics.Rect; - import com.panda3ds.pandroid.math.Vector2; public interface ConsoleLayout { - void update(int screenWidth, int screenHeight); + void update(int screenWidth, int screenHeight); - void setBottomDisplaySourceSize(int width, int height); - void setTopDisplaySourceSize(int width, int height); + void setBottomDisplaySourceSize(int width, int height); + void setTopDisplaySourceSize(int width, int height); - Rect getBottomDisplayBounds(); - Rect getTopDisplayBounds(); + Rect getBottomDisplayBounds(); + Rect getTopDisplayBounds(); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java index a54db8f7a..d86161678 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java @@ -2,80 +2,76 @@ import android.graphics.Rect; import android.util.Size; - import com.panda3ds.pandroid.math.Vector2; public class DefaultScreenLayout implements ConsoleLayout { - private final Rect topDisplay = new Rect(); - private final Rect bottomDisplay = new Rect(); - - private final Vector2 screenSize = new Vector2(1.0F, 1.0F); - private final Vector2 topSourceSize = new Vector2(1.0F, 1.0F); - private final Vector2 bottomSourceSize = new Vector2(1.0F, 1.0F); - - @Override - public void update(int screenWidth, int screenHeight) { - screenSize.set(screenWidth, screenHeight); - updateBounds(); - } - - @Override - public void setBottomDisplaySourceSize(int width, int height) { - bottomSourceSize.set(width,height); - updateBounds(); - } - @Override - public void setTopDisplaySourceSize(int width, int height) { - topSourceSize.set(width,height); - updateBounds(); - } - - private void updateBounds(){ - int screenWidth = (int) screenSize.x; - int screenHeight = (int) screenSize.y; - - if (screenWidth > screenHeight){ - - int topDisplayWidth = (int) ((screenHeight / topSourceSize.y) * topSourceSize.x); - int topDisplayHeight = screenHeight; - - if (topDisplayWidth > (screenWidth*0.7)){ - topDisplayWidth = (int) (screenWidth * 0.7); - topDisplayHeight = (int) ((topDisplayWidth/topSourceSize.x)* topSourceSize.y); - } - - int bottomDisplayHeight = (int) (((screenWidth-topDisplayWidth)/ bottomSourceSize.x)* bottomSourceSize.y); - - - topDisplay.set(0, 0, topDisplayWidth, topDisplayHeight); - bottomDisplay.set(topDisplayWidth, 0, topDisplayWidth+(screenWidth-topDisplayWidth), bottomDisplayHeight); - } else { - int topScreenHeight = (int) ((screenWidth/ topSourceSize.x) * topSourceSize.y); - topDisplay.set(0,0,screenWidth,topScreenHeight); - - int bottomDisplayHeight = (int)((screenWidth/ bottomSourceSize.x) * bottomSourceSize.y); - int bottomDisplayWidth = screenWidth; - int bottomDisplayX = 0; - - if (topScreenHeight + bottomDisplayHeight > screenHeight){ - bottomDisplayHeight = (screenHeight-topScreenHeight); - bottomDisplayWidth = (int) ((bottomDisplayHeight/ bottomSourceSize.y)*bottomSourceSize.x); - bottomDisplayX = (screenWidth-bottomDisplayX)/2; - } - - topDisplay.set(0,0, screenWidth,topScreenHeight); - bottomDisplay.set(bottomDisplayX, topScreenHeight, bottomDisplayX+bottomDisplayWidth,topScreenHeight+bottomDisplayHeight); - } - } - - - @Override - public Rect getBottomDisplayBounds() { - return bottomDisplay; - } - - @Override - public Rect getTopDisplayBounds() { - return topDisplay; - } + private final Rect topDisplay = new Rect(); + private final Rect bottomDisplay = new Rect(); + + private final Vector2 screenSize = new Vector2(1.0F, 1.0F); + private final Vector2 topSourceSize = new Vector2(1.0F, 1.0F); + private final Vector2 bottomSourceSize = new Vector2(1.0F, 1.0F); + + @Override + public void update(int screenWidth, int screenHeight) { + screenSize.set(screenWidth, screenHeight); + updateBounds(); + } + + @Override + public void setBottomDisplaySourceSize(int width, int height) { + bottomSourceSize.set(width, height); + updateBounds(); + } + @Override + public void setTopDisplaySourceSize(int width, int height) { + topSourceSize.set(width, height); + updateBounds(); + } + + private void updateBounds() { + int screenWidth = (int) screenSize.x; + int screenHeight = (int) screenSize.y; + + if (screenWidth > screenHeight) { + int topDisplayWidth = (int) ((screenHeight / topSourceSize.y) * topSourceSize.x); + int topDisplayHeight = screenHeight; + + if (topDisplayWidth > (screenWidth * 0.7)) { + topDisplayWidth = (int) (screenWidth * 0.7); + topDisplayHeight = (int) ((topDisplayWidth / topSourceSize.x) * topSourceSize.y); + } + + int bottomDisplayHeight = (int) (((screenWidth - topDisplayWidth) / bottomSourceSize.x) * bottomSourceSize.y); + + topDisplay.set(0, 0, topDisplayWidth, topDisplayHeight); + bottomDisplay.set(topDisplayWidth, 0, topDisplayWidth + (screenWidth - topDisplayWidth), bottomDisplayHeight); + } else { + int topScreenHeight = (int) ((screenWidth / topSourceSize.x) * topSourceSize.y); + topDisplay.set(0, 0, screenWidth, topScreenHeight); + + int bottomDisplayHeight = (int) ((screenWidth / bottomSourceSize.x) * bottomSourceSize.y); + int bottomDisplayWidth = screenWidth; + int bottomDisplayX = 0; + + if (topScreenHeight + bottomDisplayHeight > screenHeight) { + bottomDisplayHeight = (screenHeight - topScreenHeight); + bottomDisplayWidth = (int) ((bottomDisplayHeight / bottomSourceSize.y) * bottomSourceSize.x); + bottomDisplayX = (screenWidth - bottomDisplayX) / 2; + } + + topDisplay.set(0, 0, screenWidth, topScreenHeight); + bottomDisplay.set(bottomDisplayX, topScreenHeight, bottomDisplayX + bottomDisplayWidth, topScreenHeight + bottomDisplayHeight); + } + } + + @Override + public Rect getBottomDisplayBounds() { + return bottomDisplay; + } + + @Override + public Rect getTopDisplayBounds() { + return topDisplay; + } } From 609d3fc196984c7f071ca6efa9b7ea1c16906907 Mon Sep 17 00:00:00 2001 From: gabriel Date: Thu, 7 Dec 2023 17:49:22 -0400 Subject: [PATCH 11/15] Fix words --- src/pandroid/app/src/main/AndroidManifest.xml | 2 +- .../panda3ds/pandroid/app/GameActivity.java | 13 +++--- .../com/panda3ds/pandroid/math/Vector2.java | 4 -- .../panda3ds/pandroid/utils/Constants.java | 4 +- .../pandroid/view/PandaGlRenderer.java | 4 +- .../pandroid/view/PandaGlSurfaceView.java | 14 +++---- .../view/controller/ControllerNode.java | 4 +- .../view/controller/nodes/Joystick.java | 42 +++++++++---------- .../controller/nodes/TouchScreenNodeImpl.java | 12 +++--- .../view/renderer/layout/ConsoleLayout.java | 1 - .../renderer/layout/DefaultScreenLayout.java | 2 +- 11 files changed, 45 insertions(+), 57 deletions(-) diff --git a/src/pandroid/app/src/main/AndroidManifest.xml b/src/pandroid/app/src/main/AndroidManifest.xml index 978edcc56..291496f4b 100644 --- a/src/pandroid/app/src/main/AndroidManifest.xml +++ b/src/pandroid/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ + android:glEsVersion="0x0030001"/> { - findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE); - }); + ((CheckBox) findViewById(R.id.hide_screen_controller)).setOnCheckedChangeListener((buttonView, isChecked) -> findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE)); } @Override diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java index 4208b6102..becec9e1b 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/math/Vector2.java @@ -2,15 +2,11 @@ public class Vector2 { public float x, y; - public Vector2(Vector2 value) { this(value.x, value.y); } - public Vector2(float x, float y) { this.x = x; this.y = y; } - public float distanceTo(Vector2 vec) { return distance(x, y, vec.x, vec.y); } - public static float distance(float x, float y, float x2, float y2) { return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); } public void set(float x, float y) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index bc3899877..3485180e5 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -6,7 +6,7 @@ public class Constants { public static final int INPUT_KEY_LEFT = 1 << 5; public static final int INPUT_KEY_RIGHT = 1 << 4; - public static final int INPUT_KEY_A = 1 << 0; + public static final int INPUT_KEY_A = 1; public static final int INPUT_KEY_B = 1 << 1; public static final int INPUT_KEY_X = 1 << 10; public static final int INPUT_KEY_Y = 1 << 11; @@ -22,5 +22,5 @@ public class Constants { public static final int N3DS_FULL_HEIGHT = 480; public static final String EXTRA_PATH = "path"; - public static final String LOG_TAG = "Alber"; + public static final String LOG_TAG = "pandroid"; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index b21e33537..0df05e9fc 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -42,8 +42,8 @@ protected void finalize() throws Throwable { } public void onSurfaceCreated(GL10 unused, EGLConfig config) { - Log.i("pandroid", glGetString(GL_EXTENSIONS)); - Log.w("pandroid", glGetString(GL_VERSION)); + Log.i(Constants.LOG_TAG, glGetString(GL_EXTENSIONS)); + Log.w(Constants.LOG_TAG, glGetString(GL_VERSION)); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java index f5a19efeb..eb65762d5 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java @@ -1,20 +1,18 @@ package com.panda3ds.pandroid.view; import android.content.Context; -import android.graphics.Canvas; import android.opengl.GLSurfaceView; -import android.util.Log; + import androidx.annotation.NonNull; import com.panda3ds.pandroid.math.Vector2; -import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.controller.TouchEvent; import com.panda3ds.pandroid.view.controller.nodes.TouchScreenNodeImpl; import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl { final PandaGlRenderer renderer; - private int size_width; - private int size_height; + private int width; + private int height; public PandaGlSurfaceView(Context context, String romPath) { super(context); @@ -29,14 +27,14 @@ public PandaGlSurfaceView(Context context, String romPath) { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - size_width = getMeasuredWidth(); - size_height = getMeasuredHeight(); + width = getMeasuredWidth(); + height = getMeasuredHeight(); } @NonNull @Override public Vector2 getSize() { - return new Vector2(size_width, size_height); + return new Vector2(width, height); } @Override diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java index e5b8795e1..e6c1dc92b 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java @@ -7,10 +7,10 @@ public interface ControllerNode { @NonNull default Vector2 getPosition() { - View me = (View) this; + View view = (View) this; int[] position = new int[2]; - me.getLocationInWindow(position); + view.getLocationInWindow(position); return new Vector2(position[0], position[1]); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java index df487bd8d..ad3df6b12 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java @@ -7,18 +7,18 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import androidx.annotation.NonNull; -import androidx.appcompat.widget.AppCompatTextView; + import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; import com.panda3ds.pandroid.view.controller.listeners.JoystickListener; public class Joystick extends BasicControllerNode implements ControllerNode { - private float stick_x = 0; - private float stick_y = 0; + private float axisX = 0; + private float axisY = 0; - private int size_width = 0; - private int size_height = 0; + private int width = 0; + private int height = 0; private JoystickListener joystickListener; @@ -42,18 +42,18 @@ protected void onDraw(Canvas canvas) { @Override public void onDrawForeground(Canvas canvas) { - size_width = getWidth(); - size_height = getHeight(); + width = getWidth(); + height = getHeight(); - int analogIconSize = size_width - getPaddingLeft(); + int analogIconSize = width - getPaddingLeft(); float middleIconSize = analogIconSize / 2.0F; - float middle = size_width / 2.0F; + float middle = width / 2.0F; float maxDistance = (middle - middleIconSize) * 0.9F; - float tx = maxDistance * stick_x; - float ty = maxDistance * stick_y; + float tx = maxDistance * axisX; + float ty = maxDistance * axisY; float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty)); radius = Math.min(maxDistance, radius); @@ -62,8 +62,8 @@ public void onDrawForeground(Canvas canvas) { float rx = (float) (radius * Math.cos(Math.PI * 2 * deg / 360.0)); float ry = (float) (radius * Math.sin(Math.PI * 2 * deg / 360.0)); - stick_x = Math.max(-1.0f, Math.min(1.0f, stick_x)); - stick_y = Math.max(-1.0f, Math.min(1.0f, stick_y)); + axisX = Math.max(-1.0f, Math.min(1.0f, axisX)); + axisY = Math.max(-1.0f, Math.min(1.0f, axisY)); float x = middle - middleIconSize + rx; float y = middle - middleIconSize + ry; @@ -77,19 +77,19 @@ public void onDrawForeground(Canvas canvas) { } } - public Vector2 getAxis() { return new Vector2(Math.max(-1.0F, Math.min(1.0F, stick_x)), Math.max(-1.0F, Math.min(1.0F, stick_y))); } + public Vector2 getAxis() { return new Vector2(Math.max(-1.0F, Math.min(1.0F, axisX)), Math.max(-1.0F, Math.min(1.0F, axisY))); } public void setJoystickListener(JoystickListener joystickListener) { this.joystickListener = joystickListener; } @NonNull @Override public Vector2 getSize() { - return new Vector2(size_width, size_height); + return new Vector2(width, height); } @Override public void onTouch(TouchEvent event) { - float middle = size_width / 2.0F; + float middle = width / 2.0F; float x = event.getX(); float y = event.getY(); @@ -97,17 +97,17 @@ public void onTouch(TouchEvent event) { x = Math.max(0, Math.min(middle * 2, x)); y = Math.max(0, Math.min(middle * 2, y)); - stick_x = ((x - middle) / middle); + axisX = ((x - middle) / middle); - stick_y = ((y - middle) / middle); + axisY = ((y - middle) / middle); if (event.getAction() == TouchEvent.ACTION_UP) { - stick_x = 0; - stick_y = 0; + axisX = 0; + axisY = 0; } if (joystickListener != null) { - joystickListener.onJoystickAxisChange(this, stick_x, stick_y); + joystickListener.onJoystickAxisChange(this, axisX, axisY); } invalidate(); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java index 1009d29c0..39e6aae98 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java @@ -1,22 +1,20 @@ package com.panda3ds.pandroid.view.controller.nodes; import android.graphics.Rect; -import android.util.Log; import android.view.View; + import com.panda3ds.pandroid.AlberDriver; import com.panda3ds.pandroid.R; -import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; public interface TouchScreenNodeImpl extends ControllerNode { default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) { - View me = (View) this; - boolean hasDownEvent = me.getTag(R.id.TagEventHasDown) != null && (boolean) me.getTag(R.id.TagEventHasDown); + View view = (View) this; + boolean hasDownEvent = view.getTag(R.id.TagEventHasDown) != null && (boolean) view.getTag(R.id.TagEventHasDown); Rect bounds = renderer.getLayout().getBottomDisplayBounds(); - ; if (event.getX() >= bounds.left && event.getY() >= bounds.top && event.getX() <= bounds.right && event.getY() <= bounds.bottom) { int x = (int) (event.getX() - bounds.left); @@ -27,12 +25,12 @@ default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) { AlberDriver.TouchScreenDown(x, y); - me.setTag(R.id.TagEventHasDown, true); + view.setTag(R.id.TagEventHasDown, true); } if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP) { AlberDriver.TouchScreenUp(); - me.setTag(R.id.TagEventHasDown, false); + view.setTag(R.id.TagEventHasDown, false); } } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java index dc83c59f0..7ec00974c 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/ConsoleLayout.java @@ -1,7 +1,6 @@ package com.panda3ds.pandroid.view.renderer.layout; import android.graphics.Rect; -import com.panda3ds.pandroid.math.Vector2; public interface ConsoleLayout { void update(int screenWidth, int screenHeight); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java index d86161678..adfe54436 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java @@ -1,7 +1,7 @@ package com.panda3ds.pandroid.view.renderer.layout; import android.graphics.Rect; -import android.util.Size; + import com.panda3ds.pandroid.math.Vector2; public class DefaultScreenLayout implements ConsoleLayout { From 00bf1bc6b870c46c4e8c66e47a4aebec613f3429 Mon Sep 17 00:00:00 2001 From: offtkp Date: Fri, 8 Dec 2023 02:24:02 +0200 Subject: [PATCH 12/15] Reduce jni boilerplate --- src/jni_driver.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/jni_driver.cpp b/src/jni_driver.cpp index 6d3bd104e..82720e2a6 100644 --- a/src/jni_driver.cpp +++ b/src/jni_driver.cpp @@ -13,7 +13,10 @@ HIDService* hidService = nullptr; RendererGL* renderer = nullptr; bool romLoaded = false; -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Initialize(JNIEnv* env, jobject obj) { +#define AlberFunction(type, name) JNIEXPORT type JNICALL Java_com_panda3ds_pandroid_AlberDriver_##name + +extern "C" { +AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) { emulator = std::make_unique(); if (emulator->getRendererType() != RendererType::OpenGL) { @@ -31,7 +34,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Initial emulator->initGraphicsContext(nullptr); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_RunFrame(JNIEnv* env, jobject obj, jint fbo) { +AlberFunction(void, RunFrame)(JNIEnv* env, jobject obj, jint fbo) { renderer->setFBO(fbo); renderer->resetStateManager(); emulator->runFrame(); @@ -39,36 +42,33 @@ extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_RunFram hidService->updateInputs(emulator->getTicks()); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Finalize(JNIEnv* env, jobject obj) { +AlberFunction(void, Finalize)(JNIEnv* env, jobject obj) { emulator = nullptr; hidService = nullptr; renderer = nullptr; } -extern "C" JNIEXPORT jboolean JNICALL Java_com_panda3ds_pandroid_AlberDriver_HasRomLoaded(JNIEnv* env, jobject obj) { return romLoaded; } +AlberFunction(jboolean, HasRomLoaded)(JNIEnv* env, jobject obj) { return romLoaded; } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_LoadRom(JNIEnv* env, jobject obj, jstring path) { +AlberFunction(void, LoadRom)(JNIEnv* env, jobject obj, jstring path) { const char* pathStr = env->GetStringUTFChars(path, nullptr); romLoaded = emulator->loadROM(pathStr); __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s, result: %d", pathStr, (int)romLoaded); env->ReleaseStringUTFChars(path, pathStr); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenDown(JNIEnv* env, jobject obj, jint x, jint y) { - hidService->setTouchScreenPress((u16)x, (u16)y); -} +AlberFunction(void, TouchScreenDown)(JNIEnv* env, jobject obj, jint x, jint y) { hidService->setTouchScreenPress((u16)x, (u16)y); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenUp(JNIEnv* env, jobject obj) { hidService->releaseTouchScreen(); } +AlberFunction(void, TouchScreenUp)(JNIEnv* env, jobject obj) { hidService->releaseTouchScreen(); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_KeyUp(JNIEnv* env, jobject obj, jint keyCode) { - hidService->releaseKey((u32)keyCode); -} +AlberFunction(void, KeyUp)(JNIEnv* env, jobject obj, jint keyCode) { hidService->releaseKey((u32)keyCode); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_KeyDown(JNIEnv* env, jobject obj, jint keyCode) { - hidService->pressKey((u32)keyCode); -} +AlberFunction(void, KeyDown)(JNIEnv* env, jobject obj, jint keyCode) { hidService->pressKey((u32)keyCode); } -extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_SetCirclepadAxis(JNIEnv* env, jobject obj, jint x, jint y) { +AlberFunction(void, SetCirclepadAxis)(JNIEnv* env, jobject obj, jint x, jint y) { hidService->setCirclepadX((s16)x); hidService->setCirclepadY((s16)y); } +} + +#undef AlberFunction \ No newline at end of file From a78a1a099f562ad100d0d80f30c09a02ce1e49c0 Mon Sep 17 00:00:00 2001 From: offtkp Date: Fri, 8 Dec 2023 03:12:21 +0200 Subject: [PATCH 13/15] More peach fixups --- .../panda3ds/pandroid/app/GameActivity.java | 4 ++-- .../panda3ds/pandroid/app/MainActivity.java | 8 +++---- .../panda3ds/pandroid/utils/Constants.java | 23 ++++++++----------- .../panda3ds/pandroid/utils/PathUtils.java | 19 ++++----------- .../pandroid/view/PandaGlRenderer.java | 8 +++++++ .../view/controller/ControllerLayout.java | 7 +++--- .../pandroid/view/controller/TouchEvent.java | 10 +++----- .../pandroid/view/controller/TouchType.java | 7 ++++++ .../view/controller/nodes/Button.java | 5 ++-- .../view/controller/nodes/Joystick.java | 19 +++++++-------- .../controller/nodes/TouchScreenNodeImpl.java | 3 ++- .../renderer/layout/DefaultScreenLayout.java | 6 ++--- 12 files changed, 60 insertions(+), 59 deletions(-) create mode 100644 src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchType.java diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index d086e85f5..dfba96e5f 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -23,14 +23,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); - if (!intent.hasExtra(Constants.EXTRA_PATH)) { + if (!intent.hasExtra(Constants.ACTIVITY_PARAMETER_PATH)) { setContentView(new FrameLayout(this)); Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show(); finish(); return; } - PandaGlSurfaceView pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH)); + PandaGlSurfaceView pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.ACTIVITY_PARAMETER_PATH)); setContentView(R.layout.game_activity); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java index 181cfb4ea..368efe0e9 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java @@ -16,14 +16,14 @@ import com.panda3ds.pandroid.utils.PathUtils; public class MainActivity extends BaseActivity { - private static final int PICK_3DS_ROM = 2; + private static final int PICK_ROM = 2; private static final int PERMISSION_REQUEST_CODE = 3; private void openFile() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); - startActivityForResult(intent, PICK_3DS_ROM); + startActivityForResult(intent, PICK_ROM); } @Override @@ -46,11 +46,11 @@ protected void onCreate(Bundle savedInstanceState) { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == PICK_3DS_ROM) { + if (requestCode == PICK_ROM) { if (resultCode == RESULT_OK) { String path = PathUtils.getPath(getApplicationContext(), data.getData()); Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show(); - startActivity(new Intent(this, GameActivity.class).putExtra(Constants.EXTRA_PATH, path)); + startActivity(new Intent(this, GameActivity.class).putExtra(Constants.ACTIVITY_PARAMETER_PATH, path)); } super.onActivityResult(requestCode, resultCode, data); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index 3485180e5..6b480c239 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -1,26 +1,23 @@ package com.panda3ds.pandroid.utils; public class Constants { + public static final int INPUT_KEY_A = 1 << 0; + public static final int INPUT_KEY_B = 1 << 1; + public static final int INPUT_KEY_SELECT = 1 << 2; + public static final int INPUT_KEY_START = 1 << 3; + public static final int INPUT_KEY_RIGHT = 1 << 4; + public static final int INPUT_KEY_LEFT = 1 << 5; public static final int INPUT_KEY_UP = 1 << 6; public static final int INPUT_KEY_DOWN = 1 << 7; - public static final int INPUT_KEY_LEFT = 1 << 5; - public static final int INPUT_KEY_RIGHT = 1 << 4; - - public static final int INPUT_KEY_A = 1; - public static final int INPUT_KEY_B = 1 << 1; - public static final int INPUT_KEY_X = 1 << 10; - public static final int INPUT_KEY_Y = 1 << 11; - public static final int INPUT_KEY_R = 1 << 8; public static final int INPUT_KEY_L = 1 << 9; - - public static final int INPUT_KEY_START = 1 << 3; - public static final int INPUT_KEY_SELECT = 1 << 2; + public static final int INPUT_KEY_X = 1 << 10; + public static final int INPUT_KEY_Y = 1 << 11; public static final int N3DS_WIDTH = 400; public static final int N3DS_HALF_HEIGHT = 240; - public static final int N3DS_FULL_HEIGHT = 480; + public static final int N3DS_FULL_HEIGHT = N3DS_HALF_HEIGHT * 2; - public static final String EXTRA_PATH = "path"; + public static final String ACTIVITY_PARAMETER_PATH = "path"; public static final String LOG_TAG = "pandroid"; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java index ccf655bf2..0434e53f6 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java @@ -11,9 +11,8 @@ public class PathUtils { public static String getPath(final Context context, final Uri uri) { - // DocumentProvider if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) { - if (isExternalStorageDocument(uri)) { // ExternalStorageProvider + if (isExternalStorageDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; @@ -33,14 +32,12 @@ public static String getPath(final Context context, final Uri uri) { return System.getenv(storageDefinition) + "/" + split[1]; } - } else if (isDownloadsDocument(uri)) { // DownloadsProvider - + } else if (isDownloadsDocument(uri)) { final String id = DocumentsContract.getDocumentId(uri); final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); - - } else if (isMediaDocument(uri)) { // MediaProvider + } else if (isMediaDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; @@ -56,18 +53,13 @@ public static String getPath(final Context context, final Uri uri) { final String selection = "_id=?"; final String[] selectionArgs = new String[] {split[1]}; - return getDataColumn(context, contentUri, selection, selectionArgs); } - } else if ("content".equalsIgnoreCase(uri.getScheme())) { // MediaStore (and general) - - // Return the remote address + } else if ("content".equalsIgnoreCase(uri.getScheme())) { if (isGooglePhotosUri(uri)) return uri.getLastPathSegment(); - return getDataColumn(context, uri, null, null); - - } else if ("file".equalsIgnoreCase(uri.getScheme())) { // File + } else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } @@ -78,7 +70,6 @@ public static String getDataColumn(Context context, Uri uri, String selection, S Cursor cursor = null; final String column = "_data"; final String[] projection = {column}; - try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index 0df05e9fc..128e9b4fa 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -45,6 +45,14 @@ public void onSurfaceCreated(GL10 unused, EGLConfig config) { Log.i(Constants.LOG_TAG, glGetString(GL_EXTENSIONS)); Log.w(Constants.LOG_TAG, glGetString(GL_VERSION)); + int[] version = new int[2]; + glGetIntegerv(GL_MAJOR_VERSION, version, 0); + glGetIntegerv(GL_MINOR_VERSION, version, 1); + + if (version[0] < 3 || (version[0] == 3 && version[1] < 1)) { + Log.e(Constants.LOG_TAG, "OpenGL 3.1 or higher is required"); + } + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java index 137bd3126..4af28497e 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java @@ -79,8 +79,7 @@ private void processTouch(boolean up, float x, float y, int index) { int[] globalPosition = new int[2]; getLocationInWindow(globalPosition); - int action = TouchEvent.ACTION_MOVE; - + TouchType action = TouchType.ACTION_MOVE; if ((!activeTouchEvents.containsKey(index))) { if (up) return; ControllerNode node = null; @@ -97,13 +96,13 @@ private void processTouch(boolean up, float x, float y, int index) { } if (node != null) { activeTouchEvents.put(index, node); - action = TouchEvent.ACTION_DOWN; + action = TouchType.ACTION_DOWN; } else { return; } } - if (up) action = TouchEvent.ACTION_UP; + if (up) action = TouchType.ACTION_UP; ControllerNode node = activeTouchEvents.get(index); Vector2 pos = node.getPosition(); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java index d3b40db95..8c940414d 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java @@ -1,20 +1,16 @@ package com.panda3ds.pandroid.view.controller; public class TouchEvent { - public static final int ACTION_DOWN = 0; - public static final int ACTION_MOVE = 1; - public static final int ACTION_UP = 2; - - private final int action; + private final TouchType action; private final float x, y; public float getX() { return x; } public float getY() { return y; } - public int getAction() { return action; } + public TouchType getAction() { return action; } - public TouchEvent(float x, float y, int action) { + public TouchEvent(float x, float y, TouchType action) { this.x = x; this.y = y; this.action = action; diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchType.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchType.java new file mode 100644 index 000000000..697729158 --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchType.java @@ -0,0 +1,7 @@ +package com.panda3ds.pandroid.view.controller; + +public enum TouchType { + ACTION_DOWN, + ACTION_MOVE, + ACTION_UP +}; \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java index 4dadc22ba..83c38d483 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Button.java @@ -11,6 +11,7 @@ import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; +import com.panda3ds.pandroid.view.controller.TouchType; import com.panda3ds.pandroid.view.controller.listeners.ButtonStateListener; public class Button extends BasicControllerNode { @@ -58,8 +59,8 @@ public Vector2 getSize() { @Override public void onTouch(TouchEvent event) { - pressed = event.getAction() != TouchEvent.ACTION_UP; - setAlpha(pressed ? 0.2F : 1.0F); + pressed = event.getAction() != TouchType.ACTION_UP; + setAlpha(pressed ? 0.2f : 1.0f); if (stateListener != null) { stateListener.onButtonPressedChange(this, pressed); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java index ad3df6b12..b63e9d665 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java @@ -11,6 +11,7 @@ import com.panda3ds.pandroid.math.Vector2; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; +import com.panda3ds.pandroid.view.controller.TouchType; import com.panda3ds.pandroid.view.controller.listeners.JoystickListener; public class Joystick extends BasicControllerNode implements ControllerNode { @@ -47,20 +48,20 @@ public void onDrawForeground(Canvas canvas) { int analogIconSize = width - getPaddingLeft(); - float middleIconSize = analogIconSize / 2.0F; - float middle = width / 2.0F; + float middleIconSize = analogIconSize / 2.0f; + float middle = width / 2.0f; - float maxDistance = (middle - middleIconSize) * 0.9F; + float maxDistance = (middle - middleIconSize) * 0.9f; float tx = maxDistance * axisX; float ty = maxDistance * axisY; - float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty)); + float radius = Vector2.distance(0.0f, 0.0f, Math.abs(tx), Math.abs(ty)); radius = Math.min(maxDistance, radius); double deg = Math.atan2(ty, tx) * (180.0 / Math.PI); - float rx = (float) (radius * Math.cos(Math.PI * 2 * deg / 360.0)); - float ry = (float) (radius * Math.sin(Math.PI * 2 * deg / 360.0)); + float rx = (float) (radius * Math.cos(2 * Math.PI * deg / 360.0)); + float ry = (float) (radius * Math.sin(2 * Math.PI * deg / 360.0)); axisX = Math.max(-1.0f, Math.min(1.0f, axisX)); axisY = Math.max(-1.0f, Math.min(1.0f, axisY)); @@ -77,7 +78,7 @@ public void onDrawForeground(Canvas canvas) { } } - public Vector2 getAxis() { return new Vector2(Math.max(-1.0F, Math.min(1.0F, axisX)), Math.max(-1.0F, Math.min(1.0F, axisY))); } + public Vector2 getAxis() { return new Vector2(Math.max(-1.0f, Math.min(1.0f, axisX)), Math.max(-1.0f, Math.min(1.0f, axisY))); } public void setJoystickListener(JoystickListener joystickListener) { this.joystickListener = joystickListener; } @@ -89,7 +90,7 @@ public Vector2 getSize() { @Override public void onTouch(TouchEvent event) { - float middle = width / 2.0F; + float middle = width / 2.0f; float x = event.getX(); float y = event.getY(); @@ -101,7 +102,7 @@ public void onTouch(TouchEvent event) { axisY = ((y - middle) / middle); - if (event.getAction() == TouchEvent.ACTION_UP) { + if (event.getAction() == TouchType.ACTION_UP) { axisX = 0; axisY = 0; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java index 39e6aae98..bf51d4fe7 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/TouchScreenNodeImpl.java @@ -7,6 +7,7 @@ import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.view.controller.ControllerNode; import com.panda3ds.pandroid.view.controller.TouchEvent; +import com.panda3ds.pandroid.view.controller.TouchType; import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; public interface TouchScreenNodeImpl extends ControllerNode { @@ -28,7 +29,7 @@ default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) { view.setTag(R.id.TagEventHasDown, true); } - if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP) { + if (hasDownEvent && event.getAction() == TouchType.ACTION_UP) { AlberDriver.TouchScreenUp(); view.setTag(R.id.TagEventHasDown, false); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java index adfe54436..a726b2e68 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/renderer/layout/DefaultScreenLayout.java @@ -8,9 +8,9 @@ public class DefaultScreenLayout implements ConsoleLayout { private final Rect topDisplay = new Rect(); private final Rect bottomDisplay = new Rect(); - private final Vector2 screenSize = new Vector2(1.0F, 1.0F); - private final Vector2 topSourceSize = new Vector2(1.0F, 1.0F); - private final Vector2 bottomSourceSize = new Vector2(1.0F, 1.0F); + private final Vector2 screenSize = new Vector2(1.0f, 1.0f); + private final Vector2 topSourceSize = new Vector2(1.0f, 1.0f); + private final Vector2 bottomSourceSize = new Vector2(1.0f, 1.0f); @Override public void update(int screenWidth, int screenHeight) { From e6880b15641f4fae33880e407ac77289fb041f58 Mon Sep 17 00:00:00 2001 From: offtkp Date: Fri, 8 Dec 2023 03:28:43 +0200 Subject: [PATCH 14/15] Even more peach stuff --- src/jni_driver.cpp | 11 ++++++++--- .../java/com/panda3ds/pandroid/utils/Constants.java | 4 ++-- .../com/panda3ds/pandroid/view/PandaGlRenderer.java | 3 +++ .../panda3ds/pandroid/view/PandaGlSurfaceView.java | 5 ++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/jni_driver.cpp b/src/jni_driver.cpp index 82720e2a6..770e16da7 100644 --- a/src/jni_driver.cpp +++ b/src/jni_driver.cpp @@ -15,19 +15,24 @@ bool romLoaded = false; #define AlberFunction(type, name) JNIEXPORT type JNICALL Java_com_panda3ds_pandroid_AlberDriver_##name +void throwException(JNIEnv* env, const char* message) { + jclass exceptionClass = env->FindClass("java/lang/RuntimeException"); + env->ThrowNew(exceptionClass, message); +} + extern "C" { AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) { emulator = std::make_unique(); if (emulator->getRendererType() != RendererType::OpenGL) { - throw std::runtime_error("Renderer is not OpenGL"); + return throwException(env, "Renderer type is not OpenGL"); } renderer = static_cast(emulator->getRenderer()); hidService = &emulator->getServiceManager().getHID(); if (!gladLoadGLES2Loader(reinterpret_cast(eglGetProcAddress))) { - throw std::runtime_error("OpenGL ES init failed"); + return throwException(env, "Failed to load OpenGL ES 2.0"); } __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES %d.%d", GLVersion.major, GLVersion.minor); @@ -36,6 +41,7 @@ AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) { AlberFunction(void, RunFrame)(JNIEnv* env, jobject obj, jint fbo) { renderer->setFBO(fbo); + // TODO: don't reset entire state manager renderer->resetStateManager(); emulator->runFrame(); @@ -53,7 +59,6 @@ AlberFunction(jboolean, HasRomLoaded)(JNIEnv* env, jobject obj) { return romLoad AlberFunction(void, LoadRom)(JNIEnv* env, jobject obj, jstring path) { const char* pathStr = env->GetStringUTFChars(path, nullptr); romLoaded = emulator->loadROM(pathStr); - __android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s, result: %d", pathStr, (int)romLoaded); env->ReleaseStringUTFChars(path, pathStr); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index 6b480c239..d94164c71 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -15,8 +15,8 @@ public class Constants { public static final int INPUT_KEY_Y = 1 << 11; public static final int N3DS_WIDTH = 400; - public static final int N3DS_HALF_HEIGHT = 240; - public static final int N3DS_FULL_HEIGHT = N3DS_HALF_HEIGHT * 2; + public static final int N3DS_FULL_HEIGHT = 480; + public static final int N3DS_HALF_HEIGHT = N3DS_FULL_HEIGHT / 2; public static final String ACTIVITY_PARAMETER_PATH = "path"; public static final String LOG_TAG = "pandroid"; diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index 128e9b4fa..8dd350ced 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -69,6 +69,9 @@ public void onSurfaceCreated(GL10 unused, EGLConfig config) { screenFbo = generateBuffer[0]; glBindFramebuffer(GL_FRAMEBUFFER, screenFbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, screenTexture, 0); + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + Log.e(Constants.LOG_TAG, "Framebuffer is not complete"); + } glBindFramebuffer(GL_FRAMEBUFFER, 0); AlberDriver.Initialize(); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java index eb65762d5..c813294c7 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java @@ -2,6 +2,7 @@ import android.content.Context; import android.opengl.GLSurfaceView; +import android.os.Debug; import androidx.annotation.NonNull; import com.panda3ds.pandroid.math.Vector2; @@ -17,7 +18,9 @@ public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNode public PandaGlSurfaceView(Context context, String romPath) { super(context); setEGLContextClientVersion(3); - setDebugFlags(DEBUG_LOG_GL_CALLS); + if (Debug.isDebuggerConnected()) { + setDebugFlags(DEBUG_LOG_GL_CALLS); + } renderer = new PandaGlRenderer(romPath); setRenderer(renderer); } From 63a09dd51fb88013ef71612e7e01e78b415495f6 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:47:32 +0200 Subject: [PATCH 15/15] Android bonk --- src/jni_driver.cpp | 3 --- .../src/main/java/com/panda3ds/pandroid/app/GameActivity.java | 3 --- .../src/main/java/com/panda3ds/pandroid/app/MainActivity.java | 1 - .../src/main/java/com/panda3ds/pandroid/utils/PathUtils.java | 3 --- .../com/panda3ds/pandroid/view/PandaLayoutController.java | 2 -- .../panda3ds/pandroid/view/controller/ControllerLayout.java | 4 +--- .../com/panda3ds/pandroid/view/controller/ControllerNode.java | 1 - .../com/panda3ds/pandroid/view/controller/TouchEvent.java | 2 -- .../pandroid/view/controller/nodes/BasicControllerNode.java | 2 -- .../com/panda3ds/pandroid/view/controller/nodes/Joystick.java | 3 --- 10 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/jni_driver.cpp b/src/jni_driver.cpp index 770e16da7..8f5c352ed 100644 --- a/src/jni_driver.cpp +++ b/src/jni_driver.cpp @@ -63,11 +63,8 @@ AlberFunction(void, LoadRom)(JNIEnv* env, jobject obj, jstring path) { } AlberFunction(void, TouchScreenDown)(JNIEnv* env, jobject obj, jint x, jint y) { hidService->setTouchScreenPress((u16)x, (u16)y); } - AlberFunction(void, TouchScreenUp)(JNIEnv* env, jobject obj) { hidService->releaseTouchScreen(); } - AlberFunction(void, KeyUp)(JNIEnv* env, jobject obj, jint keyCode) { hidService->releaseKey((u32)keyCode); } - AlberFunction(void, KeyDown)(JNIEnv* env, jobject obj, jint keyCode) { hidService->pressKey((u32)keyCode); } AlberFunction(void, SetCirclepadAxis)(JNIEnv* env, jobject obj, jint x, jint y) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index dfba96e5f..2da73b972 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -17,7 +17,6 @@ import com.panda3ds.pandroid.view.PandaLayoutController; public class GameActivity extends BaseActivity { - @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -31,14 +30,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } PandaGlSurfaceView pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.ACTIVITY_PARAMETER_PATH)); - setContentView(R.layout.game_activity); ((FrameLayout) findViewById(R.id.panda_gl_frame)) .addView(pandaSurface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); PandaLayoutController controllerLayout = findViewById(R.id.controller_layout); - controllerLayout.initialize(); ((CheckBox) findViewById(R.id.hide_screen_controller)).setOnCheckedChangeListener((buttonView, isChecked) -> findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE)); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java index 368efe0e9..f4fc27bf1 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java @@ -40,7 +40,6 @@ protected void onCreate(Bundle savedInstanceState) { } setContentView(R.layout.activity_main); - findViewById(R.id.load_rom).setOnClickListener(v -> { openFile(); }); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java index 0434e53f6..9bfaa0e4a 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/PathUtils.java @@ -83,10 +83,7 @@ public static String getDataColumn(Context context, Uri uri, String selection, S } public static boolean isExternalStorageDocument(Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); } - public static boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); } - public static boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); } - public static boolean isGooglePhotosUri(Uri uri) { return "com.google.android.apps.photos.content".equals(uri.getAuthority()); } } \ No newline at end of file diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java index 543ab840d..617b407e9 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaLayoutController.java @@ -11,9 +11,7 @@ public class PandaLayoutController extends ControllerLayout { public PandaLayoutController(Context context) { super(context); } - public PandaLayoutController(Context context, AttributeSet attrs) { super(context, attrs); } - public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java index 4af28497e..32451bc76 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerLayout.java @@ -19,9 +19,7 @@ public class ControllerLayout extends RelativeLayout { private final ArrayList controllerNodes = new ArrayList<>(); public ControllerLayout(Context context) { this(context, null); } - public ControllerLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } - public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { @@ -131,7 +129,7 @@ public void onViewRemoved(View child) { refreshChildren(); } - /*@TODO: Need replace that methods for prevent Android send events directly to children*/ + // TODO: Need to replace these methods to prevent Android sending events directly to children @Override public ArrayList getTouchables() { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java index e6c1dc92b..7d45550a9 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/ControllerNode.java @@ -17,6 +17,5 @@ default Vector2 getPosition() { default boolean isVisible() { return ((View) this).isShown(); } @NonNull Vector2 getSize(); - void onTouch(TouchEvent event); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java index 8c940414d..6b82d2019 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/TouchEvent.java @@ -5,9 +5,7 @@ public class TouchEvent { private final float x, y; public float getX() { return x; } - public float getY() { return y; } - public TouchType getAction() { return action; } public TouchEvent(float x, float y, TouchType action) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java index 224be9a41..d196c7ecd 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/BasicControllerNode.java @@ -9,8 +9,6 @@ public abstract class BasicControllerNode extends AppCompatTextView implements ControllerNode { public BasicControllerNode(@NonNull Context context) { super(context); } - public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); } - public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java index b63e9d665..cf33afb6f 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/nodes/Joystick.java @@ -20,11 +20,9 @@ public class Joystick extends BasicControllerNode implements ControllerNode { private int width = 0; private int height = 0; - private JoystickListener joystickListener; public Joystick(Context context) { this(context, null); } - public Joystick(Context context, AttributeSet attrs) { this(context, attrs, 0); } public Joystick(Context context, AttributeSet attrs, int defStyleAttr) { @@ -99,7 +97,6 @@ public void onTouch(TouchEvent event) { y = Math.max(0, Math.min(middle * 2, y)); axisX = ((x - middle) / middle); - axisY = ((y - middle) / middle); if (event.getAction() == TouchType.ACTION_UP) {