Merge branch 'master' of https://github.com/reicast/emulator into pandora

Conflicts:
	shell/android/src/com/reicast/emulator/GL2JNIActivity.java
	shell/android/src/com/reicast/emulator/GL2JNIView.java
	shell/android/src/com/reicast/emulator/JNIdc.java
	shell/android/src/com/reicast/emulator/MOGAInput.java
This commit is contained in:
ptitSeb 2014-01-11 15:57:32 +01:00
commit a15a5257b1
27 changed files with 1932 additions and 442 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.DS_Store .DS_Store
*.class *.class
*.orig
bin/ bin/
gen/ gen/

View File

@ -18,11 +18,13 @@ Let's try to keep everything under a single project :)
To build for android To build for android
-------------------- --------------------
``` Tools required:
cd newdc\android\libnewdc * Latest Android SDK and NDK (duh)
android update project -p . * Ant
cd ..\..\..\reicast\android From project root directory:
```
cd shell\android
android update project -p . android update project -p .
ndk-build -j 4 ndk-build -j 4
@ -64,6 +66,7 @@ Team
You can check the currently active committers on [the pretty graphs page](https://github.com/reicast/reicast-emulator/graphs/contributors) You can check the currently active committers on [the pretty graphs page](https://github.com/reicast/reicast-emulator/graphs/contributors)
Chat on freenode #reicast.
The original reicast team consisted of drk||Raziel (mostly just writing code), PsyMan (debugging/testing and everything else) and a little bit of gb_away The original reicast team consisted of drk||Raziel (mostly just writing code), PsyMan (debugging/testing and everything else) and a little bit of gb_away

View File

@ -52,7 +52,7 @@ else
RZDCY_CXXFLAGS := \ RZDCY_CXXFLAGS := \
$(CFLAGS) -c -g -O3 -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps \ $(CFLAGS) -c -g -O3 -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps \
-D_ANDROID -DRELEASE -DTARGET_BEAGLE\ -D_ANDROID -DRELEASE -DTARGET_BEAGLE\
-march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mfloat-abi=softfp \ -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 \
-frename-registers -fsingle-precision-constant -ffast-math \ -frename-registers -fsingle-precision-constant -ffast-math \
-ftree-vectorize -fomit-frame-pointer -fno-exceptions -fno-rtti -std=gnu++11 -ftree-vectorize -fomit-frame-pointer -fno-exceptions -fno-rtti -std=gnu++11
endif endif

View File

@ -78,7 +78,7 @@ void mcfg_CreateDevices()
void mcfg_DestroyDevices() void mcfg_DestroyDevices()
{ {
for (int i=0;i<3;i++) for (int i=0;i<=3;i++)
for (int j=0;j<5;j++) for (int j=0;j<=5;j++)
delete MapleDevices[i][j]; delete MapleDevices[i][j];
} }

View File

@ -5,6 +5,8 @@
#include "maple_cfg.h" #include "maple_cfg.h"
#include <time.h> #include <time.h>
#include "deps/zlib/zlib.h"
const char* maple_sega_controller_name = "Dreamcast Controller"; const char* maple_sega_controller_name = "Dreamcast Controller";
const char* maple_sega_vmu_name = "Visual Memory"; const char* maple_sega_vmu_name = "Visual Memory";
const char* maple_sega_kbd_name = "Emulated Dreamcast Keyboard"; const char* maple_sega_kbd_name = "Emulated Dreamcast Keyboard";
@ -234,6 +236,28 @@ struct maple_sega_controller: maple_base
This is pretty much done (?) This is pretty much done (?)
*/ */
#ifdef HAS_VMU #ifdef HAS_VMU
u8 vmu_default[] = {
0x78,0x9c,0xed,0xd2,0x31,0x4e,0x02,0x61,0x10,0x06,0xd0,0x8f,0x04,0x28,0x4c,0x2c,
0x28,0x2d,0x0c,0xa5,0x57,0xe0,0x16,0x56,0x16,0x76,0x14,0x1e,0xc4,0x03,0x50,0x98,
0x50,0x40,0x69,0xc1,0x51,0x28,0xbc,0x8e,0x8a,0x0a,0xeb,0xc2,0xcf,0x66,0x13,0x1a,
0x13,0xa9,0x30,0x24,0xe6,0xbd,0xc9,0x57,0xcc,0x4c,0x33,0xc5,0x2c,0xb3,0x48,0x6e,
0x67,0x01,0x00,0x00,0x00,0x00,0x00,0x4e,0xaf,0xdb,0xe4,0x7a,0xd2,0xcf,0x53,0x16,
0x6d,0x46,0x99,0xb6,0xc9,0x78,0x9e,0x3c,0x5f,0x9c,0xfb,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x5f,0xd5,0x45,0xfd,0xef,0xaa,0xca,0x6b,0xde,0xf2,0x9e,0x55,
0x3e,0xf2,0x99,0xaf,0xac,0xb3,0x49,0x95,0xef,0xd4,0xa9,0x9a,0xdd,0xdd,0x0f,0x9d,
0x52,0xca,0xc3,0x91,0x7f,0xb9,0x9a,0x0f,0x6e,0x92,0xfb,0xee,0xa1,0x2f,0x6d,0x76,
0xe9,0x64,0x9b,0xcb,0xf4,0xf2,0x92,0x61,0x33,0x79,0xfc,0xeb,0xb7,0xe5,0x44,0xf6,
0x77,0x19,0x06,0xef,
};
struct maple_sega_vmu: maple_base struct maple_sega_vmu: maple_base
{ {
FILE* file; FILE* file;
@ -266,6 +290,20 @@ struct maple_sega_vmu: maple_base
{ {
fread(flash_data,1,sizeof(flash_data),file); fread(flash_data,1,sizeof(flash_data),file);
} }
u8 sum = 0;
for (int i=0;i<sizeof(flash_data);i++)
sum|=flash_data[i];
if (sum == 0) {
printf("Initialising empty vmu...\n");
uLongf dec_sz = sizeof(flash_data);
int rv=uncompress(flash_data, &dec_sz, vmu_default, sizeof(vmu_default));
verify(rv == Z_OK);
verify(dec_sz == sizeof(flash_data));
}
} }
virtual ~maple_sega_vmu() virtual ~maple_sega_vmu()
{ {

View File

@ -1390,15 +1390,19 @@ public:
FifoSplitter<0> TAFifo0; FifoSplitter<0> TAFifo0;
int ta_parse_cnt = 0;
bool ta_parse_vdrc(TA_context* ctx) bool ta_parse_vdrc(TA_context* ctx)
{ {
bool rv=true; bool rv=false;
verify( vd_ctx == 0); verify( vd_ctx == 0);
vd_ctx = ctx; vd_ctx = ctx;
vd_rc = vd_ctx->rend; vd_rc = vd_ctx->rend;
if (!settings.pvr.ta_skip) ta_parse_cnt++;
if (0 == (ta_parse_cnt % ( settings.pvr.ta_skip + 1)))
{ {
TAFifo0.vdec_init(); TAFifo0.vdec_init();

View File

@ -565,6 +565,22 @@ void ngen_CC_Param(shil_opcode* op,shil_param* par,CanonicalParamType tp)
switch(tp) switch(tp)
{ {
case CPT_f32rv: case CPT_f32rv:
#ifdef ARM_HARDFP
{
if (reg.IsAllocg(*par))
{
//printf("MOV(reg.map(*par),r0); %d\n",reg.map(*par));
VMOV(reg.mapg(*par),f0);
}
else if (reg.IsAllocf(*par))
{
//VMOV(reg.mapf(*par),0,r0); %d\n",reg.map(*par));
VMOV(reg.mapfs(*par),f0);
}
}
break;
#endif
case CPT_u32rv: case CPT_u32rv:
case CPT_u64rvL: case CPT_u64rvL:
{ {
@ -606,6 +622,8 @@ void ngen_CC_Param(shil_opcode* op,shil_param* par,CanonicalParamType tp)
void ngen_CC_Call(shil_opcode* op,void* function) void ngen_CC_Call(shil_opcode* op,void* function)
{ {
u32 rd=r0; u32 rd=r0;
u32 fd=f0;
for (int i=CC_pars.size();i-->0;) for (int i=CC_pars.size();i-->0;)
{ {
if (CC_pars[i].type==CPT_ptr) if (CC_pars[i].type==CPT_ptr)
@ -616,6 +634,25 @@ void ngen_CC_Call(shil_opcode* op,void* function)
{ {
if (CC_pars[i].par->is_reg()) if (CC_pars[i].par->is_reg())
{ {
#ifdef ARM_HARDFP
if (CC_pars[i].type == CPT_f32)
{
if (reg.IsAllocg(*CC_pars[i].par))
{
//printf("MOV((eReg)rd,reg.map(*CC_pars[i].par)); %d %d\n",rd,reg.map(*CC_pars[i].par));
VMOV((eFSReg)fd,reg.mapg(*CC_pars[i].par));
}
else if (reg.IsAllocf(*CC_pars[i].par))
{
//printf("LoadSh4Reg_mem((eReg)rd, *CC_pars[i].par); %d\n",rd);
VMOV((eFSReg)fd,reg.mapfs(*CC_pars[i].par));
}
else
die("Must not happen!\n");
continue;
}
#endif
if (reg.IsAllocg(*CC_pars[i].par)) if (reg.IsAllocg(*CC_pars[i].par))
{ {
//printf("MOV((eReg)rd,reg.map(*CC_pars[i].par)); %d %d\n",rd,reg.map(*CC_pars[i].par)); //printf("MOV((eReg)rd,reg.map(*CC_pars[i].par)); %d %d\n",rd,reg.map(*CC_pars[i].par));
@ -631,6 +668,7 @@ void ngen_CC_Call(shil_opcode* op,void* function)
} }
else else
{ {
verify(CC_pars[i].type != CPT_f32);
//printf("MOV32((eReg)rd, CC_pars[i].par->_imm); %d\n",rd); //printf("MOV32((eReg)rd, CC_pars[i].par->_imm); %d\n",rd);
MOV32((eReg)rd, CC_pars[i].par->_imm); MOV32((eReg)rd, CC_pars[i].par->_imm);
} }

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>

View File

@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reicast.emulator" package="com.reicast.emulator"
android:versionCode="6" android:versionCode="6"
android:versionName="0.r5+" > android:versionName="0.r6" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
@ -9,11 +9,13 @@
<uses-permission android:name="android.permission.VIBRATE"></uses-permission> <uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/title_activity_main" > android:label="@string/title_activity_main" >

View File

@ -32,10 +32,28 @@ LOCAL_MODULE := dc
LOCAL_CFLAGS := $(LOCAL_CXXFLAGS) -DHAS_VMU LOCAL_CFLAGS := $(LOCAL_CXXFLAGS) -DHAS_VMU
LOCAL_DISABLE_FORMAT_STRING_CHECKS=true LOCAL_DISABLE_FORMAT_STRING_CHECKS=true
LOCAL_ASFLAGS := -fvisibility=hidden LOCAL_ASFLAGS := -fvisibility=hidden
LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz
#-Wl,-Map,./res/raw/syms.mp3 #-Wl,-Map,./res/raw/syms.mp3
LOCAL_ARM_MODE := arm LOCAL_ARM_MODE := arm
#
# android has poor support for hardfp calling.
# r9b+ is required, and it only works for internal calls
# the opengl drivers would really benefit from this, but they are still using softfp
# the header files tell gcc to automatically use aapcs for calling system/etc
# so there is no real perfomance difference
#
# The way this is implemented is a huge hack on the android/linux side
# (but then again, which part of android isn't a huge hack?)
#ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),)
#LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -DARM_HARDFP
#LOCAL_LDLIBS += -lm_hard
#ifeq (,$(filter -fuse-ld=mcld,$(APP_LDFLAGS) $(LOCAL_LDFLAGS)))
#LOCAL_LDFLAGS += -Wl,--no-warn-mismatch
#endif
#endif
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue) $(call import-module,android/native_app_glue)

View File

@ -13,6 +13,7 @@
#include "profiler/profiler.h" #include "profiler/profiler.h"
#include "cfg/cfg.h" #include "cfg/cfg.h"
#include "rend/TexCache.h" #include "rend/TexCache.h"
#include "hw/maple/maple_devs.h"
#include "util.h" #include "util.h"
@ -29,9 +30,11 @@ extern "C"
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv *env,jobject obj,jint w,jint h) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv *env,jobject obj,jint w,jint h) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,jobject obj) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj,u32 k_code, u32 l_t, u32 r_t, u32 jx, u32 jy) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj, jintArray k_code, jintArray l_t, jintArray r_t, jintArray jx, jintArray jy) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vjoy(JNIEnv * env, jobject obj,u32 id,float x, float y, float w, float h) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vjoy(JNIEnv * env, jobject obj,u32 id,float x, float y, float w, float h) __attribute__((visibility("default")));
//JNIEXPORT jint JNICALL Java_com_reicast_emulator_JNIdc_play(JNIEnv *env,jobject obj,jshortArray result,jint size); //JNIEXPORT jint JNICALL Java_com_reicast_emulator_JNIdc_play(JNIEnv *env,jobject obj,jshortArray result,jint size);
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers) __attribute__((visibility("default")));
}; };
void egl_stealcntx(); void egl_stealcntx();
@ -39,6 +42,7 @@ void SetApplicationPath(wchar *path);
int dc_init(int argc,wchar* argv[]); int dc_init(int argc,wchar* argv[]);
void dc_run(); void dc_run();
void dc_term(); void dc_term();
void mcfg_Create(MapleDeviceType type,u32 bus,u32 port);
bool VramLockedWrite(u8* address); bool VramLockedWrite(u8* address);
@ -51,6 +55,9 @@ extern int screen_width,screen_height;
static u64 tvs_base; static u64 tvs_base;
static char CurFileName[256]; static char CurFileName[256];
// Additonal controllers 2, 3 and 4 connected ?
static bool add_controllers[3] = { false, false, false };
u16 kcode[4]; u16 kcode[4];
u32 vks[4]; u32 vks[4];
s8 joyx[4],joyy[4]; s8 joyx[4],joyy[4];
@ -84,6 +91,13 @@ static void *ThreadHandler(void *UserData)
strcat(Args[2],P); strcat(Args[2],P);
} }
// Add additonal controllers
for (int i = 0; i < 3; i++)
{
if (add_controllers[i])
mcfg_Create(MDT_SegaController,i+1,5);
}
// Run nullDC emulator // Run nullDC emulator
dc_init(Args[2]? 3:1,Args); dc_init(Args[2]? 3:1,Args);
} }
@ -247,14 +261,28 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,job
while(!rend_single_frame()) ; while(!rend_single_frame()) ;
} }
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj,u32 k_code, u32 l_t, u32 r_t, u32 jx, u32 jy) JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj, jintArray k_code, jintArray l_t, jintArray r_t, jintArray jx, jintArray jy)
{ {
lt[0] = l_t; jint *k_code_body = env->GetIntArrayElements(k_code, 0);
rt[0] = r_t; jint *l_t_body = env->GetIntArrayElements(l_t, 0);
kcode[0] = k_code; jint *r_t_body = env->GetIntArrayElements(r_t, 0);
kcode[3] = kcode[2] = kcode[1] = 0xFFFF; jint *jx_body = env->GetIntArrayElements(jx, 0);
joyx[0]=jx; jint *jy_body = env->GetIntArrayElements(jy, 0);
joyy[0]=jy;
for(int i = 0; i < 4; i++)
{
kcode[i] = k_code_body[i];
lt[i] = l_t_body[i];
rt[i] = r_t_body[i];
joyx[i] = jx_body[i];
joyy[i] = jy_body[i];
}
env->ReleaseIntArrayElements(k_code, k_code_body, 0);
env->ReleaseIntArrayElements(l_t, l_t_body, 0);
env->ReleaseIntArrayElements(r_t, r_t_body, 0);
env->ReleaseIntArrayElements(jx, jx_body, 0);
env->ReleaseIntArrayElements(jy, jy_body, 0);
} }
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv * env, jobject obj, jint w,jint h) JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv * env, jobject obj, jint w,jint h)
@ -283,6 +311,13 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vjoy(JNIEnv * env, jobjec
} }
} }
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers)
{
jboolean *controllers_body = env->GetBooleanArrayElements(controllers, 0);
memcpy(add_controllers, controllers_body, 3);
env->ReleaseBooleanArrayElements(controllers, controllers_body, 0);
}
u32 os_Push(void* frame, u32 amt, bool wait) u32 os_Push(void* frame, u32 amt, bool wait)
{ {
verify(amt==SAMPLE_COUNT); verify(amt==SAMPLE_COUNT);
@ -294,4 +329,4 @@ u32 os_Push(void* frame, u32 amt, bool wait)
bool os_IsAudioBuffered() bool os_IsAudioBuffered()
{ {
return jenv->CallIntMethod(track,writemid,jsamples,-1)==0; return jenv->CallIntMethod(track,writemid,jsamples,-1)==0;
} }

View File

@ -3,80 +3,182 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout <!-- LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/dynarec_text"
android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:layout_weight="1"
android:ems="10"
android:text="@string/select_dynarec" />
<TextView <Switch
android:layout_weight="1" android:id="@+id/dynarec_option"
android:id="@+id/textView1" android:layout_width="wrap_content"
android:layout_width="0dip" android:layout_height="wrap_content" />
android:layout_height="wrap_content" </LinearLayout -->
android:ems="10"
android:text="@string/select_stretch" />
<Switch
android:id="@+id/stretch_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/unstable_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_unstable" />
<Switch
android:id="@+id/unstable_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" > android:orientation="vertical" >
<TextView <TextView
android:id="@+id/textView1" android:id="@+id/region_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/set_frameskip" /> android:text="@string/select_region" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:orientation="horizontal" >
<SeekBar <Spinner
android:layout_weight="1" android:layout_weight="1"
android:id="@+id/frame_seekbar" android:id="@+id/region_spinner"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:ems="10" >
android:progress="0" </Spinner>
android:max="5"/>
<TextView
android:layout_weight="1"
android:id="@+id/current_frames"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:ems="10"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout -->
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/limitfps_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_limitfps" />
<Switch
android:id="@+id/limitfps_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/mipmaps_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_mipmaps" />
<Switch
android:id="@+id/mipmaps_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/stretch_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_stretch" />
<Switch
android:id="@+id/stretch_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/frameskip_text"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/set_frameskip" />
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:orientation="horizontal" >
<TextView <TextView
android:layout_weight="1" android:id="@+id/current_frames"
android:id="@+id/textView1"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<SeekBar
android:id="@+id/frame_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" android:ems="10"
android:text="@string/select_render" /> android:max="5"
android:progress="0" />
<Switch
android:id="@+id/render_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout> <!-- LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/render_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_render" />
<Switch
android:id="@+id/render_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout -->
</LinearLayout>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/touch_vibration" />
<Switch
android:id="@+id/compoundButtonTouchVibrationEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_1" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_2" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_3" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_4" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
</LinearLayout>

View File

@ -3,80 +3,183 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout <!-- LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/dynarec_text"
android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:layout_weight="1"
android:ems="10"
android:text="@string/select_dynarec" />
<TextView <CheckBox
android:layout_weight="1" android:id="@+id/dynarec_option"
android:id="@+id/textView1" android:layout_width="wrap_content"
android:layout_width="0dip" android:layout_height="wrap_content" />
android:layout_height="wrap_content" </LinearLayout -->
android:ems="10"
android:text="@string/select_stretch" />
<CheckBox
android:id="@+id/stretch_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/unstable_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_unstable" />
<CheckBox
android:id="@+id/unstable_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" > android:orientation="vertical" >
<TextView <TextView
android:id="@+id/textView1" android:id="@+id/region_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/set_frameskip" /> android:text="@string/select_region" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:orientation="horizontal" >
<SeekBar <Spinner
android:layout_weight="1" android:layout_weight="1"
android:id="@+id/frame_seekbar" android:id="@+id/region_spinner"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:ems="10" >
android:progress="0"
android:max="5"/> </Spinner>
<TextView
android:layout_weight="1"
android:id="@+id/current_frames"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:ems="10"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout -->
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/limitfps_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_limitfps" />
<CheckBox
android:id="@+id/limitfps_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/mipmaps_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_mipmaps" />
<CheckBox
android:id="@+id/mipmaps_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/stretch_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_stretch" />
<CheckBox
android:id="@+id/stretch_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/frameskip_text"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/set_frameskip" />
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:orientation="horizontal" >
<TextView <TextView
android:layout_weight="1" android:id="@+id/current_frames"
android:id="@+id/textView1"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<SeekBar
android:id="@+id/frame_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" android:ems="10"
android:text="@string/select_render" /> android:max="5"
android:progress="0" />
<CheckBox
android:id="@+id/render_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/render_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:text="@string/select_render" />
<CheckBox
android:id="@+id/render_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout -->
</LinearLayout>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/touch_vibration" />
<CheckBox
android:id="@+id/compoundButtonTouchVibrationEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_1" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_2" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_3" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_4" />
<TextView
android:layout_weight="1"
android:id="@+id/textViewDeviceDescriptorPlayer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<Button
android:layout_weight="1"
android:id="@+id/buttonSelectControllerPlayer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_controller" />
<Button
android:layout_weight="1"
android:id="@+id/buttonRemoveControllerPlayer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_controller" />
</LinearLayout>
</LinearLayout>

View File

@ -28,6 +28,17 @@
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="32dp" /> android:textSize="32dp" />
<ImageView
android:id="@+id/options"
android:layout_width="48dp"
android:layout_height="fill_parent"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:scaleType="fitCenter"
android:src="@drawable/open_folder" />
<ImageView <ImageView
android:id="@+id/config" android:id="@+id/config"
android:layout_width="48dp" android:layout_width="48dp"
@ -50,4 +61,9 @@
android:src="@drawable/question" /> android:src="@drawable/question" />
</LinearLayout> </LinearLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,80 @@
<resources>
<string name="app_name">reicast</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">セッティング</string>
<string name="title_activity_main">reicast</string>
<string name="system_path">システムパス (とのデータフォルダーの場所 dc_boot.bin/dc_flash.bin)</string>
<string name="browser_path">デフォルトのシステムパス</string>
<string name="games_path">ストレージパス (の場所 .gdi .cdi or .cdh イメージ)</string>
<string name="game_path">デフォルトゲーム·ストレージ</string>
<string name="boot_bios">ブートドリームキャストビオス</string>
<string name="missing_bios">BIOSが不足している。ドリームキャストBIOSが動作するように、このエミュレータに必要です。 BIOSファイル内に配置します %1$s/data/dc_boot.bin</string>
<string name="missing_flash">行方不明に点滅します。ドリームキャストのFlashが動作するためにこのエミュレータに必要です。 Flashファイル内に配置します %1$s/data/dc_flash.bin</string>
<string name="require_bios">あなたは、BIOSを提供する必要が</string>
<string name="folder_bios">BOOT BIOS</string>
<string name="folder_select">SELECT CURRENT FOLDER</string>
<string name="select_dynarec">Dynarec Options</string>
<string name="select_unstable">Unstable Optimisations</string>
<string name="select_region">DC Region</string>
<string name="select_limitfps">Limit FPS</string>
<string name="select_mipmaps">Use Mipmaps (古いSGX540のために修正)</string>
<string name="select_stretch">Widescreen Mode</string>
<string name="set_frameskip">Frameskip Value</string>
<string name="select_render">PVR Rendering</string>
<string name="games_listing">利用可能なドリームキャストのゲーム</string>
<string name="controller_1">コントローラ 1</string>
<string name="controller_2">コントローラ 2</string>
<string name="controller_3">コントローラ 3</string>
<string name="controller_4">コントローラ 4</string>
<string name="controller_none">None</string>
<string name="select_controller">セレクトコントローラ</string>
<string name="remove_controller">コントローラを取り外し</string>
<string name="select_controller_title">セレクトコントローラ</string>
<string name="select_controller_message">ポートに割り当てるコントローラのいずれかのボタンを押してください</string>
<string name="controller_already_in_use">このコントローラは、すでに使用されています!</string>
<string-array name="images">
<item>cdi</item>
<item>chd</item>
<item>gdi</item>
</string-array>
<string-array name="region">
<item></item>
<item></item>
<item></item>
<item>(Default)</item>
</string-array>
<string name="drawer_open">Slider Menu Opened</string>
<string name="drawer_close">Slider Menu Closed</string>
<!-- Nav Drawer Menu Items -->
<string-array name="nav_drawer_items">
<item>Browser</item>
<item>Settings</item>
<item>Paths</item>
<item>Controllers</item>
<item>About</item>
</string-array>
<!-- Nav Drawer List Item Icons -->
<!-- Matched to Nav Drawer Menu Items -->
<array name="nav_drawer_icons">
<item>@drawable/disk_unknown</item>
<item>@drawable/config</item>
<item>@drawable/open_folder</item>
<item>@drawable/config</item>
<item>@drawable/question</item>
</array>
<!-- Content Description -->
<string name="desc_list_item_icon">Item Icon</string>
</resources>

View File

@ -4,20 +4,58 @@
<string name="hello_world">Hello world!</string> <string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string> <string name="menu_settings">Settings</string>
<string name="title_activity_main">reicast</string> <string name="title_activity_main">reicast</string>
<string name="system_path">System Path (location of dc_boot.bin/dc_flash.bin)</string> <string name="system_path">System Path (location of the data folder with dc_boot.bin/dc_flash.bin inside)</string>
<string name="browser_path">Default System Path</string> <string name="browser_path">Default System Path</string>
<string name="games_path">Storage Path (location of .gid .cdi or .cdh images)</string> <string name="games_path">Storage Path (location of .gdi, .chd or .cdi images)</string>
<string name="game_path">Default Game Storage</string> <string name="game_path">Default Game Storage</string>
<string name="select_stretch">Stretch to Fullscreen</string>
<string name="set_frameskip">Frameskipping Amount</string> <string name="boot_bios">Boot Dreamcast Bios</string>
<string name="select_render">PVR Rendering</string> <string name="missing_bios">BIOS Missing. The Dreamcast BIOS is required for this emulator to work. Place the BIOS file in %1$s/data/dc_boot.bin</string>
<string name="missing_flash">Flash Missing. The Dreamcast Flash is required for this emulator to work. Place the Flash file in %1$s/data/dc_flash.bin</string>
<string name="require_bios">You have to provide the BIOS</string>
<string name="folder_bios">BOOT BIOS</string>
<string name="folder_select">SELECT CURRENT FOLDER</string>
<string name="select_dynarec">Dynarec Options</string>
<string name="select_unstable">Unstable Optimisations</string>
<string name="select_region">DC Region</string>
<string name="select_limitfps">Limit FPS</string>
<string name="select_mipmaps">Use Mipmaps (fix for old SGX540)</string>
<string name="select_stretch">Widescreen Mode</string>
<string name="set_frameskip">Frameskip Value</string>
<string name="select_render">PVR Rendering (does nothing for now)</string>
<string name="games_listing">Available Dreamcast Games</string> <string name="games_listing">Available Dreamcast Games</string>
<string name="touch_vibration">Touch Vibration</string>
<string name="controller_1">Controller 1</string>
<string name="controller_2">Controller 2</string>
<string name="controller_3">Controller 3</string>
<string name="controller_4">Controller 4</string>
<string name="controller_not_connected">Controller Not Connected</string>
<string name="controller_none_selected">No Controller Selected</string>
<string name="select_controller">Select Controller</string>
<string name="remove_controller">Remove Controller</string>
<string name="select_controller_title">Select Controller</string>
<string name="select_controller_message">Press any button on the controller to assign to port</string>
<string name="controller_already_in_use">This controller is already in use!</string>
<string name="about_title">About reicast</string>
<string name="about_text">reicast is a dreamcast emulator\n\nVersion:</string>
<string-array name="images"> <string-array name="images">
<item>cdi</item> <item>cdi</item>
<item>chd</item> <item>chd</item>
<item>gdi</item> <item>gdi</item>
</string-array> </string-array>
<string-array name="region">
<item></item>
<item></item>
<item></item>
<item>(Default)</item>
</string-array>
<string name="drawer_open">Slider Menu Opened</string> <string name="drawer_open">Slider Menu Opened</string>
<string name="drawer_close">Slider Menu Closed</string> <string name="drawer_close">Slider Menu Closed</string>
@ -25,16 +63,18 @@
<!-- Nav Drawer Menu Items --> <!-- Nav Drawer Menu Items -->
<string-array name="nav_drawer_items"> <string-array name="nav_drawer_items">
<item>Browser</item> <item>Browser</item>
<item>Options</item> <item>Settings</item>
<item>Emulator</item> <item>Paths</item>
<item>Controllers</item>
<item>About</item> <item>About</item>
</string-array> </string-array>
<!-- Nav Drawer List Item Icons --> <!-- Nav Drawer List Item Icons -->
<!-- Keep them in order as the titles are in --> <!-- Matched to Nav Drawer Menu Items -->
<array name="nav_drawer_icons"> <array name="nav_drawer_icons">
<item>@drawable/disk_unknown</item> <item>@drawable/disk_unknown</item>
<item>@drawable/config</item> <item>@drawable/config</item>
<item>@drawable/open_folder</item>
<item>@drawable/config</item> <item>@drawable/config</item>
<item>@drawable/question</item> <item>@drawable/question</item>
</array> </array>
@ -42,4 +82,4 @@
<!-- Content Description --> <!-- Content Description -->
<string name="desc_list_item_icon">Item Icon</string> <string name="desc_list_item_icon">Item Icon</string>
</resources> </resources>

View File

@ -32,9 +32,15 @@ public class ConfigureFragment extends Fragment {
Activity parentActivity; Activity parentActivity;
TextView mainFrames; TextView mainFrames;
OnClickListener mCallback; OnClickListener mCallback;
boolean dynarecopt = true;
boolean unstableopt = false;
int dcregion = 3;
boolean limitfps = true;
boolean mipmaps = true;
boolean widescreen = false; boolean widescreen = false;
boolean pvrrender = false;
int frameskip = 0; int frameskip = 0;
boolean pvrrender = false;
private SharedPreferences mPrefs; private SharedPreferences mPrefs;
private File sdcard = Environment.getExternalStorageDirectory(); private File sdcard = Environment.getExternalStorageDirectory();
@ -74,6 +80,29 @@ public class ConfigureFragment extends Fragment {
String currentLine; String currentLine;
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
currentLine = scanner.nextLine(); currentLine = scanner.nextLine();
// Check if the existing emu.cfg has the setting and get current value
/*if (StringUtils.containsIgnoreCase(currentLine, "Dynarec.Enabled")) {
dynarecopt = Boolean.valueOf(currentLine.replace(
"Dynarec.Enabled=", ""));
}*/
if (StringUtils.containsIgnoreCase(currentLine, "Dynarec.unstable-opt")) {
unstableopt = Boolean.valueOf(currentLine.replace(
"Dynarec.unstable-opt=", ""));
}
/*if (StringUtils.containsIgnoreCase(currentLine, "Dreamcast.Region")) {
dcregion = Integer.valueOf(currentLine.replace(
"Dreamcast.Region=", ""));
}*/
if (StringUtils.containsIgnoreCase(currentLine, "aica.LimitFPS")) {
limitfps = Boolean.valueOf(currentLine.replace(
"aica.LimitFPS=", ""));
}
if (StringUtils.containsIgnoreCase(currentLine, "rend.UseMipmaps")) {
mipmaps = Boolean.valueOf(currentLine.replace(
"rend.UseMipmaps=", ""));
}
if (StringUtils.containsIgnoreCase(currentLine, if (StringUtils.containsIgnoreCase(currentLine,
"rend.WideScreen")) { "rend.WideScreen")) {
widescreen = Boolean.valueOf(currentLine.replace( widescreen = Boolean.valueOf(currentLine.replace(
@ -83,19 +112,187 @@ public class ConfigureFragment extends Fragment {
frameskip = Integer.valueOf(currentLine.replace( frameskip = Integer.valueOf(currentLine.replace(
"ta.skip=", "")); "ta.skip=", ""));
} }
if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) { /*if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) {
pvrrender = Boolean.valueOf(currentLine.replace( pvrrender = Boolean.valueOf(currentLine.replace(
"pvr.rend=", "")); "pvr.rend=", ""));
} }*/
} }
scanner.close(); scanner.close();
} }
} catch (Exception e) { } catch (Exception e) {
Log.d("reicast", "Exception: " + e); Log.d("reicast", "Exception: " + e);
} }
// Generate the menu options and fill in existing settings
/*OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() {
mainFrames = (TextView) getView().findViewById(R.id.current_frames); public void onCheckedChanged(CompoundButton buttonView,
mainFrames.setText(String.valueOf(frameskip)); boolean isChecked) {
mPrefs.edit().putBoolean("dynarec_opt", isChecked).commit();
dynarecopt = isChecked;
if (!executeAppendConfig("Dynarec.Enabled",
String.valueOf(isChecked ? 1 : 0))) {
executeWriteConfig();
}
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
Switch dynarec_opt = (Switch) getView().findViewById(
R.id.dynarec_option);
boolean dynarec = mPrefs.getBoolean("dynarec_opt", dynarecopt);
if (dynarec) {
dynarec_opt.setChecked(true);
} else {
dynarec_opt.setChecked(false);
}
dynarec_opt.setOnCheckedChangeListener(dynarec_options);
} else {
CheckBox dynarec_opt = (CheckBox) getView().findViewById(
R.id.dynarec_option);
boolean dynarec = mPrefs.getBoolean("dynarec_opt", dynarecopt);
if (dynarec) {
dynarec_opt.setChecked(true);
} else {
dynarec_opt.setChecked(false);
}
dynarec_opt.setOnCheckedChangeListener(dynarec_options);
}*/
OnCheckedChangeListener unstable_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean("unstable_opt", isChecked).commit();
unstableopt = isChecked;
if (!executeAppendConfig("Dynarec.unstable-opt",
String.valueOf(isChecked ? 1 : 0))) {
executeWriteConfig();
}
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
Switch unstable_opt = (Switch) getView().findViewById(
R.id.unstable_option);
boolean unstable = mPrefs.getBoolean("unstable_opt", unstableopt);
if (unstable) {
unstable_opt.setChecked(true);
} else {
unstable_opt.setChecked(false);
}
unstable_opt.setOnCheckedChangeListener(unstable_option);
} else {
CheckBox unstable_opt = (CheckBox) getView().findViewById(
R.id.unstable_option);
boolean unstable = mPrefs.getBoolean("unstable_opt", unstableopt);
if (unstable) {
unstable_opt.setChecked(true);
} else {
unstable_opt.setChecked(false);
}
unstable_opt.setOnCheckedChangeListener(unstable_option);
}
/*String[] regions = parentActivity.getResources().getStringArray(R.array.region);
Spinner region_spnr = (Spinner) getView().findViewById(
R.id.region_spinner);
ArrayAdapter<String> localeAdapter = new ArrayAdapter<String>(
parentActivity, android.R.layout.simple_spinner_item, regions);
localeAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
region_spnr.setAdapter(localeAdapter);
int dc_region = mPrefs.getInt("dc_region", dcregion);
region_spnr.setSelection(dc_region, true);
region_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
mPrefs.edit().putInt("dc_region", pos).commit();
dcregion = pos;
if (!executeAppendConfig("Dreamcast.Region",
String.valueOf(pos))) {
executeWriteConfig();
}
}
public void onNothingSelected(AdapterView<?> arg0) {
mPrefs.edit().putInt("dc_region", 3).commit();
}
});*/
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean("limit_fps", isChecked).commit();
limitfps = isChecked;
if (!executeAppendConfig("aica.LimitFPS",
String.valueOf(isChecked ? 1 : 0))) {
executeWriteConfig();
}
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
Switch limit_fps = (Switch) getView().findViewById(
R.id.limitfps_option);
boolean limited = mPrefs.getBoolean("limit_fps", limitfps);
if (limited) {
limit_fps.setChecked(true);
} else {
limit_fps.setChecked(false);
}
limit_fps.setOnCheckedChangeListener(limitfps_option);
} else {
CheckBox limit_fps = (CheckBox) getView().findViewById(
R.id.limitfps_option);
boolean limited = mPrefs.getBoolean("limit_fps", limitfps);
if (limited) {
limit_fps.setChecked(true);
} else {
limit_fps.setChecked(false);
}
limit_fps.setOnCheckedChangeListener(limitfps_option);
}
OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean("use_mipmaps", isChecked).commit();
mipmaps = isChecked;
if (!executeAppendConfig("rend.UseMipmaps",
String.valueOf(isChecked ? 1 : 0))) {
executeWriteConfig();
}
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
Switch mipmap_opt = (Switch) getView().findViewById(
R.id.mipmaps_option);
boolean mipmapped = mPrefs.getBoolean("use_mipmaps", mipmaps);
if (mipmapped) {
mipmap_opt.setChecked(true);
} else {
mipmap_opt.setChecked(false);
}
mipmap_opt.setOnCheckedChangeListener(mipmaps_option);
} else {
CheckBox mipmap_opt = (CheckBox) getView().findViewById(
R.id.mipmaps_option);
boolean mipmapped = mPrefs.getBoolean("use_mipmaps", mipmaps);
if (mipmapped) {
mipmap_opt.setChecked(true);
} else {
mipmap_opt.setChecked(false);
}
mipmap_opt.setOnCheckedChangeListener(mipmaps_option);
}
OnCheckedChangeListener full_screen = new OnCheckedChangeListener() { OnCheckedChangeListener full_screen = new OnCheckedChangeListener() {
@ -130,6 +327,9 @@ public class ConfigureFragment extends Fragment {
} }
stretch_view.setOnCheckedChangeListener(full_screen); stretch_view.setOnCheckedChangeListener(full_screen);
} }
mainFrames = (TextView) getView().findViewById(R.id.current_frames);
mainFrames.setText(String.valueOf(frameskip));
SeekBar frameSeek = (SeekBar) getView() SeekBar frameSeek = (SeekBar) getView()
.findViewById(R.id.frame_seekbar); .findViewById(R.id.frame_seekbar);
@ -160,7 +360,7 @@ public class ConfigureFragment extends Fragment {
} }
}); });
OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() { /*OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
@ -192,13 +392,16 @@ public class ConfigureFragment extends Fragment {
pvr_render.setChecked(false); pvr_render.setChecked(false);
} }
pvr_render.setOnCheckedChangeListener(pvr_rendering); pvr_render.setOnCheckedChangeListener(pvr_rendering);
} }*/
} }
private boolean executeAppendConfig(String identifier, String value) { private boolean executeAppendConfig(String identifier, String value) {
File config = new File(home_directory, "emu.cfg"); File config = new File(home_directory, "emu.cfg");
if (config.exists()) { if (config.exists()) {
try { try {
// Read existing emu.cfg and substitute new setting value
StringBuilder rebuildFile = new StringBuilder(); StringBuilder rebuildFile = new StringBuilder();
Scanner scanner = new Scanner(config); Scanner scanner = new Scanner(config);
String currentLine; String currentLine;
@ -229,24 +432,26 @@ public class ConfigureFragment extends Fragment {
if (config.exists()) { if (config.exists()) {
config.delete(); config.delete();
} }
// Write new emu.cfg using current display values
StringBuilder rebuildFile = new StringBuilder(); StringBuilder rebuildFile = new StringBuilder();
rebuildFile.append("[config]" + "\n"); rebuildFile.append("[config]" + "\n");
rebuildFile.append("Dynarec.Enabled=1" + "\n"); rebuildFile.append("Dynarec.Enabled=" + String.valueOf(dynarecopt ? 1 : 0) + "\n");
rebuildFile.append("Dynarec.idleskip=1" + "\n"); rebuildFile.append("Dynarec.idleskip=1" + "\n");
rebuildFile.append("Dynarec.unstable-opt=0" + "\n"); rebuildFile.append("Dynarec.unstable-opt=" + String.valueOf(unstableopt ? 1 : 0) + "\n");
rebuildFile.append("Dreamcast.Cable=3" + "\n"); rebuildFile.append("Dreamcast.Cable=3" + "\n");
rebuildFile.append("Dreamcast.RTC=2018927206" + "\n"); rebuildFile.append("Dreamcast.RTC=2018927206" + "\n");
rebuildFile.append("Dreamcast.Region=3" + "\n"); rebuildFile.append("Dreamcast.Region=" + String.valueOf(dcregion) + "\n");
rebuildFile.append("Dreamcast.Broadcast=4" + "\n"); rebuildFile.append("Dreamcast.Broadcast=4" + "\n");
rebuildFile.append("aica.LimitFPS=1" + "\n"); rebuildFile.append("aica.LimitFPS=" + String.valueOf(limitfps ? 1 : 0) + "\n");
rebuildFile.append("aica.NoBatch=0" + "\n"); rebuildFile.append("aica.NoBatch=0" + "\n");
rebuildFile.append("rend.UseMipmaps=1" + "\n"); rebuildFile.append("rend.UseMipmaps=" + String.valueOf(mipmaps ? 1 : 0) + "\n");
rebuildFile.append("rend.WideScreen=" rebuildFile.append("rend.WideScreen="
+ String.valueOf(widescreen ? 1 : 0) + "\n"); + String.valueOf(widescreen ? 1 : 0) + "\n");
rebuildFile.append("pvr.Subdivide=0" + "\n"); rebuildFile.append("pvr.Subdivide=0" + "\n");
rebuildFile.append("ta.skip=" + String.valueOf(frameskip) + "\n"); rebuildFile.append("ta.skip=" + String.valueOf(frameskip) + "\n");
rebuildFile.append("pvr.rend=" + String.valueOf(pvrrender ? 1 : 0) rebuildFile.append("pvr.rend=" + String.valueOf(pvrrender ? 1 : 0) + "\n");
+ "\n");
rebuildFile.append("image=null" + "\n"); rebuildFile.append("image=null" + "\n");
FileOutputStream fos = new FileOutputStream(config); FileOutputStream fos = new FileOutputStream(config);
fos.write(rebuildFile.toString().getBytes()); fos.write(rebuildFile.toString().getBytes());

View File

@ -0,0 +1,311 @@
package com.reicast.emulator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class ControllersFragment extends Fragment {
private Activity parentActivity;
private int listenForButton = 0;
private AlertDialog alertDialogSelectController;
private SharedPreferences sharedPreferences;
// Container Activity must implement this interface
public interface OnClickListener {
public void onMainBrowseSelected(String path_entry, boolean games);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.controllers_fragment, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
parentActivity = getActivity();
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(parentActivity);
CompoundButton compoundButtonTouchVibrationEnabled = (CompoundButton) getView()
.findViewById(R.id.compoundButtonTouchVibrationEnabled);
compoundButtonTouchVibrationEnabled.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
sharedPreferences.edit().putBoolean("touch_vibration_enabled", isChecked).commit();
}
});
Button buttonSelectControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer1);
buttonSelectControllerPlayer1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(1);
}
});
Button buttonSelectControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer2);
buttonSelectControllerPlayer2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(2);
}
});
Button buttonSelectControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer3);
buttonSelectControllerPlayer3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(3);
}
});
Button buttonSelectControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer4);
buttonSelectControllerPlayer4.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(4);
}
});
Button buttonRemoveControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer1);
buttonRemoveControllerPlayer1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(1);
}
});
Button buttonRemoveControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer2);
buttonRemoveControllerPlayer2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(2);
}
});
Button buttonRemoveControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer3);
buttonRemoveControllerPlayer3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(3);
}
});
Button buttonRemoveControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer4);
buttonRemoveControllerPlayer4.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(4);
}
});
updateVibration();
updateControllers();
}
private void updateVibration() {
boolean touchVibrationEnabled = sharedPreferences.getBoolean("touch_vibration_enabled", true);
CompoundButton compoundButtonTouchVibrationEnabled = (CompoundButton) getView()
.findViewById(R.id.compoundButtonTouchVibrationEnabled);
compoundButtonTouchVibrationEnabled.setChecked(touchVibrationEnabled);
}
private void updateControllers() {
String deviceDescriptorPlayer1 = sharedPreferences.getString("device_descriptor_player_1", null);
String deviceDescriptorPlayer2 = sharedPreferences.getString("device_descriptor_player_2", null);
String deviceDescriptorPlayer3 = sharedPreferences.getString("device_descriptor_player_3", null);
String deviceDescriptorPlayer4 = sharedPreferences.getString("device_descriptor_player_4", null);
String labelPlayer1 = null, labelPlayer2 = null, labelPlayer3 = null, labelPlayer4 = null;
for (int devideId : InputDevice.getDeviceIds()) {
InputDevice dev = InputDevice.getDevice(devideId);
String descriptor = dev.getDescriptor();
if (descriptor != null) {
if (descriptor.equals(deviceDescriptorPlayer1))
labelPlayer1 = dev.getName() + " (" + descriptor + ")";
else if (descriptor.equals(deviceDescriptorPlayer2))
labelPlayer2 = dev.getName() + " (" + descriptor + ")";
else if (descriptor.equals(deviceDescriptorPlayer3))
labelPlayer3 = dev.getName() + " (" + descriptor + ")";
else if (descriptor.equals(deviceDescriptorPlayer4))
labelPlayer4 = dev.getName() + " (" + descriptor + ")";
}
}
TextView textViewDeviceDescriptorPlayer1 = (TextView) getView()
.findViewById(R.id.textViewDeviceDescriptorPlayer1);
Button buttonRemoveControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer1);
if (labelPlayer1 != null) {
textViewDeviceDescriptorPlayer1.setText(labelPlayer1);
buttonRemoveControllerPlayer1.setEnabled(true);
} else {
if (deviceDescriptorPlayer1 != null) {
textViewDeviceDescriptorPlayer1.setText(getString(R.string.controller_not_connected) + " (" + deviceDescriptorPlayer1 + ")");
buttonRemoveControllerPlayer1.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer1.setText(getString(R.string.controller_none_selected));
buttonRemoveControllerPlayer1.setEnabled(false);
}
}
TextView textViewDeviceDescriptorPlayer2 = (TextView) getView()
.findViewById(R.id.textViewDeviceDescriptorPlayer2);
Button buttonRemoveControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer2);
if (labelPlayer2 != null) {
textViewDeviceDescriptorPlayer2.setText(labelPlayer2);
buttonRemoveControllerPlayer2.setEnabled(true);
} else {
if (deviceDescriptorPlayer2 != null) {
textViewDeviceDescriptorPlayer2.setText(getString(R.string.controller_not_connected) + " (" + deviceDescriptorPlayer2 + ")");
buttonRemoveControllerPlayer2.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer2.setText(getString(R.string.controller_none_selected));
buttonRemoveControllerPlayer2.setEnabled(false);
}
}
TextView textViewDeviceDescriptorPlayer3 = (TextView) getView()
.findViewById(R.id.textViewDeviceDescriptorPlayer3);
Button buttonRemoveControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer3);
if (labelPlayer3 != null) {
textViewDeviceDescriptorPlayer3.setText(labelPlayer3);
buttonRemoveControllerPlayer3.setEnabled(true);
} else {
if (deviceDescriptorPlayer3 != null) {
textViewDeviceDescriptorPlayer3.setText(getString(R.string.controller_not_connected) + " (" + deviceDescriptorPlayer3 + ")");
buttonRemoveControllerPlayer3.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer3.setText(getString(R.string.controller_none_selected));
buttonRemoveControllerPlayer3.setEnabled(false);
}
}
TextView textViewDeviceDescriptorPlayer4 = (TextView) getView()
.findViewById(R.id.textViewDeviceDescriptorPlayer4);
Button buttonRemoveControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer4);
if (labelPlayer4 != null) {
textViewDeviceDescriptorPlayer4.setText(labelPlayer4);
buttonRemoveControllerPlayer4.setEnabled(true);
} else {
if (deviceDescriptorPlayer4 != null) {
textViewDeviceDescriptorPlayer4.setText(getString(R.string.controller_not_connected) + " (" + deviceDescriptorPlayer4 + ")");
buttonRemoveControllerPlayer4.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer4.setText(getString(R.string.controller_none_selected));
buttonRemoveControllerPlayer4.setEnabled(false);
}
}
}
private void selectController(int playerNum) {
listenForButton = playerNum;
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(getString(R.string.select_controller_title));
builder.setMessage(getString(R.string.select_controller_message) + " " + String.valueOf(listenForButton) + ".");
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
listenForButton = 0;
dialog.dismiss();
}
});
builder.setOnKeyListener(new Dialog.OnKeyListener() {
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return mapDevice(keyCode, event);
}
});
alertDialogSelectController = builder.create();
alertDialogSelectController.show();
}
private boolean mapDevice(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
return false;
String descriptor = InputDevice.getDevice(event.getDeviceId()).getDescriptor();
if (descriptor == null)
return false;
String deviceDescriptorPlayer1 = sharedPreferences.getString("device_descriptor_player_1", null);
String deviceDescriptorPlayer2 = sharedPreferences.getString("device_descriptor_player_2", null);
String deviceDescriptorPlayer3 = sharedPreferences.getString("device_descriptor_player_3", null);
String deviceDescriptorPlayer4 = sharedPreferences.getString("device_descriptor_player_4", null);
if (descriptor.equals(deviceDescriptorPlayer1) || descriptor.equals(deviceDescriptorPlayer2) ||
descriptor.equals(deviceDescriptorPlayer3) || descriptor.equals(deviceDescriptorPlayer4)) {
Toast.makeText(parentActivity, getString(R.string.controller_already_in_use), Toast.LENGTH_SHORT).show();
return true;
}
switch(listenForButton) {
case 0:
return false;
case 1:
sharedPreferences.edit().putString("device_descriptor_player_1", descriptor).commit();
break;
case 2:
sharedPreferences.edit().putString("device_descriptor_player_2", descriptor).commit();
break;
case 3:
sharedPreferences.edit().putString("device_descriptor_player_3", descriptor).commit();
break;
case 4:
sharedPreferences.edit().putString("device_descriptor_player_4", descriptor).commit();
break;
}
Log.d("New controller for port " + String.valueOf(listenForButton) + ":", descriptor);
listenForButton = 0;
alertDialogSelectController.cancel();
updateControllers();
return true;
}
private void removeController(int playerNum) {
switch(playerNum) {
case 1:
sharedPreferences.edit().putString("device_descriptor_player_1", null).commit();
break;
case 2:
sharedPreferences.edit().putString("device_descriptor_player_2", null).commit();
break;
case 3:
sharedPreferences.edit().putString("device_descriptor_player_3", null).commit();
break;
case 4:
sharedPreferences.edit().putString("device_descriptor_player_4", null).commit();
break;
}
updateControllers();
}
}

View File

@ -152,18 +152,6 @@ public class FileBrowser extends Fragment {
if (!home.exists() || !home.isDirectory()) { if (!home.exists() || !home.isDirectory()) {
Toast.makeText(getActivity(), "Please configure a home directory", Toast.makeText(getActivity(), "Please configure a home directory",
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
OptionsFragment optsFrag = (OptionsFragment) getActivity()
.getSupportFragmentManager().findFragmentByTag(
"OPTIONS_FRAG");
if (optsFrag != null) {
if (optsFrag.isVisible()) {
return;
}
}
optsFrag = new OptionsFragment();
getActivity().getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, optsFrag, "OPTIONS_FRAG")
.addToBackStack(null).commit();
} }
if (!ImgBrowse) { if (!ImgBrowse) {
@ -171,67 +159,6 @@ public class FileBrowser extends Fragment {
} else { } else {
generate(ExternalFiles(new File(game_directory))); generate(ExternalFiles(new File(game_directory)));
} }
File bios = new File(home_directory, "data/dc_boot.bin");
File flash = new File(home_directory, "data/dc_flash.bin");
String msg = null;
if (!bios.exists())
msg = "BIOS Missing. The Dreamcast BIOS is required for this emulator to work. Place the BIOS file in "
+ home_directory + "/data/dc_boot.bin";
else if (!flash.exists())
msg = "Flash Missing. The Dreamcast Flash is required for this emulator to work. Place the Flash file in "
+ home_directory + "/data/dc_flash.bin";
if (msg != null) {
vib.vibrate(50);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
parentActivity);
// set title
alertDialogBuilder.setTitle("You have to provide the BIOS");
// set dialog message
alertDialogBuilder
.setMessage(msg)
.setCancelable(false)
.setPositiveButton("Dismiss",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
// if this button is clicked, close
// current activity
parentActivity.finish();
}
})
.setNegativeButton("Options",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
OptionsFragment optsFrag = (OptionsFragment) getActivity()
.getSupportFragmentManager()
.findFragmentByTag("OPTIONS_FRAG");
if (optsFrag != null) {
if (optsFrag.isVisible()) {
return;
}
}
optsFrag = new OptionsFragment();
getActivity()
.getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container,
optsFrag, "OPTIONS_FRAG")
.addToBackStack(null).commit();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
} }
class DirSort implements Comparator<File> { class DirSort implements Comparator<File> {
@ -291,10 +218,11 @@ public class FileBrowser extends Fragment {
.findViewById(R.id.game_list); .findViewById(R.id.game_list);
v.removeAllViews(); v.removeAllViews();
((TextView) parentActivity.findViewById(R.id.text_cwd)).setText(R.string.games_listing);
bootBiosItem(v); bootBiosItem(v);
((TextView) parentActivity.findViewById(R.id.text_cwd))
.setText(R.string.games_listing);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
final View childview = parentActivity.getLayoutInflater().inflate( final View childview = parentActivity.getLayoutInflater().inflate(
R.layout.app_list_item, null, false); R.layout.app_list_item, null, false);
@ -377,7 +305,7 @@ public class FileBrowser extends Fragment {
R.layout.app_list_item, null, false); R.layout.app_list_item, null, false);
((TextView) childview.findViewById(R.id.item_name)) ((TextView) childview.findViewById(R.id.item_name))
.setText("Boot Dreamcast Bios"); .setText(getString(R.string.boot_bios));
childview.setTag(null); childview.setTag(null);
@ -476,10 +404,10 @@ public class FileBrowser extends Fragment {
if (list.get(i) == null) { if (list.get(i) == null) {
if (ImgBrowse == true) if (ImgBrowse == true)
((TextView) childview.findViewById(R.id.item_name)) ((TextView) childview.findViewById(R.id.item_name))
.setText("BOOT BIOS"); .setText(getString(R.string.folder_bios));
if (ImgBrowse == false) if (ImgBrowse == false)
((TextView) childview.findViewById(R.id.item_name)) ((TextView) childview.findViewById(R.id.item_name))
.setText("SELECT CURRENT FOLDER"); .setText(getString(R.string.folder_select));
} else if (list.get(i) == parent) } else if (list.get(i) == parent)
((TextView) childview.findViewById(R.id.item_name)) ((TextView) childview.findViewById(R.id.item_name))
.setText(".."); .setText("..");
@ -529,7 +457,7 @@ public class FileBrowser extends Fragment {
.fromFile(new File(root_sd .fromFile(new File(root_sd
.getAbsolutePath()))); .getAbsolutePath())));
vib.vibrate(250); vib.vibrate(250);
if (games) { if (games) {
game_directory = root_sd.getAbsolutePath(); game_directory = root_sd.getAbsolutePath();
mPrefs.edit() mPrefs.edit()
@ -540,8 +468,8 @@ public class FileBrowser extends Fragment {
mPrefs.edit() mPrefs.edit()
.putString("home_directory", .putString("home_directory",
home_directory).commit(); home_directory).commit();
File data_directory = new File(home_directory, File data_directory = new File(
"data"); home_directory, "data");
if (!data_directory.exists() if (!data_directory.exists()
|| !data_directory.isDirectory()) { || !data_directory.isDirectory()) {
data_directory.mkdirs(); data_directory.mkdirs();
@ -592,5 +520,4 @@ public class FileBrowser extends Fragment {
v.addView(sep); v.addView(sep);
} }
} }
} }

View File

@ -2,35 +2,35 @@ package com.reicast.emulator;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap;
import tv.ouya.console.api.OuyaController; import tv.ouya.console.api.OuyaController;
import com.reicast.emulator.GL2JNIView.EmuThread; import com.reicast.emulator.GL2JNIView.EmuThread;
import android.view.InputDevice; import android.content.SharedPreferences;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView.ScaleType; import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import android.widget.Toast; import android.widget.Toast;
import android.net.Uri;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class GL2JNIActivity extends Activity { public class GL2JNIActivity extends Activity {
@ -38,9 +38,13 @@ public class GL2JNIActivity extends Activity {
PopupWindow popUp; PopupWindow popUp;
LayoutParams params; LayoutParams params;
MOGAInput moga = new MOGAInput(); MOGAInput moga = new MOGAInput();
static boolean nVidia = false; static boolean[] xbox = { false, false, false, false }, nVidia = { false, false, false, false };
float[] globalLS_X = new float[4], globalLS_Y = new float[4], previousLS_X = new float[4], previousLS_Y = new float[4];
int map[]; public static HashMap<Integer, String> deviceId_deviceDescriptor = new HashMap<Integer, String>();
public static HashMap<String, Integer> deviceDescriptor_PlayerNum = new HashMap<String, Integer>();
int map[][];
View addbut(int x, OnClickListener ocl) { View addbut(int x, OnClickListener ocl) {
ImageButton but = new ImageButton(this); ImageButton but = new ImageButton(this);
@ -137,32 +141,81 @@ public class GL2JNIActivity extends Activity {
// Call parent onCreate() // Call parent onCreate()
super.onCreate(icicle); super.onCreate(icicle);
OuyaController.init(this);
map = new int[4][];
// Populate device descriptor-to-player-map from preferences
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_1", null), 0);
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_2", null), 1);
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_3", null), 2);
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_4", null), 3);
boolean controllerTwoConnected = false;
boolean controllerThreeConnected = false;
boolean controllerFourConnected = false;
for (HashMap.Entry<String, Integer> e : deviceDescriptor_PlayerNum.entrySet()) {
String descriptor = e.getKey();
Integer playerNum = e.getValue();
switch (playerNum) {
case 1:
if (descriptor != null)
controllerTwoConnected = true;
break;
case 2:
if (descriptor != null)
controllerThreeConnected = true;
break;
case 3:
if (descriptor != null)
controllerFourConnected = true;
break;
}
}
JNIdc.initControllers(new boolean[] {controllerTwoConnected, controllerThreeConnected, controllerFourConnected});
int joys[] = InputDevice.getDeviceIds(); int joys[] = InputDevice.getDeviceIds();
for (int i = 0; i < joys.length; i++) { for (int i = 0; i < joys.length; i++) {
String descriptor = InputDevice.getDevice(joys[i]).getDescriptor();
Log.d("reidc", "InputDevice ID: " + joys[i]); Log.d("reidc", "InputDevice ID: " + joys[i]);
Log.d("reidc", "InputDevice Name: " Log.d("reidc", "InputDevice Name: "
+ InputDevice.getDevice(joys[i]).getName()); + InputDevice.getDevice(joys[i]).getName());
Log.d("reidc", "InputDevice Descriptor: " + descriptor);
deviceId_deviceDescriptor.put(joys[i], descriptor);
}
for (int i = 0; i < joys.length; i++) {
Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(joys[i]));
if (playerNum != null) {
if (InputDevice.getDevice(joys[i]).getName() if (InputDevice.getDevice(joys[i]).getName()
.equals("Sony PLAYSTATION(R)3 Controller")) { .equals("Sony PLAYSTATION(R)3 Controller")) {
map = new int[] { map[playerNum] = new int[] {
OuyaController.BUTTON_Y, key_CONT_B, OuyaController.BUTTON_Y, key_CONT_Y,
OuyaController.BUTTON_U, key_CONT_A, OuyaController.BUTTON_U, key_CONT_X,
OuyaController.BUTTON_O, key_CONT_X, OuyaController.BUTTON_O, key_CONT_A,
OuyaController.BUTTON_A, key_CONT_Y, OuyaController.BUTTON_A, key_CONT_B,
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP, OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
OuyaController.BUTTON_DPAD_DOWN, key_CONT_DPAD_DOWN, OuyaController.BUTTON_DPAD_DOWN,
OuyaController.BUTTON_DPAD_LEFT, key_CONT_DPAD_LEFT, key_CONT_DPAD_DOWN,
OuyaController.BUTTON_DPAD_RIGHT, key_CONT_DPAD_RIGHT, OuyaController.BUTTON_DPAD_LEFT,
key_CONT_DPAD_LEFT,
OuyaController.BUTTON_DPAD_RIGHT,
key_CONT_DPAD_RIGHT,
OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_MENU, key_CONT_START,
OuyaController.BUTTON_R1, key_CONT_START OuyaController.BUTTON_R1, key_CONT_START
}; };
} else if (InputDevice.getDevice(joys[i]).getName() } else if (InputDevice.getDevice(joys[i]).getName()
.contains("NVIDIA Corporation NVIDIA Controller")) { .equals("Microsoft X-Box 360 pad")) {
map = new int[] { map[playerNum] = new int[] {
OuyaController.BUTTON_O, key_CONT_A, OuyaController.BUTTON_O, key_CONT_A,
OuyaController.BUTTON_A, key_CONT_B, OuyaController.BUTTON_A, key_CONT_B,
OuyaController.BUTTON_Y, key_CONT_Y, OuyaController.BUTTON_Y, key_CONT_Y,
@ -178,9 +231,32 @@ public class GL2JNIActivity extends Activity {
OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_MENU, key_CONT_START,
OuyaController.BUTTON_R1, key_CONT_START }; OuyaController.BUTTON_R1, key_CONT_START };
nVidia = true;
xbox[playerNum] = true;
globalLS_X[playerNum] = previousLS_X[playerNum] = 0.0f;
globalLS_Y[playerNum] = previousLS_Y[playerNum] = 0.0f;
} else if (InputDevice.getDevice(joys[i]).getName()
.contains("NVIDIA Corporation NVIDIA Controller")) {
map[playerNum] = new int[] {
OuyaController.BUTTON_O, key_CONT_A,
OuyaController.BUTTON_A, key_CONT_B,
OuyaController.BUTTON_Y, key_CONT_Y,
OuyaController.BUTTON_U, key_CONT_X,
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
OuyaController.BUTTON_DPAD_DOWN,
key_CONT_DPAD_DOWN,
OuyaController.BUTTON_DPAD_LEFT,
key_CONT_DPAD_LEFT,
OuyaController.BUTTON_DPAD_RIGHT,
key_CONT_DPAD_RIGHT,
OuyaController.BUTTON_MENU, key_CONT_START,
OuyaController.BUTTON_R1, key_CONT_START };
nVidia[playerNum] = true;
} else if (!moga.isActive) { // Ouya controller } else if (!moga.isActive) { // Ouya controller
map = new int[] { map[playerNum] = new int[] {
OuyaController.BUTTON_O, key_CONT_A, OuyaController.BUTTON_O, key_CONT_A,
OuyaController.BUTTON_A, key_CONT_B, OuyaController.BUTTON_A, key_CONT_B,
OuyaController.BUTTON_Y, key_CONT_Y, OuyaController.BUTTON_Y, key_CONT_Y,
@ -197,6 +273,7 @@ public class GL2JNIActivity extends Activity {
OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_MENU, key_CONT_START,
OuyaController.BUTTON_R1, key_CONT_START }; OuyaController.BUTTON_R1, key_CONT_START };
} }
}
} }
// When viewing a resource, pass its URI to the native code for opening // When viewing a resource, pass its URI to the native code for opening
@ -217,9 +294,10 @@ public class GL2JNIActivity extends Activity {
// Log.w("INPUT", event.toString() + " " + event.getSource()); // Log.w("INPUT", event.toString() + " " + event.getSource());
// Get all the axis for the KeyEvent // Get all the axis for the KeyEvent
if (nVidia) { Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
JNIdc.hide_osd();
} if (playerNum == null)
return false;
if (!moga.isActive) { if (!moga.isActive) {
@ -234,16 +312,29 @@ public class GL2JNIActivity extends Activity {
float L2 = event.getAxisValue(OuyaController.AXIS_L2); float L2 = event.getAxisValue(OuyaController.AXIS_L2);
float R2 = event.getAxisValue(OuyaController.AXIS_R2); float R2 = event.getAxisValue(OuyaController.AXIS_R2);
GL2JNIView.lt = (int) (L2 * 255); if (xbox[playerNum] || nVidia[playerNum]) {
GL2JNIView.rt = (int) (R2 * 255); previousLS_X[playerNum] = globalLS_X[playerNum];
previousLS_Y[playerNum] = globalLS_Y[playerNum];
globalLS_X[playerNum] = LS_X;
globalLS_Y[playerNum] = LS_Y;
}
GL2JNIView.jx = (int) (LS_X * 126); GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.jy = (int) (LS_Y * 126); GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
} }
} }
return true; if ((xbox[playerNum] || nVidia[playerNum]) && ((globalLS_X[playerNum] == previousLS_X[playerNum] && globalLS_Y[playerNum] == previousLS_Y[playerNum])
|| (previousLS_X[playerNum] == 0.0f && previousLS_Y[playerNum] == 0.0f)))
// Only handle Left Stick on an Xbox 360 controller if there was some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
return false;
else
return true;
} }
private static final int key_CONT_B = 0x0002; private static final int key_CONT_B = 0x0002;
@ -290,16 +381,19 @@ public class GL2JNIActivity extends Activity {
* }; * };
*/ */
boolean handle_key(int kc, boolean down) { boolean handle_key(Integer playerNum, int kc, boolean down) {
if (playerNum == null)
return false;
if (!moga.isActive) { if (!moga.isActive) {
boolean rav = false; boolean rav = false;
for (int i = 0; i < map.length; i += 2) { for (int i = 0; i < map[playerNum].length; i += 2) {
if (map[i + 0] == kc) { if (map[playerNum][i + 0] == kc) {
if (down) if (down)
GL2JNIView.kcode_raw &= ~map[i + 1]; GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else else
GL2JNIView.kcode_raw |= map[i + 1]; GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
rav = true; rav = true;
break; break;
@ -314,12 +408,17 @@ public class GL2JNIActivity extends Activity {
} }
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
return handle_key(keyCode, false) || super.onKeyUp(keyCode, event); Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
return handle_key(playerNum, keyCode, false) || super.onKeyUp(keyCode, event);
} }
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (handle_key(keyCode, true)) { Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
JNIdc.hide_osd();
if (handle_key(playerNum, keyCode, true)) {
if(playerNum == 0)
JNIdc.hide_osd();
return true; return true;
} }
@ -377,4 +476,4 @@ public class GL2JNIActivity extends Activity {
mView.onResume(); mView.onResume();
moga.onResume(); moga.onResume();
} }
} }

66
shell/android/src/com/reicast/emulator/GL2JNIView.java Normal file → Executable file
View File

@ -1,33 +1,25 @@
package com.reicast.emulator; package com.reicast.emulator;
import android.app.Application;
import android.content.Context;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.opengl.GLU;
import android.os.Vibrator;
import java.nio.FloatBuffer;
import android.media.AudioManager;
import android.media.AudioFormat;
import android.media.AudioTrack;
import android.content.res.Configuration;
import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import android.content.res.Configuration;
import android.content.SharedPreferences;
import android.graphics.PixelFormat;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.opengl.GLSurfaceView;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.MotionEvent;
/** /**
* A simple GLSurfaceView sub-class that demonstrate how to perform * A simple GLSurfaceView sub-class that demonstrate how to perform
@ -115,6 +107,8 @@ class GL2JNIView extends GLSurfaceView
}; };
Renderer rend; Renderer rend;
private boolean touchVibrationEnabled;
public GL2JNIView(Context context,String newFileName,boolean translucent,int depth,int stencil) public GL2JNIView(Context context,String newFileName,boolean translucent,int depth,int stencil)
@ -122,6 +116,9 @@ class GL2JNIView extends GLSurfaceView
super(context); super(context);
setKeepScreenOn(true); setKeepScreenOn(true);
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
touchVibrationEnabled = prefs.getBoolean("touch_vibration_enabled", true);
// This is the game we are going to run // This is the game we are going to run
fileName = newFileName; fileName = newFileName;
@ -130,7 +127,9 @@ class GL2JNIView extends GLSurfaceView
JNIdc.data(1, GL2JNIActivity.syms); JNIdc.data(1, GL2JNIActivity.syms);
JNIdc.hide_osd(); JNIdc.hide_osd();
JNIdc.kcode(0xFFFF,0,0,128,128); int[] kcode = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF };
int[] rt = { 0, 0, 0, 0 }, lt = { 0, 0, 0, 0 };
int[] jx = { 128, 128, 128, 128 }, jy = { 128, 128, 128, 128 };
JNIdc.init(fileName); JNIdc.init(fileName);
@ -274,8 +273,8 @@ class GL2JNIView extends GLSurfaceView
} }
*/ */
static int kcode_raw = 0xFFFF; static int[] kcode_raw = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF };
static int lt, rt, jx, jy; static int[] lt = new int[4], rt = new int[4], jx = new int[4], jy = new int[4];
@Override public boolean onTouchEvent(final MotionEvent event) @Override public boolean onTouchEvent(final MotionEvent event)
{ {
@ -317,7 +316,8 @@ class GL2JNIView extends GLSurfaceView
if (vjoy[j][4]>=-2) if (vjoy[j][4]>=-2)
{ {
if (vjoy[j][5]==0) if (vjoy[j][5]==0)
vib.vibrate(50); if (touchVibrationEnabled)
vib.vibrate(50);
vjoy[j][5]=2; vjoy[j][5]=2;
} }
@ -331,8 +331,8 @@ class GL2JNIView extends GLSurfaceView
anal_id=event.getPointerId(i); anal_id=event.getPointerId(i);
} }
else if (vjoy[j][4]==-4) ; else if (vjoy[j][4]==-4) ;
else if(vjoy[j][4]==-1) lt=pre; else if(vjoy[j][4]==-1) lt[0]=pre;
else if(vjoy[j][4]==-2) rt=pre; else if(vjoy[j][4]==-2) rt[0]=pre;
else else
rv&=~(int)vjoy[j][4]; rv&=~(int)vjoy[j][4];
} }
@ -375,8 +375,8 @@ class GL2JNIView extends GLSurfaceView
reset_analog(); reset_analog();
anal_id=-1; anal_id=-1;
rv=0xFFFF; rv=0xFFFF;
rt=0; rt[0]=0;
lt=0; lt[0]=0;
for(int j=0;j<vjoy.length;j++) for(int j=0;j<vjoy.length;j++)
vjoy[j][5]=0; vjoy[j][5]=0;
break; break;
@ -401,9 +401,9 @@ class GL2JNIView extends GLSurfaceView
if(GL2JNIActivity.keys[0]!=0) rv&=~key_CONT_B; if(GL2JNIActivity.keys[0]!=0) rv&=~key_CONT_B;
*/ */
kcode_raw = rv; kcode_raw[0] = rv;
jx = get_anal(11, 0); jx[0] = get_anal(11, 0);
jy = get_anal(11, 1); jy[0] = get_anal(11, 1);
return(true); return(true);
} }
@ -789,4 +789,4 @@ public void onStop() {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

5
shell/android/src/com/reicast/emulator/JNIdc.java Normal file → Executable file
View File

@ -1,6 +1,5 @@
package com.reicast.emulator; package com.reicast.emulator;
import android.media.AudioTrack;
public class JNIdc public class JNIdc
{ {
@ -17,11 +16,13 @@ public class JNIdc
public static native void rendinit(int w,int y); public static native void rendinit(int w,int y);
public static native void rendframe(); public static native void rendframe();
public static native void kcode(int kcode,int lt, int rt, int jx, int jy); public static native void kcode(int[] kcode, int[] lt, int[] rt, int[] jx, int[] jy);
public static native void vjoy(int id,float x, float y, float w, float h); public static native void vjoy(int id,float x, float y, float w, float h);
//public static native int play(short result[],int size); //public static native int play(short result[],int size);
public static native void initControllers(boolean[] controllers);
public static void show_osd() { public static void show_osd() {
JNIdc.vjoy(13, 1,0,0,0); JNIdc.vjoy(13, 1,0,0,0);
} }

View File

@ -3,21 +3,10 @@ package com.reicast.emulator;
/******************************************************************************/ /******************************************************************************/
import java.util.Map.Entry;
import java.util.TreeMap;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.SystemClock;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.util.Log;
import com.bda.controller.Controller; import com.bda.controller.Controller;
import com.bda.controller.ControllerListener; import com.bda.controller.ControllerListener;
import com.bda.controller.KeyEvent; import com.bda.controller.KeyEvent;
@ -125,21 +114,21 @@ public class MOGAInput
mController.onResume(); mController.onResume();
/* /*
for(final Entry<Integer, ExampleInteger> entry : mStates.entrySet()) for(final Entry&lt;Integer, ExampleInteger&gt; entry : mStates.entrySet())
{ {
final int key = entry.getKey(); final int key = entry.getKey();
final ExampleInteger value = entry.getValue(); final ExampleInteger value = entry.getValue();
value.mValue = mController.getState(key); value.mValue = mController.getState(key);
} }
for(final Entry<Integer, ExampleInteger> entry : mKeys.entrySet()) for(final Entry&lt;Integer, ExampleInteger&gt; entry : mKeys.entrySet())
{ {
final int key = entry.getKey(); final int key = entry.getKey();
final ExampleInteger value = entry.getValue(); final ExampleInteger value = entry.getValue();
value.mValue = mController.getKeyCode(key); value.mValue = mController.getKeyCode(key);
} }
for(final Entry<Integer, ExampleFloat> entry : mMotions.entrySet()) for(final Entry&lt;Integer, ExampleFloat&gt; entry : mMotions.entrySet())
{ {
final int key = entry.getKey(); final int key = entry.getKey();
final ExampleFloat value = entry.getValue(); final ExampleFloat value = entry.getValue();
@ -152,13 +141,20 @@ public class MOGAInput
{ {
public void onKeyEvent(KeyEvent event) public void onKeyEvent(KeyEvent event)
{ {
JNIdc.hide_osd(); Integer playerNum = GL2JNIActivity.deviceDescriptor_PlayerNum.get(GL2JNIActivity.deviceId_deviceDescriptor.get(event.getControllerId()));
for (int i = 0; i < map.length; i += 2) {
if (playerNum == null)
return;
if(playerNum == 0)
JNIdc.hide_osd();
for (int i = 0; i &lt; map.length; i += 2) {
if (map[i + 0] == event.getKeyCode()) { if (map[i + 0] == event.getKeyCode()) {
if (event.getAction() == 0) //FIXME to const if (event.getAction() == 0) //FIXME to const
GL2JNIView.kcode_raw &= ~map[i + 1]; GL2JNIView.kcode_raw[playerNum] &amp;= ~map[i + 1];
else else
GL2JNIView.kcode_raw |= map[i + 1]; GL2JNIView.kcode_raw[playerNum] |= map[i + 1];
break; break;
} }
@ -167,21 +163,27 @@ public class MOGAInput
public void onMotionEvent(MotionEvent event) public void onMotionEvent(MotionEvent event)
{ {
JNIdc.hide_osd(); Integer playerNum = GL2JNIActivity.deviceDescriptor_PlayerNum.get(GL2JNIActivity.deviceId_deviceDescriptor.get(event.getControllerId()));
if (playerNum == null)
return;
if(playerNum == 0)
JNIdc.hide_osd();
float LS_X = event.getAxisValue(MotionEvent.AXIS_X); float LS_X = event.getAxisValue(MotionEvent.AXIS_X);
float LS_Y = event.getAxisValue(MotionEvent.AXIS_Y); float LS_Y = event.getAxisValue(MotionEvent.AXIS_Y);
float L2 = event.getAxisValue(MotionEvent.AXIS_LTRIGGER); float L2 = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);
float R2 = event.getAxisValue(MotionEvent.AXIS_RTRIGGER); float R2 = event.getAxisValue(MotionEvent.AXIS_RTRIGGER);
GL2JNIView.lt = (int) (L2 * 255); GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt = (int) (R2 * 255); GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx = (int) (LS_X * 126); GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
GL2JNIView.jy = (int) (LS_Y * 126); GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
/* /*
for(final Entry<Integer, ExampleFloat> entry : mMotions.entrySet()) for(final Entry&lt;Integer, ExampleFloat&gt; entry : mMotions.entrySet())
{ {
final int key = entry.getKey(); final int key = entry.getKey();
final ExampleFloat value = entry.getValue(); final ExampleFloat value = entry.getValue();
@ -191,9 +193,15 @@ public class MOGAInput
public void onStateEvent(StateEvent event) public void onStateEvent(StateEvent event)
{ {
JNIdc.hide_osd(); Integer playerNum = GL2JNIActivity.deviceDescriptor_PlayerNum.get(GL2JNIActivity.deviceId_deviceDescriptor.get(event.getControllerId()));
if (event.getState() == ACTION_CONNECTED) { if (playerNum == null)
return;
if(playerNum == 0)
JNIdc.hide_osd();
if (event.getState() == StateEvent.STATE_CONNECTION &amp;&amp; event.getAction() == ACTION_CONNECTED) {
Toast.makeText(act.getApplicationContext(), "MOGA Connected!", Toast.LENGTH_SHORT).show(); Toast.makeText(act.getApplicationContext(), "MOGA Connected!", Toast.LENGTH_SHORT).show();
isActive = true; isActive = true;
} }

View File

@ -6,6 +6,8 @@ import java.util.ArrayList;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@ -27,7 +29,6 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
public class MainActivity extends FragmentActivity implements public class MainActivity extends FragmentActivity implements
@ -59,81 +60,21 @@ public class MainActivity extends FragmentActivity implements
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.mainuilayout_fragment); setContentView(R.layout.mainuilayout_fragment);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
home_directory = mPrefs.getString("home_directory", home_directory);
JNIdc.config(home_directory);
// Check that the activity is using the layout version with // Check that the activity is using the layout version with
// the fragment_container FrameLayout // the fragment_container FrameLayout
if (findViewById(R.id.fragment_container) != null) { if (findViewById(R.id.fragment_container) != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
navMenuTitles = getResources().getStringArray(
R.array.nav_drawer_items);
// nav drawer icons from resources
navMenuIcons = getResources().obtainTypedArray(
R.array.nav_drawer_icons);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
navDrawerItems = new ArrayList<NavDrawerItem>();
// adding nav drawer items to array
// Browser
navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons
.getResourceId(0, -1)));
// Options
navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons
.getResourceId(1, -1)));
// Config
navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons
.getResourceId(2, -1)));
// About
navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons
.getResourceId(3, -1)));
// Recycle the typed array
navMenuIcons.recycle();
mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
// setting the nav drawer list adapter
adapter = new NavDrawerListAdapter(getApplicationContext(),
navDrawerItems);
mDrawerList.setAdapter(adapter);
// enabling action bar app icon and behaving it as toggle button
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, // nav menu toggle icon
R.string.app_name, // nav drawer open - description for
// accessibility
R.string.app_name // nav drawer close - description for
// accessibility
) {
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
// calling onPrepareOptionsMenu() to show action bar
// icons
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
// calling onPrepareOptionsMenu() to hide action bar
// icons
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
// However, if we're being restored from a previous state, // However, if we're being restored from a previous state,
// then we don't need to do anything and should return or else // then we don't need to do anything and should return or else
// we could end up with overlapping fragments. // we could end up with overlapping fragments.
if (savedInstanceState != null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
return; if (savedInstanceState != null) {
return;
}
} }
// Create a new Fragment to be placed in the activity layout // Create a new Fragment to be placed in the activity layout
@ -155,41 +96,135 @@ public class MainActivity extends FragmentActivity implements
.add(R.id.fragment_container, firstFragment).commit(); .add(R.id.fragment_container, firstFragment).commit();
} }
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
navMenuTitles = getResources().getStringArray(
R.array.nav_drawer_items);
// nav drawer icons from resources
navMenuIcons = getResources().obtainTypedArray(
R.array.nav_drawer_icons);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
navDrawerItems = new ArrayList<NavDrawerItem>();
// adding nav drawer items to array
// Browser
navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons
.getResourceId(0, 0)));
// Settings
navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons
.getResourceId(1, 0)));
// Paths
navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons
.getResourceId(2, 0)));
// Controllers
navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons
.getResourceId(3, 0)));
// About
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons
.getResourceId(4, 0)));
// Recycle the typed array
navMenuIcons.recycle();
mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
// setting the nav drawer list adapter
adapter = new NavDrawerListAdapter(getApplicationContext(),
navDrawerItems);
mDrawerList.setAdapter(adapter);
// enabling action bar app icon and behaving it as toggle button
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, // nav menu toggle icon
R.string.app_name, // nav drawer open - description for
// accessibility
R.string.app_name // nav drawer close - description for
// accessibility
) {
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
// calling onPrepareOptionsMenu() to show action bar
// icons
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
// calling onPrepareOptionsMenu() to hide action bar
// icons
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
// if (savedInstanceState == null) {
// displayView(0);
//
// }
} else {
findViewById(R.id.options).setOnClickListener(
new OnClickListener() {
public void onClick(View view) {
OptionsFragment optionsFrag = (OptionsFragment) getSupportFragmentManager()
.findFragmentByTag("OPTIONS_FRAG");
if (optionsFrag != null) {
if (optionsFrag.isVisible()) {
return;
}
}
optionsFrag = new OptionsFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container,
optionsFrag, "OPTIONS_FRAG")
.addToBackStack(null).commit();
/*
* AlertDialog.Builder alertDialogBuilder = new
* AlertDialog.Builder( MainActivity.this);
*
* // set title
* alertDialogBuilder.setTitle("Configure");
*
* // set dialog message alertDialogBuilder
* .setMessage("No configuration for now :D")
* .setCancelable(false)
* .setPositiveButton("Oh well",new
* DialogInterface.OnClickListener() { public void
* onClick(DialogInterface dialog,int id) {
* //FileBrowser.this.finish(); } });
*
* // create alert dialog AlertDialog alertDialog =
* alertDialogBuilder.create();
*
* // show it alertDialog.show();
*/
}
});
findViewById(R.id.config).setOnClickListener(new OnClickListener() { findViewById(R.id.config).setOnClickListener(new OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
OptionsFragment optsFrag = (OptionsFragment) getSupportFragmentManager() ConfigureFragment configFrag = (ConfigureFragment) getSupportFragmentManager()
.findFragmentByTag("OPTIONS_FRAG"); .findFragmentByTag("CONFIG_FRAG");
if (optsFrag != null) { if (configFrag != null) {
if (optsFrag.isVisible()) { if (configFrag.isVisible()) {
return; return;
} }
} }
optsFrag = new OptionsFragment(); configFrag = new ConfigureFragment();
getSupportFragmentManager() getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_container, optsFrag, .replace(R.id.fragment_container, configFrag,
"OPTIONS_FRAG").addToBackStack(null) "CONFIG_FRAG").addToBackStack(null)
.commit(); .commit();
/*
* AlertDialog.Builder alertDialogBuilder = new
* AlertDialog.Builder( MainActivity.this);
*
* // set title alertDialogBuilder.setTitle("Configure");
*
* // set dialog message alertDialogBuilder
* .setMessage("No configuration for now :D")
* .setCancelable(false) .setPositiveButton("Oh well",new
* DialogInterface.OnClickListener() { public void
* onClick(DialogInterface dialog,int id) {
* //FileBrowser.this.finish(); } });
*
* // create alert dialog AlertDialog alertDialog =
* alertDialogBuilder.create();
*
* // show it alertDialog.show();
*/
} }
}); });
@ -232,16 +267,75 @@ public class MainActivity extends FragmentActivity implements
}); });
} }
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
home_directory = mPrefs.getString("home_directory", home_directory);
JNIdc.config(home_directory);
} }
public void onGameSelected(Uri uri) { public void onGameSelected(Uri uri) {
Intent inte = new Intent(Intent.ACTION_VIEW, uri, getBaseContext(), File bios = new File(home_directory, "data/dc_boot.bin");
File flash = new File(home_directory, "data/dc_flash.bin");
String msg = null;
if (!bios.exists())
msg = getString(R.string.missing_bios, home_directory);
else if (!flash.exists())
msg = getString(R.string.missing_flash, home_directory);
if (msg != null) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
this);
// set title
alertDialogBuilder.setTitle("You have to provide the BIOS");
// set dialog message
alertDialogBuilder
.setMessage(msg)
.setCancelable(false)
.setPositiveButton("Dismiss",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
// if this button is clicked, close
// current activity
//MainActivity.this.finish();
}
})
.setNegativeButton("Options",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
FileBrowser firstFragment = new FileBrowser();
Bundle args = new Bundle();
//args.putBoolean("ImgBrowse", false);
// specify ImgBrowse option. true = images, false = folders only
args.putString("browse_entry", sdcard.toString());
// specify a path for selecting folder options
args.putBoolean("games_entry", false);
// selecting a BIOS folder, so this is not games
firstFragment.setArguments(args);
// In case this activity was started with special instructions from
// an Intent, pass the Intent's extras to the fragment as arguments
// firstFragment.setArguments(getIntent().getExtras());
// Add the fragment to the 'fragment_container' FrameLayout
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER")
.addToBackStack(null).commit();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
else {
Intent inte = new Intent(Intent.ACTION_VIEW, uri, getBaseContext(),
GL2JNIActivity.class); GL2JNIActivity.class);
startActivity(inte); startActivity(inte);
}
} }
public void onFolderSelected(Uri uri) { public void onFolderSelected(Uri uri) {
@ -266,9 +360,12 @@ public class MainActivity extends FragmentActivity implements
FileBrowser firstFragment = new FileBrowser(); FileBrowser firstFragment = new FileBrowser();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean("ImgBrowse", false); args.putBoolean("ImgBrowse", false);
args.putString("browse_entry", path_entry);
args.putBoolean("games_entry", games);
// specify ImgBrowse option. true = images, false = folders only // specify ImgBrowse option. true = images, false = folders only
args.putString("browse_entry", path_entry);
// specify a path for selecting folder options
args.putBoolean("games_entry", games);
// specify if the desired path is for games or data
firstFragment.setArguments(args); firstFragment.setArguments(args);
// In case this activity was started with special instructions from // In case this activity was started with special instructions from
// an Intent, pass the Intent's extras to the fragment as arguments // an Intent, pass the Intent's extras to the fragment as arguments
@ -319,17 +416,6 @@ public class MainActivity extends FragmentActivity implements
frag_tag = "MAIN_BROWSER"; frag_tag = "MAIN_BROWSER";
break; break;
case 1: case 1:
fragment = (OptionsFragment) getSupportFragmentManager()
.findFragmentByTag("OPTIONS_FRAG");
if (fragment != null) {
if (fragment.isVisible()) {
return;
}
}
fragment = new OptionsFragment();
frag_tag = "OPTIONS_FRAG";
break;
case 2:
fragment = (ConfigureFragment) getSupportFragmentManager() fragment = (ConfigureFragment) getSupportFragmentManager()
.findFragmentByTag("CONFIG_FRAG"); .findFragmentByTag("CONFIG_FRAG");
if (fragment != null) { if (fragment != null) {
@ -340,18 +426,48 @@ public class MainActivity extends FragmentActivity implements
fragment = new ConfigureFragment(); fragment = new ConfigureFragment();
frag_tag = "CONFIG_FRAG"; frag_tag = "CONFIG_FRAG";
break; break;
case 2:
fragment = (OptionsFragment) getSupportFragmentManager()
.findFragmentByTag("OPTIONS_FRAG");
if (fragment != null) {
if (fragment.isVisible()) {
return;
}
}
fragment = new OptionsFragment();
frag_tag = "OPTIONS_FRAG";
break;
case 3: case 3:
fragment = (ControllersFragment) getSupportFragmentManager()
.findFragmentByTag("CONTROLLERS_FRAG");
if (fragment != null) {
if (fragment.isVisible()) {
return;
}
}
fragment = new ControllersFragment();
frag_tag = "CONTROLLERS_FRAG";
break;
case 4:
fragment = null; fragment = null;
// vib.vibrate(50); // vib.vibrate(50);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
MainActivity.this); MainActivity.this);
// set title // set title
alertDialogBuilder.setTitle("About reicast"); alertDialogBuilder.setTitle(getString(R.string.about_title));
String versionName = "";
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionName = pInfo.versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
// set dialog message // set dialog message
alertDialogBuilder alertDialogBuilder
.setMessage("reicast is a dreamcast emulator") .setMessage(getString(R.string.about_text) + " " + versionName)
.setCancelable(false) .setCancelable(false)
.setPositiveButton("Dismiss", .setPositiveButton("Dismiss",
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {

View File

@ -52,11 +52,14 @@ public class OptionsFragment extends Fragment {
+ " must implement OnClickListener"); + " must implement OnClickListener");
} }
int joys[] = InputDevice.getDeviceIds(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
for (int i = 0; i < joys.length; i++) { int joys[] = InputDevice.getDeviceIds();
Log.d("reidc", "InputDevice ID: " + joys[i]); for (int i = 0; i < joys.length; i++) {
Log.d("reidc", "InputDevice Name: " Log.d("reidc", "InputDevice ID: " + joys[i]);
+ InputDevice.getDevice(joys[i]).getName()); Log.d("reidc",
"InputDevice Name: "
+ InputDevice.getDevice(joys[i]).getName());
}
} }
} }
@ -72,10 +75,10 @@ public class OptionsFragment extends Fragment {
// setContentView(R.layout.activity_main); // setContentView(R.layout.activity_main);
parentActivity = getActivity(); parentActivity = getActivity();
mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity); mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity);
home_directory = mPrefs.getString("home_directory", home_directory); home_directory = mPrefs.getString("home_directory", home_directory);
mainBrowse = (Button) getView().findViewById(R.id.browse_main_path); mainBrowse = (Button) getView().findViewById(R.id.browse_main_path);
final EditText editBrowse = (EditText) getView().findViewById( final EditText editBrowse = (EditText) getView().findViewById(