Skip to content

Commit 22b9ccd

Browse files
committed
Add writeHIDReport with using ReportBeforeUnion
1 parent bffda3d commit 22b9ccd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/XboxSeriesXControllerESP32_asukiaaa.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <NimBLEDevice.h>
44
#include <XboxControllerNotificationParser.h>
5+
56
#include <XboxSeriesXHIDReportBuilder_asukiaaa.hpp>
67

78
// #define XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL Serial
@@ -171,11 +172,16 @@ class Core {
171172
}
172173
NimBLEClient* pClient = pConnectedClient;
173174
auto pService = pClient->getService(uuidServiceHid);
175+
#ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
176+
XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println(pService->toString().c_str());
177+
#endif
174178
for (auto pChara : *pService->getCharacteristics()) {
175179
if (pChara->canWrite()) {
176180
#ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
177181
XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println(
178182
"canWrite " + String(pChara->canWrite()));
183+
XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println(
184+
pChara->toString().c_str());
179185
writeWithComment(pChara, dataArr, dataLen);
180186
#else
181187
pChara->writeValue(dataArr, dataLen, false);
@@ -189,6 +195,14 @@ class Core {
189195
writeHIDReport((uint8_t*)repo.arr8t, repo.arr8tLen);
190196
}
191197

198+
void writeHIDReport(
199+
const XboxSeriesXHIDReportBuilder_asukiaaa::ReportBeforeUnion&
200+
repoBeforeUnion) {
201+
XboxSeriesXHIDReportBuilder_asukiaaa::ReportBase repo;
202+
repo.v = repoBeforeUnion;
203+
writeHIDReport((uint8_t*)repo.arr8t, repo.arr8tLen);
204+
}
205+
192206
void onLoop() {
193207
if (!isConnected()) {
194208
if (advDevice != nullptr) {
@@ -235,8 +249,6 @@ class Core {
235249
}
236250

237251
XboxControllerNotificationParser xboxNotif;
238-
const size_t notifByteLen = XboxControllerNotificationParser::expectedDataLen;
239-
uint8_t notifByteArr[XboxControllerNotificationParser::expectedDataLen];
240252

241253
bool isWaitingForFirstNotification() {
242254
return connectionState == ConnectionState::WaitingForFirstNotification;
@@ -495,8 +507,6 @@ class Core {
495507
XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println("");
496508
#endif
497509
xboxNotif.update(pData, length);
498-
memcpy(notifByteArr, pData,
499-
length < notifByteLen ? length : notifByteLen);
500510
receivedNotificationAt = millis();
501511
#ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
502512
// XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.print(xboxNotif.toString());

0 commit comments

Comments
 (0)