Package com.jme3.input.android
Class AndroidJoyInput
- java.lang.Object
-
- com.jme3.input.android.AndroidJoyInput
-
- All Implemented Interfaces:
com.jme3.input.Input,com.jme3.input.JoyInput
- Direct Known Subclasses:
AndroidJoyInput14
public class AndroidJoyInput extends java.lang.Object implements com.jme3.input.JoyInputMain class that manages various joystick devices. Joysticks can be many forms including a simulated joystick to communicate the device orientation as well as physical gamepads.
This class manages all the joysticks and feeds the inputs from each back to jME's InputManager. This handler also supports the joystick.rumble(rumbleAmount) method. In this case, when joystick.rumble(rumbleAmount) is called, the Android device will vibrate if the device has a built-in vibrate motor. Because Android does not allow for the user to define the intensity of the vibration, the rumble amount (ie strength) is converted into vibration pulses The stronger the strength amount, the shorter the delay between pulses. If amount is 1, then the vibration stays on the whole time. If amount is 0.5, the vibration will a pulse of equal parts vibration and delay. To turn off vibration, set rumble amount to 0. MainActivity needs the following line to enable Joysticks on Android platforms joystickEventsEnabled = true; This is done to allow for battery conservation when sensor data or gamepads are not required by the application.To use the joystick rumble feature, the following line needs to be added to the Android Manifest File <uses-permission android:name="android.permission.VIBRATE"/>- Author:
- iwgeric
-
-
Field Summary
Fields Modifier and Type Field Description static booleandisableSensorsprotected AndroidInputHandlerinputHandlerprotected java.util.List<com.jme3.input.Joystick>joystickList
-
Constructor Summary
Constructors Constructor Description AndroidJoyInput(AndroidInputHandler inputHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEvent(com.jme3.input.event.InputEvent event)voiddestroy()longgetInputTimeNanos()voidinitialize()booleanisInitialized()com.jme3.input.Joystick[]loadJoysticks(com.jme3.input.InputManager inputManager)voidloadSettings(com.jme3.system.AppSettings settings)voidpauseJoysticks()Pauses the joystick device listeners to save battery life if they are not needed.voidresumeJoysticks()Resumes the joystick device listeners.voidsetInputListener(com.jme3.input.RawInputListener listener)voidsetJoyRumble(int joyId, float amount)voidsetView(android.opengl.GLSurfaceView view)voidupdate()
-
-
-
Field Detail
-
disableSensors
public static boolean disableSensors
-
inputHandler
protected AndroidInputHandler inputHandler
-
joystickList
protected java.util.List<com.jme3.input.Joystick> joystickList
-
-
Constructor Detail
-
AndroidJoyInput
public AndroidJoyInput(AndroidInputHandler inputHandler)
-
-
Method Detail
-
setView
public void setView(android.opengl.GLSurfaceView view)
-
loadSettings
public void loadSettings(com.jme3.system.AppSettings settings)
-
addEvent
public void addEvent(com.jme3.input.event.InputEvent event)
-
pauseJoysticks
public void pauseJoysticks()
Pauses the joystick device listeners to save battery life if they are not needed. Used to pause when the activity pauses
-
resumeJoysticks
public void resumeJoysticks()
Resumes the joystick device listeners. Used to resume when the activity comes to the top of the stack
-
initialize
public void initialize()
- Specified by:
initializein interfacecom.jme3.input.Input
-
isInitialized
public boolean isInitialized()
- Specified by:
isInitializedin interfacecom.jme3.input.Input
-
destroy
public void destroy()
- Specified by:
destroyin interfacecom.jme3.input.Input
-
setInputListener
public void setInputListener(com.jme3.input.RawInputListener listener)
- Specified by:
setInputListenerin interfacecom.jme3.input.Input
-
getInputTimeNanos
public long getInputTimeNanos()
- Specified by:
getInputTimeNanosin interfacecom.jme3.input.Input
-
setJoyRumble
public void setJoyRumble(int joyId, float amount)- Specified by:
setJoyRumblein interfacecom.jme3.input.JoyInput
-
loadJoysticks
public com.jme3.input.Joystick[] loadJoysticks(com.jme3.input.InputManager inputManager)
- Specified by:
loadJoysticksin interfacecom.jme3.input.JoyInput
-
update
public void update()
- Specified by:
updatein interfacecom.jme3.input.Input
-
-