diff options
author | tomaszduda23 <[email protected]> | 2022-07-07 01:11:55 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-07 02:11:55 +0300 |
commit | dd251eeaf915a207f292ee26e8e04f839d45417f (patch) | |
tree | 01568a7b8b0740b6019ed1a699f0e38139fe5841 | |
parent | c09567c1a90d76f302ced8ff3a7db5ad32192cc1 (diff) |
change name of method getOfflineAs->isOffline to simplyfy the interface (#92)
-rw-r--r-- | hid/src/main.cpp | 8 | ||||
-rw-r--r-- | hid/src/ps2/hid.h | 4 | ||||
-rw-r--r-- | hid/src/usb/hid.h | 30 |
3 files changed, 21 insertions, 21 deletions
diff --git a/hid/src/main.cpp b/hid/src/main.cpp index 30343862..162636ab 100644 --- a/hid/src/main.cpp +++ b/hid/src/main.cpp @@ -284,23 +284,23 @@ static void _sendResponse(uint8_t code) { response[2] = PROTO::OUTPUTS1::DYNAMIC; # endif if (_usb_kbd) { - response[1] |= _usb_kbd->getOfflineAs(PROTO::PONG::KEYBOARD_OFFLINE); + response[1] |= _usb_kbd->isOffline() ? PROTO::PONG::KEYBOARD_OFFLINE : 0; response[1] |= _usb_kbd->getLedsAs(PROTO::PONG::CAPS, PROTO::PONG::SCROLL, PROTO::PONG::NUM); response[2] |= PROTO::OUTPUTS1::KEYBOARD::USB; } else if (_ps2_kbd) { - response[1] |= _ps2_kbd->getOfflineAs(PROTO::PONG::KEYBOARD_OFFLINE); + response[1] |= _ps2_kbd->isOffline() ? PROTO::PONG::KEYBOARD_OFFLINE : 0; response[1] |= _ps2_kbd->getLedsAs(PROTO::PONG::CAPS, PROTO::PONG::SCROLL, PROTO::PONG::NUM); response[2] |= PROTO::OUTPUTS1::KEYBOARD::PS2; } if (_usb_mouse_abs) { - response[1] |= _usb_mouse_abs->getOfflineAs(PROTO::PONG::MOUSE_OFFLINE); + 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->getOfflineAs(PROTO::PONG::MOUSE_OFFLINE); + 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 6b5e616d..ec55b80a 100644 --- a/hid/src/ps2/hid.h +++ b/hid/src/ps2/hid.h @@ -74,8 +74,8 @@ class Ps2Keyboard { } } - uint8_t getOfflineAs(uint8_t offline) { - return 0; + bool isOffline() { + return false; } uint8_t getLedsAs(uint8_t caps, uint8_t scroll, uint8_t num) { diff --git a/hid/src/usb/hid.h b/hid/src/usb/hid.h index 5f840661..9d5ab75e 100644 --- a/hid/src/usb/hid.h +++ b/hid/src/usb/hid.h @@ -37,12 +37,12 @@ // https://github.com/arduino/ArduinoCore-avr/blob/2f67c916f6ab6193c404eebe22efe901e0f9542d/cores/arduino/USBCore.cpp#L249 // https://sourceforge.net/p/arduinomidilib/svn/41/tree/branch/3.1/Teensy/teensy_core/usb_midi/usb_api.cpp#l103 # ifdef AUM -# define CHECK_AUM_USB { if (!aumIsUsbConnected()) { return offline; } } +# define CHECK_AUM_USB { if (!aumIsUsbConnected()) { return true; } } # else # define CHECK_AUM_USB # endif -# define CLS_GET_OFFLINE_AS(_hid) \ - uint8_t getOfflineAs(uint8_t offline) { \ +# define CLS_IS_OFFLINE(_hid) \ + bool isOffline() { \ CHECK_AUM_USB; \ uint8_t ep = _hid.getPluggedEndpoint(); \ uint8_t intr_state = SREG; \ @@ -51,16 +51,16 @@ bool rw_allowed = UEINTX & (1 << RWAL); \ SREG = intr_state; \ if (rw_allowed) { \ - return 0; \ + return false; \ } \ - return offline; \ + return true; \ } -# define CHECK_HID_EP { if (getOfflineAs(1)) return; } +# define CHECK_HID_EP { if (isOffline()) return; } #else -# define CLS_GET_OFFLINE_AS(_hid) \ - uint8_t getOfflineAs(uint8_t offline) { \ - return 0; \ +# define CLS_IS_OFFLINE(_hid) \ + bool isOffline() { \ + return false; \ } # define CHECK_HID_EP @@ -79,7 +79,7 @@ class UsbKeyboard { static unsigned long prev_ts = 0; if (is_micros_timed_out(prev_ts, 50000)) { static bool prev_online = true; - bool online = !getOfflineAs(1); + bool online = !isOffline(); if (!_sent || (online && !prev_online)) { _sendCurrent(); } @@ -102,7 +102,7 @@ class UsbKeyboard { } } - CLS_GET_OFFLINE_AS(_kbd) + CLS_IS_OFFLINE(_kbd) uint8_t getLedsAs(uint8_t caps, uint8_t scroll, uint8_t num) { uint8_t leds = _kbd.getLeds(); @@ -119,7 +119,7 @@ class UsbKeyboard { void _sendCurrent() { # ifdef HID_USB_CHECK_ENDPOINT - if (getOfflineAs(1)) { + if (isOffline()) { _sent = false; } else { # endif @@ -175,7 +175,7 @@ class UsbMouseAbsolute { _mouse.move(0, 0, delta_y); } - CLS_GET_OFFLINE_AS(_mouse) + CLS_IS_OFFLINE(_mouse) private: SingleAbsoluteMouse_ _mouse; @@ -212,7 +212,7 @@ class UsbMouseRelative { _mouse.move(0, 0, delta_y); } - CLS_GET_OFFLINE_AS(_mouse) + CLS_IS_OFFLINE(_mouse) private: BootMouse_ _mouse; @@ -225,5 +225,5 @@ class UsbMouseRelative { }; #undef CLS_SEND_BUTTONS -#undef CLS_GET_OFFLINE_AS +#undef CLS_IS_OFFLINE #undef CHECK_HID_EP |