driver/KeyboardioHID: make cpplint happy

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
f/driver/keyboardiohid-orig
Gergely Nagy 4 years ago committed by Jesse Vincent
parent ada56fe6b9
commit 2c4a274cb3
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -137,11 +137,11 @@ bool BootKeyboard_::setup(USBSetup& setup) {
if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE) {
if (request == HID_GET_REPORT) {
// TODO: HID_GetReport();
// TODO(anyone): HID_GetReport();
return true;
}
if (request == HID_GET_PROTOCOL) {
// TODO improve
// TODO(anyone) improve
#ifdef __AVR__
UEDATX = protocol;
#endif
@ -151,7 +151,7 @@ bool BootKeyboard_::setup(USBSetup& setup) {
return true;
}
if (request == HID_GET_IDLE) {
// TODO improve
// TODO(anyone) improve
#ifdef __AVR__
UEDATX = idle;
#endif
@ -187,10 +187,8 @@ bool BootKeyboard_::setup(USBSetup& setup) {
USB_RecvControl(&leds, length);
return true;
}
}
// Input (set HID report)
else if (setup.wValueH == HID_REPORT_TYPE_INPUT) {
} else { // Input (set HID report)
if (setup.wValueH == HID_REPORT_TYPE_INPUT) {
if (length == sizeof(_keyReport)) {
USB_RecvControl(&_keyReport, length);
return true;
@ -198,6 +196,7 @@ bool BootKeyboard_::setup(USBSetup& setup) {
}
}
}
}
return false;
}

@ -132,15 +132,15 @@ bool HID_::setup(USBSetup& setup) {
if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE) {
if (request == HID_GET_REPORT) {
// TODO: HID_GetReport();
// TODO(anyone): HID_GetReport();
return true;
}
if (request == HID_GET_PROTOCOL) {
// TODO: Send8(protocol);
// TODO(anyone): Send8(protocol);
return true;
}
if (request == HID_GET_IDLE) {
// TODO: Send8(idle);
// TODO(anyone): Send8(idle);
}
}

@ -94,7 +94,7 @@ class HID_ : public PluggableUSBModule {
void AppendDescriptor(HIDSubDescriptor* node);
uint8_t getLEDs(void) {
return setReportData.leds;
};
}
protected:
// Implementation of the PluggableUSBModule

@ -124,24 +124,21 @@ int Keyboard_::sendReport(void) {
lastKeyReport.modifiers = keyReport.modifiers;
int returnCode = HID().SendReport(HID_REPORTID_NKRO_KEYBOARD, &lastKeyReport, sizeof(lastKeyReport));
lastKeyReport.modifiers = last_mods;
}
} else {
// If modifiers are being turned off, then we send the new report with the previous modifiers.
// We need to do this, at least on Linux 4.17 + Wayland.
// Jesse has observed that sending Shift + 3 key up events in the same report
// will sometimes result in a spurious '3' rather than '#', especially when the keys
// had been held for a while
else if (( (lastKeyReport.modifiers ^ keyReport.modifiers) & lastKeyReport.modifiers)
if (( (lastKeyReport.modifiers ^ keyReport.modifiers) & lastKeyReport.modifiers)
&& (memcmp(lastKeyReport.keys,keyReport.keys, sizeof(keyReport.keys)))) {
uint8_t mods = keyReport.modifiers;
keyReport.modifiers = lastKeyReport.modifiers;
int returnCode = HID().SendReport(HID_REPORTID_NKRO_KEYBOARD, &keyReport, sizeof(lastKeyReport));
keyReport.modifiers = mods;
}
}
int returnCode = sendReportUnchecked();
if (returnCode > 0)
@ -218,15 +215,14 @@ size_t Keyboard_::press(uint8_t k) {
uint8_t bit = 1 << (uint8_t(k) % 8);
keyReport.keys[k / 8] |= bit;
return 1;
}
// It's a modifier key
else if (k >= HID_KEYBOARD_FIRST_MODIFIER && k <= HID_KEYBOARD_LAST_MODIFIER) {
} else { // It's a modifier key
if (k >= HID_KEYBOARD_FIRST_MODIFIER && k <= HID_KEYBOARD_LAST_MODIFIER) {
// Convert key into bitfield (0 - 7)
k = k - HID_KEYBOARD_FIRST_MODIFIER;
keyReport.modifiers |= (1 << k);
return 1;
}
}
// No empty/pressed key was found
return 0;
@ -238,15 +234,14 @@ size_t Keyboard_::release(uint8_t k) {
uint8_t bit = 1 << (k % 8);
keyReport.keys[k / 8] &= ~bit;
return 1;
}
// It's a modifier key
else if (k >= HID_KEYBOARD_FIRST_MODIFIER && k <= HID_KEYBOARD_LAST_MODIFIER) {
} else { // It's a modifier key
if (k >= HID_KEYBOARD_FIRST_MODIFIER && k <= HID_KEYBOARD_LAST_MODIFIER) {
// Convert key into bitfield (0 - 7)
k = k - HID_KEYBOARD_FIRST_MODIFIER;
keyReport.modifiers &= ~(1 << k);
return 1;
}
}
// No empty/pressed key was found
return 0;

@ -64,7 +64,7 @@ class Keyboard_ {
uint8_t getLEDs() {
return HID().getLEDs();
};
}
HID_KeyboardReport_Data_t keyReport;
HID_KeyboardReport_Data_t lastKeyReport;

@ -27,7 +27,7 @@ THE SOFTWARE.
#include "../DescriptorPrimitives.h"
static const uint8_t _hidMultiReportDescriptorSystem[] PROGMEM = {
//TODO limit to system keys only?
//TODO(anyone): limit to system keys only?
/* System Control (Power Down, Sleep, Wakeup, ...) */
D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) */
D_USAGE, 0x80, /* USAGE (System Control) */

@ -84,11 +84,11 @@ bool SingleAbsoluteMouse_::setup(USBSetup& setup) {
if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE) {
if (request == HID_GET_REPORT) {
// TODO: HID_GetReport();
// TODO(anyone): HID_GetReport();
return true;
}
if (request == HID_GET_PROTOCOL) {
// TODO: Send8(protocol);
// TODO(anyone): Send8(protocol);
return true;
}
}

@ -48,6 +48,6 @@ class SingleAbsoluteMouse_ : public PluggableUSBModule, public AbsoluteMouseAPI
uint8_t protocol;
uint8_t idle;
virtual inline void sendReport(void* data, int length) override;
inline void sendReport(void* data, int length) override;
};
extern SingleAbsoluteMouse_ SingleAbsoluteMouse;

Loading…
Cancel
Save