89
.github/workflows/Android_Build.yml
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
name: Android Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
x64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Fetch submodules
|
||||||
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
|
- name: Setup Vulkan SDK
|
||||||
|
uses: humbletim/setup-vulkan-sdk@v1.2.0
|
||||||
|
with:
|
||||||
|
vulkan-query-version: latest
|
||||||
|
vulkan-use-cache: true
|
||||||
|
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Tools, Glslang
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'zulu' # See 'Supported distributions' for available options
|
||||||
|
java-version: '17'
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86_64 -DENABLE_VULKAN=0
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/x86_64/
|
||||||
|
cd src/pandroid
|
||||||
|
./gradlew assembleDebug
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
- name: Upload executable
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Android APK (x86-64)
|
||||||
|
path: './src/pandroid/app/build/outputs/apk/debug/app-debug.apk'
|
||||||
|
|
||||||
|
arm64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Fetch submodules
|
||||||
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
|
- name: Setup Vulkan SDK
|
||||||
|
uses: humbletim/setup-vulkan-sdk@v1.2.0
|
||||||
|
with:
|
||||||
|
vulkan-query-version: latest
|
||||||
|
vulkan-use-cache: true
|
||||||
|
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Tools, Glslang
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'zulu' # See 'Supported distributions' for available options
|
||||||
|
java-version: '17'
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DENABLE_VULKAN=0 -DCMAKE_CXX_FLAGS="-march=armv8.1-a+crypto"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/arm64-v8a/
|
||||||
|
cd src/pandroid
|
||||||
|
./gradlew assembleDebug
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
- name: Upload executable
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Android APK (arm64)
|
||||||
|
path: './src/pandroid/app/build/outputs/apk/debug/app-debug.apk'
|
||||||
|
|
|
@ -184,6 +184,7 @@ 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)
|
set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp)
|
||||||
|
|
||||||
# Frontend source files
|
# Frontend source files
|
||||||
|
if(NOT ANDROID)
|
||||||
if(ENABLE_QT_GUI)
|
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_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)
|
set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp)
|
||||||
|
@ -195,6 +196,7 @@ else()
|
||||||
set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp)
|
set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp)
|
||||||
set(FRONTEND_HEADER_FILES "")
|
set(FRONTEND_HEADER_FILES "")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
||||||
include/cpu.hpp include/cpu_dynarmic.hpp include/memory.hpp include/renderer.hpp include/kernel/kernel.hpp
|
include/cpu.hpp include/cpu_dynarmic.hpp include/memory.hpp include/renderer.hpp include/kernel/kernel.hpp
|
||||||
|
@ -378,6 +380,10 @@ if(ENABLE_VULKAN)
|
||||||
set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_VK_SOURCE_FILES})
|
set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_VK_SOURCE_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ANDROID)
|
||||||
|
set(ALL_SOURCES ${ALL_SOURCES} src/jni_driver.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BUILD_HYDRA_CORE)
|
if(BUILD_HYDRA_CORE)
|
||||||
include_directories(third_party/hydra_core/include)
|
include_directories(third_party/hydra_core/include)
|
||||||
add_library(Alber SHARED ${ALL_SOURCES} src/hydra_core.cpp)
|
add_library(Alber SHARED ${ALL_SOURCES} src/hydra_core.cpp)
|
||||||
|
@ -386,11 +392,19 @@ else()
|
||||||
add_executable(Alber ${ALL_SOURCES})
|
add_executable(Alber ${ALL_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ANDROID)
|
||||||
|
target_link_libraries(Alber PRIVATE EGL log)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LTO OR ENABLE_USER_BUILD)
|
if(ENABLE_LTO OR ENABLE_USER_BUILD)
|
||||||
set_target_properties(Alber PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
set_target_properties(Alber PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
endif()
|
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)
|
if(ENABLE_DISCORD_RPC AND NOT ANDROID)
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_DISCORD_RPC=1")
|
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_DISCORD_RPC=1")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "emulator.hpp"
|
#include "emulator.hpp"
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
#include <SDL_filesystem.h>
|
#include <SDL_filesystem.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
76
src/jni_driver.cpp
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "emulator.hpp"
|
||||||
|
#include "renderer_gl/renderer_gl.hpp"
|
||||||
|
#include "services/hid.hpp"
|
||||||
|
|
||||||
|
std::unique_ptr<Emulator> emulator = nullptr;
|
||||||
|
HIDService* hidService = nullptr;
|
||||||
|
RendererGL* renderer = nullptr;
|
||||||
|
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<Emulator>();
|
||||||
|
|
||||||
|
if (emulator->getRendererType() != RendererType::OpenGL) {
|
||||||
|
return throwException(env, "Renderer type is not OpenGL");
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer = static_cast<RendererGL*>(emulator->getRenderer());
|
||||||
|
hidService = &emulator->getServiceManager().getHID();
|
||||||
|
|
||||||
|
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(eglGetProcAddress))) {
|
||||||
|
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);
|
||||||
|
emulator->initGraphicsContext(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
AlberFunction(void, RunFrame)(JNIEnv* env, jobject obj, jint fbo) {
|
||||||
|
renderer->setFBO(fbo);
|
||||||
|
// TODO: don't reset entire state manager
|
||||||
|
renderer->resetStateManager();
|
||||||
|
emulator->runFrame();
|
||||||
|
|
||||||
|
hidService->updateInputs(emulator->getTicks());
|
||||||
|
}
|
||||||
|
|
||||||
|
AlberFunction(void, Finalize)(JNIEnv* env, jobject obj) {
|
||||||
|
emulator = nullptr;
|
||||||
|
hidService = nullptr;
|
||||||
|
renderer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlberFunction(jboolean, HasRomLoaded)(JNIEnv* env, jobject obj) { return romLoaded; }
|
||||||
|
|
||||||
|
AlberFunction(void, LoadRom)(JNIEnv* env, jobject obj, jstring path) {
|
||||||
|
const char* pathStr = env->GetStringUTFChars(path, nullptr);
|
||||||
|
romLoaded = emulator->loadROM(pathStr);
|
||||||
|
env->ReleaseStringUTFChars(path, pathStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
hidService->setCirclepadX((s16)x);
|
||||||
|
hidService->setCirclepadY((s16)y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef AlberFunction
|
15
src/pandroid/.gitignore
vendored
Normal file
|
@ -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
|
42
src/pandroid/app/build.gradle.kts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
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")
|
||||||
|
}
|
21
src/pandroid/app/proguard-rules.pro
vendored
Normal file
|
@ -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
|
37
src/pandroid/app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage"/>
|
||||||
|
|
||||||
|
<uses-feature
|
||||||
|
android:required="true"
|
||||||
|
android:glEsVersion="0x0030001"/>
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:requestLegacyExternalStorage="true"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.Pandroid"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".app.MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".app.GameActivity"
|
||||||
|
android:configChanges="screenSize|screenLayout|orientation|density|uiMode">
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.panda3ds.pandroid;
|
||||||
|
|
||||||
|
public class AlberDriver {
|
||||||
|
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 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"); }
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.panda3ds.pandroid.app;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class BaseActivity extends AppCompatActivity {}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.panda3ds.pandroid.app;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
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 {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
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.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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
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;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
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_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_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_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.ACTIVITY_PARAMETER_PATH, path));
|
||||||
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.panda3ds.pandroid.math;
|
||||||
|
|
||||||
|
public class Vector2 {
|
||||||
|
public float x, y;
|
||||||
|
public Vector2(float x, float y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = 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) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +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_R = 1 << 8;
|
||||||
|
public static final int INPUT_KEY_L = 1 << 9;
|
||||||
|
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_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";
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.panda3ds.pandroid.utils;
|
||||||
|
|
||||||
|
import android.content.ContentUris;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
|
||||||
|
public class PathUtils {
|
||||||
|
public static String getPath(final Context context, final Uri uri) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) {
|
||||||
|
if (isExternalStorageDocument(uri)) {
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
String storageDefinition;
|
||||||
|
|
||||||
|
if ("primary".equalsIgnoreCase(type)) {
|
||||||
|
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (Environment.isExternalStorageRemovable()) {
|
||||||
|
storageDefinition = "EXTERNAL_STORAGE";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
storageDefinition = "SECONDARY_STORAGE";
|
||||||
|
}
|
||||||
|
|
||||||
|
return System.getenv(storageDefinition) + "/" + split[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
} 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)) {
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String selection = "_id=?";
|
||||||
|
final String[] selectionArgs = new String[] {split[1]};
|
||||||
|
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
if (isGooglePhotosUri(uri)) return uri.getLastPathSegment();
|
||||||
|
return getDataColumn(context, uri, null, null);
|
||||||
|
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
return uri.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
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()); }
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package com.panda3ds.pandroid.view;
|
||||||
|
|
||||||
|
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.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(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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
|
Log.e(Constants.LOG_TAG, "Framebuffer is not complete");
|
||||||
|
}
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.panda3ds.pandroid.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
|
import android.os.Debug;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import com.panda3ds.pandroid.math.Vector2;
|
||||||
|
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 width;
|
||||||
|
private int height;
|
||||||
|
|
||||||
|
public PandaGlSurfaceView(Context context, String romPath) {
|
||||||
|
super(context);
|
||||||
|
setEGLContextClientVersion(3);
|
||||||
|
if (Debug.isDebuggerConnected()) {
|
||||||
|
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);
|
||||||
|
width = getMeasuredWidth();
|
||||||
|
height = getMeasuredHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Vector2 getSize() {
|
||||||
|
return new Vector2(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouch(TouchEvent event) {
|
||||||
|
onTouchScreenPress(renderer, event);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.panda3ds.pandroid.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import com.panda3ds.pandroid.AlberDriver;
|
||||||
|
import com.panda3ds.pandroid.R;
|
||||||
|
import com.panda3ds.pandroid.utils.Constants;
|
||||||
|
import com.panda3ds.pandroid.view.controller.ControllerLayout;
|
||||||
|
import com.panda3ds.pandroid.view.controller.nodes.Button;
|
||||||
|
import com.panda3ds.pandroid.view.controller.nodes.Joystick;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
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,
|
||||||
|
|
||||||
|
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_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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
((Joystick) findViewById(R.id.left_analog)).setJoystickListener((joystick, axisX, axisY) -> {
|
||||||
|
AlberDriver.SetCirclepadAxis((int) (axisX * 0x9C), (int) (axisY * 0x9C) * -1);
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshChildren();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
private final HashMap<Integer, ControllerNode> activeTouchEvents = new HashMap<>();
|
||||||
|
private final ArrayList<ControllerNode> 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<ControllerNode> 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<ControllerNode> 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);
|
||||||
|
|
||||||
|
TouchType action = TouchType.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 = TouchType.ACTION_DOWN;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (up) action = TouchType.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 to replace these methods to prevent Android sending events directly to children
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<View> getTouchables() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
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 view = (View) this;
|
||||||
|
|
||||||
|
int[] position = new int[2];
|
||||||
|
view.getLocationInWindow(position);
|
||||||
|
return new Vector2(position[0], position[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
default boolean isVisible() { return ((View) this).isShown(); }
|
||||||
|
|
||||||
|
@NonNull Vector2 getSize();
|
||||||
|
void onTouch(TouchEvent event);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller;
|
||||||
|
|
||||||
|
public class TouchEvent {
|
||||||
|
private final TouchType action;
|
||||||
|
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) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller;
|
||||||
|
|
||||||
|
public enum TouchType {
|
||||||
|
ACTION_DOWN,
|
||||||
|
ACTION_MOVE,
|
||||||
|
ACTION_UP
|
||||||
|
};
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller.listeners;
|
||||||
|
|
||||||
|
import com.panda3ds.pandroid.view.controller.nodes.Button;
|
||||||
|
|
||||||
|
public interface ButtonStateListener {
|
||||||
|
void onButtonPressedChange(Button button, boolean pressed);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller.listeners;
|
||||||
|
|
||||||
|
import com.panda3ds.pandroid.view.controller.nodes.Joystick;
|
||||||
|
|
||||||
|
public interface JoystickListener {
|
||||||
|
void onJoystickAxisChange(Joystick joystick, float axisX, float axisY);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller.nodes;
|
||||||
|
|
||||||
|
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, @Nullable AttributeSet attrs) { super(context, attrs); }
|
||||||
|
public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller.nodes;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
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.TouchType;
|
||||||
|
import com.panda3ds.pandroid.view.controller.listeners.ButtonStateListener;
|
||||||
|
|
||||||
|
public class Button extends BasicControllerNode {
|
||||||
|
private boolean pressed = false;
|
||||||
|
private int width, height;
|
||||||
|
|
||||||
|
private ButtonStateListener stateListener;
|
||||||
|
|
||||||
|
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, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
width = getWidth();
|
||||||
|
height = getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setTextAlignment(TEXT_ALIGNMENT_CENTER);
|
||||||
|
setGravity(Gravity.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStateListener(ButtonStateListener stateListener) { this.stateListener = stateListener; }
|
||||||
|
|
||||||
|
public boolean isPressed() { return pressed; }
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Vector2 getSize() {
|
||||||
|
return new Vector2(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouch(TouchEvent event) {
|
||||||
|
pressed = event.getAction() != TouchType.ACTION_UP;
|
||||||
|
setAlpha(pressed ? 0.2f : 1.0f);
|
||||||
|
if (stateListener != null) {
|
||||||
|
stateListener.onButtonPressedChange(this, pressed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller.nodes;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
private float axisX = 0;
|
||||||
|
private float axisY = 0;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
|
paint.setColor(Color.RED);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Paint paint = new Paint();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawForeground(Canvas canvas) {
|
||||||
|
width = getWidth();
|
||||||
|
height = getHeight();
|
||||||
|
|
||||||
|
int analogIconSize = width - getPaddingLeft();
|
||||||
|
|
||||||
|
float middleIconSize = analogIconSize / 2.0f;
|
||||||
|
float middle = width / 2.0f;
|
||||||
|
|
||||||
|
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));
|
||||||
|
radius = Math.min(maxDistance, radius);
|
||||||
|
|
||||||
|
double deg = Math.atan2(ty, tx) * (180.0 / Math.PI);
|
||||||
|
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));
|
||||||
|
|
||||||
|
float x = middle - middleIconSize + rx;
|
||||||
|
float y = middle - middleIconSize + ry;
|
||||||
|
|
||||||
|
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 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(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouch(TouchEvent event) {
|
||||||
|
float middle = width / 2.0f;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
axisX = ((x - middle) / middle);
|
||||||
|
axisY = ((y - middle) / middle);
|
||||||
|
|
||||||
|
if (event.getAction() == TouchType.ACTION_UP) {
|
||||||
|
axisX = 0;
|
||||||
|
axisY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (joystickListener != null) {
|
||||||
|
joystickListener.onJoystickAxisChange(this, axisX, axisY);
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.panda3ds.pandroid.view.controller.nodes;
|
||||||
|
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.panda3ds.pandroid.AlberDriver;
|
||||||
|
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 {
|
||||||
|
default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) {
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
|
||||||
|
view.setTag(R.id.TagEventHasDown, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasDownEvent && event.getAction() == TouchType.ACTION_UP) {
|
||||||
|
AlberDriver.TouchScreenUp();
|
||||||
|
view.setTag(R.id.TagEventHasDown, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.panda3ds.pandroid.view.renderer.layout;
|
||||||
|
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.panda3ds.pandroid.view.renderer.layout;
|
||||||
|
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
2
src/pandroid/app/src/main/jniLibs/.gitignore
vendored
Normal file
|
@ -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
|
0
src/pandroid/app/src/main/jniLibs/arm64-v8a/.gitkeep
Normal file
0
src/pandroid/app/src/main/jniLibs/x86_64/.gitkeep
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,30 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/screen_gamepad_show" android:state_checked="false"/>
|
||||||
|
<item android:drawable="@drawable/screen_gamepad_hide" android:state_checked="true"/>
|
||||||
|
</selector>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#FFF"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:width="24dp"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FFF" android:pathData="M21.19,21.19L2.81,2.81L1.39,4.22L3.3,6.13C2.54,6.41 2,7.15 2,8v8c0,1.1 0.9,2 2,2h11.17l4.61,4.61L21.19,21.19zM9,13v2H7v-2H5v-2h2V9.83L10.17,13H9zM20.7,17.87C21.46,17.59 22,16.85 22,16V8c0,-1.1 -0.9,-2 -2,-2H8.83L20.7,17.87zM17.5,9c0.83,0 1.5,0.67 1.5,1.5S18.33,12 17.5,12S16,11.33 16,10.5S16.67,9 17.5,9z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#FFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FFF" android:pathData="M21,6L3,6c-1.1,0 -2,0.9 -2,2v8c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.1 -0.9,-2 -2,-2zM11,13L8,13v3L6,16v-3L3,13v-2h3L6,8h2v3h3v2zM15.5,15c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM19.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S18.67,9 19.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<padding
|
||||||
|
android:left="10dp"
|
||||||
|
android:top="10dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:bottom="10dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#0000"/>
|
||||||
|
<stroke android:color="#6FFF" android:width="1dp"/>
|
||||||
|
<corners android:radius="999dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#5FFF"/>
|
||||||
|
<stroke android:color="#6FFF" android:width="1dp"/>
|
||||||
|
<corners android:topLeftRadius="8dp" android:topRightRadius="8dp"
|
||||||
|
android:bottomLeftRadius="8dp"
|
||||||
|
android:bottomRightRadius="8dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#5FFF"/>
|
||||||
|
<stroke android:color="#6FFF" android:width="1dp"/>
|
||||||
|
<corners android:topLeftRadius="8dp" android:topRightRadius="8dp"
|
||||||
|
android:bottomLeftRadius="8dp"
|
||||||
|
android:bottomRightRadius="16dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#5FFF"/>
|
||||||
|
<stroke android:color="#6FFF" android:width="1dp"/>
|
||||||
|
<corners android:topLeftRadius="8dp" android:topRightRadius="8dp"
|
||||||
|
android:bottomLeftRadius="16dp"
|
||||||
|
android:bottomRightRadius="8dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#5FFF"/>
|
||||||
|
<stroke android:color="#6FFF" android:width="1dp"/>
|
||||||
|
<corners android:radius="999dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
22
src/pandroid/app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".app.MainActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="bottom|end"
|
||||||
|
android:padding="17dp">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/load_rom"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:text="@string/load_rom"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
28
src/pandroid/app/src/main/res/layout/controller_dpad.xml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="96dp"
|
||||||
|
android:layout_height="96dp">
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_up"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginLeft="30dp"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_left"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginTop="30dp"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_down"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginTop="60dp"
|
||||||
|
android:layout_marginLeft="30dp"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_right"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_marginLeft="60dp"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
32
src/pandroid/app/src/main/res/layout/controller_gamepad.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="96dp"
|
||||||
|
android:layout_height="96dp">
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_x"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:text="X"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_y"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:text="Y"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_b"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginTop="60dp"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:text="B"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_a"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_marginLeft="60dp"
|
||||||
|
android:text="A"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
132
src/pandroid/app/src/main/res/layout/game_activity.xml
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#000">
|
||||||
|
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.PandaLayoutController
|
||||||
|
android:id="@+id/controller_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/panda_gl_frame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/overlay_controller"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="bottom"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_l"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_gravity="left"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:background="@drawable/simple_card_button_left"
|
||||||
|
android:text="L"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_r"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:background="@drawable/simple_card_button_right"
|
||||||
|
android:text="R"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="60dp">
|
||||||
|
|
||||||
|
<include layout="@layout/controller_dpad"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Joystick
|
||||||
|
android:id="@+id/left_analog"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:background="@drawable/simple_analog_background"
|
||||||
|
android:foreground="@drawable/simple_circle_button"
|
||||||
|
android:padding="40dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end|bottom"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<include layout="@layout/controller_gamepad"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|center">
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_start"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/simple_card_button"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:text="START"/>
|
||||||
|
|
||||||
|
<com.panda3ds.pandroid.view.controller.nodes.Button
|
||||||
|
android:id="@+id/button_select"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/simple_card_button"
|
||||||
|
style="@style/ControllerSimpleButton"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:text="SELECT"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</com.panda3ds.pandroid.view.PandaLayoutController>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="25dp">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/hide_screen_controller"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:checked="true"
|
||||||
|
android:button="@drawable/screen_gamepad_checkbox"
|
||||||
|
android:layout_gravity="bottom|right"
|
||||||
|
android:buttonTint="#FFF"
|
||||||
|
android:alpha="0.4"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
BIN
src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
src/pandroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/pandroid/app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 982 B |
BIN
src/pandroid/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/pandroid/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
BIN
src/pandroid/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
BIN
src/pandroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
7
src/pandroid/app/src/main/res/values-night/themes.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Base.Theme.Pandroid" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your dark theme here. -->
|
||||||
|
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
5
src/pandroid/app/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
4
src/pandroid/app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">pandroid</string>
|
||||||
|
<string name="load_rom">Load ROM</string>
|
||||||
|
</resources>
|
10
src/pandroid/app/src/main/res/values/styleable.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="ControllerSimpleButton">
|
||||||
|
<item name="android:layout_height">32dp</item>
|
||||||
|
<item name="android:layout_width">32dp</item>
|
||||||
|
<item name="android:textColor">#FFF</item>
|
||||||
|
<item name="textAllCaps">true</item>
|
||||||
|
<item name="android:background">@drawable/simple_circle_button</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
9
src/pandroid/app/src/main/res/values/themes.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Base.Theme.Pandroid" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your light theme here. -->
|
||||||
|
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Pandroid" parent="Base.Theme.Pandroid" />
|
||||||
|
</resources>
|
4
src/pandroid/app/src/main/res/values/values.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<item name="TagEventHasDown" type="id"/>
|
||||||
|
</resources>
|
13
src/pandroid/app/src/main/res/xml/backup_rules.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older that API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
19
src/pandroid/app/src/main/res/xml/data_extraction_rules.xml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
4
src/pandroid/build.gradle.kts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
id("com.android.application") version "8.1.2" apply false
|
||||||
|
}
|
21
src/pandroid/gradle.properties
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
|
# thereby reducing the size of the R class for that library
|
||||||
|
android.nonTransitiveRClass=true
|
BIN
src/pandroid/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
src/pandroid/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Tue Nov 14 14:40:27 EET 2023
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
185
src/pandroid/gradlew
vendored
Executable file
|
@ -0,0 +1,185 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
89
src/pandroid/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
17
src/pandroid/settings.gradle.kts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "pandroid"
|
||||||
|
include(":app")
|