Rename identifiers.

This commit is contained in:
László Monda
2018-04-28 11:38:38 +02:00
parent 06ebed5537
commit 9d66f5ff76
3 changed files with 18 additions and 17 deletions

View File

@@ -163,18 +163,18 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
} }
}}; }};
static bool computerSleeping = false; static bool isHostSleeping = false;
#ifdef LED_DRIVERS_ENABLED #ifdef LED_DRIVERS_ENABLED
static uint8_t oldKeyBacklightBrightness = 0xFF; static uint8_t oldKeyBacklightBrightness = 0xFF;
static bool capsLockOn = false, agentOn = false, adaptiveOn = false; static bool capsLockOn = false, agentOn = false, adaptiveOn = false;
#endif #endif
bool IsComputerSleeping(void) { bool IsHostSleeping(void) {
return computerSleeping; return isHostSleeping;
} }
static void ComputerIsSleeping(void) { static void suspendHost(void) {
computerSleeping = true; isHostSleeping = true;
#ifdef LED_DRIVERS_ENABLED #ifdef LED_DRIVERS_ENABLED
// Save the state of the icons // Save the state of the icons
capsLockOn = LedDisplay_GetIcon(LedDisplayIcon_CapsLock); capsLockOn = LedDisplay_GetIcon(LedDisplayIcon_CapsLock);
@@ -195,13 +195,13 @@ static void ComputerIsSleeping(void) {
#endif #endif
} }
void WakeupComputer(bool sendResume) { void WakeUpHost(bool sendResume) {
if (sendResume) { // The device should wake up the computer if (sendResume) { // The device should wake up the computer
// Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL); // Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL);
USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL); USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL);
} }
computerSleeping = false; // The computer is now awake isHostSleeping = false; // The computer is now awake
#ifdef LED_DRIVERS_ENABLED #ifdef LED_DRIVERS_ENABLED
// Restore keyboard backlight and text // Restore keyboard backlight and text
@@ -229,8 +229,9 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
return status; return status;
} }
if (computerSleeping) if (isHostSleeping) {
WakeupComputer(false); // Wake up the keyboard if there is any activity on the bus WakeUpHost(false); // Wake up the keyboard if there is any activity on the bus.
}
switch (event) { switch (event) {
case kUSB_DeviceEventBusReset: case kUSB_DeviceEventBusReset:
@@ -239,13 +240,13 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
break; break;
case kUSB_DeviceEventSuspend: case kUSB_DeviceEventSuspend:
if (UsbCompositeDevice.attach) { if (UsbCompositeDevice.attach) {
ComputerIsSleeping(); // The computer sends this event when it goes to sleep, so turn off all the LEDs suspendHost(); // The computer sends this event when it goes to sleep, so turn off all the LEDs.
status = kStatus_USB_Success; status = kStatus_USB_Success;
} }
break; break;
case kUSB_DeviceEventResume: case kUSB_DeviceEventResume:
// We will just wake up the computer if there is any activity on the bus // We will just wake up the computer if there is any activity on the bus.
// The problem is that the computer won't send a resume event when it boots, so the lights will never come back on // The problem is that the computer won't send a resume event when it boots, so the lights will never come back on.
status = kStatus_USB_Success; status = kStatus_USB_Success;
break; break;
case kUSB_DeviceEventSetConfiguration: case kUSB_DeviceEventSetConfiguration:

View File

@@ -33,7 +33,7 @@
//Functions: //Functions:
void InitUsb(void); void InitUsb(void);
bool IsComputerSleeping(void); bool IsHostSleeping(void);
void WakeupComputer(bool sendResume); void WakeUpHost(bool sendResume);
#endif #endif

View File

@@ -377,7 +377,7 @@ void UpdateUsbReports(void)
{ {
UsbReportUpdateCounter++; UsbReportUpdateCounter++;
// Process the key inputs at a constant rate when moving the mouse, so the mouse speed is consistent // Process the key inputs at a constant rate when moving the mouse, so the mouse speed is consistent.
bool hasActiveMouseState = false; bool hasActiveMouseState = false;
for (uint8_t i=0; i<ACTIVE_MOUSE_STATES_COUNT; i++) { for (uint8_t i=0; i<ACTIVE_MOUSE_STATES_COUNT; i++) {
hasActiveMouseState = true; hasActiveMouseState = true;
@@ -428,7 +428,7 @@ void UpdateUsbReports(void)
IsUsbMouseReportSent = false; IsUsbMouseReportSent = false;
} }
if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsComputerSleeping()) { if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsHostSleeping()) {
WakeupComputer(true); // Wake up the computer if any key is pressed and the computer is sleeping WakeUpHost(true); // Wake up the computer if any key is pressed and the computer is sleeping.
} }
} }