mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Adds ability to simulate joysticks and event info (#727)
Thanks @pjreiniger for the initiali implementation and work on this.
This commit is contained in:
committed by
Peter Johnson
parent
7007725d9f
commit
35d68d2a34
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
@@ -14,8 +15,12 @@
|
||||
#include "MockData/NotifyListenerVector.h"
|
||||
|
||||
namespace hal {
|
||||
struct JoystickOutputStore;
|
||||
struct MatchInfoDataStore;
|
||||
|
||||
class DriverStationData {
|
||||
public:
|
||||
DriverStationData();
|
||||
void ResetData();
|
||||
|
||||
int32_t RegisterEnabledCallback(HAL_NotifyCallback callback, void* param,
|
||||
@@ -75,6 +80,26 @@ class DriverStationData {
|
||||
double GetMatchTime();
|
||||
void SetMatchTime(double matchTime);
|
||||
|
||||
void GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes);
|
||||
void GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs);
|
||||
void GetJoystickButtons(int32_t joystickNum, HAL_JoystickButtons* buttons);
|
||||
void GetJoystickDescriptor(int32_t joystickNum,
|
||||
HAL_JoystickDescriptor* descriptor);
|
||||
void GetJoystickOutputs(int32_t joystickNum, int64_t* outputs,
|
||||
int32_t* leftRumble, int32_t* rightRumble);
|
||||
void GetMatchInfo(HAL_MatchInfo* info);
|
||||
void FreeMatchInfo(const HAL_MatchInfo* info);
|
||||
|
||||
void SetJoystickAxes(int32_t joystickNum, const HAL_JoystickAxes* axes);
|
||||
void SetJoystickPOVs(int32_t joystickNum, const HAL_JoystickPOVs* povs);
|
||||
void SetJoystickButtons(int32_t joystickNum,
|
||||
const HAL_JoystickButtons* buttons);
|
||||
void SetJoystickDescriptor(int32_t joystickNum,
|
||||
const HAL_JoystickDescriptor* descriptor);
|
||||
void SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
|
||||
int32_t leftRumble, int32_t rightRumble);
|
||||
void SetMatchInfo(const HAL_MatchInfo* info);
|
||||
|
||||
void NotifyNewData();
|
||||
|
||||
private:
|
||||
@@ -96,6 +121,17 @@ class DriverStationData {
|
||||
std::shared_ptr<NotifyListenerVector> m_allianceStationIdCallbacks = nullptr;
|
||||
std::atomic<double> m_matchTime{0.0};
|
||||
std::shared_ptr<NotifyListenerVector> m_matchTimeCallbacks = nullptr;
|
||||
|
||||
std::mutex m_joystickDataMutex;
|
||||
std::mutex m_matchInfoMutex;
|
||||
|
||||
std::unique_ptr<HAL_JoystickAxes[]> m_joystickAxes;
|
||||
std::unique_ptr<HAL_JoystickPOVs[]> m_joystickPOVs;
|
||||
std::unique_ptr<HAL_JoystickButtons[]> m_joystickButtons;
|
||||
|
||||
std::unique_ptr<JoystickOutputStore[]> m_joystickOutputs;
|
||||
std::unique_ptr<HAL_JoystickDescriptor[]> m_joystickDescriptor;
|
||||
std::unique_ptr<MatchInfoDataStore> m_matchInfo;
|
||||
};
|
||||
extern DriverStationData SimDriverStationData;
|
||||
} // namespace hal
|
||||
|
||||
Reference in New Issue
Block a user