diff --git a/newdc/sdl/main.cpp b/core/sdl/main.cpp old mode 100755 new mode 100644 similarity index 100% rename from newdc/sdl/main.cpp rename to core/sdl/main.cpp diff --git a/shell/android/libs/com.bda.controller.jar b/shell/android/libs/com.bda.controller.jar new file mode 100644 index 000000000..7a708c092 Binary files /dev/null and b/shell/android/libs/com.bda.controller.jar differ diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index b060f8cae..447c934ea 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -37,6 +37,8 @@ public class GL2JNIActivity extends Activity { GL2JNIView mView; PopupWindow popUp; LayoutParams params; + MOGAInput moga = new MOGAInput(); + int map[]; View addbut(int x, OnClickListener ocl) { @@ -116,6 +118,7 @@ public class GL2JNIActivity extends Activity { @Override protected void onCreate(Bundle icicle) { + moga.onCreate(this); requestWindowFeature(Window.FEATURE_NO_TITLE); createPopup(); @@ -237,8 +240,6 @@ public class GL2JNIActivity extends Activity { return true; } - int rv = 0xFFFF; - private static final int key_CONT_B = 0x0002; private static final int key_CONT_A = 0x0004; private static final int key_CONT_START = 0x0008; @@ -251,7 +252,7 @@ public class GL2JNIActivity extends Activity { // TODO: Controller mapping in options. Trunk has Ouya layout. This is a DS3 // layout. - ;/* + /* * map[]= 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, @@ -288,17 +289,15 @@ public class GL2JNIActivity extends Activity { for (int i = 0; i < map.length; i += 2) { if (map[i + 0] == kc) { if (down) - this.rv &= ~map[i + 1]; + GL2JNIView.kcode_raw &= ~map[i + 1]; else - this.rv |= map[i + 1]; + GL2JNIView.kcode_raw |= map[i + 1]; rav = true; break; } } - GL2JNIView.kcode_raw = rv; - return rav; } @@ -332,6 +331,13 @@ public class GL2JNIActivity extends Activity { protected void onPause() { super.onPause(); mView.onPause(); + moga.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + moga.onDestroy(); } @Override @@ -357,5 +363,6 @@ public class GL2JNIActivity extends Activity { protected void onResume() { super.onResume(); mView.onResume(); + moga.onResume(); } } diff --git a/shell/android/src/com/reicast/emulator/MOGAInput.java b/shell/android/src/com/reicast/emulator/MOGAInput.java new file mode 100644 index 000000000..f69ee9b2b --- /dev/null +++ b/shell/android/src/com/reicast/emulator/MOGAInput.java @@ -0,0 +1,211 @@ +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; +import com.bda.controller.MotionEvent; +import com.bda.controller.StateEvent; + +/******************************************************************************/ + +/* + +*/ +public class MOGAInput +{ + static final int DELAY = 1000 / 50; // 50 Hz + + static final int ACTION_CONNECTED = Controller.ACTION_CONNECTED; + static final int ACTION_DISCONNECTED = Controller.ACTION_DISCONNECTED; + static final int ACTION_VERSION_MOGA = Controller.ACTION_VERSION_MOGA; + static final int ACTION_VERSION_MOGAPRO = Controller.ACTION_VERSION_MOGAPRO; + + Controller mController = null; + + + private static final int key_CONT_B = 0x0002; + private static final int key_CONT_A = 0x0004; + private static final int key_CONT_START = 0x0008; + private static final int key_CONT_DPAD_UP = 0x0010; + private static final int key_CONT_DPAD_DOWN = 0x0020; + private static final int key_CONT_DPAD_LEFT = 0x0040; + private static final int key_CONT_DPAD_RIGHT = 0x0080; + private static final int key_CONT_Y = 0x0200; + private static final int key_CONT_X = 0x0400; + + int[] map = new int[] { + KeyEvent.KEYCODE_BUTTON_B, key_CONT_B, + KeyEvent.KEYCODE_BUTTON_A, key_CONT_A, + KeyEvent.KEYCODE_BUTTON_X, key_CONT_X, + KeyEvent.KEYCODE_BUTTON_Y, key_CONT_Y, + + KeyEvent.KEYCODE_DPAD_UP, key_CONT_DPAD_UP, + KeyEvent.KEYCODE_DPAD_DOWN, key_CONT_DPAD_DOWN, + KeyEvent.KEYCODE_DPAD_LEFT, key_CONT_DPAD_LEFT, + KeyEvent.KEYCODE_DPAD_RIGHT, key_CONT_DPAD_RIGHT, + + KeyEvent.KEYCODE_BUTTON_START, key_CONT_START, + }; + + public MOGAInput() + { + /* + mStates.put(StateEvent.STATE_CONNECTION, new ExampleInteger("STATE_CONNECTION......")); + mStates.put(StateEvent.STATE_POWER_LOW, new ExampleInteger("STATE_POWER_LOW......")); + mStates.put(StateEvent.STATE_CURRENT_PRODUCT_VERSION, new ExampleInteger("STATE_CURRENT_PRODUCT_VERSION")); + mStates.put(StateEvent.STATE_SUPPORTED_PRODUCT_VERSION, new ExampleInteger("STATE_SUPPORTED_PRODUCT_VERSION")); + + mKeys.put(KeyEvent.KEYCODE_DPAD_UP, new ExampleInteger("KEYCODE_DPAD_UP......")); + mKeys.put(KeyEvent.KEYCODE_DPAD_DOWN, new ExampleInteger("KEYCODE_DPAD_DOWN......")); + mKeys.put(KeyEvent.KEYCODE_DPAD_LEFT, new ExampleInteger("KEYCODE_DPAD_LEFT......")); + mKeys.put(KeyEvent.KEYCODE_DPAD_RIGHT, new ExampleInteger("KEYCODE_DPAD_RIGHT......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_A, new ExampleInteger("KEYCODE_BUTTON_A......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_B, new ExampleInteger("KEYCODE_BUTTON_B......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_X, new ExampleInteger("KEYCODE_BUTTON_X......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_Y, new ExampleInteger("KEYCODE_BUTTON_Y......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_L1, new ExampleInteger("KEYCODE_BUTTON_L1......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_R1, new ExampleInteger("KEYCODE_BUTTON_R1......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_L2, new ExampleInteger("KEYCODE_BUTTON_L2......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_R2, new ExampleInteger("KEYCODE_BUTTON_R2......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_THUMBL, new ExampleInteger("KEYCODE_BUTTON_THUMBL......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_THUMBR, new ExampleInteger("KEYCODE_BUTTON_THUMBR......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_START, new ExampleInteger("KEYCODE_BUTTON_START......")); + mKeys.put(KeyEvent.KEYCODE_BUTTON_SELECT, new ExampleInteger("KEYCODE_BUTTON_SELECT......")); + + mMotions.put(MotionEvent.AXIS_X, new ExampleFloat("AXIS_X.........")); + mMotions.put(MotionEvent.AXIS_Y, new ExampleFloat("AXIS_Y.........")); + mMotions.put(MotionEvent.AXIS_Z, new ExampleFloat("AXIS_Z.........")); + mMotions.put(MotionEvent.AXIS_RZ, new ExampleFloat("AXIS_RZ.......")); + mMotions.put(MotionEvent.AXIS_LTRIGGER, new ExampleFloat("AXIS_LTRIGGER.........")); + mMotions.put(MotionEvent.AXIS_RTRIGGER, new ExampleFloat("AXIS_RTRIGGER.........")); + */ + } + + protected void onCreate(Activity 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(); + + /* + for(final Entry entry : mStates.entrySet()) + { + final int key = entry.getKey(); + final ExampleInteger value = entry.getValue(); + value.mValue = mController.getState(key); + } + + for(final Entry entry : mKeys.entrySet()) + { + final int key = entry.getKey(); + final ExampleInteger value = entry.getValue(); + value.mValue = mController.getKeyCode(key); + } + + for(final Entry entry : mMotions.entrySet()) + { + final int key = entry.getKey(); + final ExampleFloat value = entry.getValue(); + value.mValue = mController.getAxisValue(key); + } + */ + } + + class ExampleControllerListener implements ControllerListener + { + public void onKeyEvent(KeyEvent event) + { + Log.w("KEYINPUT", event.toString()); + for (int i = 0; i < map.length; i += 2) { + if (map[i + 0] == event.getKeyCode()) { + if (event.getAction() == 0) //FIXME to const + GL2JNIView.kcode_raw &= ~map[i + 1]; + else + GL2JNIView.kcode_raw |= map[i + 1]; + + 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()); + + float LS_X = event.getAxisValue(MotionEvent.AXIS_X); + float LS_Y = event.getAxisValue(MotionEvent.AXIS_Y); + float L2 = event.getAxisValue(MotionEvent.AXIS_LTRIGGER); + float R2 = event.getAxisValue(MotionEvent.AXIS_RTRIGGER); + + GL2JNIView.lt = (int) (L2 * 255); + GL2JNIView.rt = (int) (R2 * 255); + + GL2JNIView.jx = (int) (LS_X * 126); + GL2JNIView.jy = (int) (LS_Y * 126); + + /* + for(final Entry entry : mMotions.entrySet()) + { + final int key = entry.getKey(); + final ExampleFloat value = entry.getValue(); + value.mValue = event.getAxisValue(key); + }*/ + } + + public void onStateEvent(StateEvent event) + { + Log.w("SINPUT", event.toString()); + /* + final ExampleInteger value = mStates.get(event.getState()); + if(value != null) + { + value.mValue = event.getAction(); + }*/ + } + } +} diff --git a/shell/android2/libnewdc/.classpath b/shell/android2/libnewdc/.classpath deleted file mode 100644 index 7bc01d9a9..000000000 --- a/shell/android2/libnewdc/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/shell/android2/libnewdc/.project b/shell/android2/libnewdc/.project deleted file mode 100644 index 8d7847b8f..000000000 --- a/shell/android2/libnewdc/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - libnewdc - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/shell/android2/libnewdc/AndroidManifest.xml b/shell/android2/libnewdc/AndroidManifest.xml deleted file mode 100644 index 5ef3c1cfd..000000000 --- a/shell/android2/libnewdc/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/shell/android2/libnewdc/build.xml b/shell/android2/libnewdc/build.xml deleted file mode 100644 index 72c521ea6..000000000 --- a/shell/android2/libnewdc/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shell/android2/libnewdc/proguard-project.txt b/shell/android2/libnewdc/proguard-project.txt deleted file mode 100644 index f2fe1559a..000000000 --- a/shell/android2/libnewdc/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/shell/android2/libnewdc/project.properties b/shell/android2/libnewdc/project.properties deleted file mode 100644 index 9d8f08b7f..000000000 --- a/shell/android2/libnewdc/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -android.library=true -# Project target. -target=android-15