Class Joystick
java.lang.Object
io.github.roboblazers7617.buttonbox.Control
io.github.roboblazers7617.buttonbox.controls.Joystick
- Direct Known Subclasses:
PhysicalJoystick
A joystick with X and Y axes and a momentary button.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets whether the joystick button is pressed or not.Gets a trigger for the button.doublegetX()Gets the X axis value.doublegetY()Gets the Y axis value.voidsetButton(boolean pressed) Sets whether the joystick button is pressed or not.voidsetupNetworkTables(NetworkTable table) Called by the Control class when the NetworkTable is set byControl.setTable(NetworkTable).voidShould set up any simulation-specific things.voidsetX(double value) Sets the X axis value.voidsetY(double value) Sets the Y axis value.voidUpdates the control's state on the client.voidUpdates the control's state on the server.Methods inherited from class io.github.roboblazers7617.buttonbox.Control
getId, getTable, setTable, updateHardware, updateOnClient
-
Constructor Details
-
Joystick
Create a new Joystick.- Parameters:
id- The ID string for the Joystick to use.- See Also:
-
-
Method Details
-
setupSimulation
public void setupSimulation()Description copied from class:ControlShould set up any simulation-specific things.Called as a part of the constructor if the library is running in simulation.
- Overrides:
setupSimulationin classControl
-
updateServer
public void updateServer()Description copied from class:ControlUpdates the control's state on the server.This doesn't do anything by default, and should be overridden by the class inheritting this.
- Overrides:
updateServerin classControl
-
updateClient
public void updateClient()Description copied from class:ControlUpdates the control's state on the client. This should get any feedback from the server, but this should not interface with the buttonbox hardware.This doesn't do anything by default, and should be overridden by the class inheritting this.
- Overrides:
updateClientin classControl
-
setupNetworkTables
Description copied from class:ControlCalled by the Control class when the NetworkTable is set byControl.setTable(NetworkTable). intended to be called outside of the class.This should create all of the NetworkTables publishers and subscribers for the inheritting class.
- Overrides:
setupNetworkTablesin classControl- Parameters:
table- The table to use. When called byControl.setTable(NetworkTable), this is a subtable with the ID string as its key.
-
getX
public double getX()Gets the X axis value.- Returns:
- The current X axis value [0-1].
-
getY
public double getY()Gets the Y axis value.- Returns:
- The current Y axis value [0-1].
-
getButton
public boolean getButton()Gets whether the joystick button is pressed or not.- Returns:
- Is the button pressed?
-
getButtonTrigger
Gets a trigger for the button.- Returns:
- Trigger.
-
setX
public void setX(double value) Sets the X axis value.- Parameters:
value- The value to set it to [0-1].
-
setY
public void setY(double value) Sets the Y axis value.- Parameters:
value- The value to set it to [0-1].
-
setButton
public void setButton(boolean pressed) Sets whether the joystick button is pressed or not.- Parameters:
pressed- Is the button pressed?
-