Controller

open class Controller : Gamepad

A wrapper around a Gamepad object that provides a Controls interface and custom input calculations. These gamepad objects are used natively in BunyipsOpMode, and are the drop-in replacements for gamepad1 and gamepad2.

Author

Lucas Bubner, 2024

Since

1.0.0-pre

See also

Constructors

Link copied to clipboard
constructor(@NonNull gamepad: Gamepad)
Create a new Controller to manage.

Properties

Link copied to clipboard
open var dd: Boolean
Shorthand for dpad_down
Link copied to clipboard
open var dl: Boolean
Shorthand for dpad_left
Link copied to clipboard
open var dr: Boolean
Shorthand for dpad_right
Link copied to clipboard
open var du: Boolean
Shorthand for dpad_up
Link copied to clipboard
open var lb: Boolean
Shorthand for left_bumper
Link copied to clipboard
open var lsb: Boolean
Shorthand for left_stick_button
Link copied to clipboard
open var lsx: Float
Shorthand for left_stick_x
Link copied to clipboard
open var lsy: Float
Shorthand for left_stick_y
Link copied to clipboard
open var lt: Float
Shorthand for left_trigger
Link copied to clipboard
open var rb: Boolean
Shorthand for right_bumper
Link copied to clipboard
open var rsb: Boolean
Shorthand for right_stick_button
Link copied to clipboard
open var rsx: Float
Shorthand for right_stick_x
Link copied to clipboard
open var rsy: Float
Shorthand for right_stick_y
Link copied to clipboard
open var rt: Float
Shorthand for right_trigger
Link copied to clipboard
val sdk: Gamepad
The SDK gamepad that this Controller wraps and takes input from.

Inherited properties

Link copied to clipboard
open var a: Boolean
Link copied to clipboard
open var b: Boolean
Link copied to clipboard
open var back: Boolean
Link copied to clipboard
open var circle: Boolean
Link copied to clipboard
open var cross: Boolean
Link copied to clipboard
open var dpad_down: Boolean
Link copied to clipboard
open var dpad_left: Boolean
Link copied to clipboard
Link copied to clipboard
open var dpad_up: Boolean
Link copied to clipboard
open var guide: Boolean
Link copied to clipboard
Link copied to clipboard
open var id: Int
Link copied to clipboard
val ID_SYNTHETIC: Int = -2
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var ledQueue: EvictingBlockingQueue<Gamepad.LedEffect>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
protected open var nanotimeTransmit: Long
Link copied to clipboard
protected val nanotimeTransmitInterval: Long = 200000000
Link copied to clipboard
Link copied to clipboard
protected open var nextSequenceNumber: AtomicInteger
Link copied to clipboard
open var options: Boolean
Link copied to clipboard
open var ps: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var rumbleQueue: EvictingBlockingQueue<Gamepad.RumbleEffect>
Link copied to clipboard
protected open var sequenceNumber: Int
Link copied to clipboard
open var share: Boolean
Link copied to clipboard
open var square: Boolean
Link copied to clipboard
open var start: Boolean
Link copied to clipboard
open var timestamp: Long
Link copied to clipboard
open var touchpad: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var triangle: Boolean
Link copied to clipboard
open var type: Gamepad.Type
Link copied to clipboard
protected open var user: Byte
Link copied to clipboard
protected open var userForEffects: Byte
Link copied to clipboard
open var x: Boolean
Link copied to clipboard
open var y: Boolean

Functions

Link copied to clipboard
open fun get(@NonNull button: Controls): Boolean
Get the value of a button.
open fun get(@NonNull axis: Controls.Analog): Float
Get the value of an axis.
Link copied to clipboard
open fun getDebounced(@NonNull button: Controls): Boolean
Check if a button is currently pressed on a gamepad, with debounce to ignore a press that was already detected upon the first call of this function and button.
Link copied to clipboard
open fun resetDebounce(@NonNull button: Controls)
Call to reset the initial debounce state of getDebounced, allowing further calls to this method to capture the initial state of the button again.
Link copied to clipboard
open fun set(@NonNull button: Controls, @Nullable predicate: Predicate<Boolean>): Controller
Customise how a button is read.
Customise how an axis is read.
Customise how a group of axes is read.
Customise how a group of buttons is read.
Link copied to clipboard
open fun update()
Update the public fields of this Controller with the values from the wrapped Gamepad, performing calculations on the inputs as specified by the user.
Link copied to clipboard
protected open fun updateButtonAliases()

Inherited functions

Link copied to clipboard
protected open fun allocateWholeWriteBuffer(overallSize: Int): ByteBuffer
Link copied to clipboard
open fun atRest(): Boolean
Link copied to clipboard
open fun copy(gamepad: Gamepad)
Link copied to clipboard
open fun fromByteArray(byteArray: Array<Byte>)
Link copied to clipboard
protected open fun genericToString(): String
Link copied to clipboard
open fun getGamepadId(): Int
Link copied to clipboard
protected open fun getReadBuffer(byteArray: Array<Byte>): ByteBuffer
Link copied to clipboard
open fun getRobocolMsgType(): RobocolParsable.MsgType
Link copied to clipboard
Link copied to clipboard
open fun getUser(): GamepadUser
Link copied to clipboard
protected open fun getWholeReadBuffer(byteArray: Array<Byte>): ByteBuffer
Link copied to clipboard
protected open fun getWriteBuffer(payloadSize: Int): ByteBuffer
Link copied to clipboard
open fun initializeSequenceNumber(sequenceNumber: Int)
Link copied to clipboard
open fun isRumbling(): Boolean
Link copied to clipboard
protected open fun ps4ToString(): String
Link copied to clipboard
open fun refreshTimestamp()
Link copied to clipboard
open fun reset()
Link copied to clipboard
infix fun Controller.rising(button: Controls): Boolean

getDebounced extension for Controller.

Link copied to clipboard
open fun rumble(durationMs: Int)
Link copied to clipboard
open fun rumbleBlips(count: Int)
Link copied to clipboard
open fun runLedEffect(effect: Gamepad.LedEffect)
Link copied to clipboard
open fun runRumbleEffect(effect: Gamepad.RumbleEffect)
Link copied to clipboard
open fun setGamepadId(id: Int)
Link copied to clipboard
open fun setLedColor(r: Double, g: Double, b: Double, durationMs: Int)
Link copied to clipboard
open fun setSequenceNumber(sequenceNumber: Short)
Link copied to clipboard
open fun setTimestamp(timestamp: Long)
Link copied to clipboard
open fun setUser(user: GamepadUser)
Link copied to clipboard
open fun setUserForEffects(userForEffects: Byte)
Link copied to clipboard
open fun shouldTransmit(nanotimeNow: Long): Boolean
Link copied to clipboard
open fun stopRumble()
Link copied to clipboard
open fun toByteArray(): Array<Byte>
Link copied to clipboard
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
open fun type(): Gamepad.Type