Package com.jme3.input.android
Class AndroidJoyInput
java.lang.Object
com.jme3.input.android.AndroidJoyInput
- Direct Known Subclasses:
AndroidJoyInput14
Main 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.
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"/>
-
Field Summary
FieldsFields inherited from interface com.jme3.input.JoyInput
AXIS_POV_X, AXIS_POV_Y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvent(InputEvent event) voiddestroy()Ceases listening to events from the device.longvoidInitializes the native side to listen into events from the device.booleanJoystick[]loadJoysticks(InputManager inputManager) Loads a list of joysticks from the system.voidloadSettings(AppSettings settings) voidPauses the joystick device listeners to save battery life if they are not needed.voidResumes the joystick device listeners.voidsetInputListener(RawInputListener listener) Sets the input listener to receive events from this device.voidsetJoyRumble(int joyId, float amount) Causes the joystick atjoyIdindex to rumble with the given amount.voidsetView(android.opengl.GLSurfaceView view) voidupdate()Queries the device for input.
-
Field Details
-
disableSensors
public static boolean disableSensors -
inputHandler
-
joystickList
-
-
Constructor Details
-
AndroidJoyInput
-
-
Method Details
-
setView
public void setView(android.opengl.GLSurfaceView view) -
loadSettings
-
addEvent
-
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()Description copied from interface:InputInitializes the native side to listen into events from the device.- Specified by:
initializein interfaceInput
-
isInitialized
public boolean isInitialized()- Specified by:
isInitializedin interfaceInput- Returns:
- True if the device has been initialized and not destroyed.
- See Also:
-
destroy
public void destroy()Description copied from interface:InputCeases listening to events from the device. -
setInputListener
Description copied from interface:InputSets the input listener to receive events from this device. The appropriate events should be dispatched through the callbacks in RawInputListener.- Specified by:
setInputListenerin interfaceInput- Parameters:
listener- the desired listener
-
getInputTimeNanos
public long getInputTimeNanos()- Specified by:
getInputTimeNanosin interfaceInput- Returns:
- The current absolute time as nanoseconds. This time is expected to be relative to the time given in InputEvents time property.
-
setJoyRumble
public void setJoyRumble(int joyId, float amount) Description copied from interface:JoyInputCauses the joystick atjoyIdindex to rumble with the given amount.- Specified by:
setJoyRumblein interfaceJoyInput- Parameters:
joyId- The joystick indexamount- Rumble amount. Should be between 0 and 1.
-
loadJoysticks
Description copied from interface:JoyInputLoads a list of joysticks from the system.- Specified by:
loadJoysticksin interfaceJoyInput- Parameters:
inputManager- The input manager requesting to load joysticks- Returns:
- A list of joysticks that are installed.
-
update
public void update()Description copied from interface:InputQueries the device for input. All events should be sent to the RawInputListener set with setInputListener.
-