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
Main class that manages joystick devices. Joysticks can be physical gamepads,
the on-screen virtual joystick, or an explicitly-enabled sensor joystick.
This class manages all the joysticks and feeds the inputs from each back to jME's InputManager. This handler also supports redirecting joystick.rumble(rumbleAmount) to the Android device vibrator if AppSettings#setOnDeviceJoystickRumble(boolean) is enabled and 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 joysticks are not required by the application.
This class manages all the joysticks and feeds the inputs from each back to jME's InputManager. This handler also supports redirecting joystick.rumble(rumbleAmount) to the Android device vibrator if AppSettings#setOnDeviceJoystickRumble(boolean) is enabled and 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 joysticks 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
FieldsModifier and TypeFieldDescriptionprotected AndroidInputHandlerprotected List<com.jme3.input.Joystick> Fields inherited from interface com.jme3.input.JoyInput
AXIS_POV_X, AXIS_POV_Y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvent(com.jme3.input.event.InputEvent event) voiddestroy()longvoidbooleancom.jme3.input.Joystick[]loadJoysticks(com.jme3.input.InputManager inputManager) voidloadSettings(com.jme3.system.AppSettings settings) voidbooleanonTouch(android.view.MotionEvent event) voidPauses the joystick device listeners to save battery life if they are not needed.voidResumes the joystick device listeners.voidsetInputListener(com.jme3.input.RawInputListener listener) voidsetJoyRumble(int joyId, float amountHigh, float amountLow, float duration) protected voidsetPhysicalJoystickAvailable(boolean available) voidsetView(android.opengl.GLSurfaceView view) voidstopJoyRumble(int joyId) voidupdate()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jme3.input.JoyInput
setJoyRumble
-
Field Details
-
inputHandler
-
joystickList
-
-
Constructor Details
-
AndroidJoyInput
-
-
Method Details
-
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 amountHigh, float amountLow, float duration) - Specified by:
setJoyRumblein interfacecom.jme3.input.JoyInput
-
stopJoyRumble
public void stopJoyRumble(int joyId) - Specified by:
stopJoyRumblein interfacecom.jme3.input.JoyInput
-
loadJoysticks
public com.jme3.input.Joystick[] loadJoysticks(com.jme3.input.InputManager inputManager) - Specified by:
loadJoysticksin interfacecom.jme3.input.JoyInput
-
onTouch
public boolean onTouch(android.view.MotionEvent event) -
onKeyboardInput
public void onKeyboardInput() -
update
public void update()- Specified by:
updatein interfacecom.jme3.input.Input
-
setPhysicalJoystickAvailable
protected void setPhysicalJoystickAvailable(boolean available)
-