WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
CommandJoystick.h
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
6#include <frc/Joystick.h>
7
8#include "Trigger.h"
11
12namespace frc2 {
13/**
14 * A version of {@link frc::Joystick} with {@link Trigger} factories for
15 * command-based.
16 *
17 * @see frc::Joystick
18 */
20 public:
21 /**
22 * Construct an instance of a controller.
23 *
24 * @param port The port index on the Driver Station that the controller is
25 * plugged into.
26 */
27 explicit CommandJoystick(int port);
28
29 /**
30 * Get the underlying GenericHID object.
31 *
32 * @return the wrapped GenericHID object
33 */
35
36 /**
37 * Constructs an event instance around the trigger button's digital signal.
38 *
39 * @param loop the event loop instance to attach the event to. Defaults to the
40 * CommandScheduler's default loop.
41 * @return an event instance representing the trigger button's digital signal
42 * attached to the given loop.
43 */
45 frc::EventLoop* loop =
46 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
47
48 /**
49 * Constructs an event instance around the top button's digital signal.
50 *
51 * @param loop the event loop instance to attach the event to. Defaults to the
52 * CommandScheduler's default loop.
53 * @return an event instance representing the top button's digital signal
54 * attached to the given loop.
55 */
56 class Trigger Top(frc::EventLoop* loop = CommandScheduler::GetInstance()
57 .GetDefaultButtonLoop()) const;
58 /**
59 * Get the magnitude of the direction vector formed by the joystick's
60 * current position relative to its origin.
61 *
62 * @return The magnitude of the direction vector
63 */
64 double GetMagnitude() const;
65
66 /**
67 * Get the direction of the vector formed by the joystick and its origin.
68 *
69 * @return The direction of the vector.
70 */
71 units::radian_t GetDirection() const;
72
73 private:
74 frc::Joystick m_hid;
75};
76} // namespace frc2
A version of frc::GenericHID with Trigger factories for command-based.
Definition CommandGenericHID.h:19
A version of frc::Joystick with Trigger factories for command-based.
Definition CommandJoystick.h:19
class Trigger Top(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the top button's digital signal.
CommandJoystick(int port)
Construct an instance of a controller.
double GetMagnitude() const
Get the magnitude of the direction vector formed by the joystick's current position relative to its o...
units::radian_t GetDirection() const
Get the direction of the vector formed by the joystick and its origin.
frc::Joystick & GetHID()
Get the underlying GenericHID object.
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
This class provides an easy way to link commands to conditions.
Definition Trigger.h:32
Handle input from standard Joysticks connected to the Driver Station.
Definition Joystick.h:23
Definition FunctionalCommand.h:13
Definition CAN.h:11