USB Host Shield 2.0
PS5Trigger.cpp
Go to the documentation of this file.
1 
32 #include "PS5Trigger.h"
33 
34 void PS5Trigger::processTrigger(uint8_t* buffer) {
35  // Switch on effect
36  switch (data.effectType) {
37  // Continious
38  case EffectType::ContinuousResitance:
39  // Mode
40  buffer[0x00] = 0x01;
41  // Parameters
42  buffer[0x01] = data.Continuous.startPosition;
43  buffer[0x02] = data.Continuous.force;
44 
45  break;
46 
47  // Section
48  case EffectType::SectionResitance:
49  // Mode
50  buffer[0x00] = 0x02;
51  // Parameters
52  buffer[0x01] = data.Section.startPosition;
53  buffer[0x02] = data.Section.endPosition;
54 
55  break;
56 
57  // EffectEx
58  case EffectType::EffectEx:
59  // Mode
60  buffer[0x00] = 0x02 | 0x20 | 0x04;
61  // Parameters
62  buffer[0x01] = 0xFF - data.EffectEx.startPosition;
63  // Keep flag
64  if (data.EffectEx.keepEffect)
65  buffer[0x02] = 0x02;
66  // Forces
67  buffer[0x04] = data.EffectEx.beginForce;
68  buffer[0x05] = data.EffectEx.middleForce;
69  buffer[0x06] = data.EffectEx.endForce;
70  // Frequency
71  buffer[0x09] = data.EffectEx.frequency / 2;
72  if(buffer[0x09] < 1) buffer[0x09] = 1; // minimum frequency
73 
74  break;
75 
76  // Calibrate
77  case EffectType::Calibrate:
78  // Mode
79  buffer[0x00] = 0xFC;
80 
81  break;
82 
83  // No resistance / default
84  case EffectType::NoResitance:
85  default:
86  // All zero
87  buffer[0x00] = 0x00;
88  buffer[0x01] = 0x00;
89  buffer[0x02] = 0x00;
90 
91  break;
92  }
93  reportChanged = false;
94 }
PS5Trigger::reportChanged
bool reportChanged
Definition: PS5Trigger.h:88
PS5Trigger::processTrigger
void processTrigger(uint8_t *buffer)
Apply the trigger data to a PS5 update buffer.
Definition: PS5Trigger.cpp:34
PS5Trigger.h
Based on Ludwig F├╝chsl's DualSense Windows driver https://github.com/Ohjurot/DualSense-Windows.