Top Fields Constructors Methods
com.badlogic.gdx.controllers.desktop.support

public Class JamepadController

extends Object
implements Controller
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.controllers.Controller
Imports
com.badlogic.gdx.controllers.Controller, .ControllerListener, .ControllerMapping, .ControllerPowerLevel, com.badlogic.gdx.utils.IntFloatMap, .IntMap, .Logger, .TimeUtils, com.studiohartman.jamepad.ControllerAxis, .ControllerButton, .ControllerIndex, .ControllerUnpluggedException, java.util.UUID

Field Summary

Modifier and TypeField and Description
private int
private final IntFloatMap
private final IntMap<Boolean>
private Boolean
private static final IntMap<ControllerAxis>
private static final IntMap<ControllerButton>
private final CompositeControllerListener
private boolean
private static final ControllerAxis[]
private static final ControllerButton[]
private ControllerIndex
private static final Logger
private int
private final String
private final String
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public boolean
public float
public int
public boolean
private String
public ControllerMapping
public int
public int
public String
public int
public ControllerPowerLevel
public String
private void
public boolean
public boolean
public void
public void
public void
public void
setPlayerIndex(int
0 typically 0 to 3 for player indices, and PLAYER_IDX_UNSET for unset
index
)

Implements com.badlogic.gdx.controllers.Controller.setPlayerIndex.

Sets the player index of this controller.

public void
startVibration(int
duration, in milliseconds
duration
,
float
value between 0f and 1f
strength
)

Implements com.badlogic.gdx.controllers.Controller.startVibration.

Starts vibrating this controller, if possible.

public boolean
private ControllerAxis
toAxis(int axisCode)

private ControllerButton
toButton(int buttonCode)

public boolean
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

axisCountback to summary
private int axisCount
axisStateback to summary
private final IntFloatMap axisState
buttonStateback to summary
private final IntMap<Boolean> buttonState
canVibrateback to summary
private Boolean canVibrate
CODE_TO_AXISback to summary
private static final IntMap<ControllerAxis> CODE_TO_AXIS
CODE_TO_BUTTONback to summary
private static final IntMap<ControllerButton> CODE_TO_BUTTON
compositeControllerListenerback to summary
private final CompositeControllerListener compositeControllerListener
connectedback to summary
private boolean connected
CONTROLLER_AXIS_VALUESback to summary
private static final ControllerAxis[] CONTROLLER_AXIS_VALUES
CONTROLLER_BUTTON_VALUESback to summary
private static final ControllerButton[] CONTROLLER_BUTTON_VALUES
controllerIndexback to summary
private ControllerIndex controllerIndex
loggerback to summary
private static final Logger logger
maxButtonIndexback to summary
private int maxButtonIndex
nameback to summary
private final String name
uuidback to summary
private final String uuid
vibrationEndMsback to summary
private long vibrationEndMs

Constructor Detail

JamepadControllerback to summary
public JamepadController(ControllerIndex controllerIndex)

Method Detail

addListenerback to summary
public void addListener(ControllerListener listener)

Implements com.badlogic.gdx.controllers.Controller.addListener.

Doc from com.badlogic.gdx.controllers.Controller.addListener.

Adds a new ControllerListener to this Controller. The listener will receive calls in case the state of the controller changes. The listener will be invoked on the rendering thread.

Annotations
@Override
cancelVibrationback to summary
public void cancelVibration()

Implements com.badlogic.gdx.controllers.Controller.cancelVibration.

Doc from com.badlogic.gdx.controllers.Controller.cancelVibration.

Cancel any running vibration. May not be supported by implementations

Annotations
@Override
canVibrateback to summary
public boolean canVibrate()

Implements com.badlogic.gdx.controllers.Controller.canVibrate.

Returns:boolean

Doc from com.badlogic.gdx.controllers.Controller.canVibrate.

whether the connected controller or the current controller implementation can rumble. Note that this is no guarantee that the connected controller itself can vibrate.

Annotations
@Override
getAxisback to summary
public float getAxis(final int axisCode)

Implements com.badlogic.gdx.controllers.Controller.getAxis.

Returns:float

Doc from com.badlogic.gdx.controllers.Controller.getAxis.

the value of the axis, between -1 and 1

Annotations
@Override
getAxisCountback to summary
public int getAxisCount()

Implements com.badlogic.gdx.controllers.Controller.getAxisCount.

Returns:int

Doc from com.badlogic.gdx.controllers.Controller.getAxisCount.

number of axis of this controller. Axis indices start at 0, so the maximum axis index is one under this value.

Annotations
@Override
getButtonback to summary
public boolean getButton(final int buttonCode)

Implements com.badlogic.gdx.controllers.Controller.getButton.

Returns:boolean

Doc from com.badlogic.gdx.controllers.Controller.getButton.

whether the button is pressed.

Annotations
@Override
getInitialNameback to summary
private String getInitialName()
getMappingback to summary
public ControllerMapping getMapping()

Implements com.badlogic.gdx.controllers.Controller.getMapping.

Returns:ControllerMapping

Doc from com.badlogic.gdx.controllers.Controller.getMapping.

button and axis mapping for this controller (or platform). The connected controller might not support all features.

Annotations
@Override
getMaxButtonIndexback to summary
public int getMaxButtonIndex()

Implements com.badlogic.gdx.controllers.Controller.getMaxButtonIndex.

Returns:int

Doc from com.badlogic.gdx.controllers.Controller.getMaxButtonIndex.

the maximum button index code that can be queried

Annotations
@Override
getMinButtonIndexback to summary
public int getMinButtonIndex()

Implements com.badlogic.gdx.controllers.Controller.getMinButtonIndex.

Returns:int

Doc from com.badlogic.gdx.controllers.Controller.getMinButtonIndex.

the minimum button index code that can be queried

Annotations
@Override
getNameback to summary
public String getName()

Implements com.badlogic.gdx.controllers.Controller.getName.

Returns:String

Doc from com.badlogic.gdx.controllers.Controller.getName.

the device name

Annotations
@Override
getPlayerIndexback to summary
public int getPlayerIndex()

Implements com.badlogic.gdx.controllers.Controller.getPlayerIndex.

Returns:int

Doc from com.badlogic.gdx.controllers.Controller.getPlayerIndex.

0-based player index of this controller, or PLAYER_IDX_UNSET if none is set

Annotations
@Override
getPowerLevelback to summary
public ControllerPowerLevel getPowerLevel()

Implements com.badlogic.gdx.controllers.Controller.getPowerLevel.

Returns:ControllerPowerLevel

Doc from com.badlogic.gdx.controllers.Controller.getPowerLevel.

value of enum ControllerPowerLevel indicating battery state of the connected controller, or ControllerPowerLevel#POWER_UNKNOWN if information is not present

Annotations
@Override
getUniqueIdback to summary
public String getUniqueId()

Implements com.badlogic.gdx.controllers.Controller.getUniqueId.

Returns:String

Doc from com.badlogic.gdx.controllers.Controller.getUniqueId.

unique ID to recognize this controller if more than one of the same controller models are connected. Use this to map a controller to a player, but do not use it to save a button mapping.

Annotations
@Override
initializeStateback to summary
private void initializeState()
isConnectedback to summary
public boolean isConnected()

Implements com.badlogic.gdx.controllers.Controller.isConnected.

Returns:boolean

Doc from com.badlogic.gdx.controllers.Controller.isConnected.

true when this Controller is still connected, false if it already disconnected

Annotations
@Override
isVibratingback to summary
public boolean isVibrating()

Implements com.badlogic.gdx.controllers.Controller.isVibrating.

Returns:boolean

Doc from com.badlogic.gdx.controllers.Controller.isVibrating.

if the controller is currently rumbling

Annotations
@Override
removeListenerback to summary
public void removeListener(ControllerListener listener)

Implements com.badlogic.gdx.controllers.Controller.removeListener.

Doc from com.badlogic.gdx.controllers.Controller.removeListener.

Removes the given ControllerListener

Annotations
@Override
setControllerIndexback to summary
public void setControllerIndex(ControllerIndex controllerIndex)
setDisconnectedback to summary
public void setDisconnected()
setPlayerIndexback to summary
public void setPlayerIndex(int index)

Implements com.badlogic.gdx.controllers.Controller.setPlayerIndex.

Doc from com.badlogic.gdx.controllers.Controller.setPlayerIndex.

Sets the player index of this controller. Please note that this does not always set indication lights of controllers, it is just an internal representation on some platforms

Parameters
index:int

0 typically 0 to 3 for player indices, and PLAYER_IDX_UNSET for unset

Annotations
@Override
startVibrationback to summary
public void startVibration(int duration, float strength)

Implements com.badlogic.gdx.controllers.Controller.startVibration.

Doc from com.badlogic.gdx.controllers.Controller.startVibration.

Starts vibrating this controller, if possible.

Parameters
duration:int

duration, in milliseconds

strength:float

value between 0f and 1f

Annotations
@Override
supportsPlayerIndexback to summary
public boolean supportsPlayerIndex()

Implements com.badlogic.gdx.controllers.Controller.supportsPlayerIndex.

Returns:boolean

Doc from com.badlogic.gdx.controllers.Controller.supportsPlayerIndex.

whether the connected controller (or the implementation) can return and set the current player index

Annotations
@Override
toAxisback to summary
private ControllerAxis toAxis(int axisCode)
toButtonback to summary
private ControllerButton toButton(int buttonCode)
updateback to summary
public boolean update()
updateAxisStateback to summary
private void updateAxisState()
updateButtonsStateback to summary
private void updateButtonsState()