@@ -101,6 +101,11 @@ void LedDisplay_SetLayer(uint8_t layerId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LedDisplay_GetIcon(led_display_icon_t icon)
|
||||||
|
{
|
||||||
|
return LedDriverValues[LedDriverId_Left][8 + icon];
|
||||||
|
}
|
||||||
|
|
||||||
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled)
|
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled)
|
||||||
{
|
{
|
||||||
LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? IconsAndLayerTextsBrightness : 0;
|
LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? IconsAndLayerTextsBrightness : 0;
|
||||||
|
|||||||
@@ -26,4 +26,6 @@
|
|||||||
void LedDisplay_SetLayer(uint8_t layerId);
|
void LedDisplay_SetLayer(uint8_t layerId);
|
||||||
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled);
|
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled);
|
||||||
|
|
||||||
|
bool LedDisplay_GetIcon(led_display_icon_t icon);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#include "config.h"
|
||||||
|
#include "led_display.h"
|
||||||
|
#include "slave_drivers/is31fl3731_driver.h"
|
||||||
#include "usb_device_config.h"
|
#include "usb_device_config.h"
|
||||||
#include "usb_composite_device.h"
|
#include "usb_composite_device.h"
|
||||||
#include "usb_descriptors/usb_descriptor_hid.h"
|
#include "usb_descriptors/usb_descriptor_hid.h"
|
||||||
@@ -162,11 +165,15 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
|
|||||||
|
|
||||||
static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param)
|
static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param)
|
||||||
{
|
{
|
||||||
|
#ifdef LED_DRIVERS_ENABLED
|
||||||
|
static uint8_t oldKeyBacklightBrightness = 0xFF;
|
||||||
|
static bool capsLockOn = false, agentOn = false, adaptiveOn = false;
|
||||||
|
#endif
|
||||||
usb_status_t status = kStatus_USB_Error;
|
usb_status_t status = kStatus_USB_Error;
|
||||||
uint16_t *temp16 = (uint16_t*)param;
|
uint16_t *temp16 = (uint16_t*)param;
|
||||||
uint8_t *temp8 = (uint8_t*)param;
|
uint8_t *temp8 = (uint8_t*)param;
|
||||||
|
|
||||||
if (!param && event != kUSB_DeviceEventBusReset && event != kUSB_DeviceEventSetInterface) {
|
if (!param && event != kUSB_DeviceEventBusReset && event != kUSB_DeviceEventSetInterface && event != kUSB_DeviceEventSuspend && event != kUSB_DeviceEventResume) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +182,42 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
|
|||||||
UsbCompositeDevice.attach = 0;
|
UsbCompositeDevice.attach = 0;
|
||||||
status = kStatus_USB_Success;
|
status = kStatus_USB_Success;
|
||||||
break;
|
break;
|
||||||
|
case kUSB_DeviceEventSuspend:
|
||||||
|
if (UsbCompositeDevice.attach) {
|
||||||
|
#ifdef LED_DRIVERS_ENABLED
|
||||||
|
// Save the state of the icons
|
||||||
|
capsLockOn = LedDisplay_GetIcon(LedDisplayIcon_CapsLock);
|
||||||
|
agentOn = LedDisplay_GetIcon(LedDisplayIcon_Agent);
|
||||||
|
adaptiveOn = LedDisplay_GetIcon(LedDisplayIcon_Adaptive);
|
||||||
|
|
||||||
|
// Disable keyboard backlight
|
||||||
|
oldKeyBacklightBrightness = KeyBacklightBrightness;
|
||||||
|
KeyBacklightBrightness = 0;
|
||||||
|
LedSlaveDriver_Init(LedDriverId_Right);
|
||||||
|
LedSlaveDriver_Init(LedDriverId_Left);
|
||||||
|
|
||||||
|
// Clear the text
|
||||||
|
LedDisplay_SetText(0, NULL);
|
||||||
|
#endif
|
||||||
|
status = kStatus_USB_Success;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kUSB_DeviceEventResume:
|
||||||
|
if (UsbCompositeDevice.attach) {
|
||||||
|
#ifdef LED_DRIVERS_ENABLED
|
||||||
|
// Restore keyboard backlight and text
|
||||||
|
KeyBacklightBrightness = oldKeyBacklightBrightness;
|
||||||
|
LedSlaveDriver_Init(LedDriverId_Right);
|
||||||
|
LedSlaveDriver_Init(LedDriverId_Left);
|
||||||
|
|
||||||
|
// Restore icon states
|
||||||
|
LedDisplay_SetIcon(LedDisplayIcon_CapsLock, capsLockOn);
|
||||||
|
LedDisplay_SetIcon(LedDisplayIcon_Agent, agentOn);
|
||||||
|
LedDisplay_SetIcon(LedDisplayIcon_Adaptive, adaptiveOn);
|
||||||
|
#endif
|
||||||
|
status = kStatus_USB_Success;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case kUSB_DeviceEventSetConfiguration:
|
case kUSB_DeviceEventSetConfiguration:
|
||||||
UsbCompositeDevice.attach = 1;
|
UsbCompositeDevice.attach = 1;
|
||||||
UsbCompositeDevice.currentConfiguration = *temp8;
|
UsbCompositeDevice.currentConfiguration = *temp8;
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Whether the device is self-powered: 1 supported, 0 not supported
|
// Whether the device is self-powered: 1 supported, 0 not supported
|
||||||
#define USB_DEVICE_CONFIG_SELF_POWER 1
|
#define USB_DEVICE_CONFIG_SELF_POWER 0
|
||||||
|
|
||||||
// Whether device remote wakeup supported: 1 supported, 0 not supported
|
// Whether device remote wakeup supported: 1 supported, 0 not supported
|
||||||
#define USB_DEVICE_CONFIG_REMOTE_WAKEUP 0
|
#define USB_DEVICE_CONFIG_REMOTE_WAKEUP 1
|
||||||
|
|
||||||
// The number of control endpoints, which is always 1
|
// The number of control endpoints, which is always 1
|
||||||
#define USB_CONTROL_ENDPOINT_COUNT 1
|
#define USB_CONTROL_ENDPOINT_COUNT 1
|
||||||
|
|||||||
Reference in New Issue
Block a user