public class LibgdxGamePad extends java.lang.Object implements GamePad, com.badlogic.gdx.controllers.ControllerListener
Modifier and Type | Field and Description |
---|---|
protected boolean |
connected |
protected GamePadType |
gamePadType |
Constructor and Description |
---|
LibgdxGamePad(com.badlogic.gdx.controllers.Controller controller) |
Modifier and Type | Method and Description |
---|---|
boolean |
accelerometerMoved(com.badlogic.gdx.controllers.Controller controller,
int accelerometerCode,
com.badlogic.gdx.math.Vector3 value) |
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 . |
java.lang.String |
getModelInfo()
Returns the model information present by the hardware/driver (e.g.
|
int |
getPlayerIndex()
Returns the player assigned to this gamepad
|
PovState |
getPov(int povCode)
Returns the current value of a PoV (Dpad)
|
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() |
protected void |
notifyPovChanged(int povCode,
PovState state) |
boolean |
povMoved(com.badlogic.gdx.controllers.Controller controller,
int povCode,
com.badlogic.gdx.controllers.PovDirection value) |
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
|
boolean |
xSliderMoved(com.badlogic.gdx.controllers.Controller controller,
int sliderCode,
boolean value) |
boolean |
ySliderMoved(com.badlogic.gdx.controllers.Controller controller,
int sliderCode,
boolean value) |
protected GamePadType gamePadType
protected boolean connected
public LibgdxGamePad(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.ControllerListener
public void disconnected(com.badlogic.gdx.controllers.Controller controller)
disconnected
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean buttonDown(com.badlogic.gdx.controllers.Controller controller, int buttonCode)
buttonDown
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean buttonUp(com.badlogic.gdx.controllers.Controller controller, int buttonCode)
buttonUp
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean axisMoved(com.badlogic.gdx.controllers.Controller controller, int axisCode, float value)
axisMoved
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean povMoved(com.badlogic.gdx.controllers.Controller controller, int povCode, com.badlogic.gdx.controllers.PovDirection value)
povMoved
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean xSliderMoved(com.badlogic.gdx.controllers.Controller controller, int sliderCode, boolean value)
xSliderMoved
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean ySliderMoved(com.badlogic.gdx.controllers.Controller controller, int sliderCode, boolean value)
ySliderMoved
in interface com.badlogic.gdx.controllers.ControllerListener
public boolean accelerometerMoved(com.badlogic.gdx.controllers.Controller controller, int accelerometerCode, com.badlogic.gdx.math.Vector3 value)
accelerometerMoved
in interface com.badlogic.gdx.controllers.ControllerListener
public GamePadType getGamePadType()
GamePad
GamePadType
getGamePadType
in interface GamePad
GamePadType.UNKNOWN
if unknownpublic java.lang.String getInstanceId()
GamePad
GamePad
.
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 the same ID.getInstanceId
in interface GamePad
public java.lang.String getModelInfo()
GamePad
getModelInfo
in interface GamePad
public boolean isConnected()
GamePad
GamePad
is connectedisConnected
in interface GamePad
public boolean isButtonDown(int buttonCode)
GamePad
isButtonDown
in interface GamePad
buttonCode
- The button code (Note: these may vary per platform)public boolean isButtonUp(int buttonCode)
GamePad
isButtonUp
in interface GamePad
buttonCode
- The button code (Note: these may vary per platform)public float getAxis(int axisCode)
GamePad
public PovState getPov(int povCode)
GamePad
public boolean isAccelerometerSupported()
GamePad
isAccelerometerSupported
in interface GamePad
public org.mini2Dx.gdx.math.Vector3 getAccelerometer(int accelerometerCode)
GamePad
getAccelerometer
in interface GamePad
accelerometerCode
- The accelerometer code (Note: these may vary per platform)public float getAccelerometerSensitivity()
GamePad
getAccelerometerSensitivity
in interface GamePad
public void setAccelerometerSensitivity(float sensitivity)
GamePad
setAccelerometerSensitivity
in interface GamePad
sensitivity
- The sensitivity where 0.0 is lowest, 1.0 is highestpublic void addListener(GamePadListener listener)
GamePad
GamePadListener
to listen to state changesaddListener
in interface GamePad
listener
- The GamePadListener
to addpublic void removeListener(GamePadListener listener)
GamePad
GamePadListener
removeListener
in interface GamePad
listener
- The GamePadListener
to removeprotected void notifyConnected()
protected void notifyDisconnected()
protected void notifyButtonDown(int buttonCode)
protected void notifyButtonUp(int buttonCode)
protected void notifyPovChanged(int povCode, PovState state)
protected void notifyAxisChanged(int axisCode, float axisValue)
protected void notifyAccelerometerChanged(int accelerometerCode)
public boolean isPlayerIndicesSupported()
GamePad
isPlayerIndicesSupported
in interface GamePad
public int getPlayerIndex()
GamePad
getPlayerIndex
in interface GamePad
public void setPlayerIndex(int playerIndex)
GamePad
setPlayerIndex
in interface GamePad
playerIndex
- -1 if unassignedpublic boolean isVibrateSupported()
GamePad
isVibrateSupported
in interface GamePad
public boolean isVibrating()
GamePad
isVibrating
in interface GamePad
public float getVibrationStrength()
GamePad
getVibrationStrength
in interface GamePad
public void startVibration(float strength)
GamePad
startVibration
in interface GamePad
strength
- A value between 0f and 1fpublic void stopVibration()
GamePad
stopVibration
in interface GamePad