mechanism/driver_inputs.hpp — THE DRIVER FILE'S MECHANISM CONTROLS: hold-to-run, toggle, preset and the homing controls, each naming its mechanism by its DECLARATION, checked at build against the robot's list, and run THROUGH the mechanism service.
This header declares 4 types (37 members), 51 free functions, 1 constant, and 8 type aliass.
Extracted from include/shulib/mechanism/driver_inputs.hpp — this page is that header's documentation, reformatted, so it cannot disagree with the code. Prose about how to think about the API lives in How it works; worked recipes live in Recipes; this page is the complete, mechanical list of what exists.
kToggleAtSpeedWindowSeconds— constantenum class ControlKindstruct ControlwhileHeld_is_for_a_power_mechanism_an_arm_or_a_lift_use_toggle_or_preset— free functionwhileHeld_with_one_button_is_for_a_power_mechanism_an_arm_or_a_lift_needs_two— free functiona_toggle_on_a_flywheel_names_its_speed_like_toggle_flywheel_shoot— free functiona_toggle_is_for_a_two_position_pneumatic_or_a_flywheel_speed— free functionhomeOnPress_and_homeAtDriverStart_are_for_an_arm_or_a_lift— free functiona_control_names_a_mechanism_this_robot_does_not_have— free functiona_control_names_a_button_that_is_not_one_of_the_twelve— free functionbutton_L1_does_two_jobs— free functionbutton_L2_does_two_jobs— free functionbutton_R1_does_two_jobs— free functionbutton_R2_does_two_jobs— free functionbutton_Up_does_two_jobs— free functionbutton_Down_does_two_jobs— free functionbutton_Left_does_two_jobs— free functionbutton_Right_does_two_jobs— free functionbutton_X_does_two_jobs— free functionbutton_B_does_two_jobs— free functionbutton_Y_does_two_jobs— free functionbutton_A_does_two_jobs— free functiona_hold_needs_volts_above_0_and_at_most_12— free functiona_preset_or_a_homing_needs_a_time_limit_above_zero— free functiontwo_controls_of_the_same_kind_on_one_mechanism— free functiona_toggle_needs_a_two_position_pneumatic_or_a_flywheel_named_speed— free functiona_homing_control_on_a_mechanism_that_is_never_homed— free functiona_mechanism_has_no_driver_control_mark_it_autonOnly_if_that_is_meant— free functiona_mechanism_marked_autonOnly_also_has_a_control— free functionmore_controls_than_fit— free functiona_mechanism_that_must_be_homed_has_no_way_to_home_in_driver_control— free functiona_never_homed_mechanism_needs_unhomedVolts_for_its_buttons_to_move_it— free functiona_preset_on_a_mechanism_that_is_never_homed— free functionwhileHeld— free functionwhileHeld (overload 2)— free functionwhileHeld (overload 3)— free functionwhileHeld (overload 4)— free functionwhileHeld (overload 5)— free functionwhileHeld (overload 6)— free functiontoggle— free functiontoggle (overload 2)— free functiontoggle (overload 3)— free functiontoggle (overload 4)— free functionpreset— free functionpreset (overload 2)— free functionpreset (overload 3)— free functionhomeOnPress— free functionhomeOnPress (overload 2)— free functionhomeAtDriverStart— free functionhomeAtDriverStart (overload 2)— free functionhomeOnPress (overload 3)— free functionhomeAtDriverStart (overload 3)— free functionautonOnly— free functionstruct DriverControlscontrols— free functionclass DriverInputsDriverControls— type aliascontrols (overload 2)— type aliaswhileHeld (overload 7)— type aliastoggle (overload 5)— type aliaspreset (overload 4)— type aliashomeOnPress (overload 4)— type aliashomeAtDriverStart (overload 4)— type aliasautonOnly (overload 2)— type alias
inline constexpr double kToggleAtSpeedWindowSeconds = 5.0A driver toggle's flywheel spin-up: its "at speed" verdict window, seconds (HA-182 — invented, PROVISIONAL; a LIBRARY constant). Not a match number: the wheel keeps spinning whatever the verdict; it only bounds the step the toggle logs.
constant, declared at include/shulib/mechanism/driver_inputs.hpp:102.
enum class ControlKind : std::uint8_tWhat one driver control does (file header).
enum class, declared at include/shulib/mechanism/driver_inputs.hpp:107.
HoldwhileHeld: two buttons ± volts, or one button + volts on a power one (oneWay)
enumerator, declared at include/shulib/mechanism/driver_inputs.hpp:108.
Toggleone button: flips a two-position pneumatic, or a flywheel's named speed on / off
enumerator, declared at include/shulib/mechanism/driver_inputs.hpp:109.
Presetone button: a position, a speed or a pneumatic position
enumerator, declared at include/shulib/mechanism/driver_inputs.hpp:110.
HomeOnPressone button: home it by its declaration's method
enumerator, declared at include/shulib/mechanism/driver_inputs.hpp:111.
HomeAtDriverStartno button: home it once at driver-control entry, when nothing homed it
enumerator, declared at include/shulib/mechanism/driver_inputs.hpp:112.
AutonOnlyno control, on purpose
enumerator, declared at include/shulib/mechanism/driver_inputs.hpp:113.
struct ControlOne driver-file line. Made only by the words below, each taking the mechanism's DECLARATION (or a goal it made), so a control always names its mechanism.
struct, declared at include/shulib/mechanism/driver_inputs.hpp:118.
ControlKind kind = ControlKind::HoldWhat it does.
field, declared at include/shulib/mechanism/driver_inputs.hpp:120.
Kind mechanismKind = Kind::PowerThe kind of mechanism it commands (a declaration's kind).
field, declared at include/shulib/mechanism/driver_inputs.hpp:122.
const void* mechanism = nullptrThe declaration's address — what controls() checks against the robot's list.
field, declared at include/shulib/mechanism/driver_inputs.hpp:124.
const char* mechanismName = nullptrThe declaration's .name — what DriverInputs::bind() finds its slot by.
field, declared at include/shulib/mechanism/driver_inputs.hpp:126.
hal::ControllerButton button = hal::ControllerButton::AA hold's FORWARD (up) button; every other control's one button.
field, declared at include/shulib/mechanism/driver_inputs.hpp:128.
hal::ControllerButton back = hal::ControllerButton::AA hold's BACK (down) button (a ONE-button hold: its one button again — oneWay says so).
field, declared at include/shulib/mechanism/driver_inputs.hpp:130.
double volts = 0.0A hold's volts, (0, 12].
field, declared at include/shulib/mechanism/driver_inputs.hpp:132.
double bound = 0.0A preset's or a homing's time limit, seconds (P4: every action bounded).
field, declared at include/shulib/mechanism/driver_inputs.hpp:134.
double value = 0.0A preset's target: degrees, inches or output rpm (a flywheel toggle's speed too).
field, declared at include/shulib/mechanism/driver_inputs.hpp:136.
std::uint8_t position = 0A pneumatic preset's position (its index in the declaration).
field, declared at include/shulib/mechanism/driver_inputs.hpp:138.
const char* presetName = nullptrThe preset's (or a pneumatic position's) name; nullptr for a constant target.
field, declared at include/shulib/mechanism/driver_inputs.hpp:140.
Units units = static_cast<Units>(0)An arm's (degrees) or a lift's (inches) control: its units; UNSET for the other kinds.
field, declared at include/shulib/mechanism/driver_inputs.hpp:142.
bool oneWay = falseA ONE-button hold on a POWER mechanism (whileHeld(m, button, volts), chunk ROB1-C2): button held = +volts, released = stop; it has no back button (back repeats button and is never read).
field, declared at include/shulib/mechanism/driver_inputs.hpp:145.
inline void whileHeld_is_for_a_power_mechanism_an_arm_or_a_lift_use_toggle_or_preset()whileHeld(...) on a pneumatic or a flywheel (n24).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:150.
inline void whileHeld_with_one_button_is_for_a_power_mechanism_an_arm_or_a_lift_needs_two()whileHeld(m, button, volts) — ONE button — on an arm, a lift, a pneumatic or a flywheel (ROB1-C2).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:152.
inline void a_toggle_on_a_flywheel_names_its_speed_like_toggle_flywheel_shoot()toggle(flywheel, ...) without its speed (n51).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:154.
inline void a_toggle_is_for_a_two_position_pneumatic_or_a_flywheel_speed()toggle(...) on a power mechanism, an arm or a lift.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:156.
inline void homeOnPress_and_homeAtDriverStart_are_for_an_arm_or_a_lift()homeOnPress(...) / homeAtDriverStart(...) on a power mechanism, a flywheel or a pneumatic.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:158.
inline void a_control_names_a_mechanism_this_robot_does_not_have()A control names a mechanism the robot's list does not have (n19).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:160.
inline void a_control_names_a_button_that_is_not_one_of_the_twelve()A control names a button that is not one of the controller's twelve (a cast byte).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:162.
inline void button_L1_does_two_jobs()L1 does two jobs (a button used twice NAMES the button; the error points at the controls( line).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:164.
inline void button_L2_does_two_jobs()L2 does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:166.
inline void button_R1_does_two_jobs()R1 does two jobs (n17).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:168.
inline void button_R2_does_two_jobs()R2 does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:170.
inline void button_Up_does_two_jobs()Up does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:172.
inline void button_Down_does_two_jobs()Down does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:174.
inline void button_Left_does_two_jobs()Left does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:176.
inline void button_Right_does_two_jobs()Right does two jobs (m2).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:178.
inline void button_X_does_two_jobs()X does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:180.
inline void button_B_does_two_jobs()B does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:182.
inline void button_Y_does_two_jobs()Y does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:184.
inline void button_A_does_two_jobs()A does two jobs.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:186.
inline void a_hold_needs_volts_above_0_and_at_most_12()A hold's volts outside (0, 12] (n20).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:188.
inline void a_preset_or_a_homing_needs_a_time_limit_above_zero()A preset or a homing control with no time limit (n34).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:190.
inline void two_controls_of_the_same_kind_on_one_mechanism()Two controls of one kind on one mechanism — two holds, two toggles, two homings, two presets to one target (n21). A hold beside presets is fine: the most recent input wins (Q8).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:193.
inline void a_toggle_needs_a_two_position_pneumatic_or_a_flywheel_named_speed()A toggle on a three-position pneumatic, or on a flywheel's constant speed instead of a named one (n22).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:196.
inline void a_homing_control_on_a_mechanism_that_is_never_homed()A homing control on a mechanism declared neverHomed.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:198.
inline void a_mechanism_has_no_driver_control_mark_it_autonOnly_if_that_is_meant()A mechanism with no control and not marked autonOnly (n18).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:200.
inline void a_mechanism_marked_autonOnly_also_has_a_control()A mechanism marked autonOnly that also has a control.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:202.
inline void more_controls_than_fit()More than DriverControls::kCap controls.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:204.
inline void a_mechanism_that_must_be_homed_has_no_way_to_home_in_driver_control()A switch- or stall-homed mechanism held or preset with no way to home it in driver control (n48): its buttons would be dead after any restart off its home — add homeAtDriverStart or homeOnPress. The declaration's .unhomedVolts answers for its HOLDS only (they move it unhomed at those volts); it is never a way to HOME it — a jog never zeroes a mechanism — so a PRESET on it would end NOT_HOMED for the rest of the run, and a preset needs one of the two homing controls.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:210.
inline void a_never_homed_mechanism_needs_unhomedVolts_for_its_buttons_to_move_it()A never-homed mechanism held with no .unhomedVolts (n49): its buttons would command 0 V.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:212.
inline void a_preset_on_a_mechanism_that_is_never_homed()A preset on a never-homed mechanism (n50): always NOT_HOMED — a dead button.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:214.
[[nodiscard]] constexpr Control whileHeld(const Power& m, hal::ControllerButton forward, hal::ControllerButton back, units::Voltage volts) noexceptWHILE HELD on a POWER mechanism: forward held = +volts, back held = −volts, let go = stop (its declared safe state). (Re-check 2026-10-07: "hold" read as a position AND a brake mode.)
free function, declared at include/shulib/mechanism/driver_inputs.hpp:221.
[[nodiscard]] constexpr Control whileHeld(const Power& m, hal::ControllerButton run, units::Voltage volts) noexceptWHILE HELD, ONE BUTTON, on a POWER mechanism (chunk ROB1-C2): run held = +volts — ONE way, the declaration's .motors direction — let go = stop (its declared safe state). No back button: the button beside it stays free for another control.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:229.
template <class D> consteval Control whileHeld(const D&, hal::ControllerButton, units::Voltage)whileHeld(arm, Button::R1, 6_volt) — one button on anything but a power mechanism: refused BY NAME (an arm's or a lift's jog needs a button each way; a pneumatic or a flywheel is toggled or preset).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:237.
[[nodiscard]] constexpr Control whileHeld(const Arm& m, hal::ControllerButton up, hal::ControllerButton down, units::Voltage volts) noexceptWHILE HELD on an ARM: up held = +volts (a jog), down held = −volts, let go = HOLD HERE.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:242.
[[nodiscard]] constexpr Control whileHeld(const Lift& m, hal::ControllerButton up, hal::ControllerButton down, units::Voltage volts) noexceptWHILE HELD on a LIFT: as on an arm.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:249.
template <class D> consteval Control whileHeld(const D&, hal::ControllerButton, hal::ControllerButton, units::Voltage)whileHeld(hood, ...) / whileHeld(flywheel, ...): refused BY NAME (use toggle or preset).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:258.
[[nodiscard]] constexpr Control toggle(const Pneumatic& m, hal::ControllerButton b) noexceptEach SEEN press flips a TWO-position pneumatic.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:263.
[[nodiscard]] constexpr Control toggle(SpeedGoal g, hal::ControllerButton b) noexceptEach SEEN press spins a flywheel up to THE NAMED SPEED, or stops it: toggle(flywheel["shoot"], Button::X) (re-check 2026-10-07: "its first preset" changed silently when presets were reordered).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:269.
template <class D> consteval Control toggle(const D&, hal::ControllerButton)toggle(flywheel, X): refused BY NAME — name the speed (n51).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:276.
template <class D> consteval Control toggle(const D&, hal::ControllerButton)toggle(intake, X) / toggle(arm, X): refused BY NAME.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:283.
[[nodiscard]] constexpr Control preset(PositionGoal g, hal::ControllerButton b, units::Time bound) noexceptA SEEN press sends an arm or a lift to g (arm["score"], arm.to(95), lift.to(18_in)) within bound, then it holds there.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:289.
[[nodiscard]] constexpr Control preset(SpeedGoal g, hal::ControllerButton b, units::Time bound) noexceptA SEEN press spins a flywheel up to g (flywheel["shoot"], flywheel.at(3000)) within bound (its "at speed" verdict); it keeps spinning.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:296.
[[nodiscard]] constexpr Control preset(PneumaticGoal g, hal::ControllerButton b) noexceptA SEEN press puts a pneumatic in position g (claw["open"]) — no time limit: its move time is the robot file's.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:303.
[[nodiscard]] constexpr Control homeOnPress(const Arm& m, hal::ControllerButton b, units::Time bound) noexceptA SEEN press homes an ARM by its declaration's method, within bound.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:309.
[[nodiscard]] constexpr Control homeOnPress(const Lift& m, hal::ControllerButton b, units::Time bound) noexceptA SEEN press homes a LIFT by its declaration's method, within bound.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:314.
[[nodiscard]] constexpr Control homeAtDriverStart(const Arm& m, units::Time bound) noexceptONCE at driver-control entry, an ARM nothing has homed is homed, within bound.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:319.
[[nodiscard]] constexpr Control homeAtDriverStart(const Lift& m, units::Time bound) noexceptONCE at driver-control entry, a LIFT nothing has homed is homed, within bound.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:324.
template <class D> consteval Control homeOnPress(const D&, hal::ControllerButton, units::Time)homeOnPress(intake, ...): refused BY NAME — only an arm or a lift homes.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:331.
template <class D> consteval Control homeAtDriverStart(const D&, units::Time)homeAtDriverStart(intake, ...): refused BY NAME — only an arm or a lift homes.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:338.
template <class Declared> [[nodiscard]] constexpr Control autonOnly(const Declared& m) noexceptNO driver control, on purpose (Q8): autonOnly(hood).
free function, declared at include/shulib/mechanism/driver_inputs.hpp:345.
struct DriverControlsA driver file's controls, checked (controls(...)).
struct, declared at include/shulib/mechanism/driver_inputs.hpp:385.
static constexpr std::size_t kCap = 24The most controls one driver file holds.
field, declared at include/shulib/mechanism/driver_inputs.hpp:387.
Control c[kCap]{}The controls, in the order written.
field, declared at include/shulib/mechanism/driver_inputs.hpp:389.
std::uint8_t count = 0How many are real.
field, declared at include/shulib/mechanism/driver_inputs.hpp:391.
[[nodiscard]] constexpr std::span<const Control> all() const noexceptThe controls as a span.
function, declared at include/shulib/mechanism/driver_inputs.hpp:393.
[[nodiscard]] constexpr bool avoids(hal::ControllerButton b) const noexceptNo control takes b — the driver loop's reserved button (its re-zero).
function, declared at include/shulib/mechanism/driver_inputs.hpp:397.
template <class... C> [[nodiscard]] consteval DriverControls controls(const MechanismTable& robot, C... list)THE DRIVER FILE'S ONE LIST (file header), checked AT BUILD against the robot's list robot, each rule refused BY NAME (refused::): every control names a mechanism this robot has; no button does two jobs (the button named; a one-button hold takes its one); a hold's volts in (0, 12]; a preset's and a homing's time limit above 0 (a pneumatic preset states none); no two controls of one kind on one mechanism (a hold beside presets is fine — Q8; two presets are two kinds of one only when they aim at the same target); a toggle only on a two-position pneumatic or a flywheel's NAMED speed; a homing control only on a mechanism that homes; a switch- or stall-homed arm or lift preset only with a way to home it in driver control (homeAtDriverStart or homeOnPress), and held only with one of those or its .unhomedVolts (U5 — a jog moves it unhomed but never homes it); a never-homed one held only with .unhomedVolts, and never preset; every mechanism of the list has a control or is marked autonOnly (and then has none); at most DriverControls::kCap controls.
free function, declared at include/shulib/mechanism/driver_inputs.hpp:419.
class DriverInputsA driver file's controls at run time, bound to the robot's mechanism service (file header). Lives in the program's static storage beside the service; bind() once, at boot, after the service. Non-copyable and non-movable: the loop holds it by reference, and a copy would be a second set of button states commanding the same mechanisms.
class, declared at include/shulib/mechanism/driver_inputs.hpp:547.
static constexpr std::size_t kCap = DriverControls::kCapThe most controls (DriverControls::kCap).
field, declared at include/shulib/mechanism/driver_inputs.hpp:550.
DriverInputs() = defaultUnbound: it commands nothing until bind().
function, declared at include/shulib/mechanism/driver_inputs.hpp:553.
DriverInputs(const DriverInputs&) = deleteUnbound: it commands nothing until bind(). Non-copyable (the class's reason).
function, declared at include/shulib/mechanism/driver_inputs.hpp:555.
DriverInputs& operator=(const DriverInputs&) = deleteUnbound: it commands nothing until bind(). Non-copyable (the class's reason). Non-copy-assignable (the class's reason).
function, declared at include/shulib/mechanism/driver_inputs.hpp:557.
DriverInputs(DriverInputs&&) = deleteUnbound: it commands nothing until bind(). Non-copyable (the class's reason). Non-copy-assignable (the class's reason). Non-movable (the class's reason).
function, declared at include/shulib/mechanism/driver_inputs.hpp:559.
DriverInputs& operator=(DriverInputs&&) = deleteUnbound: it commands nothing until bind(). Non-copyable (the class's reason). Non-copy-assignable (the class's reason). Non-movable (the class's reason). Non-move-assignable (the class's reason).
function, declared at include/shulib/mechanism/driver_inputs.hpp:561.
~DriverInputs() = defaultUnbound: it commands nothing until bind(). Non-copyable (the class's reason). Non-copy-assignable (the class's reason). Non-movable (the class's reason). Non-move-assignable (the class's reason). Nothing to release: the service owns every claim.
function, declared at include/shulib/mechanism/driver_inputs.hpp:563.
void bind(MechanismService& svc, const DriverControls& controls)BIND, once, at boot, after svc is bound: each control resolved to its slot by the declaration's NAME. controls is BORROWED (static storage: a driver file's inline constexpr). A control on a mechanism that is ABSENT this boot still binds — it commands a slot that does nothing (the drive runs). PRECONDITIONS (the controls were checked against ONE robot's list at build; these check them against the robot the SERVICE is bound to, so a driver file built for another robot never commands a stranger): not bound yet; svc bound; every control but an autonOnly names a mechanism the service has, of the control's kind and units; a toggle's pneumatic has two positions; a named preset (or a flywheel toggle's named speed) is this mechanism's, at the same value; a constant target is inside its travel limits or free speed; a pneumatic preset's position is this mechanism's, by name; a homing control's mechanism homes.
function, declared at include/shulib/mechanism/driver_inputs.hpp:575.
[[nodiscard]] bool avoids(hal::ControllerButton b) const noexceptNo control takes b — the loop's re-zero button. True when unbound.
function, declared at include/shulib/mechanism/driver_inputs.hpp:604.
[[nodiscard]] bool bound() const noexceptTrue once bind() has run.
function, declared at include/shulib/mechanism/driver_inputs.hpp:608.
[[nodiscard]] bool boundTo(const MechanismService& svc) const noexceptTrue when bind() bound it to svc — the loop's check that its inputs command the service it ticks.
function, declared at include/shulib/mechanism/driver_inputs.hpp:611.
void enter()DRIVER-CONTROL ENTRY (after the service's enterDriverControl()): every hold released; every toggle's, preset's and homeOnPress's button counted as HELD (a press must be SEEN — one already down on the entry tick does nothing until released and pressed again; a hold's button is a level, and down at entry it drives at once — file header); then each homeAtDriverStart homes its mechanism when nothing has homed it (skipped when homed — by the auton, at boot, or an earlier entry), and while that home runs the mechanism's own controls wait (file header). PRECONDITION: bound.
function, declared at include/shulib/mechanism/driver_inputs.hpp:620.
void tick(const hal::IController& c, bool connected)ONE DRIVER TICK: read every control's buttons (only while connected) and command the service (file header) — the service ticks right after (teleop_loop.hpp). PRECONDITION: bound.
function, declared at include/shulib/mechanism/driver_inputs.hpp:641.
using mechanism::DriverControlsA driver file's checked list of controls.
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:825.
using mechanism::controlsThe list itself: controls(kRobotXMechanisms, ...).
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:827.
using mechanism::whileHeldHold-to-run: two buttons ± volts while held, or one button + volts on a power mechanism (oneWay).
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:829.
using mechanism::toggleOne button flips a two-position pneumatic, or a flywheel's named speed on / off.
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:831.
using mechanism::presetOne button: a preset, a constant, a speed or a pneumatic position.
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:833.
using mechanism::homeOnPressOne button homes an arm or a lift.
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:835.
using mechanism::homeAtDriverStartAn arm or a lift nothing homed is homed once at driver-control start.
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:837.
using mechanism::autonOnlyNo driver control, on purpose.
type alias, declared at include/shulib/mechanism/driver_inputs.hpp:839.
The header opens with the reasoning behind these shapes. It is reproduced here in full because a reference that only lists signatures teaches nobody why.
The header’s own reasoning — 78 lines, click to expand
mechanism/driver_inputs.hpp — THE DRIVER FILE'S MECHANISM CONTROLS: hold-to-run, toggle, preset and
the homing controls, each naming its mechanism by its DECLARATION, checked at build against the
robot's list, and run THROUGH the mechanism service (the mechanism core, chunk MECH-A4, 2026-10-22).
── What a driver file writes ────────────────────────────────────────────────────────
ONE list, checked AT BUILD (consteval controls(...): every rule below is made there, so the file
carries no static_assert of its own):
inline constexpr DriverControls kControls = controls(kRobotXMechanisms,
whileHeld(arm, Button::R1, Button::R2, 6_volt), // up / down while held; let go: it holds there
preset(arm["score"], Button::Right, 1.5_s), // the most recent button wins
whileHeld(lift, Button::L1, Button::L2, 12_volt),
homeAtDriverStart(lift, 1.5_s), // after a restart it may not be on its switch
toggle(flywheel["shoot"], Button::X), // on at "shoot" / off
whileHeld(intake, Button::A, Button::B, 12_volt),
whileHeld(sideRoller, Button::Up, 8_volt), // ONE button: runs one way while held, stops on release
autonOnly(hood)); // the hood is the autons' alone
── What each control does (DriverInputs::tick, once per driver-control tick) ──────────
* whileHeld on a POWER mechanism: held → drive(±V) every tick; released → stop (its safe state).
With ONE button (`whileHeld(sideRoller, Button::Up, 8_volt)`, chunk ROB1-C2): held → drive(+V),
released → stop — it runs ONE way only (which way is its declaration's `.motors` direction), and
takes no second button. A POWER mechanism only (an arm's or a lift's jog needs both ways).
On an ARM or a LIFT: held → jog(±V) (soft-stopped at the limits once homed; at most
`.unhomedVolts` before); released → HOLD HERE (gravity included, clamped to the range). Both
buttons held = neither (T3's ruling R2): the release rule.
* toggle: a SEEN press flips a two-position pneumatic, or spins a flywheel up to the NAMED speed
(`toggle(flywheel["shoot"], X)`) / stops it. A flywheel toggle's step is bounded by
kToggleAtSpeedWindowSeconds — only its logged "at speed" verdict: the wheel keeps spinning.
* preset: a SEEN press sends the mechanism to a preset or a constant (`arm["score"]`,
`lift.to(18_in)`, `flywheel["shoot"]`, `claw["open"]`) within its time limit; then it holds or
keeps spinning. A pneumatic position states no time limit (its move time is the robot file's).
* homeOnPress: a SEEN press homes it by its declaration's method, bounded. homeAtDriverStart:
ONCE at driver-control entry, when nothing has homed it (a restart can leave a switch- or
stall-homed mechanism off its home: its buttons would be dead — the brief's U5). WHILE THAT
HOME RUNS, the mechanism's own holds, presets and homing press WAIT (the exception below).
* autonOnly: no driver control, on purpose (Q8) — the build's "every mechanism has a control"
rule then passes it.
── THE MOST RECENT INPUT WINS (the team lead's Q8 (a)) ─────────────────────────────────
Arbitration is by the service slot's COMMAND NUMBER (Slot::commandSeq(), bumped by every command
and by a stall that ends a behaviour after its step). A hold-to-run that sees a number it did not
write has been SUPERSEDED — by a preset, a toggle, another control, an auton leftover, a stall —
and commands NOTHING until its buttons are seen released while connected (T3's "an outside stop
is never undone by a finger that never left the button", generalized).
A PRESS MUST BE SEEN — for a toggle, a preset and a homeOnPress: at entry its button counts as
held (one already down on the entry tick does nothing until it is released and pressed again),
and so does its button while the controller is disconnected (a drop is never a press, and a
reconnect with the button still down is not one either). A HOLD is a level, not a press (T3's
rule for a hold binding): its button already down on the entry tick drives at once, and a
disconnect releases it that tick. So a disconnect is a release for the holds, never a press for
the rest. All of it rests on one unmeasured belief, T3's ToggleBinding's too: the controller's
connected flag and its button levels come back TOGETHER (A4 register HA-147, invented) — the
first connected tick's level is taken as live, so a stale "up" read on it while the driver still
holds the button would make the next live "down" a press nobody made.
THE ONE EXCEPTION — the driver-start home (U5). While a homeAtDriverStart home is running, that
mechanism's OWN controls wait: a hold held during it is SUPERSEDED (nothing until its buttons are
seen released after the home ends), and a preset's or a homeOnPress's press is consumed and
dropped. Without it, a driver touching the lift in the home's first 1.5 s would CANCEL the home
("replaced by a newer command") and leave the lift unhomed — every preset NOT_HOMED and every
hold at `.unhomedVolts` (0: nothing) for the rest of the match, the dead buttons U5 exists to
prevent. Waiting costs at most the home's own time limit. Other mechanisms' controls never wait.
── Where it runs ───────────────────────────────────────────────────────────────────
teleop::runDriverControl's service overload (teleop/teleop_loop.hpp) calls enter() at loop entry
(after the service's enterDriverControl()) and tick() each tick after the T3 bindings' place and
BEFORE the service's tickFromDriverLoop() — so a press read at tick k is commanded AND ticked in
tick k — and before the loop's perTick.
── Static storage ──────────────────────────────────────────────────────────────────
A program keeps its DriverInputs in static storage beside its service, like T3's bindings: PROS
deletes the driver task on a mode change (HA-161) and a deleted task runs no destructor. bind()
once, at boot, AFTER the service is bound.
PROS-free, allocation-free. Nothing here has run on a robot.