RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz::Controller Class Referenceabstract

A V5 controller (the handheld joystick). More...

#include <Controller.hpp>

Inheritance diagram for rz::Controller:
rz::Component rz::ProsController rz::SimulationController

Classes

struct  State
 Everything read from the controller in one tick. More...

Public Types

enum class  Stick : std::uint8_t { LeftX , LeftY , RightX , RightY }
enum class  Button : std::uint8_t {
  L1 , L2 , R1 , R2 ,
  Up , Down , Left , Right ,
  X , B , Y , A
}

Public Member Functions

double stick (Stick stick) const
 How far the stick is pushed, from -1 to 1. Right and up are positive.
bool held (Button button) const
 Whether the button is down.
bool pressed (Button button) const
 Whether the button went down this tick.
bool connected () const
Task nextPress (Button button)
 Waits for the next press of button, in a later tick than this one. Checked at estimatorsUpdated.
Public Member Functions inherited from rz::Component
 Component (const Component &)=delete
Component & operator= (const Component &)=delete
 Component (Component &&)=delete
Component & operator= (Component &&)=delete
virtual ~Component ()
std::string_view name () const noexcept
 Used in log and error messages.

Static Public Attributes

static constexpr std::size_t STICK_COUNT = 4
static constexpr std::size_t BUTTON_COUNT = 12

Protected Member Functions

 Controller (std::string_view name)
virtual State read ()=0
 Reads the controller now. Sticks from -1 to 1.
Protected Member Functions inherited from rz::Component
 Component (std::string_view name)

Additional Inherited Members

Static Public Member Functions inherited from rz::Component
static Task runAll ()
 Runs the loop of every component constructed so far, in construction order, until cancelled. rz::robot runs it; tests without rz::robot run it alongside their script.

Detailed Description

A V5 controller (the handheld joystick).

A component that reads the controller at tickStarted(), so every reading in a tick is the same. While it is disconnected, sticks read 0 and buttons read released, so a controller that drops out stops the robot instead of repeating its last input.

Member Enumeration Documentation

◆ Button

enum class rz::Controller::Button : std::uint8_t
strong
Enumerator
L1 
L2 
R1 
R2 
Up 
Down 
Left 
Right 
X 
B 
Y 
A 

◆ Stick

enum class rz::Controller::Stick : std::uint8_t
strong
Enumerator
LeftX 
LeftY 
RightX 
RightY 

Constructor & Destructor Documentation

◆ Controller()

rz::Controller::Controller ( std::string_view name)
inlineexplicitprotected

Member Function Documentation

◆ connected()

bool rz::Controller::connected ( ) const
inlinenodiscard

◆ held()

bool rz::Controller::held ( Button button) const
inlinenodiscard

Whether the button is down.

◆ nextPress()

Task rz::Controller::nextPress ( Button button)
nodiscard

Waits for the next press of button, in a later tick than this one. Checked at estimatorsUpdated.

◆ pressed()

bool rz::Controller::pressed ( Button button) const
inlinenodiscard

Whether the button went down this tick.

◆ read()

virtual State rz::Controller::read ( )
nodiscardprotectedpure virtual

Reads the controller now. Sticks from -1 to 1.

◆ stick()

double rz::Controller::stick ( Stick stick) const
inlinenodiscard

How far the stick is pushed, from -1 to 1. Right and up are positive.

Member Data Documentation

◆ BUTTON_COUNT

std::size_t rz::Controller::BUTTON_COUNT = 12
staticconstexpr

◆ STICK_COUNT

std::size_t rz::Controller::STICK_COUNT = 4
staticconstexpr

The documentation for this class was generated from the following file: