Class AndroidJoyInput

All Implemented Interfaces:
Input, JoyInput
Direct Known Subclasses:

public class AndroidJoyInput extends Object implements JoyInput
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. 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 Details

    • disableSensors

      public static boolean disableSensors
    • inputHandler

      protected AndroidInputHandler inputHandler
    • joystickList

      protected List<Joystick> joystickList
  • Constructor Details

  • Method Details

    • setView

      public void setView(android.opengl.GLSurfaceView view)
    • loadSettings

      public void loadSettings(AppSettings settings)
    • addEvent

      public void addEvent(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()
      Description copied from interface: Input
      Initializes the native side to listen into events from the device.
      Specified by:
      initialize in interface Input
    • isInitialized

      public boolean isInitialized()
      Specified by:
      isInitialized in interface Input
      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.
      Specified by:
      destroy in interface Input
    • setInputListener

      public void setInputListener(RawInputListener listener)
      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 interface Input
      listener - the desired listener
    • getInputTimeNanos

      public long getInputTimeNanos()
      Specified by:
      getInputTimeNanos in interface Input
      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 at joyId index to rumble with the given amount.
      Specified by:
      setJoyRumble in interface JoyInput
      joyId - The joystick index
      amount - Rumble amount. Should be between 0 and 1.
    • loadJoysticks

      public Joystick[] loadJoysticks(InputManager inputManager)
      Description copied from interface: JoyInput
      Loads a list of joysticks from the system.
      Specified by:
      loadJoysticks in interface JoyInput
      inputManager - The input manager requesting to load joysticks
      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.
      Specified by:
      update in interface Input
      See Also: