diff --git a/cocos/platform/android/ControllerDelegate/.classpath b/cocos/platform/android/ControllerAutoAdapter/.classpath similarity index 100% rename from cocos/platform/android/ControllerDelegate/.classpath rename to cocos/platform/android/ControllerAutoAdapter/.classpath diff --git a/cocos/platform/android/ControllerDelegate/.project b/cocos/platform/android/ControllerAutoAdapter/.project similarity index 95% rename from cocos/platform/android/ControllerDelegate/.project rename to cocos/platform/android/ControllerAutoAdapter/.project index 6711d455fd..c49a037939 100644 --- a/cocos/platform/android/ControllerDelegate/.project +++ b/cocos/platform/android/ControllerAutoAdapter/.project @@ -1,6 +1,6 @@ - libcontrollerdelegate + libControllerAutoAdapter diff --git a/cocos/platform/android/ControllerDelegate/.settings/org.eclipse.jdt.core.prefs b/cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from cocos/platform/android/ControllerDelegate/.settings/org.eclipse.jdt.core.prefs rename to cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs diff --git a/cocos/platform/android/ControllerDelegate/AndroidManifest.xml b/cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml similarity index 100% rename from cocos/platform/android/ControllerDelegate/AndroidManifest.xml rename to cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml diff --git a/cocos/platform/android/ControllerDelegate/ant.properties b/cocos/platform/android/ControllerAutoAdapter/ant.properties similarity index 100% rename from cocos/platform/android/ControllerDelegate/ant.properties rename to cocos/platform/android/ControllerAutoAdapter/ant.properties diff --git a/cocos/platform/android/ControllerNibiru/build.xml b/cocos/platform/android/ControllerAutoAdapter/build.xml similarity index 98% rename from cocos/platform/android/ControllerNibiru/build.xml rename to cocos/platform/android/ControllerAutoAdapter/build.xml index 5e73af0ac0..413effd90c 100644 --- a/cocos/platform/android/ControllerNibiru/build.xml +++ b/cocos/platform/android/ControllerAutoAdapter/build.xml @@ -1,5 +1,5 @@ - + - - - - - - - - - - - - - - - - - - - diff --git a/cocos/platform/android/ControllerNibiru/.classpath b/cocos/platform/android/ControllerNibiru/.classpath deleted file mode 100644 index 51769745b2..0000000000 --- a/cocos/platform/android/ControllerNibiru/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/cocos/platform/android/ControllerNibiru/.project b/cocos/platform/android/ControllerNibiru/.project deleted file mode 100644 index c540b70b88..0000000000 --- a/cocos/platform/android/ControllerNibiru/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - libcontrollernibiru - - - - - - 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/cocos/platform/android/ControllerNibiru/.settings/org.eclipse.jdt.core.prefs b/cocos/platform/android/ControllerNibiru/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b080d2ddc8..0000000000 --- a/cocos/platform/android/ControllerNibiru/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cocos/platform/android/ControllerNibiru/AndroidManifest.xml b/cocos/platform/android/ControllerNibiru/AndroidManifest.xml deleted file mode 100644 index d1f4a837d8..0000000000 --- a/cocos/platform/android/ControllerNibiru/AndroidManifest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/cocos/platform/android/ControllerNibiru/ant.properties b/cocos/platform/android/ControllerNibiru/ant.properties deleted file mode 100644 index b0971e891e..0000000000 --- a/cocos/platform/android/ControllerNibiru/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/cocos/platform/android/ControllerNibiru/proguard-project.txt b/cocos/platform/android/ControllerNibiru/proguard-project.txt deleted file mode 100644 index f2fe1559a2..0000000000 --- a/cocos/platform/android/ControllerNibiru/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/cocos/platform/android/ControllerNibiru/res/.gitignore b/cocos/platform/android/ControllerNibiru/res/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cocos/platform/android/ControllerOuya/.classpath b/cocos/platform/android/ControllerOuya/.classpath deleted file mode 100644 index 51769745b2..0000000000 --- a/cocos/platform/android/ControllerOuya/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/cocos/platform/android/ControllerOuya/.settings/org.eclipse.jdt.core.prefs b/cocos/platform/android/ControllerOuya/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b080d2ddc8..0000000000 --- a/cocos/platform/android/ControllerOuya/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cocos/platform/android/ControllerOuya/AndroidManifest.xml b/cocos/platform/android/ControllerOuya/AndroidManifest.xml deleted file mode 100644 index d1f4a837d8..0000000000 --- a/cocos/platform/android/ControllerOuya/AndroidManifest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/cocos/platform/android/ControllerOuya/ant.properties b/cocos/platform/android/ControllerOuya/ant.properties deleted file mode 100644 index b0971e891e..0000000000 --- a/cocos/platform/android/ControllerOuya/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/cocos/platform/android/ControllerOuya/build.xml b/cocos/platform/android/ControllerOuya/build.xml deleted file mode 100644 index 7fc3634914..0000000000 --- a/cocos/platform/android/ControllerOuya/build.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cocos/platform/android/ControllerOuya/proguard-project.txt b/cocos/platform/android/ControllerOuya/proguard-project.txt deleted file mode 100644 index f2fe1559a2..0000000000 --- a/cocos/platform/android/ControllerOuya/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/cocos/platform/android/ControllerOuya/res/.gitignore b/cocos/platform/android/ControllerOuya/res/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cocos/platform/android/java/project.properties b/cocos/platform/android/java/project.properties index 732c58e368..88ca83f9d0 100644 --- a/cocos/platform/android/java/project.properties +++ b/cocos/platform/android/java/project.properties @@ -12,5 +12,4 @@ android.library=true # Project target. -target=android-16 -android.library.reference.1=../ControllerDelegate +target=android-10 diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 265387c29e..78929fb300 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -24,9 +24,6 @@ THE SOFTWARE. package org.cocos2dx.lib; import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener; -import org.cocos2dx.lib.GameControllerDelegate.ControllerEventListener; -import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat; -import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat.InputDeviceListener; import android.app.Activity; import android.content.Context; @@ -36,15 +33,12 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.os.Message; -import android.view.InputDevice; -import android.view.KeyEvent; -import android.view.MotionEvent; import android.view.ViewGroup; import android.util.Log; import android.widget.FrameLayout; import android.preference.PreferenceManager.OnActivityResultListener; -public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener, InputDeviceListener { +public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener { // =========================================================== // Constants // =========================================================== @@ -59,10 +53,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe private Cocos2dxHandler mHandler; private static Cocos2dxActivity sContext = null; private Cocos2dxVideoHelper mVideoHelper = null; - private InputManagerCompat mInputManager = null; - - protected GameControllerHelper mControllerHelper = null; - protected GameControllerDelegate mControllerDelegate = null; public static Context getContext() { return sContext; @@ -79,45 +69,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe } } - public void setGameControllerInstance(GameControllerDelegate controllerDelegate) { - if (mControllerDelegate != null) { - mControllerDelegate.onDestroy(); - mControllerDelegate = null; - } - mControllerDelegate = controllerDelegate; - mControllerDelegate.setControllerEventListener(mControllerEventListener); - mControllerDelegate.onCreate(this); - } - - public GameControllerDelegate getGameControllerInstance(){ - return mControllerDelegate; - } - - ControllerEventListener mControllerEventListener = new ControllerEventListener() { - - @Override - public void onButtonEvent(String vendorName, int controller, int button, - boolean isPressed, float value, boolean isAnalog) { - GameControllerAdapter.onButtonEvent(vendorName, controller, button, isPressed, value, isAnalog); - } - - @Override - public void onAxisEvent(String vendorName, int controller, int axisID, - float value, boolean isAnalog) { - GameControllerAdapter.onAxisEvent(vendorName, controller, axisID, value, isAnalog); - } - - @Override - public void onConnected(String vendorName, int controller) { - GameControllerAdapter.onConnected(vendorName, controller); - } - - @Override - public void onDisconnected(String vendorName, int controller) { - GameControllerAdapter.onDisconnected(vendorName, controller); - } - }; - // =========================================================== // Constructors // =========================================================== @@ -137,16 +88,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe if (mVideoHelper == null) { mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout); } - - mInputManager = InputManagerCompat.Factory.getInputManager(this); - mInputManager.registerInputDeviceListener(this, null); - - if (mControllerDelegate != null) { - mControllerDelegate.onCreate(this); - } - if (mControllerHelper == null) { - mControllerHelper = new GameControllerHelper(this); - } } // =========================================================== @@ -157,96 +98,16 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe // Methods for/from SuperClass/Interfaces // =========================================================== - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - boolean handled = false; - if (mControllerDelegate != null) { - handled = mControllerDelegate.dispatchKeyEvent(event); - } - else { - handled = mControllerHelper.dispatchKeyEvent(event); - } - return handled || super.dispatchKeyEvent(event); - } - - @Override - public boolean dispatchGenericMotionEvent(MotionEvent event) { - boolean handled = false; - if (mControllerDelegate != null) { - handled = mControllerDelegate.dispatchGenericMotionEvent(event); - }else { - handled = mControllerHelper.dispatchGenericMotionEvent(event); - } - return handled || super.dispatchGenericMotionEvent(event); - } - - @Override - public void onInputDeviceAdded(int deviceId) { - - Log.d(TAG,"onInputDeviceAdded:" + deviceId); - - InputDevice device = InputDevice.getDevice(deviceId); - int deviceSource = device.getSources(); - - if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - || ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ) - { - GameControllerAdapter.onConnected("Standard", deviceId); - } - } - /* - * This is an unusual case. Input devices don't typically change, but they - * certainly can --- for example a device may have different modes. We use - * this to make sure that the ship has an up-to-date InputDevice. - * - * @see - * com.example.inputmanagercompat.InputManagerCompat.InputDeviceListener - * #onInputDeviceChanged(int) - */ - @Override - public void onInputDeviceChanged(int deviceId) { - Log.d(TAG,"onInputDeviceChanged:" + deviceId); - } - - /* - * Remove any ship associated with the ID. - * - * @see - * com.example.inputmanagercompat.InputManagerCompat.InputDeviceListener - * #onInputDeviceRemoved(int) - */ - @Override - public void onInputDeviceRemoved(int deviceId) { - Log.d(TAG,"onInputDeviceRemoved:" + deviceId); - - InputDevice device = InputDevice.getDevice(deviceId); - int deviceSource = device.getSources(); - - if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - || ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ) - { - GameControllerAdapter.onDisconnected("Standard", deviceId); - } - } - @Override protected void onResume() { super.onResume(); Cocos2dxHelper.onResume(); this.mGLSurfaceView.onResume(); - - if (mControllerDelegate != null) { - mControllerDelegate.onResume(); - } } @Override protected void onPause() { - if (mControllerDelegate != null) { - mControllerDelegate.onPause(); - } - super.onPause(); Cocos2dxHelper.onPause(); @@ -255,11 +116,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe @Override protected void onDestroy() { - if (mControllerDelegate != null) { - mControllerDelegate.onDestroy(); - } - mControllerHelper.destrory(); - super.onDestroy(); } diff --git a/cocos/platform/android/ControllerDelegate/src/org/cocos2dx/lib/GameControllerDelegate.java b/cocos/platform/android/java/src/org/cocos2dx/lib/GameControllerDelegate.java similarity index 100% rename from cocos/platform/android/ControllerDelegate/src/org/cocos2dx/lib/GameControllerDelegate.java rename to cocos/platform/android/java/src/org/cocos2dx/lib/GameControllerDelegate.java diff --git a/tests/game-controller-test/proj.android/project.properties b/tests/game-controller-test/proj.android/project.properties index 572f7c30de..c851eff541 100644 --- a/tests/game-controller-test/proj.android/project.properties +++ b/tests/game-controller-test/proj.android/project.properties @@ -10,4 +10,4 @@ # Project target. target=android-10 -android.library.reference.1=../../../cocos/platform/android/java +android.library.reference.1=../../../cocos/platform/android/ControllerDelegate diff --git a/tests/game-controller-test/proj.android/src/org/cocos2dx/game_controller_test/AppActivity.java b/tests/game-controller-test/proj.android/src/org/cocos2dx/game_controller_test/AppActivity.java index 2675ce468b..570608bada 100644 --- a/tests/game-controller-test/proj.android/src/org/cocos2dx/game_controller_test/AppActivity.java +++ b/tests/game-controller-test/proj.android/src/org/cocos2dx/game_controller_test/AppActivity.java @@ -25,14 +25,14 @@ package org.cocos2dx.game_controller_test; import java.util.ArrayList; -import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.GameControllerActivity; import org.cocos2dx.lib.GameControllerHelper.ControllerListener; import android.bluetooth.BluetoothDevice; import android.os.Bundle; import android.util.Log; -public class AppActivity extends Cocos2dxActivity { +public class AppActivity extends GameControllerActivity { @Override protected void onCreate(Bundle savedInstanceState) {