<classpathentry combineaccessrules="false" kind="src" path="/gdx-backends-gwt"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/gdx"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/gdx-invaders"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/gdx-controllers"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/gdx-controllers-gwt"/>\r
<classpathentry kind="output" path="war/WEB-INF/classes"/>\r
</classpath>\r
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">\r
<module>\r
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />\r
+ <inherits name='com.badlogic.gdx.controllers.controllers-gwt'/>\r
<inherits name='com.badlogic.GdxInvaders' />\r
<set-configuration-property name="gdx.assetpath" value="../gdx-invaders-android/assets"/>\r
<entry-point class='com.badlogic.gdxinvaders.client.GdxInvadersGwt' />\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry excluding="com/badlogic/gdx/controllers/gwt/emu/" kind="src" path="src"/>\r
+ <classpathentry kind="src" path="src/com/badlogic/gdx/controllers/gwt/emu"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/gdx"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/gdx-controllers"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>gdx-controllers-gwt</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.7\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.7\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">\r
+<module>\r
+ <inherits name='com.badlogic.gdx.controllers'/>\r
+ <source path="gwt"/>\r
+ <super-source path="gwt/emu" />\r
+</module>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">\r
+<module>\r
+ <inherits name='com.badlogic.gdx.controllers'/>\r
+ <source path="gwt"/>\r
+ <super-source path="gwt/emu" />\r
+</module>
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright 2011 See AUTHORS file.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ ******************************************************************************/\r
+package com.badlogic.gdx.controllers;\r
+\r
+import com.badlogic.gdx.Application;\r
+import com.badlogic.gdx.Application.ApplicationType;\r
+import com.badlogic.gdx.Gdx;\r
+import com.badlogic.gdx.LifecycleListener;\r
+import com.badlogic.gdx.controllers.Controller;\r
+import com.badlogic.gdx.controllers.ControllerListener;\r
+import com.badlogic.gdx.controllers.ControllerManager;\r
+import com.badlogic.gdx.controllers.ControllerManagerStub;\r
+import com.badlogic.gdx.utils.Array;\r
+import com.badlogic.gdx.utils.ObjectMap;\r
+\r
+/** Provides access to connected {@link Controller} instances. Query\r
+ * the available controllers via {@link #getControllers()}, add and remove\r
+ * global {@link ControllerListener} instances via {@link #addListener(ControllerListener)}\r
+ * and {@link #removeListener(ControllerListener)}. The listeners will be\r
+ * invoked on the rendering thread. The global listeners will be invoked\r
+ * for all events generated by all controllers. Polling a Controller can be\r
+ * done by invoking one of its getter methods.\r
+ * \r
+ * @author Nathan Sweet */\r
+public class Controllers {\r
+ private static final String TAG = "Controllers";\r
+ static private final ObjectMap<Application, ControllerManager> managers = new ObjectMap<Application, ControllerManager>();\r
+\r
+ /**\r
+ * Returns an array of connected {@link Controller} instances. This\r
+ * method should only be called on the rendering thread.\r
+ * \r
+ * @return the connected controllers\r
+ */\r
+ static public Array<Controller> getControllers () {\r
+ initialize();\r
+ return getManager().getControllers();\r
+ }\r
+\r
+ /**\r
+ * Add a global {@link ControllerListener} that can react to\r
+ * events from all {@link Controller} instances. The listener\r
+ * will be invoked on the rendering thread.\r
+ * @param listener\r
+ */\r
+ static public void addListener (ControllerListener listener) {\r
+ initialize();\r
+ getManager().addListener(listener);\r
+ }\r
+\r
+ /**\r
+ * Removes a global {@link ControllerListener}. The method\r
+ * must be called on the rendering thread.\r
+ * @param listener\r
+ */\r
+ static public void removeListener (ControllerListener listener) {\r
+ initialize();\r
+ getManager().removeListener(listener);\r
+ }\r
+ \r
+ static private ControllerManager getManager() {\r
+ return managers.get(Gdx.app);\r
+ }\r
+\r
+ static private void initialize () {\r
+ if(managers.containsKey(Gdx.app)) return;\r
+ \r
+ \r
+ Gdx.app.log(TAG, "No controller manager is available for: " + Gdx.app.getType());\r
+ ControllerManager manager = new ControllerManagerStub();\r
+ \r
+ managers.put(Gdx.app, manager);\r
+ final Application app = Gdx.app;\r
+ Gdx.app.addLifecycleListener(new LifecycleListener() {\r
+ \r
+ @Override\r
+ public void resume () {\r
+ }\r
+ \r
+ @Override\r
+ public void pause () {\r
+ }\r
+ \r
+ @Override\r
+ public void dispose () {\r
+ managers.remove(app);\r
+ Gdx.app.log(TAG, "removed manager for application, " + managers.size + " managers active");\r
+\r
+ }\r
+ });\r
+ Gdx.app.log(TAG, "added manager for application, " + managers.size + " managers active");\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+package com.badlogic.gdx.controllers.mappings;\r
+\r
+import java.lang.reflect.Field;\r
+\r
+import com.badlogic.gdx.controllers.Controller;\r
+\r
+/**\r
+ * Button and axis indices for the OUYA {@link Controller}.\r
+ * @author mzechner\r
+ *\r
+ */\r
+public class Ouya {\r
+ public static final String ID = "OUYA Game Controller";\r
+ public static final int BUTTON_O;\r
+ public static final int BUTTON_U;\r
+ public static final int BUTTON_Y;\r
+ public static final int BUTTON_A;\r
+ public static final int BUTTON_DPAD_UP;\r
+ public static final int BUTTON_DPAD_DOWN;\r
+ public static final int BUTTON_DPAD_RIGHT;\r
+ public static final int BUTTON_DPAD_LEFT;\r
+ public static final int BUTTON_L1;\r
+ public static final int BUTTON_L2;\r
+ public static final int BUTTON_L3;\r
+ public static final int BUTTON_R1;\r
+ public static final int BUTTON_R2;\r
+ public static final int BUTTON_R3;\r
+ public static final int AXIS_LEFT_X;\r
+ public static final int AXIS_LEFT_Y;\r
+ public static final int AXIS_LEFT_TRIGGER;\r
+ public static final int AXIS_RIGHT_X;\r
+ public static final int AXIS_RIGHT_Y;\r
+ public static final int AXIS_RIGHT_TRIGGER;\r
+ /** whether the app is running on a real Ouya device **/\r
+ public static final boolean runningOnOuya;\r
+ \r
+ static {\r
+ runningOnOuya = false;\r
+ \r
+ BUTTON_O = 96;\r
+ BUTTON_U = 97;\r
+ BUTTON_Y = 98;\r
+ BUTTON_A = 99;\r
+ BUTTON_DPAD_UP = 104;\r
+ BUTTON_DPAD_DOWN = 105;\r
+ BUTTON_DPAD_RIGHT = 108;\r
+ BUTTON_DPAD_LEFT = 109;\r
+ BUTTON_L1 = 110;\r
+ BUTTON_L2 = 100;\r
+ BUTTON_L3 = 102;\r
+ BUTTON_R1 = 106;\r
+ BUTTON_R2 = 101;\r
+ BUTTON_R3 = 103;\r
+ AXIS_LEFT_X = 0;\r
+ AXIS_LEFT_Y = 1;\r
+ AXIS_LEFT_TRIGGER = 2;\r
+ AXIS_RIGHT_X = 3;\r
+ AXIS_RIGHT_Y = 4;\r
+ AXIS_RIGHT_TRIGGER = 5;\r
+ }\r
+}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>\r
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">\r
<module>\r
- <source path="controllers"/>\r
+ <source path="controllers">\r
+ <exclude name="Controllers.java"/>\r
+ </source>\r
</module>
\ No newline at end of file
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**/.svn/*" kind="src" path="src"/>
- <classpathentry excluding="**/.svn/*" kind="src" path="gen"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-backend-android"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-tests"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-audio"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-freetype"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-image"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-bullet"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers-android"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry excluding="**/.svn/*" kind="src" path="src"/>\r
+ <classpathentry excluding="**/.svn/*" kind="src" path="gen"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-backend-android"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-tests"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-audio"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-freetype"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-image"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-bullet"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers-android"/>\r
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>\r
+ <classpathentry kind="output" path="bin/classes"/>\r
+</classpath>\r