mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Added functions for detecting button press and release events (#626)
I also shuffled around the HID interfaces to be more intuitive, deprecated some Joystick and XboxController member functions, and deprecated the JoystickBase and GamepadBase classes. Supersedes #89.
This commit is contained in:
committed by
Peter Johnson
parent
c33fca34e9
commit
21585f70a8
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -38,10 +39,13 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
|
||||
static const int kJoystickPorts = 6;
|
||||
|
||||
bool GetStickButton(int stick, int button);
|
||||
bool GetStickButtonPressed(int stick, int button);
|
||||
bool GetStickButtonReleased(int stick, int button);
|
||||
|
||||
double GetStickAxis(int stick, int axis);
|
||||
int GetStickPOV(int stick, int pov);
|
||||
int GetStickButtons(int stick) const;
|
||||
bool GetStickButton(int stick, int button);
|
||||
|
||||
int GetStickAxisCount(int stick) const;
|
||||
int GetStickPOVCount(int stick) const;
|
||||
@@ -112,6 +116,10 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
std::unique_ptr<HAL_JoystickButtons[]> m_joystickButtonsCache;
|
||||
std::unique_ptr<HAL_JoystickDescriptor[]> m_joystickDescriptorCache;
|
||||
|
||||
// Joystick button rising/falling edge flags
|
||||
std::array<uint32_t, kJoystickPorts> m_joystickButtonsPressed;
|
||||
std::array<uint32_t, kJoystickPorts> m_joystickButtonsReleased;
|
||||
|
||||
// Internal Driver Station thread
|
||||
std::thread m_dsThread;
|
||||
std::atomic<bool> m_isRunning{false};
|
||||
|
||||
Reference in New Issue
Block a user