From e3d4eb50db5750a622a758284e373b5395a4accd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 7 Nov 2017 00:30:40 +0100 Subject: [PATCH] Make secondary role layer switching work. --- right/src/usb_report_updater.c | 8 +++++++- right/src/usb_report_updater.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 4b1b4d7..4159b3a 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -132,7 +132,13 @@ void UpdateActiveUsbReports(void) KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId]; } - layer_id_t activeLayer = GetActiveLayer(); + layer_id_t activeLayer = LayerId_Base; + if (secondaryRoleState == SecondaryRoleState_Triggered && IS_SECONDARY_ROLE_LAYER_SWITCHER(secondaryRole)) { + activeLayer = SECONDARY_ROLE_LAYER_TO_LAYER_ID(secondaryRole); + } + if (activeLayer == LayerId_Base) { + activeLayer = GetActiveLayer(); + } LedDisplay_SetLayer(activeLayer); if (MacroPlaying) { diff --git a/right/src/usb_report_updater.h b/right/src/usb_report_updater.h index e70c63f..7edabe6 100644 --- a/right/src/usb_report_updater.h +++ b/right/src/usb_report_updater.h @@ -6,6 +6,7 @@ #define IS_SECONDARY_ROLE_MODIFIER(secondaryRole) (SecondaryRole_LeftCtrl <= (secondaryRole) && (secondaryRole) <= SecondaryRole_RightSuper) #define IS_SECONDARY_ROLE_LAYER_SWITCHER(secondaryRole) (SecondaryRole_Mod <= (secondaryRole) && (secondaryRole) <= SecondaryRole_Mouse) #define SECONDARY_ROLE_MODIFIER_TO_HID_MODIFIER(secondaryRoleModifier) (1 << ((secondaryRoleModifier) - 1)) + #define SECONDARY_ROLE_LAYER_TO_LAYER_ID(secondaryRoleLayer) ((secondaryRoleLayer) - SecondaryRole_RightSuper) // Typedefs: