Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function performZephyrAction() {
createCentralCompileCommands
;;
make)
$NICE west build --build-dir $ROOT/device/build/$DEVICE device
$NICE west build --build-dir $ROOT/device/build/$DEVICE device
exitOnFail $?
;;
flash)
Expand Down
2 changes: 2 additions & 0 deletions doc-dev/reference-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ CONDITION = {ifLayerToggled | ifNotLayerToggled}
CONDITION = {ifRecording | ifNotRecording}
CONDITION = {ifRecordingId | ifNotRecordingId} MACROID
CONDITION = {ifModuleConnected | ifNotModuleConnected} MODULEID
CONDITION = {ifAlreadyRunning | ifNotAlreadyRunning}
MODIFIER = <modifier>
MODIFIER = suppressMods
MODIFIER = postponeKeys
Expand Down Expand Up @@ -558,6 +559,7 @@ Conditions are checked before processing the rest of the command. If the conditi
- `{ifKeymap|ifNotKeymap|ifLayer|ifNotLayer} <value>` will test if the current Keymap/Layer equals the first argument.
- `{ifLayerToggled|ifNotLayerToggled}` will return true if current layer is toggled. It will return true if the toggled layer is on top of the stack, or anywhere else as long as only the same (currently active) layers are above it in the layer stack.
- `ifRecording/ifNotRecording` and `ifRecordingId/ifNotRecordingId MACROID` test if the runtime macro recorder is in the recording state.
- `ifAlreadyRunning/ifNotAlreadyRunning` is true if another macro slot is currently playing the same macro index as the current one. Useful to prevent re-entering a macro that is already in progress.
- `ifShortcut/ifNotShortcut [IFSHORTCUT_OPTIONS]* [KEYID]*` will wait for future keypresses and compare them to the argument. See the postponer mechanism section.
- `ifGesture/ifNotGesture [IFSHORTCUT_OPTIONS]* [KEYID]*` just as `ifShortcut`, but breaks after 1000ms instead of when the key is released. See the postponer mechanism section.
- `ifPrimary/ifSecondary [ simpleStrategy | advancedStrategy | ignoreTriggersFromSameHalf | acceptTriggersFromSameHalf ] ... COMMAND` will wait until the firmware can distinguish whether primary or secondary action should be activated and then either execute `COMMAND` or skip it.
Expand Down
2 changes: 2 additions & 0 deletions right/src/macros/command_hash.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ ifKeyDefined, CommandId_ifKeyDefined
ifNotKeyDefined, CommandId_ifNotKeyDefined
ifModuleConnected, CommandId_ifModuleConnected
ifNotModuleConnected, CommandId_ifNotModuleConnected
ifAlreadyRunning, CommandId_ifAlreadyRunning
ifNotAlreadyRunning, CommandId_ifNotAlreadyRunning
ifHold, CommandId_ifHold
ifTap, CommandId_ifTap
ifSecondary, CommandId_ifSecondary
Expand Down
2 changes: 2 additions & 0 deletions right/src/macros/command_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ typedef enum {
CommandId_ifNotKeyDefined,
CommandId_ifModuleConnected,
CommandId_ifNotModuleConnected,
CommandId_ifAlreadyRunning,
CommandId_ifNotAlreadyRunning,
CommandId_ifHold,
CommandId_ifTap,
CommandId_ifSecondary,
Expand Down
24 changes: 24 additions & 0 deletions right/src/macros/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,26 @@ static bool processIfRecordingIdCommand(parser_context_t* ctx, bool negate)
return res != negate;
}

static bool processIfAlreadyRunningCommand(bool negate)
{
if (Macros_DryRun) {
return true;
}
uint8_t myIndex = S->ms.currentMacroIndex;
uint8_t mySlot = S - MacroState;
bool found = false;
for (uint8_t i = 0; i < MACRO_STATE_POOL_SIZE; i++) {
if (i == mySlot) {
continue;
}
if (MacroState[i].ms.macroPlaying && MacroState[i].ms.currentMacroIndex == myIndex) {
found = true;
break;
}
}
return found != negate;
}

static bool processIfPendingCommand(parser_context_t* ctx, bool negate)
{
uint32_t cnt = Macros_ConsumeInt(ctx);
Expand Down Expand Up @@ -2183,6 +2203,10 @@ static macro_result_t processCommand(parser_context_t* ctx)
PROCESS_CONDITION(processIfModuleConnected(ctx, false))
case CommandId_ifNotModuleConnected:
PROCESS_CONDITION(processIfModuleConnected(ctx, true))
case CommandId_ifAlreadyRunning:
PROCESS_CONDITION(processIfAlreadyRunningCommand(false))
case CommandId_ifNotAlreadyRunning:
PROCESS_CONDITION(processIfAlreadyRunningCommand(true))
case CommandId_ifHold:
return processIfHoldCommand(ctx, false);
case CommandId_ifTap:
Expand Down