SDL2 Java implementation

This commit is contained in:
Sergii Pylypenko
2022-01-03 02:12:10 +02:00
parent ef8b1d2c7d
commit 094d04a4c2
15 changed files with 253 additions and 109 deletions

View File

@@ -0,0 +1 @@
../java/DataDownloader.java

View File

@@ -22,11 +22,21 @@ freely, subject to the following restrictions:
package net.sourceforge.clonekeenplus;
import android.app.Activity;
import android.app.UiModeManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.FrameLayout;
import java.util.ArrayList;
public class MainActivity extends org.libsdl.app.SDLActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
this.instance = this;
super.onCreate(savedInstanceState);
Globals.DataDir = this.getFilesDir().getAbsolutePath();
@@ -37,7 +47,7 @@ public class MainActivity extends org.libsdl.app.SDLActivity {
{
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP )
{
ApplicationInfo info = this.getPackageManager().getApplicationInfo(Parent.getPackageName(), 0);
ApplicationInfo info = this.getPackageManager().getApplicationInfo(this.getPackageName(), 0);
if( info.splitSourceDirs != null )
{
for( String apk: info.splitSourceDirs )
@@ -60,6 +70,17 @@ public class MainActivity extends org.libsdl.app.SDLActivity {
Settings.setEnvVars(this);
}
public void downloadFinishedInitSDL() {
// TODO: implement this
}
@Override
protected void resumeNativeThread() {
Log.i("SDL", "Intercepted resumeNativeThread() from MainActivity");
super.resumeNativeThread();
}
@Override
protected String[] getLibraries() {
ArrayList<String> ret = new ArrayList<String>();
@@ -71,7 +92,7 @@ public class MainActivity extends org.libsdl.app.SDLActivity {
@Override
protected String[] getArguments() {
return new String[0];
return Globals.CommandLine.split(" ");
}
private static String GetMappedLibraryName(final String s) {
@@ -82,6 +103,41 @@ public class MainActivity extends org.libsdl.app.SDLActivity {
return s;
}
public int getApplicationVersion() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
return packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Log.i("SDL", "libSDL: Cannot get the version of our own package: " + e);
}
return 0;
}
public boolean isRunningOnOUYA() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo("tv.ouya", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) || Globals.OuyaEmulation;
}
public static void setScreenOrientation() {
// For compatibility with SDL 1.2 code
}
public static void setUpStatusLabel() {
// For compatibility with SDL 1.2 code
}
public static FrameLayout getVideoLayout() {
// For compatibility with SDL 1.2 code
return null;
}
public static MainActivity instance = null;
public String ObbMountPath = null; // Deprecated, always empty
public String assetPackPath = null; // Not saved to the config file
public boolean readExternalStoragePermissionDialogAnswered = false; // Deprecated, always false
}

1
project/javaSDL2/Mouse.java Symbolic link
View File

@@ -0,0 +1 @@
../java/Mouse.java

View File

@@ -0,0 +1 @@
../java/SDL_Keys.java

View File

@@ -0,0 +1,48 @@
/*
Simple DirectMedia Layer
Java source code (C) 2009-2014 Sergii Pylypenko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
package net.sourceforge.clonekeenplus;
import android.app.Activity;
import android.os.Bundle;
// Stubs for compatibility with SDL 1.2 code
class SettingsMenu {
public static void showConfig(final MainActivity p, final boolean firstStart) {
}
}
class RestartMainActivity extends Activity {
// For compatibility with SDL 1.2 code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public static final String ACTIVITY_AUTODETECT_SCREEN_ORIENTATION = "libsdl.org.ACTIVITY_AUTODETECT_SCREEN_ORIENTATION";
public static final String SDL_RESTART_PARAMS = "SDL_RESTART_PARAMS";
}
class DemoGLSurfaceView {
static void SetupTouchscreenKeyboardGraphics(Activity p) {
}
}

View File

@@ -0,0 +1 @@
../java/XZInputStream.java