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
Fields inherited from interface com.jme3.input.JoyInput
AXIS_POV_X, AXIS_POV_Y
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEvent
(InputEvent event) void
destroy()
Ceases listening to events from the device.long
void
Initializes the native side to listen into events from the device.boolean
Joystick[]
loadJoysticks
(InputManager inputManager) Loads a list of joysticks from the system.void
loadSettings
(AppSettings settings) void
Pauses the joystick device listeners to save battery life if they are not needed.void
Resumes the joystick device listeners.void
setInputListener
(RawInputListener listener) Sets the input listener to receive events from this device.void
setJoyRumble
(int joyId, float amount) Causes the joystick atjoyId
index to rumble with the given amount.void
setView
(android.opengl.GLSurfaceView view) void
update()
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:Input
Initializes the native side to listen into events from the device.- Specified by:
initialize
in interfaceInput
-
isInitialized
public boolean isInitialized()- Specified by:
isInitialized
in interfaceInput
- Returns:
- True if the device has been initialized and not destroyed.
- See Also:
-
destroy
public void destroy()Description copied from interface:Input
Ceases listening to events from the device. -
setInputListener
Description copied from interface:Input
Sets the input listener to receive events from this device. The appropriate events should be dispatched through the callbacks in RawInputListener.- Specified by:
setInputListener
in interfaceInput
- Parameters:
listener
- the desired listener
-
getInputTimeNanos
public long getInputTimeNanos()- Specified by:
getInputTimeNanos
in 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:JoyInput
Causes the joystick atjoyId
index to rumble with the given amount.- Specified by:
setJoyRumble
in interfaceJoyInput
- Parameters:
joyId
- The joystick indexamount
- Rumble amount. Should be between 0 and 1.
-
loadJoysticks
Description copied from interface:JoyInput
Loads a list of joysticks from the system.- Specified by:
loadJoysticks
in 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:Input
Queries the device for input. All events should be sent to the RawInputListener set with setInputListener.
-