blob: 56fc6b5ae90e735fd0326c51b9de7289fd6dbf33 [file] [log] [blame]
Ravago Jones8c65c432023-03-25 17:35:39 -07001#ifndef AOS_INPUT_REDUNDANT_JOYSTICK_DATA_H_
2#define AOS_INPUT_REDUNDANT_JOYSTICK_DATA_H_
3
4#include "frc971/input/driver_station_data.h"
5
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08006namespace frc971::input::driver_station {
Ravago Jones8c65c432023-03-25 17:35:39 -07007
8// A class to wrap driver_station::Data and map logical joystick numbers to
9// their actual numbers in the order they are on the driverstation.
10//
11// Bits 13 and 14 of the joystick bitmap are defined to be a two bit number
12// corresponding to the joystick's logical joystick number.
13class RedundantData : public Data {
14 public:
15 RedundantData(const Data &data);
16
17 bool IsPressed(POVLocation location) const override;
18 bool PosEdge(POVLocation location) const override;
19 bool NegEdge(POVLocation location) const override;
20
21 // Returns the current and previous "values" for the POV.
22 int32_t GetPOV(int joystick) const override;
23 int32_t GetOldPOV(int joystick) const override;
24
25 bool IsPressed(ButtonLocation location) const override;
26 bool PosEdge(ButtonLocation location) const override;
27 bool NegEdge(ButtonLocation location) const override;
28
29 bool GetControlBit(ControlBit bit) const override;
30 bool PosEdge(ControlBit bit) const override;
31 bool NegEdge(ControlBit bit) const override;
32
33 // Returns the value in the range [-1.0, 1.0].
34 float GetAxis(JoystickAxis axis) const override;
35
36 private:
37 static constexpr int kIdBit0Button = 14;
38 static constexpr int kIdBit1Button = 15;
39 static constexpr int kRedundantBitButton = 16;
40
41 int MapRedundantJoystick(int joystick) const;
42
43 // A mapping from logical joystick numbers to their actual order on the
44 // driverstation.
45 //
46 // Index is logical joystick number, Value is mapped joystick number.
47 std::array<int, JoystickFeature::kJoysticks> joystick_map_;
48
49 const Data &data_;
50};
51
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080052} // namespace frc971::input::driver_station
Ravago Jones8c65c432023-03-25 17:35:39 -070053
54#endif // AOS_INPUT_REDUNDANT_JOYSTICK_DATA_H_