Package ca.team3161.lib.utils.controls
Class AbstractController
- java.lang.Object
-
- ca.team3161.lib.robot.subsystem.AbstractSubsystem
-
- ca.team3161.lib.robot.subsystem.AbstractIndependentSubsystem
-
- ca.team3161.lib.robot.subsystem.RepeatingIndependentSubsystem
-
- ca.team3161.lib.utils.controls.AbstractController
-
- All Implemented Interfaces:
LifecycleListener
,Subsystem
,Gamepad
- Direct Known Subclasses:
LogitechAttack3
,LogitechDualAction
public abstract class AbstractController extends RepeatingIndependentSubsystem implements Gamepad, LifecycleListener
A Gamepad which allows button bindings and control modes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
AbstractSubsystem.RunTask
-
Nested classes/interfaces inherited from interface ca.team3161.lib.utils.controls.Gamepad
Gamepad.Axis, Gamepad.Binding, Gamepad.Button, Gamepad.Control, Gamepad.Mapping, Gamepad.PressType
-
-
Field Summary
Fields Modifier and Type Field Description protected edu.wpi.first.wpilibj.GenericHID
backingHID
protected static java.util.BitSet
BOUND_PORTS
protected java.util.Map<Gamepad.Binding,java.lang.Runnable>
buttonBindings
protected java.util.Map<Gamepad.Button,java.lang.Boolean>
buttonStates
protected java.util.Map<Gamepad.Mapping,java.util.function.Consumer<java.lang.Double>>
controlsMapping
protected java.util.Map<Gamepad.Mapping,java.util.function.Function<java.lang.Double,java.lang.Double>>
controlsModeMap
protected int
port
-
Fields inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
job, resourceLocks, THREAD_PRIORITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractController(int port, long timeout, java.util.concurrent.TimeUnit timeUnit)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
defineResources()
Define the set of resourceLocks required for this Subsystem's task.void
disableBindings()
Disable button bindings.void
enableBindings()
Enable button bindings.edu.wpi.first.wpilibj.GenericHID
getBackingHID()
Get the backing input device of this Gamepad.protected abstract java.util.Set<Gamepad.Button>
getButtons()
Get the set of Buttons on this controller.int
getPort()
Get the USB port (as numbered in the Driver Station) that this Gamepad is plugged into.void
onLifecycleChange(LifecycleEvent event)
void
task()
The background task to run.-
Methods inherited from class ca.team3161.lib.robot.subsystem.RepeatingIndependentSubsystem
isDone, start
-
Methods inherited from class ca.team3161.lib.robot.subsystem.AbstractIndependentSubsystem
getExecutorService
-
Methods inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
acquireResources, cancel, getJob, isCancelled, isScheduled, isStarted, releaseResources, require
-
-
-
-
Field Detail
-
backingHID
protected final edu.wpi.first.wpilibj.GenericHID backingHID
-
controlsModeMap
protected final java.util.Map<Gamepad.Mapping,java.util.function.Function<java.lang.Double,java.lang.Double>> controlsModeMap
-
controlsMapping
protected final java.util.Map<Gamepad.Mapping,java.util.function.Consumer<java.lang.Double>> controlsMapping
-
buttonBindings
protected final java.util.Map<Gamepad.Binding,java.lang.Runnable> buttonBindings
-
buttonStates
protected final java.util.Map<Gamepad.Button,java.lang.Boolean> buttonStates
-
port
protected final int port
-
BOUND_PORTS
protected static final java.util.BitSet BOUND_PORTS
-
-
Method Detail
-
getBackingHID
public edu.wpi.first.wpilibj.GenericHID getBackingHID()
Get the backing input device of this Gamepad.- Specified by:
getBackingHID
in interfaceGamepad
- Returns:
- the backing input device, eg Joystick
-
getPort
public int getPort()
Get the USB port (as numbered in the Driver Station) that this Gamepad is plugged into.
-
enableBindings
public void enableBindings()
Enable button bindings. If bindings are not enabled, then no bound actions will be executed. By default, bindings are not enabled.- Specified by:
enableBindings
in interfaceGamepad
-
disableBindings
public void disableBindings()
Disable button bindings. If bindings are not enabled, then no bound actions will be executed. By default, bindings are not enabled.- Specified by:
disableBindings
in interfaceGamepad
-
defineResources
public void defineResources()
Define the set of resourceLocks required for this Subsystem's task.- Specified by:
defineResources
in interfaceSubsystem
- See Also:
AbstractSubsystem.require(Object)
-
getButtons
protected abstract java.util.Set<Gamepad.Button> getButtons()
Get the set of Buttons on this controller.- Returns:
- a set of Buttons
-
task
public void task() throws java.lang.Exception
Description copied from interface:Subsystem
The background task to run.
-
onLifecycleChange
public void onLifecycleChange(LifecycleEvent event)
- Specified by:
onLifecycleChange
in interfaceLifecycleListener
-
-