(Android) - New phoenix frontend - use startActivityForResult for filebrowsing

- Get rid of most PHOENIX_LEGACY ifdefs - code now works for both Phoenix and
Phoenix-legacy
- Refresh rate auto-configuration should work now on Phoenix
- Going to get rid of Phoenix-legacy soon altogether
This commit is contained in:
twinaphex 2012-12-09 20:32:00 +01:00
parent a5e3df4e72
commit fdc65d7851
5 changed files with 44 additions and 17 deletions

View File

@ -49,7 +49,7 @@ ifeq ($(PERF_TEST), 1)
LOCAL_CFLAGS += -DPERF_TEST
endif
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DPHOENIX_LEGACY -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DHAVE_CONFIGFILE=1 -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DHAVE_CONFIGFILE=1 -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 -llog -ldl
LOCAL_C_INCLUDES += $(LIBXML_PATH)

View File

@ -26,9 +26,7 @@
#include "../../../performance.h"
#include "../../../driver.h"
#ifdef PHOENIX_LEGACY
#include "../../../config.def.h"
#endif
void free_saved_state(struct android_app* android_app)
{
@ -338,21 +336,19 @@ static void* android_app_entry(void* param)
// Get arguments */
android_get_char_argv(rom_path, sizeof(rom_path), "ROM");
android_get_char_argv(libretro_path, sizeof(libretro_path), "LIBRETRO");
#ifdef PHOENIX_LEGACY
char refreshrate_char[128];
float refreshrate;
android_get_char_argv(refreshrate_char,sizeof(refreshrate_char), "REFRESHRATE");
refreshrate = (float)strtod(refreshrate_char, NULL);
#endif
RARCH_LOG("Checking arguments passed...\n");
RARCH_LOG("ROM Filename: [%s].\n", rom_path);
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
#ifdef PHOENIX_LEGACY
RARCH_LOG("Display Refresh rate: %.2fHz.\n", refreshrate);
#ifdef PHOENIX_LEGACY
/* ugly hack for now - hardcode libretro path to 'allowed' dir */
snprintf(libretro_path, sizeof(libretro_path), "/data/data/com.retroarch/lib/libretro.so");
#endif
@ -390,7 +386,6 @@ static void* android_app_entry(void* param)
g_extern.verbose = true;
#ifdef PHOENIX_LEGACY
bool disp_refresh_read = refreshrate > 0.0f;
g_android.disp_refresh_rate = refresh_rate;
@ -405,7 +400,6 @@ static void* android_app_entry(void* param)
}
RARCH_LOG("Setting RetroArch video refresh rate to: %.2fHz.\n", g_android.disp_refresh_rate);
#endif
while(!(g_android.input_state & (1ULL << RARCH_WINDOW_READY)))
{

View File

@ -169,10 +169,10 @@ public class DirectoryActivity extends Activity implements AdapterView.OnItemCli
}
else
{
final Intent intent = new Intent(this, selected.isFile() ? NativeActivity.class : DirectoryActivity.class)
.putExtra("ROM", selected.getAbsolutePath())
.putExtra("LIBRETRO", getIntent().getStringExtra("LIBRETRO"));
startActivity(intent);
Intent intent=new Intent();
intent.putExtra("PATH", selected.getAbsolutePath());
setResult(RESULT_OK, intent);
finish();
}
}

View File

@ -1,6 +1,7 @@
package org.retroarch.browser;
import org.retroarch.R;
import java.io.*;
import android.content.*;
@ -44,6 +45,16 @@ class ModuleWrapper implements IconAdapterItem
public class ModuleActivity extends Activity implements AdapterView.OnItemClickListener
{
private IconAdapter<ModuleWrapper> adapter;
static private final int ACTIVITY_LOAD_ROM = 0;
static private String libretro_path;
public float getRefreshRate()
{
final WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
final Display display = wm.getDefaultDisplay();
float rate = display.getRefreshRate();
return rate;
}
@Override public void onCreate(Bundle savedInstanceState)
{
@ -57,7 +68,7 @@ public class ModuleActivity extends Activity implements AdapterView.OnItemClickL
list.setAdapter(adapter);
list.setOnItemClickListener(this);
setTitle("Select Emulator");
setTitle("Select Libretro core");
// Populate the list
final String modulePath = getApplicationInfo().nativeLibraryDir;
@ -80,10 +91,32 @@ public class ModuleActivity extends Activity implements AdapterView.OnItemClickL
@Override public void onItemClick(AdapterView<?> aListView, View aView, int aPosition, long aID)
{
final ModuleWrapper item = adapter.getItem(aPosition);
startActivity(new Intent(ModuleActivity.this, DirectoryActivity.class)
.putExtra("LIBRETRO", item.file.getAbsolutePath()));
libretro_path = item.file.getAbsolutePath();
Intent myIntent;
myIntent = new Intent(this, DirectoryActivity.class);
startActivityForResult(myIntent, ACTIVITY_LOAD_ROM);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Intent myIntent;
switch(requestCode)
{
case ACTIVITY_LOAD_ROM:
if(data.getStringExtra("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);
myIntent.putExtra("REFRESHRATE", Float.toString(getRefreshRate()));
startActivity(myIntent);
}
break;
}
}
@Override public boolean onCreateOptionsMenu(Menu aMenu)
{

View File

@ -191,7 +191,7 @@ void config_set_defaults(void)
// Android screens can have variable refresh rates - don't set a
// hardcoded value for Android devices
#if defined(ANDROID) && defined(PHOENIX_LEGACY)
#if defined(ANDROID)
g_settings.video.refresh_rate = g_android.disp_refresh_rate;
#else
g_settings.video.refresh_rate = refresh_rate;