This commit is contained in:
Nav
2023-01-14 03:03:22 +00:00
parent dfaac9e30f
commit e6f53b1afd
3 changed files with 4 additions and 8 deletions

View File

@@ -75,18 +75,18 @@ namespace Bloom::Usb
}
void HidInterface::write(std::vector<unsigned char>&& buffer) {
if (buffer.size() > this->getInputReportSize()) {
if (buffer.size() > this->inputReportSize) {
throw DeviceCommunicationFailure(
"Cannot send data via HID interface - data exceeds maximum packet size."
);
}
if (buffer.size() < this->getInputReportSize()) {
if (buffer.size() < this->inputReportSize) {
/*
* Every report we send via the USB HID interface should be of a fixed size.
* In the event of a report being too small, we just fill the buffer vector with 0.
*/
buffer.resize(this->getInputReportSize(), 0);
buffer.resize(this->inputReportSize, 0);
}
int transferred = 0;

View File

@@ -37,10 +37,6 @@ namespace Bloom::Usb
HidInterface(HidInterface&& other) = default;
HidInterface& operator = (HidInterface&& other) = default;
std::size_t getInputReportSize() const {
return this->inputReportSize;
}
/**
* Obtains a hid_device instance and claims the HID interface on the device.
*/