SDL  2.0
org.libsdl.app.SDLControllerManager Class Reference
+ Collaboration diagram for org.libsdl.app.SDLControllerManager:

Static Public Member Functions

static native int nativeSetupJNI ()
 
static native int nativeAddJoystick (int device_id, String name, String desc, int vendor_id, int product_id, boolean is_accelerometer, int button_mask, int naxes, int nhats, int nballs)
 
static native int nativeRemoveJoystick (int device_id)
 
static native int nativeAddHaptic (int device_id, String name)
 
static native int nativeRemoveHaptic (int device_id)
 
static native int onNativePadDown (int device_id, int keycode)
 
static native int onNativePadUp (int device_id, int keycode)
 
static native void onNativeJoy (int device_id, int axis, float value)
 
static native void onNativeHat (int device_id, int hat_id, int x, int y)
 
static void initialize ()
 
static boolean handleJoystickMotionEvent (MotionEvent event)
 
static void pollInputDevices ()
 
static void pollHapticDevices ()
 
static void hapticRun (int device_id, float intensity, int length)
 
static void hapticStop (int device_id)
 
static boolean isDeviceSDLJoystick (int deviceId)
 

Static Protected Attributes

static SDLJoystickHandler mJoystickHandler
 
static SDLHapticHandler mHapticHandler
 

Static Private Attributes

static final String TAG = "SDLControllerManager"
 

Detailed Description

Definition at line 14 of file SDLControllerManager.java.

Member Function Documentation

◆ handleJoystickMotionEvent()

static boolean org.libsdl.app.SDLControllerManager.handleJoystickMotionEvent ( MotionEvent  event)
inlinestatic

Definition at line 61 of file SDLControllerManager.java.

Referenced by org.libsdl.app.SDLControllerManager.isDeviceSDLJoystick().

61  {
62  return mJoystickHandler.handleMotionEvent(event);
63  }
struct _cl_event * event
static SDLJoystickHandler mJoystickHandler

◆ hapticRun()

static void org.libsdl.app.SDLControllerManager.hapticRun ( int  device_id,
float  intensity,
int  length 
)
inlinestatic

This method is called by SDL using JNI.

Definition at line 82 of file SDLControllerManager.java.

82  {
83  mHapticHandler.run(device_id, intensity, length);
84  }
GLuint GLsizei GLsizei * length

◆ hapticStop()

static void org.libsdl.app.SDLControllerManager.hapticStop ( int  device_id)
inlinestatic

This method is called by SDL using JNI.

Definition at line 89 of file SDLControllerManager.java.

90  {
91  mHapticHandler.stop(device_id);
92  }

◆ initialize()

static void org.libsdl.app.SDLControllerManager.initialize ( )
inlinestatic

Definition at line 38 of file SDLControllerManager.java.

Referenced by org.libsdl.app.SDL.initialize().

38  {
39  if (mJoystickHandler == null) {
40  if (Build.VERSION.SDK_INT >= 19) {
41  mJoystickHandler = new SDLJoystickHandler_API19();
42  } else if (Build.VERSION.SDK_INT >= 16) {
43  mJoystickHandler = new SDLJoystickHandler_API16();
44  } else if (Build.VERSION.SDK_INT >= 12) {
45  mJoystickHandler = new SDLJoystickHandler_API12();
46  } else {
47  mJoystickHandler = new SDLJoystickHandler();
48  }
49  }
50 
51  if (mHapticHandler == null) {
52  if (Build.VERSION.SDK_INT >= 26) {
53  mHapticHandler = new SDLHapticHandler_API26();
54  } else {
55  mHapticHandler = new SDLHapticHandler();
56  }
57  }
58  }
static SDLJoystickHandler mJoystickHandler

◆ isDeviceSDLJoystick()

static boolean org.libsdl.app.SDLControllerManager.isDeviceSDLJoystick ( int  deviceId)
inlinestatic

if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) { Log.v(TAG, "Input device " + device.getName() + " is a joystick."); } if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) { Log.v(TAG, "Input device " + device.getName() + " is a dpad."); } if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) { Log.v(TAG, "Input device " + device.getName() + " is a gamepad."); }

Definition at line 95 of file SDLControllerManager.java.

References device, e, org.libsdl.app.SDLActivity.getContentView(), org.libsdl.app.SDL.getContext(), org.libsdl.app.SDLControllerManager.handleJoystickMotionEvent(), haptic, i, org.libsdl.app.SDLControllerManager.isDeviceSDLJoystick(), org.libsdl.app.SDLActivity.isDeXMode(), j, org.libsdl.app.SDLActivity.mSeparateMouseAndTouch, org.libsdl.app.SDLControllerManager.nativeAddHaptic(), org.libsdl.app.SDLControllerManager.nativeAddJoystick(), org.libsdl.app.SDLControllerManager.nativeRemoveHaptic(), org.libsdl.app.SDLControllerManager.nativeRemoveJoystick(), org.libsdl.app.SDLControllerManager.onNativeHat(), org.libsdl.app.SDLControllerManager.onNativeJoy(), org.libsdl.app.SDLActivity.onNativeMouse(), org.libsdl.app.SDLControllerManager.pollHapticDevices(), and org.libsdl.app.SDLControllerManager.pollInputDevices().

Referenced by org.libsdl.app.SDLControllerManager.isDeviceSDLJoystick(), and org.libsdl.app.SDLActivity.setSystemCursor().

95  {
96  InputDevice device = InputDevice.getDevice(deviceId);
97  // We cannot use InputDevice.isVirtual before API 16, so let's accept
98  // only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
99  if ((device == null) || (deviceId < 0)) {
100  return false;
101  }
102  int sources = device.getSources();
103 
104  /* This is called for every button press, so let's not spam the logs */
105  /**
106  if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) {
107  Log.v(TAG, "Input device " + device.getName() + " is a joystick.");
108  }
109  if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
110  Log.v(TAG, "Input device " + device.getName() + " is a dpad.");
111  }
112  if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
113  Log.v(TAG, "Input device " + device.getName() + " is a gamepad.");
114  }
115  **/
116 
117  return (((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) ||
118  ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
119  ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
120  );
121  }
GLsizei GLenum * sources
static SDL_AudioDeviceID device
Definition: loopwave.c:37

◆ nativeAddHaptic()

static native int org.libsdl.app.SDLControllerManager.nativeAddHaptic ( int  device_id,
String  name 
)
static

◆ nativeAddJoystick()

static native int org.libsdl.app.SDLControllerManager.nativeAddJoystick ( int  device_id,
String  name,
String  desc,
int  vendor_id,
int  product_id,
boolean  is_accelerometer,
int  button_mask,
int  naxes,
int  nhats,
int  nballs 
)
static

◆ nativeRemoveHaptic()

static native int org.libsdl.app.SDLControllerManager.nativeRemoveHaptic ( int  device_id)
static

◆ nativeRemoveJoystick()

static native int org.libsdl.app.SDLControllerManager.nativeRemoveJoystick ( int  device_id)
static

◆ nativeSetupJNI()

static native int org.libsdl.app.SDLControllerManager.nativeSetupJNI ( )
static

◆ onNativeHat()

static native void org.libsdl.app.SDLControllerManager.onNativeHat ( int  device_id,
int  hat_id,
int  x,
int  y 
)
static

◆ onNativeJoy()

static native void org.libsdl.app.SDLControllerManager.onNativeJoy ( int  device_id,
int  axis,
float  value 
)
static

◆ onNativePadDown()

static native int org.libsdl.app.SDLControllerManager.onNativePadDown ( int  device_id,
int  keycode 
)
static

◆ onNativePadUp()

static native int org.libsdl.app.SDLControllerManager.onNativePadUp ( int  device_id,
int  keycode 
)
static

◆ pollHapticDevices()

static void org.libsdl.app.SDLControllerManager.pollHapticDevices ( )
inlinestatic

This method is called by SDL using JNI.

Definition at line 75 of file SDLControllerManager.java.

Referenced by org.libsdl.app.SDLControllerManager.isDeviceSDLJoystick().

75  {
76  mHapticHandler.pollHapticDevices();
77  }

◆ pollInputDevices()

static void org.libsdl.app.SDLControllerManager.pollInputDevices ( )
inlinestatic

This method is called by SDL using JNI.

Definition at line 68 of file SDLControllerManager.java.

Referenced by org.libsdl.app.SDLControllerManager.isDeviceSDLJoystick().

68  {
69  mJoystickHandler.pollInputDevices();
70  }
static SDLJoystickHandler mJoystickHandler

Field Documentation

◆ mHapticHandler

SDLHapticHandler org.libsdl.app.SDLControllerManager.mHapticHandler
staticprotected

Definition at line 34 of file SDLControllerManager.java.

◆ mJoystickHandler

SDLJoystickHandler org.libsdl.app.SDLControllerManager.mJoystickHandler
staticprotected

Definition at line 33 of file SDLControllerManager.java.

◆ TAG

final String org.libsdl.app.SDLControllerManager.TAG = "SDLControllerManager"
staticprivate

Definition at line 36 of file SDLControllerManager.java.


The documentation for this class was generated from the following file: