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.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 boolean povMoved(com.badlogic.gdx.controllers.Controller controller,
int povCode,
com.badlogic.gdx.controllers.PovDirection value)
povMoved in interface com.badlogic.gdx.controllers.ControllerListenerpublic boolean xSliderMoved(com.badlogic.gdx.controllers.Controller controller,
int sliderCode,
boolean value)
xSliderMoved in interface com.badlogic.gdx.controllers.ControllerListenerpublic boolean ySliderMoved(com.badlogic.gdx.controllers.Controller controller,
int sliderCode,
boolean value)
ySliderMoved in interface com.badlogic.gdx.controllers.ControllerListenerpublic boolean accelerometerMoved(com.badlogic.gdx.controllers.Controller controller,
int accelerometerCode,
com.badlogic.gdx.math.Vector3 value)
accelerometerMoved 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 the same ID.getInstanceId 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 PovState getPov(int povCode)
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 notifyPovChanged(int povCode,
PovState state)
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