mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[hal,wpilib] Add Touchpad support (#8401)
This commit is contained in:
@@ -186,10 +186,60 @@ struct JoystickButtons {
|
||||
uint8_t Count{0};
|
||||
};
|
||||
|
||||
struct TouchpadFinger {
|
||||
bool Down{false};
|
||||
uint16_t X{0};
|
||||
uint16_t Y{0};
|
||||
};
|
||||
|
||||
struct Touchpad {
|
||||
std::span<TouchpadFinger> Fingers() {
|
||||
return std::span{FingersStore.data(), GetFingerCount()};
|
||||
}
|
||||
|
||||
std::span<const TouchpadFinger> Fingers() const {
|
||||
return std::span{FingersStore.data(), GetFingerCount()};
|
||||
}
|
||||
|
||||
size_t GetFingerCount() const { return FingerCount; }
|
||||
|
||||
void SetFingerCount(uint8_t NewCount) {
|
||||
FingerCount =
|
||||
(std::min)(NewCount,
|
||||
static_cast<uint8_t>(MRC_MAX_NUM_TOUCHPAD_FINGERS));
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<TouchpadFinger, MRC_MAX_NUM_TOUCHPAD_FINGERS> FingersStore{};
|
||||
uint8_t FingerCount{0};
|
||||
};
|
||||
|
||||
struct JoystickTouchpads {
|
||||
std::span<Touchpad> Touchpads() {
|
||||
return std::span{TouchpadsStore.data(), GetTouchpadCount()};
|
||||
}
|
||||
|
||||
std::span<const Touchpad> Touchpads() const {
|
||||
return std::span{TouchpadsStore.data(), GetTouchpadCount()};
|
||||
}
|
||||
|
||||
size_t GetTouchpadCount() const { return TouchpadCount; }
|
||||
|
||||
void SetTouchpadCount(uint8_t NewCount) {
|
||||
TouchpadCount =
|
||||
(std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_TOUCHPADS));
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<Touchpad, MRC_MAX_NUM_TOUCHPADS> TouchpadsStore{};
|
||||
uint8_t TouchpadCount{0};
|
||||
};
|
||||
|
||||
struct Joystick {
|
||||
JoystickAxes Axes;
|
||||
JoystickPovs Povs;
|
||||
JoystickButtons Buttons;
|
||||
JoystickTouchpads Touchpads;
|
||||
};
|
||||
|
||||
struct ControlData {
|
||||
|
||||
@@ -66,3 +66,5 @@
|
||||
#define MRC_MAX_JOYSTICK_NAME_LEN 256
|
||||
#define MRC_MAX_VERSION_SIZE 256
|
||||
#define MRC_MAX_ERROR_INFO_STR_LEN 10000
|
||||
#define MRC_MAX_NUM_TOUCHPAD_FINGERS 2
|
||||
#define MRC_MAX_NUM_TOUCHPADS 2
|
||||
|
||||
@@ -4,6 +4,16 @@ package mrc.proto;
|
||||
|
||||
option java_package = "com.mrc.proto";
|
||||
|
||||
message ProtobufFingerData {
|
||||
uint32 X = 1;
|
||||
uint32 Y = 2;
|
||||
bool Down = 3;
|
||||
}
|
||||
|
||||
message ProtobufTouchpadData {
|
||||
repeated ProtobufFingerData Fingers = 1;
|
||||
}
|
||||
|
||||
message ProtobufJoystickData {
|
||||
uint64 AvailableButtons = 1;
|
||||
uint64 Buttons = 2;
|
||||
@@ -13,6 +23,7 @@ message ProtobufJoystickData {
|
||||
// We can fit 8 in here.
|
||||
uint32 POVCount = 5;
|
||||
uint32 POVs = 6;
|
||||
repeated ProtobufTouchpadData Touchpads = 7;
|
||||
}
|
||||
|
||||
message ProtobufControlData {
|
||||
|
||||
Reference in New Issue
Block a user