(Android) Can now select libretro core from Phoenix too, argument
gets passed to native activity
@ -117,6 +117,31 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd)
|
||||
}
|
||||
}
|
||||
|
||||
static void android_get_char_argv(char *argv, size_t sizeof_argv, const char * arg_name, struct android_app* state)
|
||||
{
|
||||
JNIEnv *env;
|
||||
JavaVM *rarch_vm = state->activity->vm;
|
||||
|
||||
(*rarch_vm)->AttachCurrentThread(rarch_vm, &env, 0);
|
||||
|
||||
jobject me = state->activity->clazz;
|
||||
|
||||
jclass acl = (*env)->GetObjectClass(env, me); //class pointer of NativeActivity
|
||||
jmethodID giid = (*env)->GetMethodID(env, acl, "getIntent", "()Landroid/content/Intent;");
|
||||
jobject intent = (*env)->CallObjectMethod(env, me, giid); //Got our intent
|
||||
|
||||
jclass icl = (*env)->GetObjectClass(env, intent); //class pointer of Intent
|
||||
jmethodID gseid = (*env)->GetMethodID(env, icl, "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
|
||||
jstring jsParam1 = (*env)->CallObjectMethod(env, intent, gseid, (*env)->NewStringUTF(env, arg_name));
|
||||
const char *test_argv = (*env)->GetStringUTFChars(env, jsParam1, 0);
|
||||
|
||||
strncpy(argv, test_argv, sizeof_argv);
|
||||
|
||||
//When done with it, or when you've made a copy
|
||||
(*env)->ReleaseStringUTFChars(env, jsParam1, test_argv);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main entry point of a native application that is using
|
||||
* android_native_app_glue. It runs in its own thread, with its own
|
||||
@ -135,30 +160,16 @@ void android_main(struct android_app* state)
|
||||
state->onInputEvent = engine_handle_input;
|
||||
g_android.app = state;
|
||||
|
||||
char rom[512];
|
||||
char libretro_path[512];
|
||||
|
||||
// Get arguments */
|
||||
JNIEnv *env;
|
||||
JavaVM *rarch_vm = state->activity->vm;
|
||||
|
||||
(*rarch_vm)->AttachCurrentThread(rarch_vm, &env, 0);
|
||||
|
||||
jobject me = state->activity->clazz;
|
||||
|
||||
jclass acl = (*env)->GetObjectClass(env, me); //class pointer of NativeActivity
|
||||
jmethodID giid = (*env)->GetMethodID(env, acl, "getIntent", "()Landroid/content/Intent;");
|
||||
jobject intent = (*env)->CallObjectMethod(env, me, giid); //Got our intent
|
||||
|
||||
jclass icl = (*env)->GetObjectClass(env, intent); //class pointer of Intent
|
||||
jmethodID gseid = (*env)->GetMethodID(env, icl, "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
|
||||
/* ROM argument */
|
||||
jstring jsParam1 = (*env)->CallObjectMethod(env, intent, gseid, (*env)->NewStringUTF(env, "ROM"));
|
||||
const char *rom = (*env)->GetStringUTFChars(env, jsParam1, 0);
|
||||
|
||||
//When done with it, or when you've made a copy
|
||||
(*env)->ReleaseStringUTFChars(env, jsParam1, rom);
|
||||
android_get_char_argv(rom, sizeof(rom), "ROM", state);
|
||||
android_get_char_argv(libretro_path, sizeof(libretro_path), "LIBRETRO", state);
|
||||
|
||||
RARCH_LOG("Checking arguments passed...\n");
|
||||
RARCH_LOG("ROM Filename: [%s].\n", rom);
|
||||
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
|
||||
|
||||
// Prepare to monitor accelerometer
|
||||
g_android.sensorManager = ASensorManager_getInstance();
|
||||
|
@ -45,4 +45,11 @@
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>res/retroarch.cfg</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/retroarch.cfg</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
|
Before Width: | Height: | Size: 729 B |
Before Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 188 B |
Before Width: | Height: | Size: 472 B |
Before Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 729 B |
Before Width: | Height: | Size: 312 B |
@ -2,11 +2,8 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item android:id="@+id/main" android:showAsAction="ifRoom|withText" android:title="Main" android:icon="@drawable/ic_action_main"></item>
|
||||
<item android:id="@+id/open" android:showAsAction="collapseActionView" android:title="Open ROM" android:icon="@drawable/ic_action_open"></item>
|
||||
<item android:id="@+id/close" android:showAsAction="collapseActionView" android:title="Close ROM" android:icon="@drawable/ic_action_close"></item>
|
||||
<item android:id="@+id/load" android:showAsAction="collapseActionView" android:title="Load" android:icon="@drawable/ic_action_load"></item>
|
||||
<item android:id="@+id/save" android:showAsAction="collapseActionView" android:title="Save" android:icon="@drawable/ic_action_save"></item>
|
||||
<item android:id="@+id/history" android:showAsAction="collapseActionView" android:title="History" android:icon="@drawable/ic_action_history"></item>
|
||||
<item android:id="@+id/open" android:showAsAction="collapseActionView" android:title="Select ROM" android:icon="@drawable/ic_action_open"></item>
|
||||
<item android:id="@+id/libretro" android:showAsAction="collapseActionView" android:title="Select libretro core" android:icon="@drawable/ic_action_libretro"></item>
|
||||
<item android:id="@+id/settings" android:showAsAction="collapseActionView" android:title="Settings" android:icon="@drawable/ic_action_settings"></item>
|
||||
|
||||
</menu>
|
||||
|
@ -189,7 +189,7 @@ public class FileChooser extends Activity
|
||||
{
|
||||
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3)
|
||||
int arg2, long arg3)
|
||||
{
|
||||
int pos = arg0.getPositionForView(arg1);
|
||||
Option o = adapter.getItem(pos);
|
||||
@ -204,19 +204,7 @@ public class FileChooser extends Activity
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
String path = o.getPath();
|
||||
|
||||
int dotIndex = path.lastIndexOf('.');
|
||||
|
||||
String ext = null;
|
||||
if (dotIndex >= 0)
|
||||
{
|
||||
ext = path.substring(dotIndex+1).toLowerCase();
|
||||
}
|
||||
*/
|
||||
|
||||
onFileClick(o);
|
||||
onFileClick(o);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,8 +214,6 @@ public class FileChooser extends Activity
|
||||
|
||||
private void onFileClick(Option o)
|
||||
{
|
||||
Toast.makeText(this, "Loading: "+ o.name + "...", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Intent intent=new Intent();
|
||||
intent.putExtra("PATH", o.path);
|
||||
intent.putExtra("NAME", o.name);
|
||||
@ -236,7 +222,8 @@ public class FileChooser extends Activity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK)
|
||||
{
|
||||
if (_dirStack.size() > 1)
|
||||
|
@ -31,6 +31,9 @@ import android.os.Bundle;
|
||||
public class phoenix extends Activity
|
||||
{
|
||||
static private final int ACTIVITY_LOAD_ROM = 0;
|
||||
static private final int ACTIVITY_LOAD_LIBRETRO_CORE = 1;
|
||||
|
||||
static private String libretro_path;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
@ -49,6 +52,7 @@ public class phoenix extends Activity
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
Intent myIntent;
|
||||
switch (item.getItemId())
|
||||
{
|
||||
case R.id.main:
|
||||
@ -56,9 +60,14 @@ public class phoenix extends Activity
|
||||
break;
|
||||
case R.id.open:
|
||||
Toast.makeText(this, "Select a ROM image from the Filebrowser.", Toast.LENGTH_SHORT).show();
|
||||
Intent myIntent = new Intent(this, FileChooser.class);
|
||||
myIntent = new Intent(this, FileChooser.class);
|
||||
startActivityForResult(myIntent, ACTIVITY_LOAD_ROM);
|
||||
break;
|
||||
case R.id.libretro:
|
||||
Toast.makeText(this, "Select a libretro core from the Filebrowser.", Toast.LENGTH_SHORT).show();
|
||||
myIntent = new Intent(this, FileChooser.class);
|
||||
startActivityForResult(myIntent, ACTIVITY_LOAD_LIBRETRO_CORE);
|
||||
break;
|
||||
default:
|
||||
Toast.makeText(this, "MenuItem " + item.getTitle() + " selected.", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
@ -69,11 +78,32 @@ public class phoenix extends Activity
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||
{
|
||||
if(requestCode == ACTIVITY_LOAD_ROM)
|
||||
Intent myIntent;
|
||||
|
||||
switch(requestCode)
|
||||
{
|
||||
Intent myIntent = new Intent(this, NativeActivity.class);
|
||||
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
||||
startActivity(myIntent);
|
||||
case ACTIVITY_LOAD_ROM:
|
||||
if(data.getStringExtra("PATH") != null)
|
||||
{
|
||||
if(libretro_path != null)
|
||||
{
|
||||
Toast.makeText(this, "Loading: ["+ data.getStringExtra("PATH") + "]...", Toast.LENGTH_SHORT).show();
|
||||
myIntent = new Intent(this, NativeActivity.class);
|
||||
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
||||
myIntent.putExtra("LIBRETRO", libretro_path);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
else
|
||||
Toast.makeText(this, "ERROR - No libretro core has been selected, cannot start RetroArch.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
case ACTIVITY_LOAD_LIBRETRO_CORE:
|
||||
if(data.getStringExtra("PATH") != null)
|
||||
{
|
||||
Toast.makeText(this, "Libretro core path set to: ["+ data.getStringExtra("PATH") + "].", Toast.LENGTH_SHORT).show();
|
||||
libretro_path = data.getStringExtra("PATH");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|