mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 01:29:41 +01:00
Merge pull request #186 from valef/android-shortcut
Android homescreen shortcut - native part
This commit is contained in:
commit
fa55a39060
3 files changed
+27
-6
No files matched your search
+17
-3
@@ -139,7 +139,8 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_audioConfig
|
||||
|
||||
extern "C" void Java_com_henrikrydgard_libnative_NativeApp_init
|
||||
(JNIEnv *env, jclass, jint dpi, jstring jdevicetype, jstring jlangRegion, jstring japkpath,
|
||||
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jinstallID, jboolean juseNativeAudio) {
|
||||
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jshortcutParam,
|
||||
jstring jinstallID, jboolean juseNativeAudio) {
|
||||
jniEnvUI = env;
|
||||
|
||||
ILOG("NativeApp.init() -- begin");
|
||||
@@ -166,9 +167,11 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_init
|
||||
std::string externalDir = GetJavaString(env, jexternalDir);
|
||||
std::string user_data_path = GetJavaString(env, jdataDir) + "/";
|
||||
library_path = GetJavaString(env, jlibraryDir) + "/";
|
||||
std::string shortcut_param = GetJavaString(env, jshortcutParam);
|
||||
std::string installID = GetJavaString(env, jinstallID);
|
||||
|
||||
ILOG("NativeApp.init(): External storage path: %s", externalDir.c_str());
|
||||
ILOG("NativeApp.init(): Launch shortcut parameter: %s", shortcut_param.c_str());
|
||||
|
||||
std::string app_name;
|
||||
std::string app_nice_name;
|
||||
@@ -181,8 +184,19 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_init
|
||||
|
||||
NativeGetAppInfo(&app_name, &app_nice_name, &landscape);
|
||||
|
||||
const char *argv[2] = {app_name.c_str(), 0};
|
||||
NativeInit(1, argv, user_data_path.c_str(), externalDir.c_str(), installID.c_str());
|
||||
|
||||
// If shortcut_param is not empty, pass it as additional varargs argument to NativeInit() method.
|
||||
// NativeInit() is expected to treat extra argument as boot_filename, which in turn will start game immediately.
|
||||
// NOTE: Will only work if ppsspp started from Activity.onCreate(). Won't work if ppsspp app start from onResume().
|
||||
|
||||
if(shortcut_param.empty()) {
|
||||
const char *argv[2] = {app_name.c_str(), 0};
|
||||
NativeInit(1, argv, user_data_path.c_str(), externalDir.c_str(), installID.c_str());
|
||||
}
|
||||
else {
|
||||
const char *argv[3] = {app_name.c_str(), shortcut_param.c_str(), 0};
|
||||
NativeInit(2, argv, user_data_path.c_str(), externalDir.c_str(), installID.c_str());
|
||||
}
|
||||
|
||||
use_opensl_audio = juseNativeAudio;
|
||||
ILOG("NativeApp.init() -- end");
|
||||
|
||||
@@ -87,7 +87,7 @@ public class NativeActivity extends Activity {
|
||||
|
||||
// Adjust these as necessary
|
||||
private static String TAG = "NativeActivity";
|
||||
|
||||
|
||||
// Easy way to flip it on and off from code.
|
||||
private static final boolean useKitkatImmersiveMode = false;
|
||||
|
||||
@@ -101,6 +101,8 @@ public class NativeActivity extends Activity {
|
||||
|
||||
boolean useOpenSL = false;
|
||||
|
||||
private String shortcutParam = "";
|
||||
|
||||
public static String runCommand;
|
||||
public static String commandParameter;
|
||||
public static String installID;
|
||||
@@ -170,6 +172,10 @@ public class NativeActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public void setShortcutParam(String shortcutParam) {
|
||||
this.shortcutParam = ((shortcutParam == null) ? "" : shortcutParam);
|
||||
}
|
||||
|
||||
public void Initialize() {
|
||||
|
||||
//initialise audio classes. Do this here since detectOptimalAudioSettings()
|
||||
@@ -203,6 +209,7 @@ public class NativeActivity extends Activity {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
|
||||
String libraryDir = getApplicationLibraryDir(appInfo);
|
||||
File sdcard = Environment.getExternalStorageDirectory();
|
||||
Display display = ((WindowManager)this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||
@@ -230,7 +237,7 @@ public class NativeActivity extends Activity {
|
||||
String languageRegion = Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
|
||||
|
||||
NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate);
|
||||
NativeApp.init(dpi, deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, installID, useOpenSL);
|
||||
NativeApp.init(dpi, deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, shortcutParam, installID, useOpenSL);
|
||||
Log.i(TAG, "Device: " + deviceType);
|
||||
Log.i(TAG, "W : " + scrWidth + " H: " + scrHeight + " rate: " + scrRefreshRate + " fmt: " + scrPixelFormat + " dpi: " + dpi);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class NativeApp {
|
||||
public final static int DEVICE_ID_MOUSE = 2;
|
||||
public final static int DEVICE_ID_PAD_0 = 10;
|
||||
|
||||
public static native void init(int dpi, String deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String installID, boolean useOpenSL);
|
||||
public static native void init(int dpi, String deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String shortcutParam, String installID, boolean useOpenSL);
|
||||
|
||||
public static native void audioInit();
|
||||
public static native void audioShutdown();
|
||||
|
||||
Reference in new issue
Block a user