summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-07-08 23:06:23 +0300
committerMaxim Devaev <[email protected]>2022-07-08 23:06:23 +0300
commitc840ea73068f855e1ebbf738f8ae9e62dde05286 (patch)
tree017b0817c2710b435496839d14f945e7b7418573
parente864aafcf7f9dea75582c1ebcbca5e8ac1a1ae26 (diff)
refactoring
-rw-r--r--hid/lib/drivers/keyboard.h4
-rw-r--r--hid/src/main.cpp20
-rw-r--r--hid/src/ps2/hid.h10
-rw-r--r--hid/src/usb/hid.h9
4 files changed, 22 insertions, 21 deletions
diff --git a/hid/lib/drivers/keyboard.h b/hid/lib/drivers/keyboard.h
index 841106be..fe724247 100644
--- a/hid/lib/drivers/keyboard.h
+++ b/hid/lib/drivers/keyboard.h
@@ -21,8 +21,8 @@
#pragma once
-typedef struct
-{
+
+typedef struct {
bool caps;
bool scroll;
bool num;
diff --git a/hid/src/main.cpp b/hid/src/main.cpp
index 7d575b54..a512b65b 100644
--- a/hid/src/main.cpp
+++ b/hid/src/main.cpp
@@ -284,29 +284,29 @@ static void _sendResponse(uint8_t code) {
response[2] = PROTO::OUTPUTS1::DYNAMIC;
# endif
if (_usb_kbd) {
- response[1] |= _usb_kbd->isOffline() ? PROTO::PONG::KEYBOARD_OFFLINE : 0;
+ response[1] |= (_usb_kbd->isOffline() ? PROTO::PONG::KEYBOARD_OFFLINE : 0);
KeyboardLedsState leds = _usb_kbd->getLeds();
- response[1] |= leds.caps ? PROTO::PONG::CAPS : 0;
- response[1] |= leds.num ? PROTO::PONG::NUM : 0;
- response[1] |= leds.scroll ? PROTO::PONG::SCROLL : 0;
+ response[1] |= (leds.caps ? PROTO::PONG::CAPS : 0);
+ response[1] |= (leds.num ? PROTO::PONG::NUM : 0);
+ response[1] |= (leds.scroll ? PROTO::PONG::SCROLL : 0);
response[2] |= PROTO::OUTPUTS1::KEYBOARD::USB;
} else if (_ps2_kbd) {
- response[1] |= _ps2_kbd->isOffline() ? PROTO::PONG::KEYBOARD_OFFLINE : 0;
+ response[1] |= (_ps2_kbd->isOffline() ? PROTO::PONG::KEYBOARD_OFFLINE : 0);
KeyboardLedsState leds = _usb_kbd->getLeds();
- response[1] |= leds.caps ? PROTO::PONG::CAPS : 0;
- response[1] |= leds.num ? PROTO::PONG::NUM : 0;
- response[1] |= leds.scroll ? PROTO::PONG::SCROLL : 0;
+ response[1] |= (leds.caps ? PROTO::PONG::CAPS : 0);
+ response[1] |= (leds.num ? PROTO::PONG::NUM : 0);
+ response[1] |= (leds.scroll ? PROTO::PONG::SCROLL : 0);
response[2] |= PROTO::OUTPUTS1::KEYBOARD::PS2;
}
if (_usb_mouse_abs) {
- response[1] |= _usb_mouse_abs->isOffline() ? PROTO::PONG::MOUSE_OFFLINE : 0;
+ response[1] |= (_usb_mouse_abs->isOffline() ? PROTO::PONG::MOUSE_OFFLINE : 0);
if (_usb_mouse_abs->isWin98FixEnabled()) {
response[2] |= PROTO::OUTPUTS1::MOUSE::USB_WIN98;
} else {
response[2] |= PROTO::OUTPUTS1::MOUSE::USB_ABS;
}
} else if (_usb_mouse_rel) {
- response[1] |= _usb_mouse_rel->isOffline() ? PROTO::PONG::MOUSE_OFFLINE : 0;
+ response[1] |= (_usb_mouse_rel->isOffline() ? PROTO::PONG::MOUSE_OFFLINE : 0);
response[2] |= PROTO::OUTPUTS1::MOUSE::USB_REL;
} // TODO: ps2
# ifdef AUM
diff --git a/hid/src/ps2/hid.h b/hid/src/ps2/hid.h
index db7247e4..6fce88b6 100644
--- a/hid/src/ps2/hid.h
+++ b/hid/src/ps2/hid.h
@@ -80,12 +80,12 @@ class Ps2Keyboard {
}
KeyboardLedsState getLeds() {
- KeyboardLedsState result;
-
periodic();
- result.caps = _leds & 0b00000100;
- result.scroll = _leds & 0b00000001;
- result.num = _leds & 0b00000010;
+ KeyboardLedsState result = {
+ .caps = _leds & 0b00000100,
+ .scroll = _leds & 0b00000001,
+ .num = _leds & 0b00000010,
+ };
return result;
}
diff --git a/hid/src/usb/hid.h b/hid/src/usb/hid.h
index ac35179e..cd58a1f8 100644
--- a/hid/src/usb/hid.h
+++ b/hid/src/usb/hid.h
@@ -107,10 +107,11 @@ class UsbKeyboard {
KeyboardLedsState getLeds() {
uint8_t leds = _kbd.getLeds();
- KeyboardLedsState result;
- result.caps = leds & LED_CAPS_LOCK;
- result.scroll = leds & LED_SCROLL_LOCK;
- result.num = leds & LED_NUM_LOCK;
+ KeyboardLedsState result = {
+ .caps = leds & LED_CAPS_LOCK,
+ .scroll = leds & LED_SCROLL_LOCK,
+ .num = leds & LED_NUM_LOCK,
+ };
return result;
}