# HG changeset patch # User Michael Pavone # Date 1742977255 25200 # Node ID c4256ce2c45a926796b0a32a7736305509abebde # Parent e3394457427ea5342acb485dab409275517f5dfb Updated Android port using gradle toolchain and with basic Storage Access Framework support for Android 11+ support diff -r e3394457427e -r c4256ce2c45a .hgignore --- a/.hgignore Wed Mar 26 01:20:09 2025 -0700 +++ b/.hgignore Wed Mar 26 01:20:55 2025 -0700 @@ -21,12 +21,15 @@ ztests glew/* lib/* -android/obj -android/bin -android/gen -android/libs +obj/* +z80.c +z80.h +m68k.c +m68k.h +android/.gradle +android/app/build +android/app/jni/SDL android/local.properties -android/jni/SDL sdl *.o *.list diff -r e3394457427e -r c4256ce2c45a Android.mk --- a/Android.mk Wed Mar 26 01:20:09 2025 -0700 +++ b/Android.mk Wed Mar 26 01:20:55 2025 -0700 @@ -4,25 +4,28 @@ LOCAL_MODULE := main -SDL_PATH := android/jni/SDL +SDL_PATH := android/app/jni/SDL LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include -LOCAL_CFLAGS += -std=gnu99 -DX86_32 -DUSE_GLES +LOCAL_CFLAGS += -std=gnu99 -DNEW_CORE -DUSE_GLES # Add your application source files here... -LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ - 68kinst.c debug.c gst.c psg.c z80_to_x86.c backend.c io.c render_sdl.c \ - tern.c backend_x86.c gdb_remote.c m68k_core.c romdb.c m68k_core_x86.c \ - util.c wave.c blastem.c gen.c mem.c vdp.c ym2612.c config.c gen_x86.c \ - terminal.c z80inst.c menu.c arena.c zlib/adler32.c zlib/compress.c \ - zlib/crc32.c zlib/deflate.c zlib/gzclose.c zlib/gzlib.c zlib/gzread.c \ - zlib/gzwrite.c zlib/infback.c zlib/inffast.c zlib/inflate.c \ - zlib/inftrees.c zlib/trees.c zlib/uncompr.c zlib/zutil.c \ - nuklear_ui/font_android.c nuklear_ui/blastem_nuklear.c nuklear_ui/sfnt.c \ - ppm.c controller_info.c png.c system.c genesis.c sms.c serialize.c \ - saves.c hash.c xband.c zip.c bindings.c jcart.c paths.c megawifi.c \ - nor.c i2c.c sega_mapper.c realtec.c multi_game.c net.c +LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c 68kinst.c \ + debug.c gst.c psg.c z80.c backend.c io.c render_sdl.c tern.c gdb_remote.c \ + m68k.c romdb.c util.c wave.c flac.c blastem.c gen.c mem.c vdp.c ym2612.c \ + ymf262.c ym_common.c vgm.c event_log.c render_audio.c config.c terminal.c \ + z80inst.c menu.c arena.c zlib/adler32.c zlib/compress.c zlib/crc32.c \ + zlib/deflate.c zlib/gzclose.c zlib/gzlib.c zlib/gzread.c zlib/gzwrite.c \ + zlib/infback.c zlib/inffast.c zlib/inflate.c zlib/inftrees.c zlib/trees.c \ + zlib/uncompr.c zlib/zutil.c nuklear_ui/font_android.c \ + nuklear_ui/filechooser_null.c nuklear_ui/blastem_nuklear.c \ + nuklear_ui/sfnt.c ppm.c controller_info.c png.c system.c genesis.c sms.c \ + serialize.c saves.c hash.c xband.c zip.c bindings.c jcart.c paths.c \ + megawifi.c nor.c i2c.c sega_mapper.c realtec.c multi_game.c net.c coleco.c \ + pico_pcm.c ymz263b.c segacd.c lc8951.c cdimage.c cdd_mcu.c cd_graphics.c \ + cdd_fader.c rf5c164.c sft_mapper.c mediaplayer.c oscilloscope.c disasm.c \ + i8255.c gen_player.c LOCAL_SHARED_LIBRARIES := SDL2 diff -r e3394457427e -r c4256ce2c45a android/AndroidManifest.xml --- a/android/AndroidManifest.xml Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r e3394457427e -r c4256ce2c45a android/ant.properties --- a/android/ant.properties Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff -r e3394457427e -r c4256ce2c45a android/app/build.gradle --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/build.gradle Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,75 @@ +def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY'); +def buildAsApplication = !buildAsLibrary +if (buildAsApplication) { + apply plugin: 'com.android.application' +} +else { + apply plugin: 'com.android.library' +} + +android { + if (buildAsApplication) { + namespace "com.retrodev.blastem" + } + compileSdkVersion 35 + defaultConfig { + minSdkVersion 19 + targetSdkVersion 35 + versionCode 1 + versionName "1.0" + externalNativeBuild { + ndkBuild { + arguments "APP_PLATFORM=android-19" + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + } + // cmake { + // arguments "-DANDROID_APP_PLATFORM=android-19", "-DANDROID_STL=c++_static" + // // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + // abiFilters 'arm64-v8a' + // } + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + applicationVariants.all { variant -> + tasks["merge${variant.name.capitalize()}Assets"] + .dependsOn("externalNativeBuild${variant.name.capitalize()}") + } + if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) { + sourceSets.main { + jniLibs.srcDir 'libs' + } + externalNativeBuild { + ndkBuild { + path 'jni/Android.mk' + } + // cmake { + // path 'jni/CMakeLists.txt' + // } + } + + } + lint { + abortOnError false + } + + if (buildAsLibrary) { + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith(".aar")) { + def fileName = "org.libsdl.app.aar"; + output.outputFile = new File(outputFile.parent, fileName); + } + } + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') +} diff -r e3394457427e -r c4256ce2c45a android/app/jni/Android.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/jni/Android.mk Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +include $(call all-subdir-makefiles) diff -r e3394457427e -r c4256ce2c45a android/app/jni/Application.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/jni/Application.mk Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,10 @@ + +# Uncomment this if you're using STL in your project +# You can find more information here: +# https://developer.android.com/ndk/guides/cpp-support +# APP_STL := c++_shared + +APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 + +# Min runtime API level +APP_PLATFORM=android-19 diff -r e3394457427e -r c4256ce2c45a android/app/jni/src --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/jni/src Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../.. \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/proguard-rules.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/proguard-rules.pro Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,98 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in [sdk]/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# 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 *; +#} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLInputConnection { + void nativeCommitText(java.lang.String, int); + void nativeGenerateScancodeForUnichar(char); +} + +-keep,includedescriptorclasses class org.libsdl.app.SDLActivity { + # for some reason these aren't compatible with allowoptimization modifier + boolean supportsRelativeMouse(); + void setWindowStyle(boolean); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLActivity { + java.lang.String nativeGetHint(java.lang.String); # Java-side doesn't use this, so it gets minified, but C-side still tries to register it + boolean onNativeSoftReturnKey(); + void onNativeKeyboardFocusLost(); + boolean isScreenKeyboardShown(); + android.util.DisplayMetrics getDisplayDPI(); + java.lang.String clipboardGetText(); + boolean clipboardHasText(); + void clipboardSetText(java.lang.String); + int createCustomCursor(int[], int, int, int, int); + void destroyCustomCursor(int); + android.content.Context getContext(); + boolean getManifestEnvironmentVariables(); + android.view.Surface getNativeSurface(); + void initTouch(); + boolean isAndroidTV(); + boolean isChromebook(); + boolean isDeXMode(); + boolean isTablet(); + void manualBackButton(); + int messageboxShowMessageBox(int, java.lang.String, java.lang.String, int[], int[], java.lang.String[], int[]); + void minimizeWindow(); + int openURL(java.lang.String); + void requestPermission(java.lang.String, int); + int showToast(java.lang.String, int, int, int, int); + boolean sendMessage(int, int); + boolean setActivityTitle(java.lang.String); + boolean setCustomCursor(int); + void setOrientation(int, int, boolean, java.lang.String); + boolean setRelativeMouseEnabled(boolean); + boolean setSystemCursor(int); + boolean shouldMinimizeOnFocusLoss(); + boolean showTextInput(int, int, int, int); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager { + boolean initialize(boolean, boolean); + boolean openDevice(int); + int sendOutputReport(int, byte[]); + int sendFeatureReport(int, byte[]); + boolean getFeatureReport(int, byte[]); + void closeDevice(int); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLAudioManager { + int[] getAudioOutputDevices(); + int[] getAudioInputDevices(); + int[] audioOpen(int, int, int, int, int); + void audioWriteFloatBuffer(float[]); + void audioWriteShortBuffer(short[]); + void audioWriteByteBuffer(byte[]); + void audioClose(); + int[] captureOpen(int, int, int, int, int); + int captureReadFloatBuffer(float[], boolean); + int captureReadShortBuffer(short[], boolean); + int captureReadByteBuffer(byte[], boolean); + void captureClose(); + void audioSetThreadPriority(boolean, int); + native int nativeSetupJNI(); + native void removeAudioDevice(boolean, int); + native void addAudioDevice(boolean, int); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLControllerManager { + void pollInputDevices(); + void pollHapticDevices(); + void hapticRun(int, float, int); + void hapticStop(int); +} diff -r e3394457427e -r c4256ce2c45a android/app/src/main/AndroidManifest.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/AndroidManifest.xml Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r e3394457427e -r c4256ce2c45a android/app/src/main/assets/default.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/assets/default.cfg Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../../../../default.cfg \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/assets/images --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/assets/images Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../../../../images \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/assets/rom.db --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/assets/rom.db Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../../../../rom.db \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/assets/shaders --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/assets/shaders Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../../../../shaders \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/assets/systems.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/assets/systems.cfg Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../../../../systems.cfg \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/java/com/retrodev/blastem/BlastEmActivity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/java/com/retrodev/blastem/BlastEmActivity.java Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,148 @@ +package com.retrodev.blastem; +import org.libsdl.app.SDLActivity; +import android.content.ContentResolver; +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.ParcelFileDescriptor; +import android.provider.DocumentsContract; +import android.util.Log; +import android.view.View; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; + + +public class BlastEmActivity extends SDLActivity +{ + static final int DOC_TREE_CODE = 4242; + boolean chooseDirInProgress = false; + String chooseDirResult = null; + Map uriMap = new HashMap(); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + //set immersive mode on devices that support it + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + View blah = mSurface; + blah.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + ); + } + } + + public String getRomPath() { + if (chooseDirInProgress) { + if (chooseDirResult != null) { + chooseDirInProgress = false; + return chooseDirResult; + } + return null; + } + String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath(); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { + return extStorage; + } + chooseDirInProgress = true; + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); + //intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Uri.parse(extStorage)); + /*intent.putExtra("android.content.extra.SHOW_ADVANCED", true); + intent.putExtra("android.content.extra.FANCY", true); + intent.putExtra("android.content.extra.SHOW_FILESIZE", true);*/ + startActivityForResult(intent, DOC_TREE_CODE); + return null; + } + + public String[] readUriDir(String uriString) { + Uri uri = uriMap.get(uriString); + if (uri == null) { + return new String[0]; + } + //adapted from some androidx.documentfile + final ContentResolver resolver = getContentResolver(); + final ArrayList results = new ArrayList<>(); + + Cursor c = null; + try { + Log.i("BlastEm", "getTreeDocumentId: " + DocumentsContract.getTreeDocumentId(uri)); + final Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(uri, + DocumentsContract.getTreeDocumentId(uri) + ); + c = resolver.query( + childrenUri, new String[] { + DocumentsContract.Document.COLUMN_DOCUMENT_ID, + DocumentsContract.Document.COLUMN_DISPLAY_NAME, + DocumentsContract.Document.COLUMN_MIME_TYPE + }, null, null, null + ); + while (c.moveToNext()) { + final String documentId = c.getString(0); + String name = c.getString(1); + final String mime = c.getString(2); + final Uri documentUri = DocumentsContract.buildDocumentUriUsingTree(uri, + documentId); + uriMap.put(uriString + "/" + name, documentUri); + if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mime)) { + name += "/"; + } + results.add(name); + } + } catch (Exception e) { + Log.w("BlastEm", "Failed query: " + e); + } finally { + if (c != null) { + c.close(); + } + } + return results.toArray(new String[0]); + } + + public int openUriAsFd(String uriString, String mode) { + Uri uri = uriMap.get(uriString); + if (uri == null) { + Log.w("BlastEm", "Did not find URI in map: " + uriString); + return 0; + } + if (mode.equals("rb")) { + mode = "r"; + } else if (mode.equals("wb")) { + mode = "w"; + } + try { + ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(uri, mode); + if (pfd != null) { + return pfd.detachFd(); + } + Log.w("BlastEm", "openFileDescriptor returned null: " + uriString); + } catch (FileNotFoundException e) { + Log.w("BlastEm", "Failed to open URI: " + e); + } catch (IllegalArgumentException e) { + Log.w("BlastEm", "Failed to open URI: " + e); + } + return 0; + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent resultData) { + if (requestCode == DOC_TREE_CODE) { + if (resultCode == RESULT_OK && resultData != null) { + Uri uri = resultData.getData(); + getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); + chooseDirResult = uri.toString(); + uriMap.put(chooseDirResult, uri); + Log.i("BlastEm", "ACTION_OPEN_DOCUMENT_TREE got URI " + chooseDirResult); + } else { + Log.i("BlastEm", "ACTION_OPEN_DOCUMENT_TREE failed! "); + chooseDirResult = ""; + } + } else { + super.onActivityResult(requestCode, resultCode, resultData); + } + } +} \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/java/org --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/java/org Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +../../../jni/SDL/android-project/app/src/main/java/org \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary file android/app/src/main/res/mipmap-hdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary file android/app/src/main/res/mipmap-mdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary file android/app/src/main/res/mipmap-xhdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary file android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary file android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/values/colors.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/res/values/colors.xml Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/values/strings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/res/values/strings.xml Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,3 @@ + + BlastEm + diff -r e3394457427e -r c4256ce2c45a android/app/src/main/res/values/styles.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/app/src/main/res/values/styles.xml Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,7 @@ + + + + + diff -r e3394457427e -r c4256ce2c45a android/assets/default.cfg --- a/android/assets/default.cfg Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,395 +0,0 @@ - -bindings { - keys { - up gamepads.1.up - down gamepads.1.down - left gamepads.1.left - right gamepads.1.right - a gamepads.1.a - s gamepads.1.b - d gamepads.1.c - q gamepads.1.x - w gamepads.1.y - e gamepads.1.z - f gamepads.1.mode - enter gamepads.1.start - - r ui.release_mouse - [ ui.vdp_debug_mode - u ui.enter_debugger - p ui.screenshot - b ui.plane_debug - v ui.vram_debug - c ui.cram_debug - n ui.compositing_debug - esc ui.exit - ` ui.save_state - 0 ui.set_speed.0 - 1 ui.set_speed.1 - 2 ui.set_speed.2 - 3 ui.set_speed.3 - 4 ui.set_speed.4 - 5 ui.set_speed.5 - 6 ui.set_speed.6 - 7 ui.set_speed.7 - = ui.next_speed - - ui.prev_speed - f11 ui.toggle_fullscreen - tab ui.soft_reset - f5 ui.reload - z ui.sms_pause - rctrl ui.toggle_keyboard_captured - - - select gamepads.1.c - play gamepads.1.start - back ui.exit - } - pads { - default { - dpads { - 0 { - up gamepads.n.up - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - } - } - buttons { - a gamepads.n.a - b gamepads.n.b - rightshoulder gamepads.n.c - x gamepads.n.x - y gamepads.n.y - leftshoulder gamepads.n.z - back gamepads.n.mode - start gamepads.n.start - guide ui.exit - leftstick ui.save_state - } - axes { - lefty.positive gamepads.n.down - lefty.negative gamepads.n.up - leftx.positive gamepads.n.right - leftx.negative gamepads.n.left - lefttrigger ui.prev_speed - righttrigger ui.next_speed - } - } - ps4_6b_right { - axes { - lefttrigger ui.next_speed - leftx.negative gamepads.n.up - leftx.positive gamepads.n.down - lefty.negative gamepads.n.left - lefty.positive gamepads.n.right - righttrigger gamepads.n.c - } - buttons { - a gamepads.n.a - b gamepads.n.b - back ui.sms_pause - guide ui.exit - leftshoulder gamepads.n.mode - leftstick ui.save_state - rightshoulder gamepads.n.z - rightstick ui.prev_speed - start gamepads.n.start - x gamepads.n.x - y gamepads.n.y - } - dpads { - 0 { - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - up gamepads.n.up - } - } - } - ps3_6b_right { - axes { - lefttrigger ui.next_speed - leftx.negative gamepads.n.up - leftx.positive gamepads.n.down - lefty.negative gamepads.n.left - lefty.positive gamepads.n.right - righttrigger gamepads.n.c - } - buttons { - a gamepads.n.a - b gamepads.n.b - back ui.sms_pause - guide ui.exit - leftshoulder gamepads.n.mode - leftstick ui.save_state - rightshoulder gamepads.n.z - rightstick ui.prev_speed - start gamepads.n.start - x gamepads.n.x - y gamepads.n.y - } - dpads { - 0 { - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - up gamepads.n.up - } - } - } - xbox_360_6b_right { - axes { - lefttrigger ui.next_speed - leftx.negative gamepads.n.up - leftx.positive gamepads.n.down - lefty.negative gamepads.n.left - lefty.positive gamepads.n.right - righttrigger gamepads.n.c - } - buttons { - a gamepads.n.a - b gamepads.n.b - back ui.sms_pause - guide ui.exit - leftshoulder gamepads.n.mode - leftstick ui.save_state - rightshoulder gamepads.n.z - rightstick ui.prev_speed - start gamepads.n.start - x gamepads.n.x - y gamepads.n.y - } - dpads { - 0 { - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - up gamepads.n.up - } - } - } - xbone_6b_right { - axes { - lefttrigger ui.next_speed - leftx.negative gamepads.n.up - leftx.positive gamepads.n.down - lefty.negative gamepads.n.left - lefty.positive gamepads.n.right - righttrigger gamepads.n.c - } - buttons { - a gamepads.n.a - b gamepads.n.b - back ui.sms_pause - guide ui.exit - leftshoulder gamepads.n.mode - leftstick ui.save_state - rightshoulder gamepads.n.z - rightstick ui.prev_speed - start gamepads.n.start - x gamepads.n.x - y gamepads.n.y - } - dpads { - 0 { - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - up gamepads.n.up - } - } - } - genesis_6b_bumpers { - axes { - lefttrigger ui.exit - righttrigger gamepads.n.mode - } - buttons { - a gamepads.n.a - b gamepads.n.b - back ui.sms_pause - guide ui.exit - leftshoulder gamepads.n.z - rightshoulder gamepads.n.c - start gamepads.n.start - x gamepads.n.x - y gamepads.n.y - } - dpads { - 0 { - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - up gamepads.n.up - } - } - } - saturn_6b_bumpers { - axes { - lefttrigger ui.exit - righttrigger gamepads.n.mode - } - buttons { - a gamepads.n.a - b gamepads.n.b - back ui.sms_pause - guide ui.exit - leftshoulder gamepads.n.z - rightshoulder gamepads.n.c - start gamepads.n.start - x gamepads.n.x - y gamepads.n.y - } - dpads { - 0 { - down gamepads.n.down - left gamepads.n.left - right gamepads.n.right - up gamepads.n.up - } - } - } - } - mice { - 0 { - motion mouse.1.motion - buttons { - 1 mouse.1.left - 2 mouse.1.middle - 3 mouse.1.right - 4 mouse.1.start - } - } - #having the second host mouse also mapped to the first emulated - #mouse is useful for laptop users with an external mouse - 1 { - motion mouse.1.motion - buttons { - 1 mouse.1.left - 2 mouse.1.middle - 3 mouse.1.right - 4 mouse.1.start - } - } - } -} - -io { - devices { - 1 gamepad6.1 - 2 gamepad6.2 - } -} - -video { - #special value "stretch" will cause aspect to match window aspect ratio - aspect 4:3 - width 640 - #height is normally calculated automatically from width using the aspect setting - #if you would like to set it explicitly, uncomment the line below - #height 480 - vertex_shader default.v.glsl - fragment_shader default.f.glsl - scanlines off - vsync off - fullscreen off - #setting gl to off, will force use of the SDL2 fallback renderer - #this is useful for those running on machines with Open GL 2.0 unavailable - #so the warning doesn't display on startup - gl on - #scaling can be linear (for linear interpolation) or nearest (for nearest neighbor) - scaling linear - ntsc { - overscan { - #these values will result in square pixels in H40 mode - top 2 - bottom 1 - #if you want to completely hide the border instead - #comment out those two lines and uncomment these - #top 11 - #bottom 8 - - #these values will completely hide the horizontal border - left 13 - right 14 - } - } - pal { - overscan { - #these values will produce the same size border in V30 mode - #as the default NTSC settings will produce in V24 mode - #this results in a slightly vertically squished picture - #which is probably approximately correct on a properly calibrated TV - top 21 - bottom 17 - #for square pixels and zero border in V30 mode - #coment out those two lines and uncomment these - #top 30 - #bottom 24 - - #these values will completely hide the horizontal border - left 13 - right 14 - } - } -} - -audio { - rate 48000 - buffer 512 - lowpass_cutoff 3390 -} - -clocks { - m68k_divider 7 - max_cycles 3420 - speeds { - 0 100 - 1 150 - 2 200 - 3 300 - 4 400 - 5 25 - 6 50 - 7 75 - } -} - -ui { - #specifies the ROM that implements the Menu UI - rom menu.bin - #starting path for ROM browsing, accepts special variables $HOME, $EXEDIR - #and variables defined in the OS environment - initial_path $HOME - #if this is set to on, then the menu will remember the last path when visited - #if it's set to off, initial_path will always be used on startup - remember_path on - #path for storing internal screenshots, accepts the same variables as initial_path - screenshot_path $HOME - #see strftime for the format specifiers valid in screenshot_template - screenshot_template blastem_%Y%m%d_%H%M%S.png - #path template for saving SRAM, EEPROM and savestates - #accepts special variables $HOME, $EXEDIR, $USERDATA, $ROMNAME - save_path $USERDATA/blastem/$ROMNAME - #space delimited list of file extensions to filter against in menu - extensions bin gen md smd sms gg zip gz - #specifies the preferred save-state format, set to gst for Genecyst compatible states - state_format native -} - -system { - #controls how the emulated system is synced to the host - #video provides the smoothest experience when the host and emulated system have similar refresh rates - #audio provides lower audio latency, especially when there is a refresh rate mismatch - sync_source audio - #set this to random to debug initialization bugs - ram_init zero - default_region U - #controls whether MegaWiFi support is enabled or not - #MegaWiFi allows ROMs to make connections to the internet - #so it should only be enabled for ROMs you trust - megawifi off -} - - diff -r e3394457427e -r c4256ce2c45a android/assets/images --- a/android/assets/images Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -../../images \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/assets/menu.bin --- a/android/assets/menu.bin Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -../../menu.bin \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/assets/rom.db --- a/android/assets/rom.db Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -../../rom.db \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/assets/shaders --- a/android/assets/shaders Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -../../shaders \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/build.gradle --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/build.gradle Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + mavenCentral() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.1.1' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + mavenCentral() + google() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff -r e3394457427e -r c4256ce2c45a android/build.properties --- a/android/build.properties Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked in Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff -r e3394457427e -r c4256ce2c45a android/build.xml --- a/android/build.xml Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r e3394457427e -r c4256ce2c45a android/default.properties --- a/android/default.properties Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-12 diff -r e3394457427e -r c4256ce2c45a android/gradle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/gradle.properties Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,17 @@ +# 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=-Xmx1536m + +# 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 diff -r e3394457427e -r c4256ce2c45a android/gradle/wrapper/gradle-wrapper.jar Binary file android/gradle/wrapper/gradle-wrapper.jar has changed diff -r e3394457427e -r c4256ce2c45a android/gradle/wrapper/gradle-wrapper.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/gradle/wrapper/gradle-wrapper.properties Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,6 @@ +#Thu Nov 11 18:20:34 PST 2021 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff -r e3394457427e -r c4256ce2c45a android/gradlew --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/gradlew Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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 +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# 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 + +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" ] ; 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, switch paths to Windows format before running java +if $cygwin ; 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"|grep -E -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|grep -E -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=$((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 + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff -r e3394457427e -r c4256ce2c45a android/gradlew.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/gradlew.bat Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,90 @@ +@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 + +@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= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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 init + +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 init + +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 + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +: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 %CMD_LINE_ARGS% + +: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 diff -r e3394457427e -r c4256ce2c45a android/jni/Android.mk --- a/android/jni/Android.mk Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -APP_ABI=x86 -include $(call all-subdir-makefiles) diff -r e3394457427e -r c4256ce2c45a android/jni/Application.mk --- a/android/jni/Application.mk Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - -# Uncomment this if you're using STL in your project -# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information -# APP_STL := stlport_static - -APP_ABI := x86 -APP_PLATFORM := android-16 -APP_OPTIM := release diff -r e3394457427e -r c4256ce2c45a android/jni/src --- a/android/jni/src Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -../.. \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/proguard-project.txt --- a/android/proguard-project.txt Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# 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 *; -#} diff -r e3394457427e -r c4256ce2c45a android/project.properties --- a/android/project.properties Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-23 diff -r e3394457427e -r c4256ce2c45a android/res/drawable-hdpi/ic_launcher.png Binary file android/res/drawable-hdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/res/drawable-mdpi/ic_launcher.png Binary file android/res/drawable-mdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/res/drawable-xhdpi/ic_launcher.png Binary file android/res/drawable-xhdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/res/drawable-xxhdpi/ic_launcher.png Binary file android/res/drawable-xxhdpi/ic_launcher.png has changed diff -r e3394457427e -r c4256ce2c45a android/res/layout/main.xml --- a/android/res/layout/main.xml Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ - - - - - diff -r e3394457427e -r c4256ce2c45a android/res/values/strings.xml --- a/android/res/values/strings.xml Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ - - - BlastEm - diff -r e3394457427e -r c4256ce2c45a android/settings.gradle --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/settings.gradle Wed Mar 26 01:20:55 2025 -0700 @@ -0,0 +1,1 @@ +include ':app' diff -r e3394457427e -r c4256ce2c45a android/src/com/retrodev/blastem/BlastEmActivity.java --- a/android/src/com/retrodev/blastem/BlastEmActivity.java Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -package com.retrodev.blastem; -import org.libsdl.app.SDLActivity; -import android.os.Build; -import android.os.Bundle; -import android.view.View; - - -public class BlastEmActivity extends SDLActivity -{ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - //set immersive mode on devices that support it - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - View blah = mSurface; - blah.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - ); - } - } -} \ No newline at end of file diff -r e3394457427e -r c4256ce2c45a android/src/org/libsdl/app/SDL.java --- a/android/src/org/libsdl/app/SDL.java Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -package org.libsdl.app; - -import android.content.Context; - -/** - SDL library initialization -*/ -public class SDL { - - // This function should be called first and sets up the native code - // so it can call into the Java classes - public static void setupJNI() { - SDLActivity.nativeSetupJNI(); - SDLAudioManager.nativeSetupJNI(); - SDLControllerManager.nativeSetupJNI(); - } - - // This function should be called each time the activity is started - public static void initialize() { - setContext(null); - - SDLActivity.initialize(); - SDLAudioManager.initialize(); - SDLControllerManager.initialize(); - } - - // This function stores the current activity (SDL or not) - public static void setContext(Context context) { - mContext = context; - } - - public static Context getContext() { - return mContext; - } - - protected static Context mContext; -} diff -r e3394457427e -r c4256ce2c45a android/src/org/libsdl/app/SDLActivity.java --- a/android/src/org/libsdl/app/SDLActivity.java Wed Mar 26 01:20:09 2025 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1595 +0,0 @@ -package org.libsdl.app; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.lang.reflect.Method; -import java.util.Objects; - -import android.app.*; -import android.content.*; -import android.text.InputType; -import android.view.*; -import android.view.inputmethod.BaseInputConnection; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputConnection; -import android.view.inputmethod.InputMethodManager; -import android.widget.RelativeLayout; -import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.os.*; -import android.util.Log; -import android.util.SparseArray; -import android.graphics.*; -import android.graphics.drawable.Drawable; -import android.hardware.*; -import android.content.pm.ActivityInfo; - -/** - SDL Activity -*/ -public class SDLActivity extends Activity { - private static final String TAG = "SDL"; - - public static boolean mIsResumedCalled, mIsSurfaceReady, mHasFocus; - - // Handle the state of the native layer - public enum NativeState { - INIT, RESUMED, PAUSED - } - - public static NativeState mNextNativeState; - public static NativeState mCurrentNativeState; - - public static boolean mExitCalledFromJava; - - /** If shared libraries (e.g. SDL or the native application) could not be loaded. */ - public static boolean mBrokenLibraries; - - // If we want to separate mouse and touch events. - // This is only toggled in native code when a hint is set! - public static boolean mSeparateMouseAndTouch; - - // Main components - protected static SDLActivity mSingleton; - protected static SDLSurface mSurface; - protected static View mTextEdit; - protected static boolean mScreenKeyboardShown; - protected static ViewGroup mLayout; - protected static SDLClipboardHandler mClipboardHandler; - - - // This is what SDL runs in. It invokes SDL_main(), eventually - protected static Thread mSDLThread; - - /** - * This method returns the name of the shared object with the application entry point - * It can be overridden by derived classes. - */ - protected String getMainSharedObject() { - String library; - String[] libraries = SDLActivity.mSingleton.getLibraries(); - if (libraries.length > 0) { - library = "lib" + libraries[libraries.length - 1] + ".so"; - } else { - library = "libmain.so"; - } - return library; - } - - /** - * This method returns the name of the application entry point - * It can be overridden by derived classes. - */ - protected String getMainFunction() { - return "SDL_main"; - } - - /** - * This method is called by SDL before loading the native shared libraries. - * It can be overridden to provide names of shared libraries to be loaded. - * The default implementation returns the defaults. It never returns null. - * An array returned by a new implementation must at least contain "SDL2". - * Also keep in mind that the order the libraries are loaded may matter. - * @return names of shared libraries to be loaded (e.g. "SDL2", "main"). - */ - protected String[] getLibraries() { - return new String[] { - "SDL2", - // "SDL2_image", - // "SDL2_mixer", - // "SDL2_net", - // "SDL2_ttf", - "main" - }; - } - - // Load the .so - public void loadLibraries() { - for (String lib : getLibraries()) { - System.loadLibrary(lib); - } - } - - /** - * This method is called by SDL before starting the native application thread. - * It can be overridden to provide the arguments after the application name. - * The default implementation returns an empty array. It never returns null. - * @return arguments for the native application. - */ - protected String[] getArguments() { - return new String[0]; - } - - public static void initialize() { - // The static nature of the singleton and Android quirkyness force us to initialize everything here - // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values - mSingleton = null; - mSurface = null; - mTextEdit = null; - mLayout = null; - mClipboardHandler = null; - mSDLThread = null; - mExitCalledFromJava = false; - mBrokenLibraries = false; - mIsResumedCalled = false; - mIsSurfaceReady = false; - mHasFocus = true; - mNextNativeState = NativeState.INIT; - mCurrentNativeState = NativeState.INIT; - } - - // Setup - @Override - protected void onCreate(Bundle savedInstanceState) { - Log.v(TAG, "Device: " + android.os.Build.DEVICE); - Log.v(TAG, "Model: " + android.os.Build.MODEL); - Log.v(TAG, "onCreate()"); - super.onCreate(savedInstanceState); - - // Load shared libraries - String errorMsgBrokenLib = ""; - try { - loadLibraries(); - } catch(UnsatisfiedLinkError e) { - System.err.println(e.getMessage()); - mBrokenLibraries = true; - errorMsgBrokenLib = e.getMessage(); - } catch(Exception e) { - System.err.println(e.getMessage()); - mBrokenLibraries = true; - errorMsgBrokenLib = e.getMessage(); - } - - if (mBrokenLibraries) - { - AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); - dlgAlert.setMessage("An error occurred while trying to start the application. Please try again and/or reinstall." - + System.getProperty("line.separator") - + System.getProperty("line.separator") - + "Error: " + errorMsgBrokenLib); - dlgAlert.setTitle("SDL Error"); - dlgAlert.setPositiveButton("Exit", - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog,int id) { - // if this button is clicked, close current activity - SDLActivity.mSingleton.finish(); - } - }); - dlgAlert.setCancelable(false); - dlgAlert.create().show(); - - return; - } - - // Set up JNI - SDL.setupJNI(); - - // Initialize state - SDL.initialize(); - - // So we can call stuff from static callbacks - mSingleton = this; - SDL.setContext(this); - - if (Build.VERSION.SDK_INT >= 11) { - mClipboardHandler = new SDLClipboardHandler_API11(); - } else { - /* Before API 11, no clipboard notification (eg no SDL_CLIPBOARDUPDATE) */ - mClipboardHandler = new SDLClipboardHandler_Old(); - } - - // Set up the surface - mSurface = new SDLSurface(getApplication()); - - mLayout = new RelativeLayout(this); - mLayout.addView(mSurface); - - setContentView(mLayout); - - // Get filename from "Open with" of another application - Intent intent = getIntent(); - if (intent != null && intent.getData() != null) { - String filename = intent.getData().getPath(); - if (filename != null) { - Log.v(TAG, "Got filename: " + filename); - SDLActivity.onNativeDropFile(filename); - } - } - } - - // Events - @Override - protected void onPause() { - Log.v(TAG, "onPause()"); - super.onPause(); - mNextNativeState = NativeState.PAUSED; - mIsResumedCalled = false; - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.handleNativeState(); - } - - @Override - protected void onResume() { - Log.v(TAG, "onResume()"); - super.onResume(); - mNextNativeState = NativeState.RESUMED; - mIsResumedCalled = true; - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.handleNativeState(); - } - - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - Log.v(TAG, "onWindowFocusChanged(): " + hasFocus); - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.mHasFocus = hasFocus; - if (hasFocus) { - mNextNativeState = NativeState.RESUMED; - } else { - mNextNativeState = NativeState.PAUSED; - } - - SDLActivity.handleNativeState(); - } - - @Override - public void onLowMemory() { - Log.v(TAG, "onLowMemory()"); - super.onLowMemory(); - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.nativeLowMemory(); - } - - @Override - protected void onDestroy() { - Log.v(TAG, "onDestroy()"); - - if (SDLActivity.mBrokenLibraries) { - super.onDestroy(); - // Reset everything in case the user re opens the app - SDLActivity.initialize(); - return; - } - - mNextNativeState = NativeState.PAUSED; - SDLActivity.handleNativeState(); - - // Send a quit message to the application - SDLActivity.mExitCalledFromJava = true; - SDLActivity.nativeQuit(); - - // Now wait for the SDL thread to quit - if (SDLActivity.mSDLThread != null) { - try { - SDLActivity.mSDLThread.join(); - } catch(Exception e) { - Log.v(TAG, "Problem stopping thread: " + e); - } - SDLActivity.mSDLThread = null; - - //Log.v(TAG, "Finished waiting for SDL thread"); - } - - super.onDestroy(); - - // Reset everything in case the user re opens the app - SDLActivity.initialize(); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - - if (SDLActivity.mBrokenLibraries) { - return false; - } - - int keyCode = event.getKeyCode(); - // Ignore certain special keys so they're handled by Android - if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || - keyCode == KeyEvent.KEYCODE_VOLUME_UP || - keyCode == KeyEvent.KEYCODE_CAMERA || - keyCode == KeyEvent.KEYCODE_ZOOM_IN || /* API 11 */ - keyCode == KeyEvent.KEYCODE_ZOOM_OUT /* API 11 */ - ) { - return false; - } - return super.dispatchKeyEvent(event); - } - - /* Transition to next state */ - public static void handleNativeState() { - - if (mNextNativeState == mCurrentNativeState) { - // Already in same state, discard. - return; - } - - // Try a transition to init state - if (mNextNativeState == NativeState.INIT) { - - mCurrentNativeState = mNextNativeState; - return; - } - - // Try a transition to paused state - if (mNextNativeState == NativeState.PAUSED) { - nativePause(); - mSurface.handlePause(); - mCurrentNativeState = mNextNativeState; - return; - } - - // Try a transition to resumed state - if (mNextNativeState == NativeState.RESUMED) { - if (mIsSurfaceReady && mHasFocus && mIsResumedCalled) { - if (mSDLThread == null) { - // This is the entry point to the C app. - // Start up the C app thread and enable sensor input for the first time - // FIXME: Why aren't we enabling sensor input at start? - - final Thread sdlThread = new Thread(new SDLMain(), "SDLThread"); - mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true); - sdlThread.start(); - - // Set up a listener thread to catch when the native thread ends - mSDLThread = new Thread(new Runnable() { - @Override - public void run() { - try { - sdlThread.join(); - } catch (Exception e) { - // Ignore any exception - } finally { - // Native thread has finished - if (!mExitCalledFromJava) { - handleNativeExit(); - } - } - } - }, "SDLThreadListener"); - - mSDLThread.start(); - } - - nativeResume(); - mSurface.handleResume(); - mCurrentNativeState = mNextNativeState; - } - } - } - - /* The native thread has finished */ - public static void handleNativeExit() { - SDLActivity.mSDLThread = null; - mSingleton.finish(); - } - - - // Messages from the SDLMain thread - static final int COMMAND_CHANGE_TITLE = 1; - static final int COMMAND_UNUSED = 2; - static final int COMMAND_TEXTEDIT_HIDE = 3; - static final int COMMAND_SET_KEEP_SCREEN_ON = 5; - - protected static final int COMMAND_USER = 0x8000; - - /** - * This method is called by SDL if SDL did not handle a message itself. - * This happens if a received message contains an unsupported command. - * Method can be overwritten to handle Messages in a different class. - * @param command the command of the message. - * @param param the parameter of the message. May be null. - * @return if the message was handled in overridden method. - */ - protected boolean onUnhandledMessage(int command, Object param) { - return false; - } - - /** - * A Handler class for Messages from native SDL applications. - * It uses current Activities as target (e.g. for the title). - * static to prevent implicit references to enclosing object. - */ - protected static class SDLCommandHandler extends Handler { - @Override - public void handleMessage(Message msg) { - Context context = SDL.getContext(); - if (context == null) { - Log.e(TAG, "error handling message, getContext() returned null"); - return; - } - switch (msg.arg1) { - case COMMAND_CHANGE_TITLE: - if (context instanceof Activity) { - ((Activity) context).setTitle((String)msg.obj); - } else { - Log.e(TAG, "error handling message, getContext() returned no Activity"); - } - break; - case COMMAND_TEXTEDIT_HIDE: - if (mTextEdit != null) { - // Note: On some devices setting view to GONE creates a flicker in landscape. - // Setting the View's sizes to 0 is similar to GONE but without the flicker. - // The sizes will be set to useful values when the keyboard is shown again. - mTextEdit.setLayoutParams(new RelativeLayout.LayoutParams(0, 0)); - - InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0); - - mScreenKeyboardShown = false; - } - break; - case COMMAND_SET_KEEP_SCREEN_ON: - { - if (context instanceof Activity) { - Window window = ((Activity) context).getWindow(); - if (window != null) { - if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) { - window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } else { - window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } - } - } - break; - } - default: - if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) { - Log.e(TAG, "error handling message, command is " + msg.arg1); - } - } - } - } - - // Handler for the messages - Handler commandHandler = new SDLCommandHandler(); - - // Send a message from the SDLMain thread - boolean sendCommand(int command, Object data) { - Message msg = commandHandler.obtainMessage(); - msg.arg1 = command; - msg.obj = data; - return commandHandler.sendMessage(msg); - } - - // C functions we call - public static native int nativeSetupJNI(); - public static native int nativeRunMain(String library, String function, Object arguments); - public static native void nativeLowMemory(); - public static native void nativeQuit(); - public static native void nativePause(); - public static native void nativeResume(); - public static native void onNativeDropFile(String filename); - public static native void onNativeResize(int x, int y, int format, float rate); - public static native void onNativeKeyDown(int keycode); - public static native void onNativeKeyUp(int keycode); - public static native void onNativeKeyboardFocusLost(); - public static native void onNativeMouse(int button, int action, float x, float y); - public static native void onNativeTouch(int touchDevId, int pointerFingerId, - int action, float x, - float y, float p); - public static native void onNativeAccel(float x, float y, float z); - public static native void onNativeClipboardChanged(); - public static native void onNativeSurfaceChanged(); - public static native void onNativeSurfaceDestroyed(); - public static native String nativeGetHint(String name); - - /** - * This method is called by SDL using JNI. - */ - public static boolean setActivityTitle(String title) { - // Called from SDLMain() thread and can't directly affect the view - return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title); - } - - /** - * This method is called by SDL using JNI. - * This is a static method for JNI convenience, it calls a non-static method - * so that is can be overridden - */ - public static void setOrientation(int w, int h, boolean resizable, String hint) - { - if (mSingleton != null) { - mSingleton.setOrientationBis(w, h, resizable, hint); - } - } - - /** - * This can be overridden - */ - public void setOrientationBis(int w, int h, boolean resizable, String hint) - { - int orientation = -1; - - if (!Objects.equals(hint, "")) { - if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) { - orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; - } else if (hint.contains("LandscapeRight")) { - orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; - } else if (hint.contains("LandscapeLeft")) { - orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; - } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) { - orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; - } else if (hint.contains("Portrait")) { - orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; - } else if (hint.contains("PortraitUpsideDown")) { - orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; - } - } - - /* no valid hint */ - if (orientation == -1) { - if (resizable) { - /* no fixed orientation */ - } else { - if (w > h) { - orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; - } else { - orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; - } - } - } - - Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint); - if (orientation != -1) { - mSingleton.setRequestedOrientation(orientation); - } - } - - - /** - * This method is called by SDL using JNI. - */ - public static boolean isScreenKeyboardShown() - { - if (mTextEdit == null) { - return false; - } - - if (!mScreenKeyboardShown) { - return false; - } - - InputMethodManager imm = (InputMethodManager) SDL.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - return imm.isAcceptingText(); - - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean sendMessage(int command, int param) { - if (mSingleton == null) { - return false; - } - return mSingleton.sendCommand(command, Integer.valueOf(param)); - } - - /** - * This method is called by SDL using JNI. - */ - public static Context getContext() { - return SDL.getContext(); - } - - static class ShowTextInputTask implements Runnable { - /* - * This is used to regulate the pan&scan method to have some offset from - * the bottom edge of the input region and the top edge of an input - * method (soft keyboard) - */ - static final int HEIGHT_PADDING = 15; - - public int x, y, w, h; - - public ShowTextInputTask(int x, int y, int w, int h) { - this.x = x; - this.y = y; - this.w = w; - this.h = h; - } - - @Override - public void run() { - RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h + HEIGHT_PADDING); - params.leftMargin = x; - params.topMargin = y; - - if (mTextEdit == null) { - mTextEdit = new DummyEdit(SDL.getContext()); - - mLayout.addView(mTextEdit, params); - } else { - mTextEdit.setLayoutParams(params); - } - - mTextEdit.setVisibility(View.VISIBLE); - mTextEdit.requestFocus(); - - InputMethodManager imm = (InputMethodManager) SDL.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextEdit, 0); - - mScreenKeyboardShown = true; - } - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean showTextInput(int x, int y, int w, int h) { - // Transfer the task to the main thread as a Runnable - return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h)); - } - - public static boolean isTextInputEvent(KeyEvent event) { - - // Key pressed with Ctrl should be sent as SDL_KEYDOWN/SDL_KEYUP and not SDL_TEXTINPUT - if (android.os.Build.VERSION.SDK_INT >= 11) { - if (event.isCtrlPressed()) { - return false; - } - } - - return event.isPrintingKey() || event.getKeyCode() == KeyEvent.KEYCODE_SPACE; - } - - /** - * This method is called by SDL using JNI. - */ - public static Surface getNativeSurface() { - if (SDLActivity.mSurface == null) { - return null; - } - return SDLActivity.mSurface.getNativeSurface(); - } - - // Input - - /** - * This method is called by SDL using JNI. - * @return an array which may be empty but is never null. - */ - public static int[] inputGetInputDeviceIds(int sources) { - int[] ids = InputDevice.getDeviceIds(); - int[] filtered = new int[ids.length]; - int used = 0; - for (int i = 0; i < ids.length; ++i) { - InputDevice device = InputDevice.getDevice(ids[i]); - if ((device != null) && ((device.getSources() & sources) != 0)) { - filtered[used++] = device.getId(); - } - } - return Arrays.copyOf(filtered, used); - } - - // APK expansion files support - - /** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */ - private static Object expansionFile; - - /** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */ - private static Method expansionFileMethod; - - /** - * This method is called by SDL using JNI. - * @return an InputStream on success or null if no expansion file was used. - * @throws IOException on errors. Message is set for the SDL error message. - */ - public static InputStream openAPKExpansionInputStream(String fileName) throws IOException { - // Get a ZipResourceFile representing a merger of both the main and patch files - if (expansionFile == null) { - String mainHint = nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"); - if (mainHint == null) { - return null; // no expansion use if no main version was set - } - String patchHint = nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"); - if (patchHint == null) { - return null; // no expansion use if no patch version was set - } - - Integer mainVersion; - Integer patchVersion; - try { - mainVersion = Integer.valueOf(mainHint); - patchVersion = Integer.valueOf(patchHint); - } catch (NumberFormatException ex) { - ex.printStackTrace(); - throw new IOException("No valid file versions set for APK expansion files", ex); - } - - try { - // To avoid direct dependency on Google APK expansion library that is - // not a part of Android SDK we access it using reflection - expansionFile = Class.forName("com.android.vending.expansion.zipfile.APKExpansionSupport") - .getMethod("getAPKExpansionZipFile", Context.class, int.class, int.class) - .invoke(null, SDL.getContext(), mainVersion, patchVersion); - - expansionFileMethod = expansionFile.getClass() - .getMethod("getInputStream", String.class); - } catch (Exception ex) { - ex.printStackTrace(); - expansionFile = null; - expansionFileMethod = null; - throw new IOException("Could not access APK expansion support library", ex); - } - } - - // Get an input stream for a known file inside the expansion file ZIPs - InputStream fileStream; - try { - fileStream = (InputStream)expansionFileMethod.invoke(expansionFile, fileName); - } catch (Exception ex) { - // calling "getInputStream" failed - ex.printStackTrace(); - throw new IOException("Could not open stream from APK expansion file", ex); - } - - if (fileStream == null) { - // calling "getInputStream" was successful but null was returned - throw new IOException("Could not find path in APK expansion file"); - } - - return fileStream; - } - - // Messagebox - - /** Result of current messagebox. Also used for blocking the calling thread. */ - protected final int[] messageboxSelection = new int[1]; - - /** Id of current dialog. */ - protected int dialogs = 0; - - /** - * This method is called by SDL using JNI. - * Shows the messagebox from UI thread and block calling thread. - * buttonFlags, buttonIds and buttonTexts must have same length. - * @param buttonFlags array containing flags for every button. - * @param buttonIds array containing id for every button. - * @param buttonTexts array containing text for every button. - * @param colors null for default or array of length 5 containing colors. - * @return button id or -1. - */ - public int messageboxShowMessageBox( - final int flags, - final String title, - final String message, - final int[] buttonFlags, - final int[] buttonIds, - final String[] buttonTexts, - final int[] colors) { - - messageboxSelection[0] = -1; - - // sanity checks - - if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) { - return -1; // implementation broken - } - - // collect arguments for Dialog - - final Bundle args = new Bundle(); - args.putInt("flags", flags); - args.putString("title", title); - args.putString("message", message); - args.putIntArray("buttonFlags", buttonFlags); - args.putIntArray("buttonIds", buttonIds); - args.putStringArray("buttonTexts", buttonTexts); - args.putIntArray("colors", colors); - - // trigger Dialog creation on UI thread - - runOnUiThread(new Runnable() { - @Override - public void run() { - showDialog(dialogs++, args); - } - }); - - // block the calling thread - - synchronized (messageboxSelection) { - try { - messageboxSelection.wait(); - } catch (InterruptedException ex) { - ex.printStackTrace(); - return -1; - } - } - - // return selected value - - return messageboxSelection[0]; - } - - @Override - protected Dialog onCreateDialog(int ignore, Bundle args) { - - // TODO set values from "flags" to messagebox dialog - - // get colors - - int[] colors = args.getIntArray("colors"); - int backgroundColor; - int textColor; - int buttonBorderColor; - int buttonBackgroundColor; - int buttonSelectedColor; - if (colors != null) { - int i = -1; - backgroundColor = colors[++i]; - textColor = colors[++i]; - buttonBorderColor = colors[++i]; - buttonBackgroundColor = colors[++i]; - buttonSelectedColor = colors[++i]; - } else { - backgroundColor = Color.TRANSPARENT; - textColor = Color.TRANSPARENT; - buttonBorderColor = Color.TRANSPARENT; - buttonBackgroundColor = Color.TRANSPARENT; - buttonSelectedColor = Color.TRANSPARENT; - } - - // create dialog with title and a listener to wake up calling thread - - final Dialog dialog = new Dialog(this); - dialog.setTitle(args.getString("title")); - dialog.setCancelable(false); - dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface unused) { - synchronized (messageboxSelection) { - messageboxSelection.notify(); - } - } - }); - - // create text - - TextView message = new TextView(this); - message.setGravity(Gravity.CENTER); - message.setText(args.getString("message")); - if (textColor != Color.TRANSPARENT) { - message.setTextColor(textColor); - } - - // create buttons - - int[] buttonFlags = args.getIntArray("buttonFlags"); - int[] buttonIds = args.getIntArray("buttonIds"); - String[] buttonTexts = args.getStringArray("buttonTexts"); - - final SparseArray