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.GenericHIDbackingHIDprotected static java.util.BitSetBOUND_PORTSprotected java.util.Map<Gamepad.Binding,java.lang.Runnable>buttonBindingsprotected java.util.Map<Gamepad.Button,java.lang.Boolean>buttonStatesprotected java.util.Map<Gamepad.Mapping,java.util.function.Consumer<java.lang.Double>>controlsMappingprotected java.util.Map<Gamepad.Mapping,java.util.function.Function<java.lang.Double,java.lang.Double>>controlsModeMapprotected intport-
Fields inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
job, resourceLocks, THREAD_PRIORITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractController(int port, long timeout, java.util.concurrent.TimeUnit timeUnit)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddefineResources()Define the set of resourceLocks required for this Subsystem's task.voiddisableBindings()Disable button bindings.voidenableBindings()Enable button bindings.edu.wpi.first.wpilibj.GenericHIDgetBackingHID()Get the backing input device of this Gamepad.protected abstract java.util.Set<Gamepad.Button>getButtons()Get the set of Buttons on this controller.intgetPort()Get the USB port (as numbered in the Driver Station) that this Gamepad is plugged into.voidonLifecycleChange(LifecycleEvent event)voidtask()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:
getBackingHIDin 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:
enableBindingsin 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:
disableBindingsin interfaceGamepad
-
defineResources
public void defineResources()
Define the set of resourceLocks required for this Subsystem's task.- Specified by:
defineResourcesin 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.ExceptionDescription copied from interface:SubsystemThe background task to run.
-
onLifecycleChange
public void onLifecycleChange(LifecycleEvent event)
- Specified by:
onLifecycleChangein interfaceLifecycleListener
-
-