From 4651acd2c66e1dc506d0e9deca6bba82287eba69 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sun, 9 May 2021 21:06:22 +0200 Subject: [PATCH] Fixed "error: variable-sized object buf may not be initialized" warning --- SwitchProUSB.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SwitchProUSB.h b/SwitchProUSB.h index 99ee7d05..43fdadfb 100644 --- a/SwitchProUSB.h +++ b/SwitchProUSB.h @@ -89,15 +89,26 @@ protected: setLedOn(LED1); // Turn on the LED1 setLedHomeOn(); // Turn on the home LED } - }; + } return 0; }; /**@}*/ /** @name SwitchProParser implementation */ virtual void sendOutputReport(uint8_t *data, uint8_t len) { + // Based on: https://github.com/Dan611/hid-procon // The first 8 bytes are always the same. The actual report follows - uint8_t buf[8 + len] = { 0x80 /* PROCON_REPORT_SEND_USB */, 0x92 /*PROCON_USB_DO_CMD */, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00 }; + uint8_t buf[8 + len]; + buf[0] = 0x80; // PROCON_REPORT_SEND_USB + buf[1] = 0x92; // PROCON_USB_DO_CMD + buf[2] = 0x00; + buf[3] = 0x31; + buf[4] = 0x00; + buf[5] = 0x00; + buf[6] = 0x00; + buf[7] = 0x00; + + // Cope over the report memcpy(buf + 8, data, len); // Endpoint (control endpoint), Interface (0x00), Report Type (Output 0x02), Report ID (0x80), nbytes, data