Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28f5999cbb | ||
|
|
fe7505a2df | ||
|
|
b6ac16074c | ||
|
|
0bf205c5d2 | ||
|
|
e4a99a9400 | ||
|
|
1e9b5833eb | ||
|
|
79b052fca7 | ||
|
|
baee0b5682 | ||
|
|
6153d54f59 | ||
|
|
0a6ebe2903 | ||
|
|
2d7cd68459 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -5,6 +5,18 @@ 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.2] - 2018-08-02
|
||||
|
||||
Device Protocol: 4.4.0 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
|
||||
|
||||
- Fix various bugs related to secondary role handling and sticky modifier states.
|
||||
|
||||
## [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.
|
||||
static void wakeUpUhk(void) {
|
||||
SleepModeActive = 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) {
|
||||
;
|
||||
}
|
||||
|
||||
IsHostSleeping = false;
|
||||
LedSlaveDriver_UpdateLeds();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -236,6 +236,7 @@ static void handleSwitchLayerAction(key_state_t *keyState, key_action_t *action)
|
||||
static uint8_t basicScancodeIndex = 0;
|
||||
static uint8_t mediaScancodeIndex = 0;
|
||||
static uint8_t systemScancodeIndex = 0;
|
||||
static uint8_t stickyModifiers;
|
||||
|
||||
static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
{
|
||||
@@ -247,8 +248,13 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
|
||||
switch (action->type) {
|
||||
case KeyActionType_Keystroke:
|
||||
if (action->keystroke.scancode) {
|
||||
if (!keyState->previous) {
|
||||
stickyModifiers = action->keystroke.modifiers;
|
||||
}
|
||||
} else {
|
||||
ActiveUsbBasicKeyboardReport->modifiers |= action->keystroke.modifiers;
|
||||
|
||||
}
|
||||
switch (action->keystroke.keystrokeType) {
|
||||
case KeystrokeType_Basic:
|
||||
if (basicScancodeIndex >= USB_BASIC_KEYBOARD_MAX_KEYS || action->keystroke.scancode == 0) {
|
||||
@@ -271,6 +277,9 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
}
|
||||
break;
|
||||
case KeyActionType_Mouse:
|
||||
if (!keyState->previous) {
|
||||
stickyModifiers = 0;
|
||||
}
|
||||
activeMouseStates[action->mouseAction] = true;
|
||||
break;
|
||||
case KeyActionType_SwitchLayer:
|
||||
@@ -278,11 +287,13 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
break;
|
||||
case KeyActionType_SwitchKeymap:
|
||||
if (!keyState->previous) {
|
||||
stickyModifiers = 0;
|
||||
SwitchKeymapById(action->switchKeymap.keymapId);
|
||||
}
|
||||
break;
|
||||
case KeyActionType_PlayMacro:
|
||||
if (!keyState->previous) {
|
||||
stickyModifiers = 0;
|
||||
Macros_StartMacro(action->playMacro.macroId);
|
||||
}
|
||||
break;
|
||||
@@ -296,8 +307,6 @@ static secondary_role_t secondaryRole;
|
||||
|
||||
static void updateActiveUsbReports(void)
|
||||
{
|
||||
static uint8_t previousModifiers = 0;
|
||||
|
||||
if (MacroPlaying) {
|
||||
Macros_ContinueMacro();
|
||||
memcpy(ActiveUsbMouseReport, &MacroMouseReport, sizeof MacroMouseReport);
|
||||
@@ -320,7 +329,11 @@ static void updateActiveUsbReports(void)
|
||||
if (activeLayer == LayerId_Base) {
|
||||
activeLayer = GetActiveLayer();
|
||||
}
|
||||
bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base;
|
||||
bool layerChanged = previousLayer != activeLayer;
|
||||
if (layerChanged) {
|
||||
stickyModifiers = 0;
|
||||
}
|
||||
bool layerGotReleased = layerChanged && activeLayer == LayerId_Base;
|
||||
LedDisplay_SetLayer(activeLayer);
|
||||
|
||||
if (TestUsbStack) {
|
||||
@@ -366,7 +379,7 @@ static void updateActiveUsbReports(void)
|
||||
|
||||
if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
|
||||
// Press released secondary role key.
|
||||
if (!keyState->previous && action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole && secondaryRoleState == SecondaryRoleState_Released) {
|
||||
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Released) {
|
||||
secondaryRoleState = SecondaryRoleState_Pressed;
|
||||
secondaryRoleSlotId = slotId;
|
||||
secondaryRoleKeyId = keyId;
|
||||
@@ -377,6 +390,7 @@ static void updateActiveUsbReports(void)
|
||||
// Trigger secondary role.
|
||||
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) {
|
||||
secondaryRoleState = SecondaryRoleState_Triggered;
|
||||
keyState->current = false;
|
||||
} else {
|
||||
applyKeyAction(keyState, action);
|
||||
}
|
||||
@@ -405,15 +419,12 @@ static void updateActiveUsbReports(void)
|
||||
// When a layer switcher key gets pressed along with another key that produces some modifiers
|
||||
// and the accomanying key gets released then keep the related modifiers active a long as the
|
||||
// layer switcher key stays pressed. Useful for Alt+Tab keymappings and the like.
|
||||
if (activeLayer != LayerId_Base && activeLayer == PreviousHeldLayer && basicScancodeIndex == 0) {
|
||||
ActiveUsbBasicKeyboardReport->modifiers |= previousModifiers;
|
||||
}
|
||||
ActiveUsbBasicKeyboardReport->modifiers |= stickyModifiers;
|
||||
|
||||
if (secondaryRoleState == SecondaryRoleState_Triggered && IS_SECONDARY_ROLE_MODIFIER(secondaryRole)) {
|
||||
ActiveUsbBasicKeyboardReport->modifiers |= SECONDARY_ROLE_MODIFIER_TO_HID_MODIFIER(secondaryRole);
|
||||
}
|
||||
|
||||
previousModifiers = ActiveUsbBasicKeyboardReport->modifiers;
|
||||
previousLayer = activeLayer;
|
||||
}
|
||||
|
||||
@@ -425,11 +436,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 +466,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.2",
|
||||
"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 2
|
||||
|
||||
#define DEVICE_PROTOCOL_MAJOR_VERSION 4
|
||||
#define DEVICE_PROTOCOL_MINOR_VERSION 4
|
||||
|
||||
Reference in New Issue
Block a user