From c109a9e202e216469e8b729cf14c5cf342ad0e52 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sun, 11 Mar 2018 19:29:24 +0100 Subject: [PATCH] The layer keys can now also wake up the computer --- right/src/led_display.c | 2 +- right/src/led_display.h | 3 ++- right/src/usb_composite_device.c | 6 ++++++ right/src/usb_report_updater.c | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/right/src/led_display.c b/right/src/led_display.c index d6fab2b..ed00fd7 100644 --- a/right/src/led_display.c +++ b/right/src/led_display.c @@ -90,7 +90,7 @@ void LedDisplay_SetCurrentKeymapText(void) LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation); } -void LedDisplay_SetLayer(uint8_t layerId) +void LedDisplay_SetLayer(layer_id_t layerId) { for (uint8_t i = 13; i <= 45; i += 16) { LedDriverValues[LedDriverId_Left][i] = 0; diff --git a/right/src/led_display.h b/right/src/led_display.h index 2d98423..aa1bbce 100644 --- a/right/src/led_display.h +++ b/right/src/led_display.h @@ -5,6 +5,7 @@ #include #include + #include "layer.h" // Typedefs: @@ -23,7 +24,7 @@ void LedDisplay_SetText(uint8_t length, const char* text); void LedDisplay_SetCurrentKeymapText(void); - void LedDisplay_SetLayer(uint8_t layerId); + void LedDisplay_SetLayer(layer_id_t layerId); void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled); bool LedDisplay_GetIcon(led_display_icon_t icon); diff --git a/right/src/usb_composite_device.c b/right/src/usb_composite_device.c index e5fa973..2b43662 100644 --- a/right/src/usb_composite_device.c +++ b/right/src/usb_composite_device.c @@ -187,6 +187,9 @@ static void ComputerIsSleeping(void) { LedSlaveDriver_Init(LedDriverId_Right); LedSlaveDriver_Init(LedDriverId_Left); + // Turn layer LEDs off + LedDisplay_SetLayer(LayerId_Base); + // Clear the text LedDisplay_SetText(0, NULL); #endif @@ -204,6 +207,9 @@ void WakeupComputer(bool sendResume) { LedSlaveDriver_Init(LedDriverId_Right); LedSlaveDriver_Init(LedDriverId_Left); + // Update the active layer + LedDisplay_SetLayer(GetActiveLayer()); + // Restore icon states LedDisplay_SetIcon(LedDisplayIcon_CapsLock, capsLockOn); LedDisplay_SetIcon(LedDisplayIcon_Agent, agentOn); diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 8832b55..206968e 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -453,7 +453,7 @@ void UpdateUsbReports(void) IsUsbMouseReportSent = false; } - if ((!IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsComputerSleeping()) + if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsComputerSleeping()) WakeupComputer(true); // Wake up the computer if any key is pressed and the computer is sleeping Timer_SetCurrentTime(&lastUsbUpdateTime);