| Modifier and Type | Field and Description |
|---|---|
protected boolean |
connected |
protected com.badlogic.gdx.controllers.Controller |
controller |
protected GamePadType |
gamePadType |
protected java.lang.String |
model |
protected int |
playerIndex |
protected java.lang.String |
uniqueId |
protected float |
vibrateStrength |
| Constructor and Description |
|---|
LibgdxGamePad(com.badlogic.gdx.controllers.Controller controller) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(GamePadListener listener)
Adds a
GamePadListener to listen to state changes |
boolean |
axisMoved(com.badlogic.gdx.controllers.Controller controller,
int axisCode,
float value) |
boolean |
buttonDown(com.badlogic.gdx.controllers.Controller controller,
int buttonCode) |
boolean |
buttonUp(com.badlogic.gdx.controllers.Controller controller,
int buttonCode) |
void |
connected(com.badlogic.gdx.controllers.Controller controller) |
void |
disconnected(com.badlogic.gdx.controllers.Controller controller) |
org.mini2Dx.gdx.math.Vector3 |
getAccelerometer(int accelerometerCode)
Returns the current accelerometer value
|
float |
getAccelerometerSensitivity()
Returns the accelerometer sensitivity
|
float |
getAxis(int axisCode)
Returns the current value of an axis
|
GamePadType |
getGamePadType()
Returns the
GamePadType |
java.lang.String |
getInstanceId()
Returns the ID for this
GamePad. |
static java.lang.String |
getInstanceId(com.badlogic.gdx.controllers.Controller controller) |
java.lang.String |
getModelInfo()
Returns the model information present by the hardware/driver (e.g.
|
int |
getPlayerIndex()
Returns the player assigned to this gamepad
|
float |
getVibrationStrength()
Returns the strength of the vibration/rumble
|
void |
init() |
boolean |
isAccelerometerSupported()
Returns if this gamepad has accelerometer functionality
|
boolean |
isButtonDown(int buttonCode)
Returns if a specific button is currently pressed down
|
boolean |
isButtonUp(int buttonCode)
Returns if a specific button is currently released (not pressed down)
|
boolean |
isConnected()
Returns if this
GamePad is connected |
boolean |
isPlayerIndicesSupported()
Returns if this game pad supports assigning player numbers to it
|
boolean |
isVibrateSupported()
Returns if this gamepad has vibrate/rumble functionality
|
boolean |
isVibrating()
Returns if this gamepad is currently vibrating/rumbling
|
protected void |
notifyAccelerometerChanged(int accelerometerCode) |
protected void |
notifyAxisChanged(int axisCode,
float axisValue) |
protected void |
notifyButtonDown(int buttonCode) |
protected void |
notifyButtonUp(int buttonCode) |
protected void |
notifyConnected() |
protected void |
notifyDisconnected() |
void |
removeListener(GamePadListener listener)
Removes a
GamePadListener |
void |
setAccelerometerSensitivity(float sensitivity)
Sets the accelerometer sensitivity
|
void |
setPlayerIndex(int playerIndex)
Sets the player assigned to this gamepad
|
void |
startVibration(float strength)
Starts vibrating/rumbling the gamepad
|
void |
stopVibration()
Stops the vibrating/rumbling of the gamepad
|
protected java.lang.String uniqueId
protected java.lang.String model
protected int playerIndex
protected com.badlogic.gdx.controllers.Controller controller
protected GamePadType gamePadType
protected boolean connected
protected float vibrateStrength
public LibgdxGamePad(com.badlogic.gdx.controllers.Controller controller)
public static java.lang.String getInstanceId(com.badlogic.gdx.controllers.Controller controller)
public void init()
public void connected(com.badlogic.gdx.controllers.Controller controller)
connected in interface com.badlogic.gdx.controllers.ControllerListenerpublic void disconnected(com.badlogic.gdx.controllers.Controller controller)
disconnected in interface com.badlogic.gdx.controllers.ControllerListenerpublic boolean buttonDown(com.badlogic.gdx.controllers.Controller controller,
int buttonCode)
buttonDown in interface com.badlogic.gdx.controllers.ControllerListenerpublic boolean buttonUp(com.badlogic.gdx.controllers.Controller controller,
int buttonCode)
buttonUp in interface com.badlogic.gdx.controllers.ControllerListenerpublic boolean axisMoved(com.badlogic.gdx.controllers.Controller controller,
int axisCode,
float value)
axisMoved in interface com.badlogic.gdx.controllers.ControllerListenerpublic GamePadType getGamePadType()
GamePadGamePadTypegetGamePadType in interface GamePadGamePadType.UNKNOWN if unknownpublic java.lang.String getInstanceId()
GamePadGamePad.
When supported by the driver, if multiple gamepads are connected each will have a unique instance id.
Otherwise, this will fallback for to the name of the device returned by the driver.
If a gamepad is unplugged and reconnected, it will have a different ID but will connect to the previous GamePad instancegetInstanceId in interface GamePadpublic java.lang.String getModelInfo()
GamePadgetModelInfo in interface GamePadpublic boolean isConnected()
GamePadGamePad is connectedisConnected in interface GamePadpublic boolean isButtonDown(int buttonCode)
GamePadisButtonDown in interface GamePadbuttonCode - The button code (Note: these may vary per platform)public boolean isButtonUp(int buttonCode)
GamePadisButtonUp in interface GamePadbuttonCode - The button code (Note: these may vary per platform)public float getAxis(int axisCode)
GamePadpublic boolean isAccelerometerSupported()
GamePadisAccelerometerSupported in interface GamePadpublic org.mini2Dx.gdx.math.Vector3 getAccelerometer(int accelerometerCode)
GamePadgetAccelerometer in interface GamePadaccelerometerCode - The accelerometer code (Note: these may vary per platform)public float getAccelerometerSensitivity()
GamePadgetAccelerometerSensitivity in interface GamePadpublic void setAccelerometerSensitivity(float sensitivity)
GamePadsetAccelerometerSensitivity in interface GamePadsensitivity - The sensitivity where 0.0 is lowest, 1.0 is highestpublic void addListener(GamePadListener listener)
GamePadGamePadListener to listen to state changesaddListener in interface GamePadlistener - The GamePadListener to addpublic void removeListener(GamePadListener listener)
GamePadGamePadListenerremoveListener in interface GamePadlistener - The GamePadListener to removeprotected void notifyConnected()
protected void notifyDisconnected()
protected void notifyButtonDown(int buttonCode)
protected void notifyButtonUp(int buttonCode)
protected void notifyAxisChanged(int axisCode,
float axisValue)
protected void notifyAccelerometerChanged(int accelerometerCode)
public boolean isPlayerIndicesSupported()
GamePadisPlayerIndicesSupported in interface GamePadpublic int getPlayerIndex()
GamePadgetPlayerIndex in interface GamePadpublic void setPlayerIndex(int playerIndex)
GamePadsetPlayerIndex in interface GamePadplayerIndex - -1 if unassignedpublic boolean isVibrateSupported()
GamePadisVibrateSupported in interface GamePadpublic boolean isVibrating()
GamePadisVibrating in interface GamePadpublic float getVibrationStrength()
GamePadgetVibrationStrength in interface GamePadpublic void startVibration(float strength)
GamePadstartVibration in interface GamePadstrength - A value between 0f and 1fpublic void stopVibration()
GamePadstopVibration in interface GamePad