USB Host Shield 2.0
Loading...
Searching...
No Matches
PS5Trigger.h
Go to the documentation of this file.
1
33#ifndef _ps5trigger_h_
34#define _ps5trigger_h_
35
36#include <inttypes.h>
37
39private:
40 // Type of trigger effect
41 typedef enum _EffectType : uint8_t {
42 NoResitance = 0x00, // No resistance is applied
43 ContinuousResitance = 0x01, // Continuous Resitance is applied
44 SectionResitance = 0x02, // Seciton resistance is appleyed
45 EffectEx = 0x26, // Extended trigger effect
46 Calibrate = 0xFC, // Calibrate triggers
47 } EffectType;
48
49 // Trigger effect
50 typedef struct _EffectData {
51 // Trigger effect type
52 EffectType effectType;
53
54 // Union for effect parameters
55 union {
56 // Union one raw data
57 uint8_t _u1_raw[6];
58
59 // For type == ContinuousResitance
60 struct {
61 uint8_t startPosition; // Start position of resistance
62 uint8_t force; // Force of resistance
63 uint8_t _pad[4]; // PAD / UNUSED
64 } __attribute__((packed)) Continuous;
65
66 // For type == SectionResitance
67 struct {
68 uint8_t startPosition; // Start position of resistance
69 uint8_t endPosition; // End position of resistance (>= start)
70 uint8_t _pad[4]; // PAD / UNUSED
71 } __attribute__((packed)) Section;
72
73 // For type == EffectEx
74 struct {
75 uint8_t startPosition; // Position at witch the effect starts
76 bool keepEffect; // Wher the effect should keep playing when trigger goes beyond 255
77 uint8_t beginForce; // Force applied when trigger >= (255 / 2)
78 uint8_t middleForce; // Force applied when trigger <= (255 / 2)
79 uint8_t endForce; // Force applied when trigger is beyond 255
80 uint8_t frequency; // Vibration frequency of the trigger
81 } __attribute__((packed)) EffectEx;
83 } __attribute__((packed)) EffectData;
84
85 EffectData data;
86
87public:
88 bool reportChanged = false;
89
96
100 void Reset() {
101 data.effectType = EffectType::NoResitance;
102
103 reportChanged = false;
104 };
105
110 data.effectType = EffectType::NoResitance;
111
112 reportChanged = true;
113 };
114
121 if (force == 0)
122 data.effectType = EffectType::NoResitance;
123 else {
124 data.effectType = EffectType::ContinuousResitance;
125 data.Continuous.startPosition = start;
126 data.Continuous.force = force;
127 }
128
129 reportChanged = true;
130 };
131
138 data.effectType = EffectType::SectionResitance;
139 data.Section.startPosition = start;
140 data.Section.endPosition = end;
141
142 reportChanged = true;
143 };
144
155 data.effectType = EffectType::EffectEx;
156 data.EffectEx.startPosition = start;
157 data.EffectEx.keepEffect = keep;
158 data.EffectEx.beginForce = begin_force;
159 data.EffectEx.middleForce = mid_force;
160 data.EffectEx.endForce = end_force;
161 data.EffectEx.frequency = frequency;
162
163 reportChanged = true;
164 };
165
166};
167
168#endif
void setTriggerForce(uint8_t start, uint8_t force)
Definition PS5Trigger.h:120
void clearTriggerForce()
Definition PS5Trigger.h:109
void processTrigger(uint8_t *buffer)
Apply the trigger data to a PS5 update buffer.
void setTriggerForceSection(uint8_t start, uint8_t end)
Definition PS5Trigger.h:137
void setTriggerForceEffect(uint8_t start, bool keep, uint8_t begin_force, uint8_t mid_force, uint8_t end_force, uint8_t frequency)
Definition PS5Trigger.h:154
void Reset()
Definition PS5Trigger.h:100
bool reportChanged
Definition PS5Trigger.h:88