From 16851eb1d8613d096445cb40c9cb190af4f44f34 Mon Sep 17 00:00:00 2001 From: "pot..om" Date: Sun, 12 Aug 2012 01:35:56 +0000 Subject: [PATCH] Removing Android Sensor Support (undo r9610). Preparing for new way of implementing sensor support on Android. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9646 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../android/com/jme3/app/AndroidHarness.java | 22 - .../input/android/AndroidSensorInput.java | 584 ------------------ .../com/jme3/system/android/OGLESContext.java | 14 - engine/src/core/com/jme3/app/Application.java | 10 +- .../src/core/com/jme3/input/InputManager.java | 63 +- .../core/com/jme3/input/RawInputListener.java | 6 - .../src/core/com/jme3/input/SensorInput.java | 146 ----- .../input/controls/MotionSensorListener.java | 58 -- .../jme3/input/controls/SensorTrigger.java | 83 --- .../jme3/input/event/MotionSensorEvent.java | 118 ---- .../src/core/com/jme3/system/JmeContext.java | 6 - .../src/core/com/jme3/system/NullContext.java | 5 - .../com/jme3/system/awt/AwtPanelsContext.java | 5 - .../system/lwjgl/LwjglAbstractDisplay.java | 5 - .../system/lwjgl/LwjglOffscreenBuffer.java | 5 - .../com/jme3/niftygui/InputSystemJme.java | 21 +- .../src/test/jme3test/gui/TestBitmapFont.java | 2 - .../test/jme3test/gui/TestSoftwareMouse.java | 2 - 18 files changed, 13 insertions(+), 1142 deletions(-) delete mode 100644 engine/src/android/com/jme3/input/android/AndroidSensorInput.java delete mode 100644 engine/src/core/com/jme3/input/SensorInput.java delete mode 100644 engine/src/core/com/jme3/input/controls/MotionSensorListener.java delete mode 100644 engine/src/core/com/jme3/input/controls/SensorTrigger.java delete mode 100644 engine/src/core/com/jme3/input/event/MotionSensorEvent.java diff --git a/engine/src/android/com/jme3/app/AndroidHarness.java b/engine/src/android/com/jme3/app/AndroidHarness.java index 08c0fe176..66ceee379 100644 --- a/engine/src/android/com/jme3/app/AndroidHarness.java +++ b/engine/src/android/com/jme3/app/AndroidHarness.java @@ -15,9 +15,7 @@ import android.widget.ImageView; import android.widget.TextView; import com.jme3.audio.AudioRenderer; import com.jme3.audio.android.AndroidAudioRenderer; -import com.jme3.input.SensorInput; import com.jme3.input.TouchInput; -import com.jme3.input.android.AndroidSensorInput; import com.jme3.input.controls.TouchListener; import com.jme3.input.controls.TouchTrigger; import com.jme3.input.event.TouchEvent; @@ -259,16 +257,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt renderer.resumeAll(); } } - //resume the sensors - if (app.getInputManager() != null) { - SensorInput sensorInput = app.getInputManager().getSensorInput(); - if (sensorInput != null) { - logger.log(Level.INFO, "resume: {0}", sensorInput.getClass().getSimpleName()); - if (sensorInput instanceof AndroidSensorInput) { - ((AndroidSensorInput)sensorInput).resumeSensors(); - } - } - } } isGLThreadPaused = false; @@ -292,16 +280,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt renderer.pauseAll(); } } - //pause the sensors - if (app.getInputManager() != null) { - SensorInput sensorInput = app.getInputManager().getSensorInput(); - if (sensorInput != null) { - logger.log(Level.INFO, "pause: {0}", sensorInput.getClass().getSimpleName()); - if (sensorInput instanceof AndroidSensorInput) { - ((AndroidSensorInput)sensorInput).resumeSensors(); - } - } - } } isGLThreadPaused = true; logger.info("onPause"); diff --git a/engine/src/android/com/jme3/input/android/AndroidSensorInput.java b/engine/src/android/com/jme3/input/android/AndroidSensorInput.java deleted file mode 100644 index fe389f459..000000000 --- a/engine/src/android/com/jme3/input/android/AndroidSensorInput.java +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Copyright (c) 2009-2010 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.jme3.input.android; - -import android.content.Context; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.view.Display; -import android.view.Surface; -import android.view.WindowManager; -import com.jme3.input.RawInputListener; -import com.jme3.input.SensorInput; -import com.jme3.input.event.MotionSensorEvent; -import com.jme3.math.Vector3f; -import com.jme3.system.android.JmeAndroidSystem; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Android specific implementation of SensorInput. - * - * @author iwgeric - */ -public class AndroidSensorInput implements SensorInput, SensorEventListener { - private final static Logger logger = Logger.getLogger(AndroidSensorInput.class.getName()); - - private SensorManager sensorManager = null; - private RawInputListener listener = null; - private Map sensors = new HashMap(); - private boolean initialized = false; - private WindowManager window; - private Display disp; - - private final float[] curAccValues = new float[3]; - private final float[] curMagValues = new float[3]; - private final float[] curInclination = new float[9]; - private final float[] curRotation = new float[9]; - private final float[] rotatedRotation = new float[9]; - - private final ArrayList eventQueue = new ArrayList(); - - /** - * Internal class to enclose data for each sensor. - */ - private class SensorData { - int androidSensorType = -1; - int androidSensorSpeed = SensorManager.SENSOR_DELAY_UI; - Sensor sensor = null; - Vector3f lastValues = new Vector3f(); - float minChangePercent = 0f; - boolean enabled = false; - boolean paused = false; - - public SensorData(int androidSensorType, Sensor sensor) { - this.androidSensorType = androidSensorType; - this.sensor = sensor; - } - } - - /** - * Pauses the active sensors to save battery. Mostly used internally so that - * the sensors can be deactivated while the game Activity is - * in the background to save battery life - */ - public void pauseSensors() { - for (Entry entry : sensors.entrySet()) { - SensorData sensorData = entry.getValue(); - if (sensorData.sensor != null) { - unRegisterListener(entry.getKey()); - sensorData.paused = true; - } - } - } - - /** - * Resumes paused sensors. Mostly used internally so that - * the sensors can be reactivated when the game Activity is - * placed back onto the forefront. - */ - public void resumeSensors() { - for (Entry entry : sensors.entrySet()) { - SensorData sensorData = entry.getValue(); - if (sensorData.sensor != null && sensorData.paused) { - if (registerListener(entry.getKey())) { - sensorData.paused = false; - } - } - } - } - - /** - * Used internally by the context to reset the Sensor Manager on device rotations. - * Necessary because a new Activity is created on a device rotation, so the - * Sensor Manager needs to be reset with the new Activity. - */ - public void resetSensorManager() { - initSensorManager(); - } - - private void initSensorManager() { - window = JmeAndroidSystem.getActivity().getWindowManager(); - disp = window.getDefaultDisplay(); - - sensorManager = (SensorManager) JmeAndroidSystem.getActivity().getSystemService(Context.SENSOR_SERVICE); - - initSensor(SensorInput.SENSOR_TYPE_MAGNETIC_FIELD); - initSensor(SensorInput.SENSOR_TYPE_ACCELEROMETER); - initSensor(SensorInput.SENSOR_TYPE_ORIENTATION); - - } - - private boolean initSensor(int sensorType) { - boolean result = false; - boolean previouslyActive = false; - - SensorData sensorData = sensors.get((Integer)sensorType); - if (sensorData != null) { - if (sensorData.enabled) { - previouslyActive = true; - } - unRegisterListener(sensorType); - } else { - sensorData = new SensorData(sensorType, null); - sensors.put(sensorType, sensorData); - } - - switch (sensorType) { - case SensorInput.SENSOR_TYPE_MAGNETIC_FIELD: - sensorData.androidSensorType = Sensor.TYPE_MAGNETIC_FIELD; - sensorData.sensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); - break; - case SensorInput.SENSOR_TYPE_ACCELEROMETER: - sensorData.androidSensorType = Sensor.TYPE_ACCELEROMETER; - sensorData.sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - break; - case SensorInput.SENSOR_TYPE_ORIENTATION: - sensorData.androidSensorType = Sensor.TYPE_ORIENTATION; - //Orientation is not a sensor anymore but rather a call to SensorMangaer - // to get the current orientation based on the Magnetic and Accelerometer sensor data - sensorData.sensor = null; - break; - - default: - throw new IllegalArgumentException("Invalid Sensor Type."); - } - - if (sensorData.sensor != null || sensorType == SensorInput.SENSOR_TYPE_ORIENTATION) { - logger.log(Level.INFO, "Sensor Type {0} found.", sensorType); - if (previouslyActive) { - logger.log(Level.INFO, "Reactivating Sensor Type {0}.", sensorType); - registerListener(sensorType); - } - result = true; - } - - - return result; - } - - private boolean registerListener(int sensorType) { - SensorData sensorData = sensors.get((Integer)sensorType); - if (sensorData != null) { - if (sensorData.enabled) { - logger.log(Level.INFO, "Sensor Already Active: SensorType: {0}, active: {1}", - new Object[]{sensorType, sensorData.enabled}); - return true; - } - if (sensorData.sensor != null) { - if (sensorManager.registerListener(this, sensorData.sensor, sensorData.androidSensorSpeed)) { - sensorData.enabled = true; - logger.log(Level.INFO, "SensorType: {0}, active: {1}", - new Object[]{sensorType, sensorData.enabled}); - logger.log(Level.INFO, "Sensor Type {0} activated.", sensorType); - return true; - } else { - sensorData.enabled = false; - logger.log(Level.INFO, "Sensor Type {0} activation failed.", sensorType); - } - } else if (sensorType == SensorInput.SENSOR_TYPE_ORIENTATION) { - logger.log(Level.INFO, "Sensor is Orientation"); - if (registerListener(SensorInput.SENSOR_TYPE_MAGNETIC_FIELD) && registerListener(SensorInput.SENSOR_TYPE_ACCELEROMETER)) { - sensorData.enabled = true; - logger.log(Level.INFO, "Magnetic and Acceleration Sensors Registered and Orientation Sensor being simulated."); - return true; - } - } - sensorData.lastValues = null; - } - return false; - } - - private void unRegisterListener(int sensorType) { - SensorData sensorData = sensors.get((Integer)sensorType); - if (sensorData != null) { - if (sensorData.sensor != null) { - sensorManager.unregisterListener(this, sensorData.sensor); - } else if (sensorType == SensorInput.SENSOR_TYPE_ORIENTATION) { - logger.log(Level.INFO, "Mangetic and Acceleration Sensors are being deactivated with Orientation Sensor."); - unRegisterListener(SensorInput.SENSOR_TYPE_MAGNETIC_FIELD); - unRegisterListener(SensorInput.SENSOR_TYPE_ACCELEROMETER); - } - sensorData.enabled = false; - logger.log(Level.INFO, "SensorType: {0}, active: {1}", - new Object[]{sensorType, sensorData.enabled}); - logger.log(Level.INFO, "Sensor Type {0} deactivated.", sensorType); - } - } - - /* - * Android remapCoordinateSystem from the Android docs - * remapCoordinateSystem(float[] inR, int X, int Y, float[] outR) - * - * @param inR the rotation matrix to be transformed. Usually it is the matrix - * returned by getRotationMatrix(float[], float[], float[], float[]). - * - * @param outR the transformed rotation matrix. inR and outR can be the same - * array, but it is not recommended for performance reason. - * - * X defines on which world axis and direction the X axis of the device is mapped. - * Y defines on which world axis and direction the Y axis of the device is mapped. - * - * @return True if successful - */ - - private boolean remapCoordinates(float[] inR, float[] outR) { - int xDir = SensorManager.AXIS_X; - int yDir = SensorManager.AXIS_Y; - -// logger.log(Level.INFO, "Screen Rotation: {0}", getScreenRotation()); - if (getScreenRotation() == Surface.ROTATION_0) { - xDir = SensorManager.AXIS_X; - yDir = SensorManager.AXIS_Y; - } - if (getScreenRotation() == Surface.ROTATION_90) { - xDir = SensorManager.AXIS_MINUS_Y; - yDir = SensorManager.AXIS_MINUS_X; - } - if (getScreenRotation() == Surface.ROTATION_180) { - xDir = SensorManager.AXIS_MINUS_X; - yDir = SensorManager.AXIS_MINUS_Y; - } - if (getScreenRotation() == Surface.ROTATION_270) { - xDir = SensorManager.AXIS_Y; - yDir = SensorManager.AXIS_MINUS_X; - } - return SensorManager.remapCoordinateSystem(inR, xDir, yDir, outR); - } - - /** - * Returns the current device rotation. - * Surface.ROTATION_0 = device in natural default rotation - * Surface.ROTATION_90 = device in rotated 90deg counterclockwise - * Surface.ROTATION_180 = device in rotated 180deg counterclockwise - * Surface.ROTATION_270 = device in rotated 270deg counterclockwise - * - * When the Manifest locks the orientation, this value will not change during - * gametime, but if the orientation of the screen is based off the sensor, - * this value will change as the device is rotated. - * @return Current device rotation amount - */ - private int getScreenRotation() { - - return disp.getRotation(); - } - - private Integer getAndroidSensorSpeed(int sensorInputSpeed) { - Integer androidSpeed = null; - switch (sensorInputSpeed) { - case SensorInput.SENSOR_SPEED_SLOW: - androidSpeed = SensorManager.SENSOR_DELAY_UI; - break; - case SensorInput.SENSOR_SPEED_MEDIUM: - androidSpeed = SensorManager.SENSOR_DELAY_NORMAL; - break; - case SensorInput.SENSOR_SPEED_FAST: - androidSpeed = SensorManager.SENSOR_DELAY_GAME; - break; - default: - throw new IllegalArgumentException("Invalid Sensor Speed."); - } - return androidSpeed; - } - - /** - * Calculates the device orientation based off the data recieved from the - * Acceleration Sensor and Mangetic Field sensor - * Values are returned relative to the Earth. - * - * From the Android Doc - * - * Computes the device's orientation based on the rotation matrix. When it returns, the array values is filled with the result: - * values[0]: azimuth, rotation around the Z axis. - * values[1]: pitch, rotation around the X axis. - * values[2]: roll, rotation around the Y axis. - * - * The reference coordinate-system used is different from the world - * coordinate-system defined for the rotation matrix: - * X is defined as the vector product Y.Z (It is tangential to the ground at the device's current location and roughly points West). - * Y is tangential to the ground at the device's current location and points towards the magnetic North Pole. - * Z points towards the center of the Earth and is perpendicular to the ground. - * - * @return - */ - private boolean updateOrientation() { - SensorData sensorData; - sensorData = sensors.get((Integer)SensorInput.SENSOR_TYPE_MAGNETIC_FIELD); - if (sensorData == null || !sensorData.enabled) { - return false; - } - sensorData = sensors.get((Integer)SensorInput.SENSOR_TYPE_ACCELEROMETER); - if (sensorData == null || !sensorData.enabled) { - return false; - } - - sensorData = sensors.get((Integer)SensorInput.SENSOR_TYPE_ORIENTATION); - if (sensorData != null && sensorData.enabled) { - - // create new copies so they don't get updated during the getRotationMatrix call - final float[] accValues = new float[3]; - final float[] magValues = new float[3]; - synchronized(curAccValues) { - accValues[0] = curAccValues[0]; - accValues[1] = curAccValues[1]; - accValues[2] = curAccValues[2]; - } - synchronized(curMagValues) { - magValues[0] = curMagValues[0]; - magValues[1] = curMagValues[1]; - magValues[2] = curMagValues[2]; - } - - if (SensorManager.getRotationMatrix(curRotation, curInclination, accValues, magValues)) { - final float [] orientValues = new float[3]; - if (remapCoordinates(curRotation, rotatedRotation)) { - SensorManager.getOrientation(rotatedRotation, orientValues); -// logger.log(Level.INFO, "Orientation Values: {0}, {1}, {2}", -// new Object[]{orientValues[0], orientValues[1], orientValues[2]}); - - updateEventQueue(SensorInput.SENSOR_TYPE_ORIENTATION, - orientValues[0], orientValues[1], orientValues[2], System.nanoTime()); - - return true; - } else { - //logger.log(Level.INFO, "remapCoordinateSystem failed"); - } - - } else { - //logger.log(Level.INFO, "getRotationMatrix returned false"); - } - - } else { - if (!sensorData.enabled) { - //logger.log(Level.INFO, "Orientation is not active"); - } - } - return false; - } - - private void updateEventQueue(int sensorType, float x, float y, float z, long timestamp) { -// logger.log(Level.INFO, "updateEventQueue for {0}: values: {1}, {2}, {3}", -// new Object[]{sensorType, x, y, z}); - float lastX, lastY, lastZ; - float dX, dY, dZ; - - SensorData sensorData = sensors.get((Integer)sensorType); - - if (sensorData != null) { - // if lastValues is null, then this is the first scan after a registerListener - // so set lastValues to the current values so dX,dY,dZ are zero this pass - if (sensorData.lastValues == null) { - sensorData.lastValues = new Vector3f(x, y, z); - } - - lastX = sensorData.lastValues.x; - lastY = sensorData.lastValues.y; - lastZ = sensorData.lastValues.z; - - dX = x - lastX; - dY = y - lastY; - dZ = z - lastZ; - - if (dX != 0 && dY != 0 && dZ != 0) { - MotionSensorEvent motionEvent = new MotionSensorEvent(sensorType, x, y, z, dX, dY, dZ); - motionEvent.setTime(timestamp); - sensorData.lastValues.x = x; - sensorData.lastValues.y = y; - sensorData.lastValues.z = z; - - synchronized (eventQueue){ - eventQueue.add(motionEvent); - } - } else { - //logger.log(Level.INFO, "No change in Sensor Data for: {0}", sensorType); - } - } else { - //logger.log(Level.INFO, "Sensor Data is null for: {0}", sensorType); - } - } - - - - - - - - - - - - - - -// Start of methods from SensorInput - - public boolean isEnabled(int sensorType) { - logger.log(Level.INFO, "Checking isEnabled for type: {0}", sensorType); - SensorData sensorData = sensors.get((Integer)sensorType); - if (sensorData == null) { -// logger.log(Level.INFO, "sensor data is null, sensors size is: {0}", sensors.size()); - return false; - } - return sensors.get((Integer)sensorType).enabled; - } - - public void setEnable(boolean enable) { - for (Integer sensorType: sensors.keySet()) { - setEnable(sensorType, enable); - } - } - - public void setEnable(int sensorType, boolean enable) { - logger.log(Level.INFO, "Setting Sensor {0} Enable to {1}", - new Object[]{sensorType, enable}); - if (enable) { -// registerListener(sensorType, true); - registerListener(sensorType); - } else { - unRegisterListener(sensorType); - } - } - - public void setSensorFrequency(int sensorType, int updateSpeed) { - SensorData sensorData = sensors.get((Integer)sensorType); - if (sensorData == null || sensorData.enabled) { - throw new IllegalArgumentException("Sensor Type Not Configured or is already active."); - } - - sensorData.androidSensorSpeed = getAndroidSensorSpeed(updateSpeed); - } - - public Set getSensorTypes() { - return Collections.unmodifiableSet(sensors.keySet()); - } - - public void setSensorMinChange(int sensorType, float minChangePercent) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public void initialize() { - logger.log(Level.INFO, "Doing Initialize."); - initSensorManager(); - initialized = true; - } - - public void update() { - updateOrientation(); - synchronized (eventQueue){ - // flush events to listener - for (int i = 0; i < eventQueue.size(); i++){ - listener.onMotionSensorEvent(eventQueue.get(i)); - } - eventQueue.clear(); - } - } - - public void destroy() { - for (Integer i: sensors.keySet()) { - unRegisterListener(i); - } - logger.log(Level.INFO, "Doing Destroy"); - if (sensorManager != null) { - sensorManager.unregisterListener(this); - } - sensors.clear(); - eventQueue.clear(); - } - - public boolean isInitialized() { - return initialized; - } - - public void setInputListener(RawInputListener listener) { - this.listener = listener; - } - - public long getInputTimeNanos() { - return System.nanoTime(); - } - -// End of methods from SensorInput - -// Start of methods from SensorEventListener - - public void onSensorChanged(SensorEvent se) { -// logger.log(Level.INFO, "onSensorChanged for {0}: values: {1}, {2}, {3}", -// new Object[]{se.sensor.getType(), se.values[0], se.values[1], se.values[2]}); - SensorData sensorData; - int sensorType; - for (Entry entry : sensors.entrySet()) { -// if (entry.getValue().sensor == null) { -// logger.log(Level.INFO, "Sensor is null for SensorType: {0}", entry.getKey()); -// } - if (entry.getValue().sensor != null && entry.getValue().sensor.equals(se.sensor)) { - sensorType = entry.getKey(); - sensorData = entry.getValue(); - - updateEventQueue(sensorType, se.values[0], se.values[1], se.values[2], se.timestamp); - - if (sensorType == SensorInput.SENSOR_TYPE_MAGNETIC_FIELD) { - synchronized(curMagValues) { - curMagValues[0] = se.values[0]; - curMagValues[1] = se.values[1]; - curMagValues[2] = se.values[2]; - } - } - if (sensorType == SensorInput.SENSOR_TYPE_ACCELEROMETER) { - synchronized(curAccValues) { - curAccValues[0] = se.values[0]; - curAccValues[1] = se.values[1]; - curAccValues[2] = se.values[2]; - } - } - break; - } - } - } - - - public void onAccuracyChanged(Sensor sensor, int i) { - logger.log(Level.INFO, "onAccuracyChanged for {0}: accuracy: {1}", - new Object[]{sensor.toString(), i}); - } - -// End of methods from SensorEventListener - -} diff --git a/engine/src/android/com/jme3/system/android/OGLESContext.java b/engine/src/android/com/jme3/system/android/OGLESContext.java index 2a51a5244..c6608f3b5 100644 --- a/engine/src/android/com/jme3/system/android/OGLESContext.java +++ b/engine/src/android/com/jme3/system/android/OGLESContext.java @@ -43,7 +43,6 @@ import android.widget.EditText; import android.widget.FrameLayout; import com.jme3.input.*; import com.jme3.input.android.AndroidInput; -import com.jme3.input.android.AndroidSensorInput; import com.jme3.input.controls.SoftTextDialogInputListener; import com.jme3.input.dummy.DummyKeyInput; import com.jme3.input.dummy.DummyMouseInput; @@ -75,7 +74,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex protected SystemListener listener; protected boolean autoFlush = true; protected AndroidInput androidInput; - protected AndroidSensorInput androidSensorInput; protected AndroidGLSurfaceView view; protected int minFrameDuration = 0; // No FPS cap /** @@ -115,13 +113,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex } else { androidInput.setView(view); } - if (androidSensorInput == null) { - logger.log(Level.INFO, "Creating New SensorInput"); - androidSensorInput = new AndroidSensorInput(); - } else { - logger.log(Level.INFO, "Resetting SensorInput"); - androidSensorInput.resetSensorManager(); - } if (configType == ConfigType.LEGACY) { // Hardcoded egl setup clientOpenGLESVersion = 2; @@ -285,11 +276,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex return androidInput; } - @Override - public SensorInput getSensorInput() { - return androidSensorInput; - } - @Override public Timer getTimer() { return timer; diff --git a/engine/src/core/com/jme3/app/Application.java b/engine/src/core/com/jme3/app/Application.java index 75618beab..f1ebf187d 100644 --- a/engine/src/core/com/jme3/app/Application.java +++ b/engine/src/core/com/jme3/app/Application.java @@ -90,7 +90,6 @@ public class Application implements SystemListener { protected KeyInput keyInput; protected JoyInput joyInput; protected TouchInput touchInput; - protected SensorInput sensorInput; protected InputManager inputManager; protected AppStateManager stateManager; @@ -286,11 +285,7 @@ public class Application implements SystemListener { joyInput.initialize(); } - sensorInput = context.getSensorInput(); - if (sensorInput != null) - sensorInput.initialize(); - - inputManager = new InputManager(mouseInput, keyInput, joyInput, touchInput, sensorInput); + inputManager = new InputManager(mouseInput, keyInput, joyInput, touchInput); } private void initStateManager(){ @@ -631,9 +626,6 @@ public class Application implements SystemListener { if (touchInput != null) touchInput.destroy(); - if (sensorInput != null) - sensorInput.destroy(); - inputManager = null; } diff --git a/engine/src/core/com/jme3/input/InputManager.java b/engine/src/core/com/jme3/input/InputManager.java index 167fb19df..9c49032c7 100644 --- a/engine/src/core/com/jme3/input/InputManager.java +++ b/engine/src/core/com/jme3/input/InputManager.java @@ -88,7 +88,6 @@ public class InputManager implements RawInputListener { private final MouseInput mouse; private final JoyInput joystick; private final TouchInput touch; - private final SensorInput sensor; private float frameTPF; private long lastLastUpdateTime = 0; private long lastUpdateTime = 0; @@ -128,10 +127,9 @@ public class InputManager implements RawInputListener { * @param keys * @param joystick * @param touch - * @param sensor * @throws IllegalArgumentException If either mouseInput or keyInput are null. */ - public InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch, SensorInput sensor) { + public InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch) { if (keys == null || mouse == null) { throw new NullPointerException("Mouse or keyboard cannot be null"); } @@ -140,7 +138,6 @@ public class InputManager implements RawInputListener { this.mouse = mouse; this.joystick = joystick; this.touch = touch; - this.sensor = sensor; keys.setInputListener(this); mouse.setInputListener(this); @@ -151,9 +148,6 @@ public class InputManager implements RawInputListener { if (touch != null) { touch.setInputListener(this); } - if (sensor != null) { - sensor.setInputListener(this); - } firstTime = keys.getInputTimeNanos(); } @@ -397,9 +391,9 @@ public class InputManager implements RawInputListener { * Sets the mouse cursor image or animation. * Set cursor to null to show default system cursor. * To hide the cursor completely, use {@link #setCursorVisible(boolean) }. - * + * * @param jmeCursor The cursor to set, or null to reset to system cursor. - * + * * @see JmeCursor */ public void setMouseCursor(JmeCursor jmeCursor) { @@ -457,50 +451,6 @@ public class InputManager implements RawInputListener { inputQueue.add(evt); } - private void onMotionSensorEventQueued(MotionSensorEvent evt) { - int hash = SensorTrigger.sensorHash(evt.getSensorType()); - - ArrayList maps = bindings.get(hash); - if (maps == null) { - return; - } - - int size = maps.size(); - - for (int i = size - 1; i >= 0; i--) { - Mapping mapping = maps.get(i); - ArrayList listeners = mapping.listeners; - int listenerSize = listeners.size(); - for (int j = listenerSize - 1; j >= 0; j--) { - InputListener listener = listeners.get(j); - - if (listener instanceof MotionSensorListener) { - ((MotionSensorListener) listener).onMotionSensorChange(mapping.name, evt.getSensorType(), evt.getX(), evt.getY(), evt.getZ(), evt.getDX(), evt.getDY(), evt.getDZ()); - } - - } - } - } - - /** - * Callback from RawInputListener. Do not use. - */ - public void onMotionSensorEvent(MotionSensorEvent evt) { - if (!eventsPermitted) { - throw new UnsupportedOperationException("SensorInput has raised an event at an illegal time."); - } - inputQueue.add(evt); - } - - /** - * Returns the SensorInput implementation. Use this as an entry point to - * enable and disable various sensors as well as setting other sensor settings. - * @return The SensorInput implementation. - */ - public SensorInput getSensorInput() { - return sensor; - } - /** * Set the deadzone for joystick axes. * @@ -843,8 +793,6 @@ public class InputManager implements RawInputListener { listener.onJoyButtonEvent((JoyButtonEvent) event); } else if (event instanceof TouchEvent) { listener.onTouchEvent((TouchEvent) event); - } else if (event instanceof MotionSensorEvent) { - listener.onMotionSensorEvent((MotionSensorEvent) event); } else { assert false; } @@ -871,8 +819,6 @@ public class InputManager implements RawInputListener { onJoyButtonEventQueued((JoyButtonEvent) event); } else if (event instanceof TouchEvent) { onTouchEventQueued((TouchEvent) event); - } else if (event instanceof MotionSensorEvent) { - onMotionSensorEventQueued((MotionSensorEvent) event); } else { assert false; } @@ -913,9 +859,6 @@ public class InputManager implements RawInputListener { if (touch != null) { touch.update(); } - if (sensor != null) { - sensor.update(); - } eventsPermitted = false; diff --git a/engine/src/core/com/jme3/input/RawInputListener.java b/engine/src/core/com/jme3/input/RawInputListener.java index 1baf573c2..9a3f9a880 100644 --- a/engine/src/core/com/jme3/input/RawInputListener.java +++ b/engine/src/core/com/jme3/input/RawInputListener.java @@ -97,10 +97,4 @@ public interface RawInputListener { */ public void onTouchEvent(TouchEvent evt); - /** - * Invoked on motion sensor events. - * - * @param evt - */ - public void onMotionSensorEvent(MotionSensorEvent evt); } diff --git a/engine/src/core/com/jme3/input/SensorInput.java b/engine/src/core/com/jme3/input/SensorInput.java deleted file mode 100644 index a90393c80..000000000 --- a/engine/src/core/com/jme3/input/SensorInput.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2009-2010 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.jme3.input; - -import java.util.Set; - -/** - * A specific API for interfacing with sensors. - * - * In order to conserve battery power for handheld devices, sensors must be - * enabled before data will be sent. Use the setEnable method to enable or disable - * the sensors. - * - * Sensor speed can also be set. Constants in this class are used so that each - * platform implementation can decide what absolute update rate to use. Use the - * setSensorFrequency method to set the desired update rate. - * - * In order to minimize the amount of data sent to the application, there is a - * method available to set how much change is required between sensor readings - * before the new updated data is sent. Use the setSensorMinChange method to set - * a minimum data change percentage (percentage of max sensor range). Data will - * not be sent to the application until the data has changed by this amount. - * - * - * - * - * - * @author iwgeric - */ -public interface SensorInput extends Input { - - /** - * Orientation Sensor. Values returned in the onMotionSensorChanged event - * are in radians. - */ - public static final int SENSOR_TYPE_ORIENTATION = 0; - - /** - * Accelerometer Sensor. Values returned in the onMotionSensorChanged event - * are in m/s^2. Values include gravity. To get true device acceleration, - * gravity must be removed. - */ - public static final int SENSOR_TYPE_ACCELEROMETER = 1; - - /** - * Magnetic Field Sensor. Values returned in the onMotionSensorChanged event - * are in micro-Tesla (uT). - */ - public static final int SENSOR_TYPE_MAGNETIC_FIELD = 2; - - /** - * Slowest Sensor Update Speed - */ - public static final int SENSOR_SPEED_SLOW = 0; - - /** - * Medium Sensor Update Speed - */ - public static final int SENSOR_SPEED_MEDIUM = 1; - - /** - * Fastest Sensor Update Speed - */ - public static final int SENSOR_SPEED_FAST = 2; - - /** - * Returns whether a sensor is enabled or not. - * - * @param sensorType The sensor type. - * @return whether a sensor is enabled or not. - */ - public boolean isEnabled(int sensorType); - - /** - * Sets enable/disable for a specific sensor type. - * - * @param sensorType The sensor type. - * @param enable True to enable, False to disable. - */ - public void setEnable(int sensorType, boolean enable); - - /** - * Sets enable/disable for all sensor types. - * - * @param enable True to enable, False to disable. - */ - public void setEnable(boolean enable); - - /** - * Returns a list of available sensor types. - * - * @return a list of available sensor types. - */ - public Set getSensorTypes(); - - /** - * Set the minimum amount of change that is required before an event - * is created for the sensor. minChangePercent is defined as a percentage - * of the maximum sensor range. - * - * @param sensorType The sensor type. - * @param minChangePercent Percentage of changed required before creating an event. - */ - public void setSensorMinChange(int sensorType, float minChangePercent); - - /** - * Set the update frequency for the sensor. Use the defined constants in - * SensorInput for setting the speed becuase the actual update frequency is - * platform dependant. - * - * @param sensorType The sensor type. - * @param updateSpeed Target update speed as a constant (do not use absolute values) - */ - public void setSensorFrequency(int sensorType, int updateSpeed); - -} diff --git a/engine/src/core/com/jme3/input/controls/MotionSensorListener.java b/engine/src/core/com/jme3/input/controls/MotionSensorListener.java deleted file mode 100644 index 4ef4d23f9..000000000 --- a/engine/src/core/com/jme3/input/controls/MotionSensorListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2009-2010 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.jme3.input.controls; - -import com.jme3.input.SensorInput; - -/** - * MotionSensorListener is used to receive events from Sensors - * - * @author iwgeric - */ -public interface MotionSensorListener extends InputListener { - - /** - * Called when data from a sensor has been updated. - * - * @param name The name of the mapping that was invoked - * @param sensorType Sensor Type value from {@link SensorInput}. - * @param x X component of the new sensor data based on the sensor type. - * @param y Y component of the new sensor data based on the sensor type. - * @param z Z component of the new sensor data based on the sensor type. - * @param dX Change in the x component from the last update. - * @param dY Change in the y component from the last update. - * @param dZ Change in the z component from the last update. - */ - public void onMotionSensorChange(String name, int sensorType, float x, float y, float z, float dX, float dY, float dZ); - -} diff --git a/engine/src/core/com/jme3/input/controls/SensorTrigger.java b/engine/src/core/com/jme3/input/controls/SensorTrigger.java deleted file mode 100644 index 3fc7f6aa4..000000000 --- a/engine/src/core/com/jme3/input/controls/SensorTrigger.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2009-2010 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.jme3.input.controls; - -import com.jme3.input.SensorInput; - -/** - * A SensorTrigger is used as a mapping to receive events - * from a sensor. - * - * @author Kirill Vainer - */ -public class SensorTrigger implements Trigger { - -// private final SensorInput.Type sensorType; - private final int sensorType; - - /** - * Create a new SensorTrigger to receive sensor events. - * - * @param Sensor Type. See {@link SensorInput}. - */ -// public SensorTrigger(SensorInput.Type sensorType) { - public SensorTrigger(int sensorType) { -// if (sensorType == null) - if (sensorType < 0 || sensorType > 255) - throw new IllegalArgumentException("Invalide Sensor Type"); - - this.sensorType = sensorType; - } - -// public SensorInput.Type getSensorType() { - public int getSensorType() { - return sensorType; - } - - public String getName() { - return sensorType + " Sensor"; - } - -// public static int sensorHash(SensorInput.Type sensorType){ - public static int sensorHash(int sensorType){ -// assert sensorType != null; -// return 256 | (sensorType.ordinal() & 0xff); - assert sensorType >= 0 && sensorType <= 255; - return 1024 | (sensorType & 0xff); - } - - public int triggerHashCode() { - return sensorHash(sensorType); - } - -} diff --git a/engine/src/core/com/jme3/input/event/MotionSensorEvent.java b/engine/src/core/com/jme3/input/event/MotionSensorEvent.java deleted file mode 100644 index ada7c7d95..000000000 --- a/engine/src/core/com/jme3/input/event/MotionSensorEvent.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2009-2010 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.jme3.input.event; - -/** - * Motion Sensor event. - * - * @author iwgeric - */ -public class MotionSensorEvent extends InputEvent { - - private int sensorType; - private float x, y, z, dX, dY, dZ; - - public MotionSensorEvent(int sensorType, float x, float y, float z, float dX, float dY, float dZ) { - this.sensorType = sensorType; - this.x = x; - this.y = y; - this.z = z; - this.dX = dX; - this.dY = dY; - this.dZ = dZ; - } - - /** - * Sensor Type - * @return Sensor Type - */ - public int getSensorType() { - return sensorType; - } - - /** - * Current X coordinate - * @return Current X coordinate - */ - public float getX() { - return x; - } - - /** - * Current Y coordinate - * @return Current Y coordinate - */ - public float getY() { - return y; - } - - /** - * Current Z coordinate - * @return Current Z coordinate - */ - public float getZ() { - return z; - } - - /** - * The change in X coordinate - * @return change in X coordinate - */ - public float getDX() { - return dX; - } - - /** - * The change in Y coordinate - * - * @return change in Y coordinate - */ - public float getDY() { - return dY; - } - - /** - * The change in Z coordinate - * - * @return change in Z coordinate - */ - public float getDZ() { - return dZ; - } - - @Override - public String toString(){ - return "MotionSensor(Type="+sensorType+", X="+x+", Y="+y+", Z="+z+", DX="+dX+", DY="+dY+", DZ="+dZ+")"; - } - -} diff --git a/engine/src/core/com/jme3/system/JmeContext.java b/engine/src/core/com/jme3/system/JmeContext.java index dea7053d8..d684cc5fd 100644 --- a/engine/src/core/com/jme3/system/JmeContext.java +++ b/engine/src/core/com/jme3/system/JmeContext.java @@ -35,7 +35,6 @@ package com.jme3.system; import com.jme3.input.JoyInput; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; -import com.jme3.input.SensorInput; import com.jme3.input.TouchInput; import com.jme3.renderer.Renderer; @@ -132,11 +131,6 @@ public interface JmeContext { */ public TouchInput getTouchInput(); - /** - * @return Sensor device input implementation. May be null if not available. - */ - public SensorInput getSensorInput(); - /** * @return The timer for this context, or null if not created yet. */ diff --git a/engine/src/core/com/jme3/system/NullContext.java b/engine/src/core/com/jme3/system/NullContext.java index c15e39815..d0201b5e9 100644 --- a/engine/src/core/com/jme3/system/NullContext.java +++ b/engine/src/core/com/jme3/system/NullContext.java @@ -35,7 +35,6 @@ package com.jme3.system; import com.jme3.input.JoyInput; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; -import com.jme3.input.SensorInput; import com.jme3.input.TouchInput; import com.jme3.input.dummy.DummyKeyInput; import com.jme3.input.dummy.DummyMouseInput; @@ -179,10 +178,6 @@ public class NullContext implements JmeContext, Runnable { return null; } - public SensorInput getSensorInput() { - return null; - } - public void setTitle(String title) { } diff --git a/engine/src/desktop/com/jme3/system/awt/AwtPanelsContext.java b/engine/src/desktop/com/jme3/system/awt/AwtPanelsContext.java index 6891aba25..ceb6a88a6 100644 --- a/engine/src/desktop/com/jme3/system/awt/AwtPanelsContext.java +++ b/engine/src/desktop/com/jme3/system/awt/AwtPanelsContext.java @@ -3,7 +3,6 @@ package com.jme3.system.awt; import com.jme3.input.JoyInput; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; -import com.jme3.input.SensorInput; import com.jme3.input.TouchInput; import com.jme3.input.awt.AwtKeyInput; import com.jme3.input.awt.AwtMouseInput; @@ -103,10 +102,6 @@ public class AwtPanelsContext implements JmeContext { return null; } - public SensorInput getSensorInput() { - return null; - } - public Timer getTimer() { return actualContext.getTimer(); } diff --git a/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java b/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java index b9096bda6..919d3c534 100644 --- a/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java +++ b/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java @@ -35,7 +35,6 @@ package com.jme3.system.lwjgl; import com.jme3.input.JoyInput; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; -import com.jme3.input.SensorInput; import com.jme3.input.TouchInput; import com.jme3.input.lwjgl.JInputJoyInput; import com.jme3.input.lwjgl.LwjglKeyInput; @@ -259,10 +258,6 @@ public abstract class LwjglAbstractDisplay extends LwjglContext implements Runna return null; } - public SensorInput getSensorInput() { - return null; - } - public void setAutoFlushFrames(boolean enabled){ this.autoFlush = enabled; } diff --git a/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java b/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java index 8a7f7473f..05f714310 100644 --- a/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java +++ b/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java @@ -35,7 +35,6 @@ package com.jme3.system.lwjgl; import com.jme3.input.JoyInput; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; -import com.jme3.input.SensorInput; import com.jme3.input.TouchInput; import com.jme3.input.dummy.DummyKeyInput; import com.jme3.input.dummy.DummyMouseInput; @@ -190,10 +189,6 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable { return null; } - public SensorInput getSensorInput() { - return null; - } - public void setTitle(String title) { } diff --git a/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java b/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java index cbacac36b..d2a3674d3 100644 --- a/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java +++ b/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java @@ -71,13 +71,13 @@ public class InputSystemJme implements InputSystem, RawInputListener { /** * Must be set in order for nifty events to be forwarded correctly. - * - * @param nifty + * + * @param nifty */ public void setNifty(Nifty nifty) { this.nifty = nifty; } - + /** * Reset internal state of the input system. * Must be called when the display is reinitialized @@ -118,10 +118,10 @@ public class InputSystemJme implements InputSystem, RawInputListener { // If nifty consumed the mouse down event, then // it now owns the next mouse up event which // won't be forwarded to jME3. - + // processMouseEvent doesn't return true even if cursor is above // a nifty element (bug). - boolean consumed = nic.processMouseEvent(x, y, 0, button, true) + boolean consumed = nic.processMouseEvent(x, y, 0, button, true) | nifty.getCurrentScreen().isMouseOverElement(); niftyOwnsDragging[button] = consumed; if (consumed) { @@ -132,7 +132,7 @@ public class InputSystemJme implements InputSystem, RawInputListener { // Forward the event if nifty owns it or if the cursor is visible. if (niftyOwnsDragging[button] || inputManager.isCursorVisible()){ boolean consumed = nic.processMouseEvent(x, y, 0, button, false); - + // Only consume event if it ORIGINATED in nifty! if (niftyOwnsDragging[button] && consumed) { evt.setConsumed(); @@ -143,7 +143,7 @@ public class InputSystemJme implements InputSystem, RawInputListener { //System.out.format("niftyMouse(%d, %d, %d, false) = %b\n", x, y, button, consumed); } } - + private void onTouchEventQueued(TouchEvent evt, NiftyInputConsumer nic) { if (inputManager.getSimulateMouse()) { return; @@ -151,7 +151,7 @@ public class InputSystemJme implements InputSystem, RawInputListener { x = (int) evt.getX(); y = (int) (height - evt.getY()); - + // Input manager will not convert touch events to mouse events, // thus we must do it ourselves.. switch (evt.getType()) { @@ -175,7 +175,7 @@ public class InputSystemJme implements InputSystem, RawInputListener { inputPointerId = -1; handleMouseEvent(0, false, nic, evt); - + break; } } @@ -241,9 +241,6 @@ public class InputSystemJme implements InputSystem, RawInputListener { public void onJoyButtonEvent(JoyButtonEvent evt) { } - public void onMotionSensorEvent(MotionSensorEvent evt) { - } - public void onKeyEvent(KeyInputEvent evt) { inputQueue.add(evt); } diff --git a/engine/src/test/jme3test/gui/TestBitmapFont.java b/engine/src/test/jme3test/gui/TestBitmapFont.java index eb6a7cae0..08f908204 100644 --- a/engine/src/test/jme3test/gui/TestBitmapFont.java +++ b/engine/src/test/jme3test/gui/TestBitmapFont.java @@ -130,8 +130,6 @@ public class TestBitmapFont extends SimpleApplication { @Override public void onTouchEvent(TouchEvent evt) { } - @Override - public void onMotionSensorEvent(MotionSensorEvent evt) { } }; } diff --git a/engine/src/test/jme3test/gui/TestSoftwareMouse.java b/engine/src/test/jme3test/gui/TestSoftwareMouse.java index 4fc59d149..f75fde5c8 100644 --- a/engine/src/test/jme3test/gui/TestSoftwareMouse.java +++ b/engine/src/test/jme3test/gui/TestSoftwareMouse.java @@ -75,8 +75,6 @@ public class TestSoftwareMouse extends SimpleApplication { } public void onTouchEvent(TouchEvent evt) { } - public void onMotionSensorEvent(MotionSensorEvent evt) { - } }; public static void main(String[] args){