-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUsbControllerDevice.cpp
More file actions
43 lines (37 loc) · 1011 Bytes
/
UsbControllerDevice.cpp
File metadata and controls
43 lines (37 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "UsbControllerDevice.h"
#include <stdint.h>
#include "tusb.h"
UsbControllerDevice::UsbControllerDevice() : mIsUsbConnected(false), mIsControllerConnected(false) {}
UsbControllerDevice::~UsbControllerDevice() {}
void UsbControllerDevice::updateUsbConnected(bool connected)
{
mIsUsbConnected = connected;
}
bool UsbControllerDevice::isUsbConnected()
{
return mIsUsbConnected;
}
void UsbControllerDevice::updateControllerConnected(bool connected)
{
if (connected != mIsControllerConnected)
{
updateAllReleased();
}
mIsControllerConnected = connected;
}
bool UsbControllerDevice::isControllerConnected()
{
return mIsControllerConnected;
}
bool UsbControllerDevice::sendReport(uint8_t instance, uint8_t report_id)
{
bool sent = false;
if (isUsbConnected())
{
uint8_t reportSize = getReportSize();
uint8_t reportBuffer[reportSize];
getReport(reportBuffer, reportSize);
sent = tud_hid_n_report(instance, report_id, reportBuffer, reportSize);
}
return sent;
}