WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
CommandJoystick.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
10
11namespace wpi::cmd {
12/**
13 * A version of {@link wpi::Joystick} with {@link Trigger} factories for
14 * command-based.
15 *
16 * @see wpi::Joystick
17 */
19 public:
20 /**
21 * Construct an instance of a controller.
22 *
23 * @param port The port index on the Driver Station that the controller is
24 * plugged into.
25 */
26 explicit CommandJoystick(int port);
27
28 /**
29 * Get the underlying GenericHID object.
30 *
31 * @return the wrapped GenericHID object
32 */
34
35 /**
36 * Constructs an event instance around the trigger button's digital signal.
37 *
38 * @param loop the event loop instance to attach the event to. Defaults to the
39 * CommandScheduler's default loop.
40 * @return an event instance representing the trigger button's digital signal
41 * attached to the given loop.
42 */
45 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
46
47 /**
48 * Constructs an event instance around the top button's digital signal.
49 *
50 * @param loop the event loop instance to attach the event to. Defaults to the
51 * CommandScheduler's default loop.
52 * @return an event instance representing the top button's digital signal
53 * attached to the given loop.
54 */
55 class Trigger Top(wpi::EventLoop* loop = CommandScheduler::GetInstance()
56 .GetDefaultButtonLoop()) const;
57 /**
58 * Get the magnitude of the vector formed by the joystick's
59 * current position relative to its origin.
60 *
61 * @return The magnitude of the direction vector
62 */
63 double GetMagnitude() const;
64
65 /**
66 * Get the direction of the vector formed by the joystick and its origin. 0 is
67 * forward and clockwise is positive. (Straight right is π/2 radians or 90
68 * degrees.)
69 *
70 * @return The direction of the vector.
71 */
72 wpi::units::radian_t GetDirection() const;
73
74 private:
75 wpi::Joystick m_hid;
76};
77} // namespace wpi::cmd
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.hpp:15
Handle input from standard Joysticks connected to the Driver Station.
Definition Joystick.hpp:22
CommandGenericHID(int port)
Construct an instance of a device.
wpi::Joystick & GetHID()
Get the underlying GenericHID object.
class Trigger Top(wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the top button's digital signal.
double GetMagnitude() const
Get the magnitude of the vector formed by the joystick's current position relative to its origin.
class Trigger Trigger(wpi::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs an event instance around the trigger button's digital signal.
CommandJoystick(int port)
Construct an instance of a controller.
wpi::units::radian_t GetDirection() const
Get the direction of the vector formed by the joystick and its origin.
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
Definition CommandNiDsStadiaController.hpp:15
Definition CvSource.hpp:15