Added functionality to send back HID button presses to host

pull/25/head
Simon Kueppers 2023-05-21 13:56:14 +02:00
rodzic 8345f991ec
commit 43cd92f3bb
2 zmienionych plików z 20 dodań i 3 usunięć

Wyświetl plik

@ -6,23 +6,24 @@
#define USB_HID_INOUT_REPORT_LEN 4
static uint8_t buttonState = 0x00;
static uint8_t gpioState = 0x00;
static void MakeReport(uint8_t * buffer)
{
/* TODO: Read the actual states of the GPIO input hardware pins. */
buffer[0] = 0x00;
buffer[0] = buttonState & 0x0F;
buffer[1] = gpioState;
buffer[2] = 0x00;
buffer[3] = 0x00;
}
static void SendReport(void)
static bool SendReport(void)
{
uint8_t reportBuffer[USB_HID_INOUT_REPORT_LEN];
MakeReport(reportBuffer);
tud_hid_report(0, reportBuffer, sizeof(reportBuffer));
return tud_hid_report(0, reportBuffer, sizeof(reportBuffer));
}
static void ControlPTT(uint8_t gpio)
@ -160,3 +161,10 @@ void USB_HIDInit(void)
}
bool USB_HIDSendButtonState(uint8_t buttonMask)
{
buttonState = buttonMask;
return SendReport();
}

Wyświetl plik

@ -1,6 +1,15 @@
#ifndef USB_HID_H_
#define USB_HID_H_
#include <stdint.h>
#include <stdbool.h>
#define USB_HID_BUTTON_VOLUP 0x01
#define USB_HID_BUTTON_VOLDN 0x02
#define USB_HID_BUTTON_PLAYMUTE 0x04
#define USB_HID_BUTTON_RECMUTE 0x08
void USB_HIDInit(void);
bool USB_HIDSendButtonState(uint8_t inputsMask);
#endif /* USB_HID_H_ */