From ec8301ae62e0bc62d8c840efe3c2ca8802b7da7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 28 Apr 2018 13:11:25 +0200 Subject: [PATCH] Expose IsHostSleeping instead of IsHostSleeping() --- right/src/usb_composite_device.c | 12 ++++-------- right/src/usb_composite_device.h | 2 +- right/src/usb_report_updater.c | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/right/src/usb_composite_device.c b/right/src/usb_composite_device.c index e20ef72..b5989bc 100644 --- a/right/src/usb_composite_device.c +++ b/right/src/usb_composite_device.c @@ -163,16 +163,12 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = { } }}; -static bool isHostSleeping = false; +bool IsHostSleeping = false; static uint8_t oldKeyBacklightBrightness = 0xFF; static bool capsLockOn = false, agentOn = false, adaptiveOn = false; -bool IsHostSleeping(void) { - return isHostSleeping; -} - static void suspendHost(void) { - isHostSleeping = true; + IsHostSleeping = true; // Save the state of the icons capsLockOn = LedDisplay_GetIcon(LedDisplayIcon_CapsLock); agentOn = LedDisplay_GetIcon(LedDisplayIcon_Agent); @@ -197,7 +193,7 @@ void WakeUpHost(bool sendResume) { USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL); } - isHostSleeping = false; // The computer is now awake + IsHostSleeping = false; // The computer is now awake // Restore keyboard backlight and text KeyBacklightBrightness = oldKeyBacklightBrightness; @@ -223,7 +219,7 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, return status; } - if (isHostSleeping) { + if (IsHostSleeping) { WakeUpHost(false); // Wake up the keyboard if there is any activity on the bus. } diff --git a/right/src/usb_composite_device.h b/right/src/usb_composite_device.h index 19c8ca2..7c35485 100644 --- a/right/src/usb_composite_device.h +++ b/right/src/usb_composite_device.h @@ -28,12 +28,12 @@ // Variables: + extern bool IsHostSleeping; extern usb_composite_device_t UsbCompositeDevice; //Functions: void InitUsb(void); - bool IsHostSleeping(void); void WakeUpHost(bool sendResume); #endif diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 2d9aff2..ba2d097 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -428,7 +428,7 @@ void UpdateUsbReports(void) IsUsbMouseReportSent = false; } - if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsHostSleeping()) { + if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsHostSleeping) { WakeUpHost(true); // Wake up the computer if any key is pressed and the computer is sleeping. } }