Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
baee0b5682 | ||
|
|
6153d54f59 | ||
|
|
0a6ebe2903 | ||
|
|
2d7cd68459 |
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
|
||||
|
||||
## [8.4.1] - 2018-07-31
|
||||
|
||||
Device Protocol: 4.4.0 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
|
||||
|
||||
- Make some improvements to the sleep/wake code.
|
||||
|
||||
## [8.4.0] - 2018-07-24
|
||||
|
||||
Device Protocol: 4.**4.0** | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
|
||||
|
||||
Submodule lib/agent updated: ac89aff018...fa32f95438
@@ -163,21 +163,28 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
|
||||
}
|
||||
}};
|
||||
|
||||
bool IsHostSleeping = false;
|
||||
volatile bool SleepModeActive = true;
|
||||
static volatile bool wakeUpHostAllowed;
|
||||
|
||||
static void suspendHost(void) {
|
||||
IsHostSleeping = true;
|
||||
static void suspendUhk(void) {
|
||||
SleepModeActive = true;
|
||||
LedSlaveDriver_DisableLeds();
|
||||
}
|
||||
|
||||
void WakeUpHost(bool sendResume) {
|
||||
if (sendResume) { // The device should wake up the host.
|
||||
// Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL);
|
||||
USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL);
|
||||
static void wakeUpUhk(void) {
|
||||
SleepModeActive = false;
|
||||
LedSlaveDriver_UpdateLeds();
|
||||
}
|
||||
|
||||
IsHostSleeping = false;
|
||||
LedSlaveDriver_UpdateLeds();
|
||||
void WakeUpHost(void) {
|
||||
if (!wakeUpHostAllowed) {
|
||||
return;
|
||||
}
|
||||
// Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL);
|
||||
USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL);
|
||||
while (SleepModeActive) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param)
|
||||
@@ -190,10 +197,6 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
|
||||
return status;
|
||||
}
|
||||
|
||||
if (IsHostSleeping) {
|
||||
WakeUpHost(false); // Wake up the keyboard if there is any activity on the bus.
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case kUSB_DeviceEventBusReset:
|
||||
UsbCompositeDevice.attach = 0;
|
||||
@@ -201,17 +204,17 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
|
||||
break;
|
||||
case kUSB_DeviceEventSuspend:
|
||||
if (UsbCompositeDevice.attach) {
|
||||
suspendHost(); // The host sends this event when it goes to sleep, so turn off all the LEDs.
|
||||
suspendUhk(); // The host sends this event when it goes to sleep, so turn off all the LEDs.
|
||||
status = kStatus_USB_Success;
|
||||
}
|
||||
break;
|
||||
case kUSB_DeviceEventResume:
|
||||
// We will just wake up the host if there is any activity on the bus.
|
||||
// The problem is that the host won't send a resume event when it boots, so the lights will never come back on.
|
||||
wakeUpUhk();
|
||||
status = kStatus_USB_Success;
|
||||
break;
|
||||
case kUSB_DeviceEventSetConfiguration:
|
||||
UsbCompositeDevice.attach = 1;
|
||||
wakeUpUhk();
|
||||
UsbCompositeDevice.currentConfiguration = *temp8;
|
||||
UsbGenericHidSetConfiguration(UsbCompositeDevice.genericHidHandle, *temp8);
|
||||
UsbBasicKeyboardSetConfiguration(UsbCompositeDevice.basicKeyboardHandle, *temp8);
|
||||
@@ -266,6 +269,10 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
|
||||
case kUSB_DeviceEventGetHidPhysicalDescriptor:
|
||||
status = USB_DeviceGetHidPhysicalDescriptor(handle, (usb_device_get_hid_physical_descriptor_struct_t *)param);
|
||||
break;
|
||||
case kUSB_DeviceEventSetRemoteWakeup:
|
||||
wakeUpHostAllowed = *temp8;
|
||||
status = kStatus_USB_Success;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
|
||||
// Variables:
|
||||
|
||||
extern bool IsHostSleeping;
|
||||
extern volatile bool SleepModeActive;
|
||||
extern usb_composite_device_t UsbCompositeDevice;
|
||||
|
||||
//Functions:
|
||||
|
||||
void InitUsb(void);
|
||||
void WakeUpHost(bool sendResume);
|
||||
void WakeUpHost(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -425,11 +425,11 @@ void UpdateUsbReports(void)
|
||||
KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId];
|
||||
}
|
||||
|
||||
if (IsHostSleeping) {
|
||||
if (SleepModeActive) {
|
||||
for (uint8_t slotId = 0; slotId < SLOT_COUNT; slotId++) {
|
||||
for (uint8_t keyId = 0; keyId < MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||
if (KeyStates[slotId][keyId].current) {
|
||||
WakeUpHost(true);
|
||||
WakeUpHost();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -455,10 +455,6 @@ void UpdateUsbReports(void)
|
||||
bool HasUsbSystemKeyboardReportChanged = memcmp(ActiveUsbSystemKeyboardReport, GetInactiveUsbSystemKeyboardReport(), sizeof(usb_system_keyboard_report_t)) != 0;
|
||||
bool HasUsbMouseReportChanged = memcmp(ActiveUsbMouseReport, GetInactiveUsbMouseReport(), sizeof(usb_mouse_report_t)) != 0;
|
||||
|
||||
if (IsHostSleeping && (previousLayer != LayerId_Base || HasUsbBasicKeyboardReportChanged || HasUsbMediaKeyboardReportChanged || HasUsbSystemKeyboardReportChanged || HasUsbMouseReportChanged)) {
|
||||
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
|
||||
}
|
||||
|
||||
if (HasUsbBasicKeyboardReportChanged) {
|
||||
usb_status_t status = UsbBasicKeyboardAction();
|
||||
if (status == kStatus_USB_Success) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"commander": "^2.11.0",
|
||||
"shelljs": "^0.7.8"
|
||||
},
|
||||
"firmwareVersion": "8.4.0",
|
||||
"firmwareVersion": "8.4.1",
|
||||
"deviceProtocolVersion": "4.4.0",
|
||||
"moduleProtocolVersion": "4.0.0",
|
||||
"userConfigVersion": "4.1.0",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#define FIRMWARE_MAJOR_VERSION 8
|
||||
#define FIRMWARE_MINOR_VERSION 4
|
||||
#define FIRMWARE_PATCH_VERSION 0
|
||||
#define FIRMWARE_PATCH_VERSION 1
|
||||
|
||||
#define DEVICE_PROTOCOL_MAJOR_VERSION 4
|
||||
#define DEVICE_PROTOCOL_MINOR_VERSION 4
|
||||
|
||||
Reference in New Issue
Block a user