Package de.gurkenlabs.litiengine.input
Class Gamepad
java.lang.Object
de.gurkenlabs.litiengine.input.GamepadEvents
de.gurkenlabs.litiengine.input.Gamepad
- All Implemented Interfaces:
IUpdateable
public final class Gamepad
extends GamepadEvents
implements IUpdateable
The
Gamepad
class is designed as a wrapper implementation for any gamepad input that provides events and information
about player input via gamepad.- See Also:
Controller
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Gamepad.Axis
static class
Gamepad.Buttons
static class
Gamepad.DPad
static class
Gamepad.Xbox
Nested classes/interfaces inherited from class de.gurkenlabs.litiengine.input.GamepadEvents
GamepadEvents.GamepadPollListener, GamepadEvents.GamepadPressedListener, GamepadEvents.GamepadReleasedListener
Field Summary
Fields inherited from class de.gurkenlabs.litiengine.input.GamepadEvents
componentPollListeners, componentPressedListeners, componentReleasedListeners, pollListeners, pressedListeners, releasedListeners
Method Summary
Modifier and Type Method Description float
getAxisDeadzone()
Gets the deadzone for any axis components on this gamepad.int
getId()
Gets the unique id of this gamepad by which it is identified.java.lang.String
getName()
Gets the name of this gamepad.float
getPollData(java.lang.String component)
Gets the poll data for the specified component on this gamepad.float
getTriggerDeadzone()
Gets the deadzone for any trigger components on this gamepad.boolean
isPressed(java.lang.String gamepadComponent)
Determines whether the specified Gamepad component is currently pressed.void
setAxisDeadzone(float axisDeadzone)
Sets the deadzone for any axis components on this gamepad.void
setTriggerDeadzone(float triggerDeadzone)
Sets the deadzone for any trigger components on this gamepad.java.lang.String
toString()
void
update()
This method is called by the game loop on all objects that are attached to the loop.Methods inherited from class de.gurkenlabs.litiengine.input.GamepadEvents
clearEventListeners, onPoll, onPoll, onPressed, onPressed, onReleased, onReleased, removePollListener, removePollListener, removePressedListener, removePressedListener, removeReleasedListener, removeReleasedListener
Method Details
getId
public int getId()Gets the unique id of this gamepad by which it is identified.- Returns:
- The unique id of this gamepad.
getName
public java.lang.String getName()Gets the name of this gamepad.- Returns:
- The name of this gamepad.
getPollData
public float getPollData(java.lang.String component)Gets the poll data for the specified component on this gamepad.Returns the data from the last time the control has been polled.If this axis is a button, the value returned will be either 0.0f or 1.0f.If this axis is normalized, the value returned will be between -1.0f and1.0f.
- Parameters:
component
- The component to retrieve the poll data for.- Returns:
- The data from the last time the specified component has been polled; 0 if this gamepad doesn't provide the requested component.
getAxisDeadzone
public float getAxisDeadzone()Gets the deadzone for any axis components on this gamepad.A deadzone defines the poll value at which the events of this gamepad are not being triggered. This is useful to smooth out controller input and not react to idle noise.
- Returns:
- The axis deadzone for this component.
- See Also:
setAxisDeadzone(float)
getTriggerDeadzone
public float getTriggerDeadzone()Gets the deadzone for any trigger components on this gamepad.A deadzone defines the poll value at which the events of this gamepad are not being triggered. This is useful to smooth out controller input and not react to idle noise.
- Returns:
- The trigger deadzone for this gamepad.
- See Also:
setTriggerDeadzone(float)
isPressed
public boolean isPressed(java.lang.String gamepadComponent)Description copied from class:GamepadEvents
Determines whether the specified Gamepad component is currently pressed. This is useful for button type components.- Specified by:
isPressed
in classGamepadEvents
- Parameters:
gamepadComponent
- The component to check against.- Returns:
- True if the component is pressed, otherwise false.
- See Also:
Gamepad.Buttons
,Gamepad.Xbox
setAxisDeadzone
public void setAxisDeadzone(float axisDeadzone)Sets the deadzone for any axis components on this gamepad.- Parameters:
axisDeadzone
- The axis deadzone for this gamepad.- See Also:
getAxisDeadzone()
setTriggerDeadzone
public void setTriggerDeadzone(float triggerDeadzone)Sets the deadzone for any trigger components on this gamepad.- Parameters:
triggerDeadzone
- The trigger deadzone for this gamepad.- See Also:
getTriggerDeadzone()
update
public void update()Description copied from interface:IUpdateable
This method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration
.- Specified by:
update
in interfaceIUpdateable
- See Also:
ClientConfiguration.setMaxFps(int)
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object