Skip to content

Commit

Permalink
Merge branch 'common_trunk_upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
kareltucek committed Mar 5, 2022
2 parents d5fed59 + 150a206 commit 7edefbf
Show file tree
Hide file tree
Showing 53 changed files with 1,985 additions and 534 deletions.
66 changes: 43 additions & 23 deletions MACRO_DOCS.md

Large diffs are not rendered by default.

Binary file added doc/agent-onInit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
763 changes: 763 additions & 0 deletions doc/index.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions doc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"bootstrap": "^5.1.3",
"vue": "^3.2.31"
}
}
25 changes: 25 additions & 0 deletions doc/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pre {
background-color: #eee;
}

img {
max-width: 100%;
padding: 10px 0;
}

.no-wrap {
white-space: nowrap;
}

table.table td {
vertical-align: middle;
}

table.table input[type="checkbox"] {
width: 20px;
height: 20px;
}

table.table input[type="range"] {
margin-right: 10px;
}
25 changes: 21 additions & 4 deletions right/src/caret_config.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "caret_config.h"
#include "arduino_hid/ConsumerAPI.h"
#include "arduino_hid/SystemAPI.h"
#include "macros.h"

caret_configuration_t caretMediaMode = {
.axisActions = { //axis array
Expand Down Expand Up @@ -29,7 +30,20 @@ caret_configuration_t caretCaretMode = {
}
};

caret_configuration_t zoomMode = {
caret_configuration_t zoomMacMode = {
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_None },
.negativeAction = { .type = KeyActionType_None },
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE, .modifiers = HID_KEYBOARD_MODIFIER_LEFTGUI}},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_EQUAL_AND_PLUS, .modifiers = HID_KEYBOARD_MODIFIER_LEFTGUI | HID_KEYBOARD_MODIFIER_LEFTSHIFT}},
}
}
};

caret_configuration_t zoomPcMode = {
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_None },
Expand All @@ -48,10 +62,13 @@ caret_configuration_t* GetModuleCaretConfiguration(int8_t moduleId, navigation_m
return &caretCaretMode;
case NavigationMode_Media:
return &caretMediaMode;
case NavigationMode_Zoom:
return &zoomMode;
case NavigationMode_ZoomPc:
return &zoomPcMode;
case NavigationMode_ZoomMac:
return &zoomMacMode;
default:
return &caretCaretMode;
Macros_ReportErrorNum("Mode referenced in in valid context:", mode);
return NULL;
}
}

Expand Down
7 changes: 7 additions & 0 deletions right/src/config_parser/parse_keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ static parser_error_t parseLayer(config_buffer_t *buffer, uint8_t layer)
}
}

if (!ParserRunDry) {
LayerConfig[layer].layerIsDefined = true;
}

parser_error_t errorCode;
uint16_t moduleCount = ReadCompactLength(buffer);

Expand Down Expand Up @@ -203,6 +207,9 @@ parser_error_t ParseKeymap(config_buffer_t *buffer, uint8_t keymapIdx, uint8_t k
AllKeymaps[keymapIdx].abbreviation = abbreviation;
AllKeymaps[keymapIdx].abbreviationLen = abbreviationLen;
AllKeymaps[keymapIdx].offset = offset;
for (uint8_t layerIdx = 0; layerIdx < LayerId_Count; layerIdx++) {
LayerConfig[layerIdx].layerIsDefined = false;
}
if (isDefault) {
DefaultKeymapIndex = keymapIdx;
}
Expand Down
5 changes: 3 additions & 2 deletions right/src/config_parser/parse_macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ parser_error_t parseKeyMacroAction(config_buffer_t *buffer, macro_action_t *macr
macroAction->key.action = action;
macroAction->key.type = type;
macroAction->key.scancode = scancode;
macroAction->key.modifierMask = modifierMask;
macroAction->key.sticky = false;
macroAction->key.outputModMask = modifierMask;
macroAction->key.inputModMask = 0;
macroAction->key.stickyModMask = 0;
return ParserError_Success;
}

Expand Down
5 changes: 5 additions & 0 deletions right/src/key_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
};
} ATTR_PACKED key_action_t;

typedef struct {
key_action_t action;
uint8_t modifierLayerMask;
} ATTR_PACKED key_action_cached_t;

// Variables:

void UpdateActiveUsbReports(void);
Expand Down
22 changes: 22 additions & 0 deletions right/src/layer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "layer.h"
#include "lufa/HIDClassCommon.h"

layer_config_t LayerConfig[LayerId_Count] = {
{ .layerIsDefined = true, .exactModifierMatch = false, .modifierLayerMask = 0},
{ .layerIsDefined = true, .exactModifierMatch = false, .modifierLayerMask = 0},
{ .layerIsDefined = true, .exactModifierMatch = false, .modifierLayerMask = 0},
{ .layerIsDefined = true, .exactModifierMatch = false, .modifierLayerMask = 0},

// fn2 - fn5
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = 0},
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = 0},
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = 0},
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = 0},

// Shift, Control, Alt, Super
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = HID_KEYBOARD_MODIFIER_LEFTSHIFT | HID_KEYBOARD_MODIFIER_RIGHTSHIFT },
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = HID_KEYBOARD_MODIFIER_LEFTCTRL | HID_KEYBOARD_MODIFIER_RIGHTCTRL },
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = HID_KEYBOARD_MODIFIER_LEFTALT | HID_KEYBOARD_MODIFIER_RIGHTALT },
{ .layerIsDefined = false, .exactModifierMatch = false, .modifierLayerMask = HID_KEYBOARD_MODIFIER_LEFTGUI | HID_KEYBOARD_MODIFIER_RIGHTGUI },
};

17 changes: 16 additions & 1 deletion right/src/layer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#ifndef __SRC_LAYER_H__
#define __SRC_LAYER_H__

// layer.c code was refactored into layer_switcher.h
#include <stdint.h>
#include <stdbool.h>
#include "attributes.h"

// Macros:

#define IS_MODIFIER_LAYER(L) (LayerId_Shift <= (L) && (L) <= LayerId_Super)

// Typedefs:

Expand All @@ -23,4 +28,14 @@
LayerId_Count = LayerId_Last + 1,
} layer_id_t;

typedef struct {
uint8_t modifierLayerMask;
bool layerIsDefined : 1;
bool exactModifierMatch : 1;
} ATTR_PACKED layer_config_t;

// Variables:

extern layer_config_t LayerConfig[LayerId_Count];

#endif
30 changes: 27 additions & 3 deletions right/src/layer_switcher.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#include "layer_switcher.h"
#include "layer.h"
#include "ledmap.h"
#include "timer.h"
#include "macros.h"
#include "debug.h"
#include "led_display.h"
#include "usb_report_updater.h"

uint16_t DoubleTapSwitchLayerTimeout = 400;
uint16_t DoubleTapSwitchLayerReleaseTimeout = 200;

layer_id_t ActiveLayer = LayerId_Base;
bool ActiveLayerHeld = false;
uint8_t ActiveLayerModifierMask = 0;

static layer_id_t toggledLayer = LayerId_Base;
static layer_id_t heldLayer = LayerId_Base;
Expand Down Expand Up @@ -159,19 +162,40 @@ void LayerSwitcher_HoldLayer(layer_id_t layer) {
}
}

static bool layerMeetsHoldConditions(uint8_t layer, uint8_t* maskOutput) {
if (heldLayers[layer]) {
return true;
}
layer_config_t* cfg = &LayerConfig[layer];
if (cfg->layerIsDefined && cfg->modifierLayerMask) {
uint8_t maskOverlap = cfg->modifierLayerMask & InputModifiersPrevious;
if (maskOverlap == cfg->modifierLayerMask || (!cfg->exactModifierMatch && maskOverlap)) {
if (maskOutput != NULL) {
*maskOutput = maskOverlap;
}
return true;
}
}
return false;
}

// Gathers states set by LayerSwitcher_HoldLayer during previous update cycle and updates heldLayer.
void LayerSwitcher_UpdateActiveLayer() {
layer_id_t previousHeldLayer = heldLayer;
if(!heldLayers[heldLayer]) {
if (!layerMeetsHoldConditions(heldLayer, NULL)) {
heldLayer = LayerId_Base;
}
for (layer_id_t layerId = LayerId_Mod; layerId < LayerId_Count; layerId++) {
if (heldLayers[layerId] && heldLayer == LayerId_Base) {
bool heldLayerCanBeOverriden = heldLayer == LayerId_Base || (IS_MODIFIER_LAYER(heldLayer) && !IS_MODIFIER_LAYER(layerId));
if (heldLayerCanBeOverriden && layerMeetsHoldConditions(layerId, &ActiveLayerModifierMask)) {
heldLayer = layerId;
}
heldLayers[layerId] = false;
}
if(previousHeldLayer != heldLayer) {
if (!LayerConfig[heldLayer].modifierLayerMask) {
ActiveLayerModifierMask = 0;
}
if (previousHeldLayer != heldLayer) {
updateActiveLayer();
}
}
Expand Down
1 change: 1 addition & 0 deletions right/src/layer_switcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// Macros:

// Variables:
extern uint8_t ActiveLayerModifierMask;
extern layer_id_t ActiveLayer;
extern bool ActiveLayerHeld;
extern uint16_t DoubleTapSwitchLayerTimeout;
Expand Down
52 changes: 26 additions & 26 deletions right/src/led_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,32 @@ static const uint16_t letterToSegmentMap[] = {
0b00000000000000, // ^
0b10000000000000, // _
0b00000000000100, // `
0b00000000000000, // a
0b00000000000000, // b
0b00000000000000, // c
0b00000000000000, // d
0b00000000000000, // e
0b00000000000000, // f
0b00000000000000, // g
0b00000000000000, // h
0b00000000000000, // i
0b00000000000000, // j
0b00000000000000, // k
0b00000000000000, // l
0b00000000000000, // m
0b00000000000000, // n
0b00000000000000, // o
0b00000000000000, // p
0b00000000000000, // q
0b00000000000000, // r
0b00000000000000, // s
0b00000000000000, // t
0b00000000000000, // u
0b00000000000000, // v
0b00000000000000, // w
0b00000000000000, // x
0b00000000000000, // y
0b00000000000000, // z
0b01000111100011, // a (shown as A) - show lower-case letters as upper-case ones
0b11010010101001, // b (...)
0b10000100000011, // c
0b11010000101001, // d
0b10000111000011, // e
0b00000111000011, // f
0b11000110000011, // g
0b01000111100010, // h
0b10010000001001, // i
0b11000000100000, // j
0b00100101010010, // k
0b10000100000010, // l
0b01000100110110, // m
0b01100100100110, // n
0b11000100100011, // o
0b00000111100011, // p
0b11100100100011, // q
0b00100111100011, // r
0b11000011000011, // s
0b00010000001001, // t
0b11000100100010, // u
0b00001100010010, // v
0b01101100100010, // w
0b00101000010100, // x
0b00010000010100, // y
0b10001000010001, // z
0b00100001010000, // {
0b00010000001000, // |
0b00001010000100, // }
Expand Down
9 changes: 9 additions & 0 deletions right/src/lufa/HIDClassCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@
#define HID_KEYBOARD_MODIFIER_RIGHTGUI (1 << 7)
//@}

/** \name Keyboard Standard Report LED Usage IDs */
//@{
#define HID_LED_UID_NUMLOCK 1
#define HID_LED_UID_CAPSLOCK 2
#define HID_LED_UID_SCROLLLOCK 3
#define HID_LED_UID_COMPOSE 4
#define HID_LED_UID_KANA 5
//@}

/** \name Keyboard Standard Report LED Masks */
//@{
/** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
Expand Down
Loading

0 comments on commit 7edefbf

Please sign in to comment.