From 8653e5e0f8994bafd43ffe4fbfaee121611fa7e1 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Mon, 30 Dec 2013 00:52:14 +0100 Subject: [PATCH 01/34] dejcond breaks shenmue, disabled. Hrfm. This (might) reduce speed a tiny bit. --- core/hw/sh4/dyna/shil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/hw/sh4/dyna/shil.cpp b/core/hw/sh4/dyna/shil.cpp index d4ba89da4..f86ba267b 100644 --- a/core/hw/sh4/dyna/shil.cpp +++ b/core/hw/sh4/dyna/shil.cpp @@ -935,7 +935,7 @@ void AnalyseBlock(RuntimeBlockInfo* blk) srt_waw(blk); constlink(blk); - dejcond(blk); + //dejcond(blk); if (last_op_sets_flags) { shilop op= blk->oplist[blk->oplist.size()-1].op; From 258b8cf7f6227cd75108a4d8bd093eee36278f05 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Mon, 30 Dec 2013 00:53:00 +0100 Subject: [PATCH 02/34] Fix fullscreen flag --- shell/android/AndroidManifest.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/android/AndroidManifest.xml b/shell/android/AndroidManifest.xml index b2a936ab2..a92719df9 100644 --- a/shell/android/AndroidManifest.xml +++ b/shell/android/AndroidManifest.xml @@ -25,9 +25,8 @@ - - + + From 9512d37c7c184f4ebdaac3014a3911dc6dac209d Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Mon, 30 Dec 2013 00:55:17 +0100 Subject: [PATCH 03/34] Cleaning up abit, some more moga work :) --- .../com/reicast/emulator/GL2JNIActivity.java | 4 +-- .../src/com/reicast/emulator/GL2JNIView.java | 9 +++--- .../src/com/reicast/emulator/JNIdc.java | 8 +++++ .../src/com/reicast/emulator/MOGAInput.java | 31 ++++++------------- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 447c934ea..ed1576def 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -118,8 +118,8 @@ public class GL2JNIActivity extends Activity { @Override protected void onCreate(Bundle icicle) { - moga.onCreate(this); requestWindowFeature(Window.FEATURE_NO_TITLE); + moga.onCreate(this); createPopup(); /* @@ -307,7 +307,7 @@ public class GL2JNIActivity extends Activity { public boolean onKeyDown(int keyCode, KeyEvent event) { if (handle_key(keyCode, true)) { - JNIdc.vjoy(13, 0, 0, 0, 0); + JNIdc.hide_osd(); return true; } diff --git a/shell/android/src/com/reicast/emulator/GL2JNIView.java b/shell/android/src/com/reicast/emulator/GL2JNIView.java index 1797b721f..79de99c8b 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIView.java @@ -128,9 +128,10 @@ class GL2JNIView extends GLSurfaceView if (GL2JNIActivity.syms != null) JNIdc.data(1, GL2JNIActivity.syms); - JNIdc.vjoy(13, 0,0,0,0); - JNIdc.kcode(0xFFFF,0,0,128,128); - JNIdc.init(fileName); + + JNIdc.hide_osd(); + JNIdc.kcode(0xFFFF,0,0,128,128); + JNIdc.init(fileName); // By default, GLSurfaceView() creates a RGB_565 opaque surface. @@ -278,7 +279,7 @@ class GL2JNIView extends GLSurfaceView @Override public boolean onTouchEvent(final MotionEvent event) { - JNIdc.vjoy(13, 1,0,0,0); + JNIdc.show_osd(); float ty = 0.0f; float scl = getHeight()/480.0f; diff --git a/shell/android/src/com/reicast/emulator/JNIdc.java b/shell/android/src/com/reicast/emulator/JNIdc.java index 44f3eb8c8..2fdfc270d 100644 --- a/shell/android/src/com/reicast/emulator/JNIdc.java +++ b/shell/android/src/com/reicast/emulator/JNIdc.java @@ -21,4 +21,12 @@ public class JNIdc 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 void show_osd() { + JNIdc.vjoy(13, 1,0,0,0); + } + + public static void hide_osd() { + JNIdc.vjoy(13, 0,0,0,0); + } } \ No newline at end of file diff --git a/shell/android/src/com/reicast/emulator/MOGAInput.java b/shell/android/src/com/reicast/emulator/MOGAInput.java index f69ee9b2b..143826bbd 100644 --- a/shell/android/src/com/reicast/emulator/MOGAInput.java +++ b/shell/android/src/com/reicast/emulator/MOGAInput.java @@ -65,6 +65,7 @@ public class MOGAInput KeyEvent.KEYCODE_BUTTON_START, key_CONT_START, }; + Activity act; public MOGAInput() { /* @@ -101,28 +102,25 @@ public class MOGAInput protected void onCreate(Activity act) { + this.act = act; + mController = Controller.getInstance(act); mController.init(); mController.setListener(new ExampleControllerListener(), new Handler()); - - Log.w("INPUT", "Create"); } protected void onDestroy() { - Log.w("INPUT", "Desotry"); mController.exit(); } protected void onPause() { - Log.w("INPUT", "PAUSe"); mController.onPause(); } protected void onResume() { - Log.w("INPUT", "RESUMe"); mController.onResume(); /* @@ -153,7 +151,7 @@ public class MOGAInput { public void onKeyEvent(KeyEvent event) { - Log.w("KEYINPUT", event.toString()); + JNIdc.hide_osd(); for (int i = 0; i < map.length; i += 2) { if (map[i + 0] == event.getKeyCode()) { if (event.getAction() == 0) //FIXME to const @@ -164,18 +162,11 @@ public class MOGAInput break; } } - - /* - final ExampleInteger value = mKeys.get(event.getKeyCode()); - if(value != null) - { - value.mValue = event.getAction(); - }*/ } public void onMotionEvent(MotionEvent event) { - Log.w("MOINPUT", event.toString()); + JNIdc.hide_osd(); float LS_X = event.getAxisValue(MotionEvent.AXIS_X); float LS_Y = event.getAxisValue(MotionEvent.AXIS_Y); @@ -199,13 +190,11 @@ public class MOGAInput public void onStateEvent(StateEvent event) { - Log.w("SINPUT", event.toString()); - /* - final ExampleInteger value = mStates.get(event.getState()); - if(value != null) - { - value.mValue = event.getAction(); - }*/ + JNIdc.hide_osd(); + + if (event.getState() == ACTION_CONNECTED) { + Toast.makeText(act.getApplicationContext(), "MOGA Connected!", Toast.LENGTH_SHORT).show(); + } } } } From db78a741d0ee19560c6c3bf600e5ee1d8a616b9f Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 29 Dec 2013 22:11:49 -0500 Subject: [PATCH 04/34] Stop double polling Moga controllers, Hide OSD for Shield --- .../com/reicast/emulator/GL2JNIActivity.java | 84 +++++++++++-------- .../src/com/reicast/emulator/MOGAInput.java | 2 + 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index ed1576def..12438ff5b 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -38,6 +38,7 @@ public class GL2JNIActivity extends Activity { PopupWindow popUp; LayoutParams params; MOGAInput moga = new MOGAInput(); + static boolean nVidia = false; int map[]; @@ -158,47 +159,42 @@ public class GL2JNIActivity extends Activity { OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_R1, key_CONT_START - }; - } else if (InputDevice.getDevice(joys[i]).getName() - .equals("Moga 2") - || InputDevice.getDevice(joys[i]).getName() - .equals("Moga 2 HID") - || InputDevice.getDevice(joys[i]).getName() - .equals("Moga Pro 2") - || InputDevice.getDevice(joys[i]).getName() - .equals("Moga Pro 2 HID") - || InputDevice.getDevice(joys[i]).getName() - .equals("Broadcom Bluetooth HID")) { - map = 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, + }; + } else if (InputDevice.getDevice(joys[i]).getName() + .contains("NVIDIA Corporation NVIDIA Controller")) { + map = 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_MENU, key_CONT_START, - OuyaController.BUTTON_R1, key_CONT_START + 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, - }; - } else { // Ouya controller - map = 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_MENU, key_CONT_START, + OuyaController.BUTTON_R1, key_CONT_START }; + nVidia = true; + } else if (!moga.isActive) { // Ouya controller + map = 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_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 }; - } + OuyaController.BUTTON_MENU, key_CONT_START, + OuyaController.BUTTON_R1, key_CONT_START }; + } } // When viewing a resource, pass its URI to the native code for opening @@ -219,6 +215,12 @@ public class GL2JNIActivity extends Activity { // Log.w("INPUT", event.toString() + " " + event.getSource()); // Get all the axis for the KeyEvent + if (nVidia) { + JNIdc.hide_osd(); + } + + if (!moga.isActive) { + // Joystick if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { @@ -236,6 +238,8 @@ public class GL2JNIActivity extends Activity { GL2JNIView.jx = (int) (LS_X * 126); GL2JNIView.jy = (int) (LS_Y * 126); } + + } return true; } @@ -285,6 +289,8 @@ public class GL2JNIActivity extends Activity { */ boolean handle_key(int kc, boolean down) { + if (!moga.isActive) { + boolean rav = false; for (int i = 0; i < map.length; i += 2) { if (map[i + 0] == kc) { @@ -299,6 +305,10 @@ public class GL2JNIActivity extends Activity { } return rav; + + } else { + return true; + } } public boolean onKeyUp(int keyCode, KeyEvent event) { diff --git a/shell/android/src/com/reicast/emulator/MOGAInput.java b/shell/android/src/com/reicast/emulator/MOGAInput.java index 143826bbd..800763e60 100644 --- a/shell/android/src/com/reicast/emulator/MOGAInput.java +++ b/shell/android/src/com/reicast/emulator/MOGAInput.java @@ -40,6 +40,7 @@ public class MOGAInput Controller mController = null; + public boolean isActive = false; private static final int key_CONT_B = 0x0002; private static final int key_CONT_A = 0x0004; @@ -194,6 +195,7 @@ public class MOGAInput if (event.getState() == ACTION_CONNECTED) { Toast.makeText(act.getApplicationContext(), "MOGA Connected!", Toast.LENGTH_SHORT).show(); + isActive = true; } } } From 8a1076f9fd30bfe6f755ad384415214434ed6f55 Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 29 Dec 2013 22:40:42 -0500 Subject: [PATCH 05/34] Cleanup formatting lost during merge of controller changes --- shell/android/src/com/reicast/emulator/GL2JNIActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 12438ff5b..9b5dffd55 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -162,7 +162,8 @@ public class GL2JNIActivity extends Activity { }; } else if (InputDevice.getDevice(joys[i]).getName() .contains("NVIDIA Corporation NVIDIA Controller")) { - map = new int[] { OuyaController.BUTTON_O, key_CONT_A, + map = 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, @@ -179,7 +180,8 @@ public class GL2JNIActivity extends Activity { OuyaController.BUTTON_R1, key_CONT_START }; nVidia = true; } else if (!moga.isActive) { // Ouya controller - map = new int[] { OuyaController.BUTTON_O, key_CONT_A, + map = 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, From 183d08a9220e3d9014397c3006b6feb645ed2652 Mon Sep 17 00:00:00 2001 From: MrPsyMan Date: Wed, 1 Jan 2014 07:42:49 +0200 Subject: [PATCH 06/34] Enable VMU support by default. Fake Bump Mapping handling until we take the time to do it fast+properly. --- core/hw/maple/maple_cfg.cpp | 1 + core/hw/maple/maple_devs.cpp | 1 + core/rend/TexCache.h | 22 ++++++++++++++++++++++ core/rend/gles/gltex.cpp | 6 ++---- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index 38a807eca..bb294eba3 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -4,6 +4,7 @@ #include "maple_devs.h" #include "maple_cfg.h" +#define HAS_VMU /* bus_x=0{p0=1{config};p1=2{config};config;} Plugins: diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index c3604005b..d9f35432e 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -15,6 +15,7 @@ const char* maple_sega_mic_name = "MicDevice for Dreameye"; const char* maple_sega_brand = "Produced By or Under License From SEGA ENTERPRISES,LTD."; +#define HAS_VMU enum MapleFunctionID { diff --git a/core/rend/TexCache.h b/core/rend/TexCache.h index a0a01ad76..b736dc2a8 100644 --- a/core/rend/TexCache.h +++ b/core/rend/TexCache.h @@ -182,6 +182,14 @@ pixelcvt_next(convYUV_PL,4,1) //1,0 pb->prel(3,YUV422(Y1,Yu,Yv)); } +pixelcvt_next(convBMP_PL,4,1) +{ + u16* p_in=(u16*)data; + pb->prel(0,ARGB8888(p_in[0])); + pb->prel(1,ARGB8888(p_in[1])); + pb->prel(2,ARGB8888(p_in[2])); + pb->prel(3,ARGB8888(p_in[3])); +} pixelcvt_end; //twiddled pixelcvt_start(conv565_TW,2,2) @@ -252,6 +260,14 @@ pixelcvt_next(convYUV_TW,2,2) //1,1 pb->prel(1,1,YUV422(Y1,Yu,Yv)); } +pixelcvt_next(convBMP_TW,2,2) +{ + u16* p_in=(u16*)data; + pb->prel(0,0,ARGB8888(p_in[0])); + pb->prel(0,1,ARGB8888(p_in[1])); + pb->prel(1,0,ARGB8888(p_in[2])); + pb->prel(1,1,ARGB8888(p_in[3])); +} pixelcvt_end; pixelcvt_start(convPAL4_TW,4,4) @@ -377,12 +393,14 @@ template void texture_PL >(PixelBuffer* pb,u8* p_in,u32 Width template void texture_PL >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_PL >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_PL >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); +template void texture_PL >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); //twiddled formats ! template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); +template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_TW >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); @@ -392,18 +410,21 @@ template void texture_VQ >(PixelBuffer* pb,u8* p_in,u32 Width template void texture_VQ >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_VQ >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); template void texture_VQ >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); +template void texture_VQ >(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); //Planar #define tex565_PL texture_PL > #define tex1555_PL texture_PL > #define tex4444_PL texture_PL > #define texYUV422_PL texture_PL > +#define texBMP_PL texture_PL > //Twiddle #define tex565_TW texture_TW > #define tex1555_TW texture_TW > #define tex4444_TW texture_TW > #define texYUV422_TW texture_TW > +#define texBMP_TW texture_TW > #define texPAL4_TW texture_TW > #define texPAL8_TW texture_TW > @@ -412,6 +433,7 @@ template void texture_VQ >(PixelBuffer* pb,u8* p_in,u32 Width #define tex1555_VQ texture_VQ > #define tex4444_VQ texture_VQ > #define texYUV422_VQ texture_VQ > +#define texBMP_VQ texture_VQ > void texture_PAL4(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); void texture_PAL8(PixelBuffer* pb,u8* p_in,u32 Width,u32 Height); diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index 5cbb78129..43608200e 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -40,7 +40,7 @@ PvrTexInfo format[8]= {"565", 16,GL_UNSIGNED_SHORT_5_6_5, &tex565_PL,&tex565_TW,&tex565_VQ}, //565 {"4444", 16,GL_UNSIGNED_SHORT_4_4_4_4, &tex4444_PL,&tex4444_TW,&tex4444_VQ}, //4444 {"yuv", 16,GL_UNSIGNED_SHORT_5_6_5, &texYUV422_PL,&texYUV422_TW,&texYUV422_VQ}, //yuv - {"ns/bump", 0}, //ns + {"UNSUPPORTED BUMP MAPPED POLY", 16,GL_UNSIGNED_SHORT_4_4_4_4,&texBMP_PL,&texBMP_TW,&texBMP_VQ}, //bump_ns {"pal4", 4,0,0,texPAL4_TW,0}, //pal4 {"pla8", 8,0,0,texPAL8_TW,0}, //pal8 {"ns/1555", 0}, //ns, 1555 @@ -191,6 +191,7 @@ struct TextureCacheData case 1: //1 565 R value: 5 bits; G value: 6 bits; B value: 5 bits case 2: //2 4444 value: 4 bits; RGB values: 4 bits each case 3: //3 YUV422 32 bits per 2 pixels; YUYV values: 8 bits each + case 4: //4 -NOT_PROPERLY SUPPORTED- Bump Map 16 bits/pixel; S value: 8 bits; R value: 8 bits -NOT_PROPERLY SUPPORTED- case 5: //5 4 BPP Palette Palette texture with 4 bits/pixel case 6: //6 8 BPP Palette Palette texture with 8 bits/pixel if (tcw.ScanOrder && tex->PL) @@ -229,9 +230,6 @@ struct TextureCacheData } } break; - - //4 Bump Map 16 bits/pixel; S value: 8 bits; R value: 8 bits - //Bump maps are not supported for now default: printf("Unhandled texture %d\n",tcw.PixelFmt); size=w*h*2; From 629b9e0a7926df9f5e45389d972a8dc683701677 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Thu, 2 Jan 2014 17:12:02 +0100 Subject: [PATCH 07/34] android: do not require touchscreen (fix for stb devices) --- shell/android/AndroidManifest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/android/AndroidManifest.xml b/shell/android/AndroidManifest.xml index a92719df9..b3f638feb 100644 --- a/shell/android/AndroidManifest.xml +++ b/shell/android/AndroidManifest.xml @@ -9,11 +9,13 @@ - + + + From 7a4d44c2df3f2bde37ec734d1d5a47c78f17cbc0 Mon Sep 17 00:00:00 2001 From: Matteo Hausner Date: Thu, 2 Jan 2014 19:02:42 +0100 Subject: [PATCH 08/34] Added Xbox 360 controller support --- .../com/reicast/emulator/GL2JNIActivity.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 9b5dffd55..481807861 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -38,7 +38,8 @@ public class GL2JNIActivity extends Activity { PopupWindow popUp; LayoutParams params; MOGAInput moga = new MOGAInput(); - static boolean nVidia = false; + static boolean xbox = false, nVidia = false; + float globalLS_X, globalLS_Y, previousLS_X, previousLS_Y; int map[]; @@ -160,6 +161,25 @@ public class GL2JNIActivity extends Activity { OuyaController.BUTTON_R1, key_CONT_START }; + } else if (InputDevice.getDevice(joys[i]).getName() + .equals("Microsoft X-Box 360 pad")) { + map = 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 }; + xbox = true; } else if (InputDevice.getDevice(joys[i]).getName() .contains("NVIDIA Corporation NVIDIA Controller")) { map = new int[] { @@ -234,6 +254,13 @@ public class GL2JNIActivity extends Activity { float L2 = event.getAxisValue(OuyaController.AXIS_L2); float R2 = event.getAxisValue(OuyaController.AXIS_R2); + if (xbox) { + previousLS_X = globalLS_X; + previousLS_Y = globalLS_Y; + globalLS_X = LS_X; + globalLS_Y = LS_Y; + } + GL2JNIView.lt = (int) (L2 * 255); GL2JNIView.rt = (int) (R2 * 255); @@ -242,8 +269,13 @@ public class GL2JNIActivity extends Activity { } } - - return true; + + if (xbox && globalLS_X == previousLS_X && globalLS_Y == previousLS_Y) + // 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; From 12b29f003ad5800bdcc830a5508d90d7bc044315 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Fri, 3 Jan 2014 18:55:25 +0100 Subject: [PATCH 09/34] Fix MOGA detection, change options to paths --- shell/android/res/values/strings.xml | 6 +++--- shell/android/src/com/reicast/emulator/MOGAInput.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml index 90b0ccecd..ab66f48ad 100644 --- a/shell/android/res/values/strings.xml +++ b/shell/android/res/values/strings.xml @@ -8,7 +8,7 @@ Default System Path Storage Path (location of .gid .cdi or .cdh images) Default Game Storage - Stretch to Fullscreen + Widescreen Mode Frameskipping Amount PVR Rendering Available Dreamcast Games @@ -25,8 +25,8 @@ Browser - Options - Emulator + Paths + Settings About diff --git a/shell/android/src/com/reicast/emulator/MOGAInput.java b/shell/android/src/com/reicast/emulator/MOGAInput.java index 800763e60..81609a2f2 100644 --- a/shell/android/src/com/reicast/emulator/MOGAInput.java +++ b/shell/android/src/com/reicast/emulator/MOGAInput.java @@ -193,7 +193,7 @@ public class MOGAInput { JNIdc.hide_osd(); - if (event.getState() == ACTION_CONNECTED) { + if (event.getState() == StateEvent.STATE_CONNECTION && event.getAction() == ACTION_CONNECTED) { Toast.makeText(act.getApplicationContext(), "MOGA Connected!", Toast.LENGTH_SHORT).show(); isActive = true; } From 05571cf7ea5dbeea4deb9a34b4a6a106b205dcb1 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Fri, 3 Jan 2014 19:28:37 +0100 Subject: [PATCH 10/34] Frameskip, unstable opts - make ta_skip to ta frame skipping instead of skipping parsing entierly. it handles 1 out of every (N+1) frames. - re purpose rend to unstable opts, as pvr.rend is of no real use right now --- core/hw/pvr/ta_vtx.cpp | 10 +++++--- shell/android/res/values/strings.xml | 2 +- .../reicast/emulator/ConfigureFragment.java | 23 +++++++++---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/core/hw/pvr/ta_vtx.cpp b/core/hw/pvr/ta_vtx.cpp index 587ba6288..4d122a7c4 100644 --- a/core/hw/pvr/ta_vtx.cpp +++ b/core/hw/pvr/ta_vtx.cpp @@ -1390,15 +1390,19 @@ public: FifoSplitter<0> TAFifo0; +int ta_parse_cnt = 0; + bool ta_parse_vdrc(TA_context* ctx) { - bool rv=true; + bool rv=false; verify( vd_ctx == 0); vd_ctx = ctx; 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(); diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml index ab66f48ad..670bc05ea 100644 --- a/shell/android/res/values/strings.xml +++ b/shell/android/res/values/strings.xml @@ -10,7 +10,7 @@ Default Game Storage Widescreen Mode Frameskipping Amount - PVR Rendering + Unstable Optimisations Available Dreamcast Games diff --git a/shell/android/src/com/reicast/emulator/ConfigureFragment.java b/shell/android/src/com/reicast/emulator/ConfigureFragment.java index 3d2324611..3c2b56f0f 100644 --- a/shell/android/src/com/reicast/emulator/ConfigureFragment.java +++ b/shell/android/src/com/reicast/emulator/ConfigureFragment.java @@ -33,7 +33,7 @@ public class ConfigureFragment extends Fragment { TextView mainFrames; OnClickListener mCallback; boolean widescreen = false; - boolean pvrrender = false; + boolean unstable_opt = false; int frameskip = 0; private SharedPreferences mPrefs; @@ -83,9 +83,9 @@ public class ConfigureFragment extends Fragment { frameskip = Integer.valueOf(currentLine.replace( "ta.skip=", "")); } - if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) { - pvrrender = Boolean.valueOf(currentLine.replace( - "pvr.rend=", "")); + if (StringUtils.containsIgnoreCase(currentLine, "Dynarec.unstable-opt")) { + unstable_opt = Boolean.valueOf(currentLine.replace( + "Dynarec.unstable-opt=", "")); } } scanner.close(); @@ -164,9 +164,9 @@ public class ConfigureFragment extends Fragment { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - mPrefs.edit().putBoolean("pvr_render", isChecked).commit(); - pvrrender = isChecked; - if (!executeAppendConfig("pvr.rend", + mPrefs.edit().putBoolean("unstable_opt", isChecked).commit(); + unstable_opt = isChecked; + if (!executeAppendConfig("Dynarec.unstable-opt", String.valueOf(isChecked ? 1 : 0))) { executeWriteConfig(); } @@ -175,7 +175,7 @@ public class ConfigureFragment extends Fragment { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { Switch pvr_render = (Switch) getView().findViewById( R.id.render_option); - boolean rendered = mPrefs.getBoolean("pvr_render", pvrrender); + boolean rendered = mPrefs.getBoolean("unstable_opt", unstable_opt); if (rendered) { pvr_render.setChecked(true); } else { @@ -185,7 +185,7 @@ public class ConfigureFragment extends Fragment { } else { CheckBox pvr_render = (CheckBox) getView().findViewById( R.id.render_option); - boolean rendered = mPrefs.getBoolean("pvr_render", pvrrender); + boolean rendered = mPrefs.getBoolean("unstable_opt", unstable_opt); if (rendered) { pvr_render.setChecked(true); } else { @@ -233,7 +233,7 @@ public class ConfigureFragment extends Fragment { rebuildFile.append("[config]" + "\n"); rebuildFile.append("Dynarec.Enabled=1" + "\n"); rebuildFile.append("Dynarec.idleskip=1" + "\n"); - rebuildFile.append("Dynarec.unstable-opt=0" + "\n"); + rebuildFile.append("Dynarec.unstable-opt=" + String.valueOf(unstable_opt ? 1 : 0) + "\n"); rebuildFile.append("Dreamcast.Cable=3" + "\n"); rebuildFile.append("Dreamcast.RTC=2018927206" + "\n"); rebuildFile.append("Dreamcast.Region=3" + "\n"); @@ -245,8 +245,7 @@ public class ConfigureFragment extends Fragment { + String.valueOf(widescreen ? 1 : 0) + "\n"); rebuildFile.append("pvr.Subdivide=0" + "\n"); rebuildFile.append("ta.skip=" + String.valueOf(frameskip) + "\n"); - rebuildFile.append("pvr.rend=" + String.valueOf(pvrrender ? 1 : 0) - + "\n"); + rebuildFile.append("pvr.rend=1" + "\n"); rebuildFile.append("image=null" + "\n"); FileOutputStream fos = new FileOutputStream(config); fos.write(rebuildFile.toString().getBytes()); From 25d4607b57abe1336e67048350b3e2e75adfae3f Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Fri, 3 Jan 2014 20:04:42 +0100 Subject: [PATCH 11/34] bump version number --- shell/android/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/android/AndroidManifest.xml b/shell/android/AndroidManifest.xml index b3f638feb..2b1351d7a 100644 --- a/shell/android/AndroidManifest.xml +++ b/shell/android/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionName="0.r6" > Date: Fri, 3 Jan 2014 21:17:37 +0100 Subject: [PATCH 12/34] embed zlib compressed version of vmu_default.bin, detect empty vmu and preformat --- core/hw/maple/maple_devs.cpp | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index d9f35432e..c352db493 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -5,6 +5,8 @@ #include "maple_cfg.h" #include +#include "deps/zlib/zlib.h" + const char* maple_sega_controller_name = "Dreamcast Controller"; const char* maple_sega_vmu_name = "Visual Memory"; const char* maple_sega_kbd_name = "Emulated Dreamcast Keyboard"; @@ -234,6 +236,28 @@ struct maple_sega_controller: maple_base This is pretty much done (?) */ #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 { FILE* file; @@ -266,6 +290,20 @@ struct maple_sega_vmu: maple_base { fread(flash_data,1,sizeof(flash_data),file); } + + u8 sum = 0; + for (int i=0;i Date: Sat, 4 Jan 2014 15:26:50 +0100 Subject: [PATCH 13/34] hardfp calling support This is commented out for android, but it is tested and works! --- core/core.mk | 2 +- core/rec-ARM/arm_dyna.cpp | 38 ++++++++++++++++++++++++++++++++++++ shell/android/jni/Android.mk | 20 ++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/core/core.mk b/core/core.mk index 446fcbc93..0b337ab30 100755 --- a/core/core.mk +++ b/core/core.mk @@ -52,7 +52,7 @@ else RZDCY_CXXFLAGS := \ $(CFLAGS) -c -g -O3 -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps \ -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 \ -ftree-vectorize -fomit-frame-pointer -fno-exceptions -fno-rtti -std=gnu++11 endif \ No newline at end of file diff --git a/core/rec-ARM/arm_dyna.cpp b/core/rec-ARM/arm_dyna.cpp index c8799ceeb..6b8829461 100644 --- a/core/rec-ARM/arm_dyna.cpp +++ b/core/rec-ARM/arm_dyna.cpp @@ -565,6 +565,22 @@ void ngen_CC_Param(shil_opcode* op,shil_param* par,CanonicalParamType tp) switch(tp) { 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_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) { u32 rd=r0; + u32 fd=f0; + for (int i=CC_pars.size();i-->0;) { 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()) { + #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)) { //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 { + verify(CC_pars[i].type != CPT_f32); //printf("MOV32((eReg)rd, CC_pars[i].par->_imm); %d\n",rd); MOV32((eReg)rd, CC_pars[i].par->_imm); } diff --git a/shell/android/jni/Android.mk b/shell/android/jni/Android.mk index 97e9cce63..6dcc047b1 100644 --- a/shell/android/jni/Android.mk +++ b/shell/android/jni/Android.mk @@ -32,10 +32,28 @@ LOCAL_MODULE := dc LOCAL_CFLAGS := $(LOCAL_CXXFLAGS) -DHAS_VMU LOCAL_DISABLE_FORMAT_STRING_CHECKS=true LOCAL_ASFLAGS := -fvisibility=hidden -LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz +LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz #-Wl,-Map,./res/raw/syms.mp3 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) $(call import-module,android/native_app_glue) From 7965f0c4223fc2c34732b14602546e49ed1b725c Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sat, 4 Jan 2014 19:34:49 -0500 Subject: [PATCH 14/34] Menu updates for easier flow, Fix up 2.3 compatibility Fix menu flow, Add explanations, Fix menu option values This places paths inside settings instead of the reverse for devices that cannot view the slider menu. The configuration options have been expanded to work toward adding all emu.cfg values as visual. Options not currently being used by the emulator are commented to avoid user confusion. Set all icons to default to browser, Replace duplicate icon Organize imports and move config to main menu for < 2.3 Fix fragment display in pre 2.3 devices by restoring views --- .../res/layout-v14/configure_fragment.xml | 190 ++++++++++---- .../android/res/layout/configure_fragment.xml | 191 ++++++++++---- .../res/layout/mainuilayout_fragment.xml | 16 ++ shell/android/res/values/strings.xml | 24 +- .../reicast/emulator/ConfigureFragment.java | 246 ++++++++++++++++-- .../com/reicast/emulator/GL2JNIActivity.java | 19 +- .../src/com/reicast/emulator/GL2JNIView.java | 32 +-- .../src/com/reicast/emulator/JNIdc.java | 1 - .../src/com/reicast/emulator/MOGAInput.java | 11 - .../com/reicast/emulator/MainActivity.java | 206 ++++++++------- .../com/reicast/emulator/OptionsFragment.java | 17 +- 11 files changed, 695 insertions(+), 258 deletions(-) diff --git a/shell/android/res/layout-v14/configure_fragment.xml b/shell/android/res/layout-v14/configure_fragment.xml index 162881b72..0ddf9c2b9 100644 --- a/shell/android/res/layout-v14/configure_fragment.xml +++ b/shell/android/res/layout-v14/configure_fragment.xml @@ -3,80 +3,182 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > - - + + + android:layout_weight="1" + android:ems="10" + android:text="@string/select_dynarec" /> - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - - + android:max="5" + android:progress="0" /> + - + + + \ No newline at end of file diff --git a/shell/android/res/layout/configure_fragment.xml b/shell/android/res/layout/configure_fragment.xml index 926822252..b7ad74cee 100644 --- a/shell/android/res/layout/configure_fragment.xml +++ b/shell/android/res/layout/configure_fragment.xml @@ -3,80 +3,183 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > - - + + + android:layout_weight="1" + android:ems="10" + android:text="@string/select_dynarec" /> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + android:max="5" + android:progress="0" /> - - + + + + + \ No newline at end of file diff --git a/shell/android/res/layout/mainuilayout_fragment.xml b/shell/android/res/layout/mainuilayout_fragment.xml index 35be3891f..492cb1fe6 100644 --- a/shell/android/res/layout/mainuilayout_fragment.xml +++ b/shell/android/res/layout/mainuilayout_fragment.xml @@ -28,6 +28,17 @@ android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="32dp" /> + + + + \ No newline at end of file diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml index 670bc05ea..a41a8edef 100644 --- a/shell/android/res/values/strings.xml +++ b/shell/android/res/values/strings.xml @@ -8,9 +8,16 @@ Default System Path Storage Path (location of .gid .cdi or .cdh images) Default Game Storage + + Dynarec Options + Unstable Optimisations + DC Region + Limit FPS + Use Mipmaps Widescreen Mode - Frameskipping Amount - Unstable Optimisations + Frameskip Value + PVR Rendering + Available Dreamcast Games @@ -18,6 +25,13 @@ chd gdi + + + + + + (Default) + Slider Menu Opened Slider Menu Closed @@ -25,17 +39,17 @@ Browser - Paths Settings + Paths About - + @drawable/disk_unknown @drawable/config - @drawable/config + @drawable/open_folder @drawable/question diff --git a/shell/android/src/com/reicast/emulator/ConfigureFragment.java b/shell/android/src/com/reicast/emulator/ConfigureFragment.java index 3c2b56f0f..dfaffaff3 100644 --- a/shell/android/src/com/reicast/emulator/ConfigureFragment.java +++ b/shell/android/src/com/reicast/emulator/ConfigureFragment.java @@ -32,9 +32,15 @@ public class ConfigureFragment extends Fragment { Activity parentActivity; TextView mainFrames; OnClickListener mCallback; + + boolean dynarecopt = true; + boolean unstableopt = false; + int dcregion = 3; + boolean limitfps = true; + boolean mipmaps = true; boolean widescreen = false; - boolean unstable_opt = false; int frameskip = 0; + boolean pvrrender = false; private SharedPreferences mPrefs; private File sdcard = Environment.getExternalStorageDirectory(); @@ -74,6 +80,29 @@ public class ConfigureFragment extends Fragment { String currentLine; while (scanner.hasNextLine()) { 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, "rend.WideScreen")) { widescreen = Boolean.valueOf(currentLine.replace( @@ -83,19 +112,187 @@ public class ConfigureFragment extends Fragment { frameskip = Integer.valueOf(currentLine.replace( "ta.skip=", "")); } - if (StringUtils.containsIgnoreCase(currentLine, "Dynarec.unstable-opt")) { - unstable_opt = Boolean.valueOf(currentLine.replace( - "Dynarec.unstable-opt=", "")); - } + /*if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) { + pvrrender = Boolean.valueOf(currentLine.replace( + "pvr.rend=", "")); + }*/ + } scanner.close(); } } catch (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); - mainFrames.setText(String.valueOf(frameskip)); + public void onCheckedChanged(CompoundButton buttonView, + 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 localeAdapter = new ArrayAdapter( + 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() { @@ -130,6 +327,9 @@ public class ConfigureFragment extends Fragment { } stretch_view.setOnCheckedChangeListener(full_screen); } + + mainFrames = (TextView) getView().findViewById(R.id.current_frames); + mainFrames.setText(String.valueOf(frameskip)); SeekBar frameSeek = (SeekBar) getView() .findViewById(R.id.frame_seekbar); @@ -160,13 +360,13 @@ public class ConfigureFragment extends Fragment { } }); - OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() { + /*OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - mPrefs.edit().putBoolean("unstable_opt", isChecked).commit(); - unstable_opt = isChecked; - if (!executeAppendConfig("Dynarec.unstable-opt", + mPrefs.edit().putBoolean("pvr_render", isChecked).commit(); + pvrrender = isChecked; + if (!executeAppendConfig("pvr.rend", String.valueOf(isChecked ? 1 : 0))) { executeWriteConfig(); } @@ -175,7 +375,7 @@ public class ConfigureFragment extends Fragment { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { Switch pvr_render = (Switch) getView().findViewById( R.id.render_option); - boolean rendered = mPrefs.getBoolean("unstable_opt", unstable_opt); + boolean rendered = mPrefs.getBoolean("pvr_render", pvrrender); if (rendered) { pvr_render.setChecked(true); } else { @@ -185,20 +385,23 @@ public class ConfigureFragment extends Fragment { } else { CheckBox pvr_render = (CheckBox) getView().findViewById( R.id.render_option); - boolean rendered = mPrefs.getBoolean("unstable_opt", unstable_opt); + boolean rendered = mPrefs.getBoolean("pvr_render", pvrrender); if (rendered) { pvr_render.setChecked(true); } else { pvr_render.setChecked(false); } pvr_render.setOnCheckedChangeListener(pvr_rendering); - } + }*/ } private boolean executeAppendConfig(String identifier, String value) { File config = new File(home_directory, "emu.cfg"); if (config.exists()) { try { + + // Read existing emu.cfg and substitute new setting value + StringBuilder rebuildFile = new StringBuilder(); Scanner scanner = new Scanner(config); String currentLine; @@ -229,23 +432,26 @@ public class ConfigureFragment extends Fragment { if (config.exists()) { config.delete(); } + + // Write new emu.cfg using current display values + StringBuilder rebuildFile = new StringBuilder(); 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.unstable-opt=" + String.valueOf(unstable_opt ? 1 : 0) + "\n"); + rebuildFile.append("Dynarec.unstable-opt=" + String.valueOf(unstableopt ? 1 : 0) + "\n"); rebuildFile.append("Dreamcast.Cable=3" + "\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("aica.LimitFPS=1" + "\n"); + rebuildFile.append("aica.LimitFPS=" + String.valueOf(limitfps ? 1 : 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=" + String.valueOf(widescreen ? 1 : 0) + "\n"); rebuildFile.append("pvr.Subdivide=0" + "\n"); rebuildFile.append("ta.skip=" + String.valueOf(frameskip) + "\n"); - rebuildFile.append("pvr.rend=1" + "\n"); + rebuildFile.append("pvr.rend=" + String.valueOf(pvrrender ? 1 : 0) + "\n"); rebuildFile.append("image=null" + "\n"); FileOutputStream fos = new FileOutputStream(config); fos.write(rebuildFile.toString().getBytes()); diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 481807861..b22916b89 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -1,36 +1,27 @@ package com.reicast.emulator; -import java.io.IOException; -import java.io.InputStream; - import tv.ouya.console.api.OuyaController; - -import com.reicast.emulator.GL2JNIView.EmuThread; - -import android.view.InputDevice; import android.annotation.TargetApi; import android.app.Activity; +import android.content.Intent; +import android.content.res.Configuration; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.util.Log; import android.view.Gravity; +import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.Window; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; +import android.view.Window; import android.widget.ImageButton; import android.widget.ImageView.ScaleType; import android.widget.LinearLayout; import android.widget.PopupWindow; 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) public class GL2JNIActivity extends Activity { diff --git a/shell/android/src/com/reicast/emulator/GL2JNIView.java b/shell/android/src/com/reicast/emulator/GL2JNIView.java index 79de99c8b..b9a75cc63 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIView.java @@ -1,33 +1,23 @@ 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.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.opengles.GL10; +import android.content.Context; +import android.content.res.Configuration; +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.util.Log; +import android.view.MotionEvent; + /** * A simple GLSurfaceView sub-class that demonstrate how to perform diff --git a/shell/android/src/com/reicast/emulator/JNIdc.java b/shell/android/src/com/reicast/emulator/JNIdc.java index 2fdfc270d..efc45bb88 100644 --- a/shell/android/src/com/reicast/emulator/JNIdc.java +++ b/shell/android/src/com/reicast/emulator/JNIdc.java @@ -1,6 +1,5 @@ package com.reicast.emulator; -import android.media.AudioTrack; public class JNIdc { diff --git a/shell/android/src/com/reicast/emulator/MOGAInput.java b/shell/android/src/com/reicast/emulator/MOGAInput.java index 81609a2f2..8c6969658 100644 --- a/shell/android/src/com/reicast/emulator/MOGAInput.java +++ b/shell/android/src/com/reicast/emulator/MOGAInput.java @@ -3,21 +3,10 @@ package com.reicast.emulator; /******************************************************************************/ -import java.util.Map.Entry; -import java.util.TreeMap; - import android.app.Activity; -import android.os.Bundle; 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.util.Log; - import com.bda.controller.Controller; import com.bda.controller.ControllerListener; import com.bda.controller.KeyEvent; diff --git a/shell/android/src/com/reicast/emulator/MainActivity.java b/shell/android/src/com/reicast/emulator/MainActivity.java index adc2e229d..5c9a6017e 100644 --- a/shell/android/src/com/reicast/emulator/MainActivity.java +++ b/shell/android/src/com/reicast/emulator/MainActivity.java @@ -27,7 +27,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; import android.widget.AdapterView; -import android.widget.LinearLayout; import android.widget.ListView; public class MainActivity extends FragmentActivity implements @@ -58,76 +57,14 @@ public class MainActivity extends FragmentActivity implements public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); 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 // the fragment_container FrameLayout 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(); - - // 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, // then we don't need to do anything and should return or else @@ -155,21 +92,90 @@ public class MainActivity extends FragmentActivity implements .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) { - findViewById(R.id.config).setOnClickListener(new OnClickListener() { + 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(); + + // 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))); + // About + navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons + .getResourceId(3, 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 optsFrag = (OptionsFragment) getSupportFragmentManager() + OptionsFragment optionsFrag = (OptionsFragment) getSupportFragmentManager() .findFragmentByTag("OPTIONS_FRAG"); - if (optsFrag != null) { - if (optsFrag.isVisible()) { + if (optionsFrag != null) { + if (optionsFrag.isVisible()) { return; } } - optsFrag = new OptionsFragment(); + optionsFrag = new OptionsFragment(); getSupportFragmentManager() .beginTransaction() - .replace(R.id.fragment_container, optsFrag, + .replace(R.id.fragment_container, optionsFrag, "OPTIONS_FRAG").addToBackStack(null) .commit(); /* @@ -193,6 +199,25 @@ public class MainActivity extends FragmentActivity implements } }); + + findViewById(R.id.config).setOnClickListener(new OnClickListener() { + public void onClick(View view) { + ConfigureFragment configFrag = (ConfigureFragment) getSupportFragmentManager() + .findFragmentByTag("CONFIG_FRAG"); + if (configFrag != null) { + if (configFrag.isVisible()) { + return; + } + } + configFrag = new ConfigureFragment(); + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.fragment_container, configFrag, + "CONFIG_FRAG").addToBackStack(null) + .commit(); + } + + }); findViewById(R.id.about).setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { @@ -232,10 +257,6 @@ 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) { @@ -266,9 +287,12 @@ public class MainActivity extends FragmentActivity implements FileBrowser firstFragment = new FileBrowser(); Bundle args = new Bundle(); args.putBoolean("ImgBrowse", false); - args.putString("browse_entry", path_entry); - args.putBoolean("games_entry", games); // 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); // In case this activity was started with special instructions from // an Intent, pass the Intent's extras to the fragment as arguments @@ -319,17 +343,6 @@ public class MainActivity extends FragmentActivity implements frag_tag = "MAIN_BROWSER"; break; 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() .findFragmentByTag("CONFIG_FRAG"); if (fragment != null) { @@ -340,6 +353,17 @@ public class MainActivity extends FragmentActivity implements fragment = new ConfigureFragment(); frag_tag = "CONFIG_FRAG"; 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: fragment = null; // vib.vibrate(50); diff --git a/shell/android/src/com/reicast/emulator/OptionsFragment.java b/shell/android/src/com/reicast/emulator/OptionsFragment.java index ebfd8fd6d..480649b29 100644 --- a/shell/android/src/com/reicast/emulator/OptionsFragment.java +++ b/shell/android/src/com/reicast/emulator/OptionsFragment.java @@ -52,11 +52,14 @@ public class OptionsFragment extends Fragment { + " must implement OnClickListener"); } - int joys[] = InputDevice.getDeviceIds(); - for (int i = 0; i < joys.length; i++) { - Log.d("reidc", "InputDevice ID: " + joys[i]); - Log.d("reidc", "InputDevice Name: " - + InputDevice.getDevice(joys[i]).getName()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { + int joys[] = InputDevice.getDeviceIds(); + for (int i = 0; i < joys.length; i++) { + Log.d("reidc", "InputDevice ID: " + joys[i]); + Log.d("reidc", + "InputDevice Name: " + + InputDevice.getDevice(joys[i]).getName()); + } } } @@ -72,10 +75,10 @@ public class OptionsFragment extends Fragment { // setContentView(R.layout.activity_main); parentActivity = getActivity(); - + mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity); home_directory = mPrefs.getString("home_directory", home_directory); - + mainBrowse = (Button) getView().findViewById(R.id.browse_main_path); final EditText editBrowse = (EditText) getView().findViewById( From 7c42c55c8f62a7c0ec043fd54b4cfec6980c7c83 Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 5 Jan 2014 01:24:23 -0500 Subject: [PATCH 15/34] Fix directory selection when BIOS is in an alternate folder This will allow selecting a different folder on the first run instead of having to place everything in /sdcard/dc first and then pick a new folder to later move to. This will still notify the user of requirements for having the BIOS in the /dc folder if they do not pick an alternate location at this time. --- .../src/com/reicast/emulator/FileBrowser.java | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/FileBrowser.java b/shell/android/src/com/reicast/emulator/FileBrowser.java index 73785f1e9..6288b5c67 100644 --- a/shell/android/src/com/reicast/emulator/FileBrowser.java +++ b/shell/android/src/com/reicast/emulator/FileBrowser.java @@ -152,18 +152,6 @@ public class FileBrowser extends Fragment { if (!home.exists() || !home.isDirectory()) { Toast.makeText(getActivity(), "Please configure a home directory", 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) { @@ -183,7 +171,7 @@ public class FileBrowser extends Fragment { 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) { + if (msg != null && ImgBrowse) { vib.vibrate(50); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( parentActivity); @@ -208,20 +196,24 @@ public class FileBrowser extends Fragment { 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() + 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", games); + // specify if the desired path is for games or data + + 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 + getActivity().getSupportFragmentManager() .beginTransaction() - .replace(R.id.fragment_container, - optsFrag, "OPTIONS_FRAG") + .replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER") .addToBackStack(null).commit(); } }); From eedb4ac233d31ed38045e5e88672590f86bf9dff Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 5 Jan 2014 01:40:34 -0500 Subject: [PATCH 16/34] Use xbox configuration for nVidia Shield to enable dpad --- shell/android/src/com/reicast/emulator/GL2JNIActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index b22916b89..515db92ed 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -245,7 +245,7 @@ public class GL2JNIActivity extends Activity { float L2 = event.getAxisValue(OuyaController.AXIS_L2); float R2 = event.getAxisValue(OuyaController.AXIS_R2); - if (xbox) { + if (xbox || nVidia) { previousLS_X = globalLS_X; previousLS_Y = globalLS_Y; globalLS_X = LS_X; @@ -261,7 +261,7 @@ public class GL2JNIActivity extends Activity { } - if (xbox && globalLS_X == previousLS_X && globalLS_Y == previousLS_Y) + if ((xbox || nVidia) && globalLS_X == previousLS_X && globalLS_Y == previousLS_Y) // 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; From 99228e8aeaf2fcbf2e17e427d097def5d89caa19 Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 5 Jan 2014 02:22:29 -0500 Subject: [PATCH 17/34] Fix missing navdrawer when returning to menu from game --- shell/android/src/com/reicast/emulator/MainActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/MainActivity.java b/shell/android/src/com/reicast/emulator/MainActivity.java index 5c9a6017e..14e41e6fd 100644 --- a/shell/android/src/com/reicast/emulator/MainActivity.java +++ b/shell/android/src/com/reicast/emulator/MainActivity.java @@ -57,7 +57,7 @@ public class MainActivity extends FragmentActivity implements public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainuilayout_fragment); - + mPrefs = PreferenceManager.getDefaultSharedPreferences(this); home_directory = mPrefs.getString("home_directory", home_directory); JNIdc.config(home_directory); @@ -69,8 +69,10 @@ public class MainActivity extends FragmentActivity implements // However, if we're being restored from a previous state, // then we don't need to do anything and should return or else // we could end up with overlapping fragments. - if (savedInstanceState != null) { - return; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) { + if (savedInstanceState != null) { + return; + } } // Create a new Fragment to be placed in the activity layout From 7a54a1da0d29a7eabd23c65b0b4776a450eb8142 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Sun, 5 Jan 2014 11:25:19 +0100 Subject: [PATCH 18/34] Fi some strings, move bios checking --- shell/android/.classpath | 2 +- shell/android/res/values/strings.xml | 8 +- .../src/com/reicast/emulator/FileBrowser.java | 65 -------- .../com/reicast/emulator/MainActivity.java | 146 +++++++++++++----- 4 files changed, 113 insertions(+), 108 deletions(-) diff --git a/shell/android/.classpath b/shell/android/.classpath index 0b0840834..d57ec0251 100644 --- a/shell/android/.classpath +++ b/shell/android/.classpath @@ -1,7 +1,7 @@ - + diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml index a41a8edef..f00a78854 100644 --- a/shell/android/res/values/strings.xml +++ b/shell/android/res/values/strings.xml @@ -4,19 +4,19 @@ Hello world! Settings reicast - System Path (location of dc_boot.bin/dc_flash.bin) + System Path (location of the data folder with dc_boot.bin/dc_flash.bin inside) Default System Path - Storage Path (location of .gid .cdi or .cdh images) + Storage Path (location of .gdi, .chd or .cdi images) Default Game Storage Dynarec Options Unstable Optimisations DC Region Limit FPS - Use Mipmaps + Use Mipmaps (fix for old SGX540) Widescreen Mode Frameskip Value - PVR Rendering + PVR Rendering (does nothing for now) Available Dreamcast Games diff --git a/shell/android/src/com/reicast/emulator/FileBrowser.java b/shell/android/src/com/reicast/emulator/FileBrowser.java index 6288b5c67..3c68528c0 100644 --- a/shell/android/src/com/reicast/emulator/FileBrowser.java +++ b/shell/android/src/com/reicast/emulator/FileBrowser.java @@ -159,71 +159,6 @@ public class FileBrowser extends Fragment { } else { 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 && ImgBrowse) { - 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) { - 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", games); - // specify if the desired path is for games or data - - 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 - getActivity().getSupportFragmentManager() - .beginTransaction() - .replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER") - .addToBackStack(null).commit(); - } - }); - - // create alert dialog - AlertDialog alertDialog = alertDialogBuilder.create(); - - // show it - alertDialog.show(); - } } class DirSort implements Comparator { diff --git a/shell/android/src/com/reicast/emulator/MainActivity.java b/shell/android/src/com/reicast/emulator/MainActivity.java index 14e41e6fd..eb8b7edfc 100644 --- a/shell/android/src/com/reicast/emulator/MainActivity.java +++ b/shell/android/src/com/reicast/emulator/MainActivity.java @@ -117,7 +117,7 @@ public class MainActivity extends FragmentActivity implements .getResourceId(1, 0))); // Paths navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons - .getResourceId(2, 0))); + .getResourceId(2, 0))); // About navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons .getResourceId(3, 0))); @@ -165,43 +165,46 @@ public class MainActivity extends FragmentActivity implements // } } 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; + 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(); + */ } - } - 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() { public void onClick(View view) { ConfigureFragment configFrag = (ConfigureFragment) getSupportFragmentManager() @@ -262,9 +265,76 @@ public class MainActivity extends FragmentActivity implements } 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 = "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) { + 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 + //FIME + //args.putBoolean("games_entry", games); + // specify if the desired path is for games or data + + 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 + //FIXME + MainActivity.this.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); - startActivity(inte); + startActivity(inte); + } } public void onFolderSelected(Uri uri) { From aabe953f7df9870e5b2dfd4e5ac9c6c59c74e931 Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 5 Jan 2014 06:08:44 -0500 Subject: [PATCH 19/34] Clean up the options call when moving to the main activity --- shell/android/src/com/reicast/emulator/MainActivity.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/MainActivity.java b/shell/android/src/com/reicast/emulator/MainActivity.java index eb8b7edfc..269bc7960 100644 --- a/shell/android/src/com/reicast/emulator/MainActivity.java +++ b/shell/android/src/com/reicast/emulator/MainActivity.java @@ -306,9 +306,8 @@ public class MainActivity extends FragmentActivity implements // specify ImgBrowse option. true = images, false = folders only args.putString("browse_entry", sdcard.toString()); // specify a path for selecting folder options - //FIME - //args.putBoolean("games_entry", games); - // specify if the desired path is for games or data + 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 @@ -316,8 +315,7 @@ public class MainActivity extends FragmentActivity implements // firstFragment.setArguments(getIntent().getExtras()); // Add the fragment to the 'fragment_container' FrameLayout - //FIXME - MainActivity.this.getSupportFragmentManager() + getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER") .addToBackStack(null).commit(); From 5b5743dd9534139416ef6f7cbe9b3a4dcc6758d4 Mon Sep 17 00:00:00 2001 From: Matteo Hausner Date: Fri, 3 Jan 2014 18:32:32 +0100 Subject: [PATCH 20/34] First steps to integrate multi-controller support --- core/hw/maple/maple_cfg.cpp | 7 +- shell/android/jni/src/Android.cpp | 38 ++++++-- .../com/reicast/emulator/GL2JNIActivity.java | 95 +++++++++++++------ .../src/com/reicast/emulator/GL2JNIView.java | 22 +++-- .../src/com/reicast/emulator/JNIdc.java | 4 +- .../src/com/reicast/emulator/MOGAInput.java | 12 +-- 6 files changed, 117 insertions(+), 61 deletions(-) diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index bb294eba3..7757a5217 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -69,6 +69,7 @@ void mcfg_Create(MapleDeviceType type,u32 bus,u32 port) void mcfg_CreateDevices() { mcfg_Create(MDT_SegaController,0,5); + mcfg_Create(MDT_SegaController,1,5); #ifdef HAS_VMU mcfg_Create(MDT_SegaVMU,0,0); @@ -78,7 +79,7 @@ void mcfg_CreateDevices() void mcfg_DestroyDevices() { - for (int i=0;i<3;i++) - for (int j=0;j<5;j++) + for (int i=0;i<=3;i++) + for (int j=0;j<=5;j++) delete MapleDevices[i][j]; -} \ No newline at end of file +} diff --git a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp index 3337ac853..f322c0d47 100644 --- a/shell/android/jni/src/Android.cpp +++ b/shell/android/jni/src/Android.cpp @@ -29,7 +29,7 @@ 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_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 jint JNICALL Java_com_reicast_emulator_JNIdc_play(JNIEnv *env,jobject obj,jshortArray result,jint size); }; @@ -244,17 +244,37 @@ JNIEXPORT jint JNICALL Java_com_reicast_emulator_JNIdc_data(JNIEnv *env,jobject JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,jobject obj) { + /*char kcode_str0[100]; + char kcode_str1[100]; + sprintf(kcode_str0,"%d", kcode[0]); + sprintf(kcode_str1,"%d", kcode[1]); + __android_log_write(ANDROID_LOG_INFO, "kcode 0", kcode_str0); + __android_log_write(ANDROID_LOG_INFO, "kcode 1", kcode_str1);*/ 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; - rt[0] = r_t; - kcode[0] = k_code; - kcode[3] = kcode[2] = kcode[1] = 0xFFFF; - joyx[0]=jx; - joyy[0]=jy; + jint *k_code_body = env->GetIntArrayElements(k_code, 0); + jint *l_t_body = env->GetIntArrayElements(l_t, 0); + jint *r_t_body = env->GetIntArrayElements(r_t, 0); + jint *jx_body = env->GetIntArrayElements(jx, 0); + jint *jy_body = env->GetIntArrayElements(jy, 0); + + 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) @@ -294,4 +314,4 @@ u32 os_Push(void* frame, u32 amt, bool wait) bool os_IsAudioBuffered() { return jenv->CallIntMethod(track,writemid,jsamples,-1)==0; -} \ No newline at end of file +} diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 515db92ed..4792f2891 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -1,5 +1,9 @@ package com.reicast.emulator; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; + import tv.ouya.console.api.OuyaController; import android.annotation.TargetApi; import android.app.Activity; @@ -29,10 +33,12 @@ public class GL2JNIActivity extends Activity { PopupWindow popUp; LayoutParams params; MOGAInput moga = new MOGAInput(); - static boolean xbox = false, nVidia = false; - float globalLS_X, globalLS_Y, previousLS_X, previousLS_Y; + 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[]; + HashMap deviceId_PlayerNum = new HashMap(); + + int map[][]; View addbut(int x, OnClickListener ocl) { ImageButton but = new ImageButton(this); @@ -111,6 +117,10 @@ public class GL2JNIActivity extends Activity { @Override protected void onCreate(Bundle icicle) { + map = new int[4][]; + deviceId_PlayerNum.put(87, 0); + deviceId_PlayerNum.put(86, 1); + requestWindowFeature(Window.FEATURE_NO_TITLE); moga.onCreate(this); @@ -129,24 +139,32 @@ public class GL2JNIActivity extends Activity { // Call parent onCreate() super.onCreate(icicle); + OuyaController.init(this); int joys[] = InputDevice.getDeviceIds(); for (int i = 0; i < joys.length; i++) { Log.d("reidc", "InputDevice ID: " + joys[i]); Log.d("reidc", "InputDevice Name: " + InputDevice.getDevice(joys[i]).getName()); + + Integer playerNum = deviceId_PlayerNum.get(joys[i]); + if (playerNum != null) { + if (InputDevice.getDevice(joys[i]).getName() .equals("Sony PLAYSTATION(R)3 Controller")) { - map = new int[] { + map[playerNum] = new int[] { OuyaController.BUTTON_Y, key_CONT_B, OuyaController.BUTTON_U, key_CONT_A, OuyaController.BUTTON_O, key_CONT_X, OuyaController.BUTTON_A, key_CONT_Y, - 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_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 @@ -154,7 +172,7 @@ public class GL2JNIActivity extends Activity { }; } else if (InputDevice.getDevice(joys[i]).getName() .equals("Microsoft X-Box 360 pad")) { - map = new int[] { + map[playerNum] = new int[] { OuyaController.BUTTON_O, key_CONT_A, OuyaController.BUTTON_A, key_CONT_B, OuyaController.BUTTON_Y, key_CONT_Y, @@ -170,10 +188,10 @@ public class GL2JNIActivity extends Activity { OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_R1, key_CONT_START }; - xbox = true; + xbox[playerNum] = true; } else if (InputDevice.getDevice(joys[i]).getName() .contains("NVIDIA Corporation NVIDIA Controller")) { - map = new int[] { + map[playerNum] = new int[] { OuyaController.BUTTON_O, key_CONT_A, OuyaController.BUTTON_A, key_CONT_B, OuyaController.BUTTON_Y, key_CONT_Y, @@ -189,9 +207,9 @@ public class GL2JNIActivity extends Activity { OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_R1, key_CONT_START }; - nVidia = true; + nVidia[playerNum] = true; } else if (!moga.isActive) { // Ouya controller - map = new int[] { + map[playerNum] = new int[] { OuyaController.BUTTON_O, key_CONT_A, OuyaController.BUTTON_A, key_CONT_B, OuyaController.BUTTON_Y, key_CONT_Y, @@ -208,6 +226,7 @@ public class GL2JNIActivity extends Activity { OuyaController.BUTTON_MENU, key_CONT_START, OuyaController.BUTTON_R1, key_CONT_START }; } + } } // When viewing a resource, pass its URI to the native code for opening @@ -228,7 +247,12 @@ public class GL2JNIActivity extends Activity { // Log.w("INPUT", event.toString() + " " + event.getSource()); // Get all the axis for the KeyEvent - if (nVidia) { + Integer playerNum = deviceId_PlayerNum.get(event.getDeviceId()); + Log.w("onGenericMotionEvent playerNum", String.valueOf(playerNum)); + if (playerNum == null) + return false; + + if (nVidia[playerNum]) { JNIdc.hide_osd(); } @@ -245,23 +269,23 @@ public class GL2JNIActivity extends Activity { float L2 = event.getAxisValue(OuyaController.AXIS_L2); float R2 = event.getAxisValue(OuyaController.AXIS_R2); - if (xbox || nVidia) { - previousLS_X = globalLS_X; - previousLS_Y = globalLS_Y; - globalLS_X = LS_X; - globalLS_Y = LS_Y; + if (xbox[playerNum] || nVidia[playerNum]) { + previousLS_X[playerNum] = globalLS_X[playerNum]; + previousLS_Y[playerNum] = globalLS_Y[playerNum]; + globalLS_X[playerNum] = LS_X; + globalLS_Y[playerNum] = LS_Y; } - GL2JNIView.lt = (int) (L2 * 255); - GL2JNIView.rt = (int) (R2 * 255); + GL2JNIView.lt[playerNum] = (int) (L2 * 255); + GL2JNIView.rt[playerNum] = (int) (R2 * 255); - GL2JNIView.jx = (int) (LS_X * 126); - GL2JNIView.jy = (int) (LS_Y * 126); + GL2JNIView.jx[playerNum] = (int) (LS_X * 126); + GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); } } - if ((xbox || nVidia) && globalLS_X == previousLS_X && globalLS_Y == previousLS_Y) + if ((xbox[playerNum] || nVidia[playerNum]) && globalLS_X[playerNum] == previousLS_X[playerNum] && globalLS_Y[playerNum] == previousLS_Y[playerNum]) // 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; @@ -313,16 +337,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) { boolean rav = false; - for (int i = 0; i < map.length; i += 2) { - if (map[i + 0] == kc) { + for (int i = 0; i < map[playerNum].length; i += 2) { + if (map[playerNum][i + 0] == kc) { if (down) - GL2JNIView.kcode_raw &= ~map[i + 1]; + GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1]; else - GL2JNIView.kcode_raw |= map[i + 1]; + GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1]; rav = true; break; @@ -337,11 +364,17 @@ public class GL2JNIActivity extends Activity { } public boolean onKeyUp(int keyCode, KeyEvent event) { - return handle_key(keyCode, false) || super.onKeyUp(keyCode, event); + Integer playerNum = deviceId_PlayerNum.get(event.getDeviceId()); + Log.w("onKeyUp playerNum", String.valueOf(playerNum)); + + return handle_key(playerNum, keyCode, false) || super.onKeyUp(keyCode, event); } public boolean onKeyDown(int keyCode, KeyEvent event) { - if (handle_key(keyCode, true)) { + Integer playerNum = deviceId_PlayerNum.get(event.getDeviceId()); + Log.w("onKeyDown playerNum", String.valueOf(playerNum)); + + if (handle_key(playerNum, keyCode, true)) { JNIdc.hide_osd(); return true; } diff --git a/shell/android/src/com/reicast/emulator/GL2JNIView.java b/shell/android/src/com/reicast/emulator/GL2JNIView.java index b9a75cc63..0098e5d5f 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIView.java @@ -120,7 +120,9 @@ class GL2JNIView extends GLSurfaceView JNIdc.data(1, GL2JNIActivity.syms); 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); @@ -264,8 +266,8 @@ class GL2JNIView extends GLSurfaceView } */ - static int kcode_raw = 0xFFFF; - static int lt, rt, jx, jy; + static int[] kcode_raw = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }; + 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) { @@ -321,8 +323,8 @@ class GL2JNIView extends GLSurfaceView anal_id=event.getPointerId(i); } else if (vjoy[j][4]==-4) ; - else if(vjoy[j][4]==-1) lt=pre; - else if(vjoy[j][4]==-2) rt=pre; + else if(vjoy[j][4]==-1) lt[0]=pre; + else if(vjoy[j][4]==-2) rt[0]=pre; else rv&=~(int)vjoy[j][4]; } @@ -365,8 +367,8 @@ class GL2JNIView extends GLSurfaceView reset_analog(); anal_id=-1; rv=0xFFFF; - rt=0; - lt=0; + rt[0]=0; + lt[0]=0; for(int j=0;j entry : mMotions.entrySet()) From 53a89c7ce2e9938d82cbba858e8cc93f3795f886 Mon Sep 17 00:00:00 2001 From: LoungeKatt Date: Sun, 5 Jan 2014 18:10:27 -0500 Subject: [PATCH 21/34] Add an ignore for orig files to prevent saved merge backups --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1d1690462..e4350c09b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store *.class +*.orig bin/ gen/ From 3cb8b2cc6ebc275d87f5c7224c02db03a60310a4 Mon Sep 17 00:00:00 2001 From: Matteo Hausner Date: Sat, 4 Jan 2014 20:08:32 +0100 Subject: [PATCH 22/34] Added configuration GUI for physical controllers Reverted changes in maple_cfg.cpp except a minor memory leak Fixed an issue with the Xbox 360 controller support, that the first press of the DPAD would not get handled Lots of improvments on multi-controller support --- core/hw/maple/maple_cfg.cpp | 1 - shell/android/jni/src/Android.cpp | 27 +- .../res/layout/controllers_fragment.xml | 151 ++++++++++ shell/android/res/values/strings.xml | 15 +- .../reicast/emulator/ControllersFragment.java | 268 ++++++++++++++++++ .../com/reicast/emulator/GL2JNIActivity.java | 76 ++++- .../src/com/reicast/emulator/JNIdc.java | 2 + .../com/reicast/emulator/MainActivity.java | 18 +- 8 files changed, 534 insertions(+), 24 deletions(-) create mode 100644 shell/android/res/layout/controllers_fragment.xml create mode 100644 shell/android/src/com/reicast/emulator/ControllersFragment.java diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index 7757a5217..16e5a63fe 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -69,7 +69,6 @@ void mcfg_Create(MapleDeviceType type,u32 bus,u32 port) void mcfg_CreateDevices() { mcfg_Create(MDT_SegaController,0,5); - mcfg_Create(MDT_SegaController,1,5); #ifdef HAS_VMU mcfg_Create(MDT_SegaVMU,0,0); diff --git a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp index f322c0d47..3abaff8b8 100644 --- a/shell/android/jni/src/Android.cpp +++ b/shell/android/jni/src/Android.cpp @@ -13,6 +13,7 @@ #include "profiler/profiler.h" #include "cfg/cfg.h" #include "rend/TexCache.h" +#include "hw/maple/maple_devs.h" #include "util.h" @@ -32,6 +33,8 @@ extern "C" 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 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(); @@ -39,6 +42,7 @@ void SetApplicationPath(wchar *path); int dc_init(int argc,wchar* argv[]); void dc_run(); void dc_term(); +void mcfg_Create(MapleDeviceType type,u32 bus,u32 port); bool VramLockedWrite(u8* address); @@ -51,6 +55,9 @@ extern int screen_width,screen_height; static u64 tvs_base; static char CurFileName[256]; +// Additonal controllers 2, 3 and 4 connected ? +static bool add_controllers[3] = { false, true, false }; + u16 kcode[4]; u32 vks[4]; s8 joyx[4],joyy[4]; @@ -84,6 +91,13 @@ static void *ThreadHandler(void *UserData) 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 dc_init(Args[2]? 3:1,Args); } @@ -244,12 +258,6 @@ JNIEXPORT jint JNICALL Java_com_reicast_emulator_JNIdc_data(JNIEnv *env,jobject JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,jobject obj) { - /*char kcode_str0[100]; - char kcode_str1[100]; - sprintf(kcode_str0,"%d", kcode[0]); - sprintf(kcode_str1,"%d", kcode[1]); - __android_log_write(ANDROID_LOG_INFO, "kcode 0", kcode_str0); - __android_log_write(ANDROID_LOG_INFO, "kcode 1", kcode_str1);*/ while(!rend_single_frame()) ; } @@ -303,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) { verify(amt==SAMPLE_COUNT); diff --git a/shell/android/res/layout/controllers_fragment.xml b/shell/android/res/layout/controllers_fragment.xml new file mode 100644 index 000000000..d5a8c5c60 --- /dev/null +++ b/shell/android/res/layout/controllers_fragment.xml @@ -0,0 +1,151 @@ + + + + + + + + + +