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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build
.vscode/settings.json
.jj
mcux_include.json
right/src/macros/command_hash.c
tags
compile_commands.json
specs
2 changes: 2 additions & 0 deletions device/prj.conf.overlays/nrf_shared.conf
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ CONFIG_TRACING_USER=y
CONFIG_PM=y
CONFIG_PM_DEVICE=y

# set -O2
CONFIG_SPEED_OPTIMIZATIONS=y
2 changes: 1 addition & 1 deletion device/src/keyboard/oled/oled_text_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static uint8_t getUtf8Length(uint8_t firstByte) {
// TODO: return resulting bounds rectangle?
void Framebuffer_DrawText(widget_t* canvas, framebuffer_t* buffer, int16_t x, int16_t y, const lv_font_t* font, const char* text, const char* textEnd)
{
bool truncated;
bool truncated = false;
if (x < 0 || y < 0) {
int16_t canvasWidth = canvas == NULL ? DISPLAY_WIDTH : canvas->w;
int16_t canvasHeight = canvas == NULL ? DISPLAY_HEIGHT : canvas->h;
Expand Down
3 changes: 1 addition & 2 deletions device/src/keyboard/oled/widgets/console_widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ widget_t ConsoleWidget_Build()
static void logConstant(const char* text)
{
consoleBufferStart = (consoleBufferStart+1) % CONSOLE_BUFFER_LINE_COUNT;
strncpy(&consoleBuffer[consoleBufferStart][0], text, CONSOLE_BUFFER_LINE_LENGTH);
consoleBuffer[consoleBufferStart][CONSOLE_BUFFER_LINE_LENGTH-1] = '\0';
snprintf(&consoleBuffer[consoleBufferStart][0], CONSOLE_BUFFER_LINE_LENGTH, "%s", text);

consoleBufferIsDirty = true;

Expand Down
7 changes: 7 additions & 0 deletions right/src/config_parser/parse_macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ parser_error_t parseCommandMacroAction(config_buffer_t *buffer, macro_action_t *
macroAction->cmd.textLen = textLen;
macroAction->cmd.cmdCount = CountCommands(macroAction->cmd.text, macroAction->cmd.textLen);

// Sanitize line endings so that we can compare faster
for (char* ptr = (char*)text; ptr < text + textLen; ptr++) {
if (*ptr == '\r') {
*ptr = '\n';
}
}

return ParserError_Success;
}

Expand Down
16 changes: 16 additions & 0 deletions right/src/macros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Generate command hash table from gperf input
find_program(GPERF_EXECUTABLE gperf)
if(GPERF_EXECUTABLE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/command_hash.c
COMMAND ${GPERF_EXECUTABLE}
-t -L ANSI-C -N command_lookup -H command_hash
${CMAKE_CURRENT_SOURCE_DIR}/command_hash.gperf
> ${CMAKE_CURRENT_SOURCE_DIR}/command_hash.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/command_hash.gperf
COMMENT "Generating command_hash.c from command_hash.gperf"
)
add_custom_target(generate_command_hash DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/command_hash.c)
add_dependencies(${PROJECT_NAME} generate_command_hash)
endif()

target_sources(${PROJECT_NAME} PRIVATE
commands.c
core.c
Expand Down
167 changes: 167 additions & 0 deletions right/src/macros/command_hash.gperf
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
%{
#include "command_ids.h"
%}
%readonly-tables
%compare-strncmp
struct command_entry { const char *name; command_id_t id; };
%%
activateKeyPostponed, CommandId_activateKeyPostponed
autoRepeat, CommandId_autoRepeat
addReg, CommandId_addReg
break, CommandId_break
bluetooth, CommandId_bluetooth
consumePending, CommandId_consumePending
clearStatus, CommandId_clearStatus
call, CommandId_call
delayUntilRelease, CommandId_delayUntilRelease
delayUntilReleaseMax, CommandId_delayUntilReleaseMax
delayUntil, CommandId_delayUntil
diagnose, CommandId_diagnose
exec, CommandId_exec
else, CommandId_else
exit, CommandId_exit
final, CommandId_final
fork, CommandId_fork
freeze, CommandId_freeze
goTo, CommandId_goTo
holdLayer, CommandId_holdLayer
holdLayerMax, CommandId_holdLayerMax
holdKeymapLayer, CommandId_holdKeymapLayer
holdKeymapLayerMax, CommandId_holdKeymapLayerMax
holdKey, CommandId_holdKey
if, CommandId_if
ifDoubletap, CommandId_ifDoubletap
ifNotDoubletap, CommandId_ifNotDoubletap
ifInterrupted, CommandId_ifInterrupted
ifNotInterrupted, CommandId_ifNotInterrupted
ifReleased, CommandId_ifReleased
ifNotReleased, CommandId_ifNotReleased
ifKeymap, CommandId_ifKeymap
ifNotKeymap, CommandId_ifNotKeymap
ifLayer, CommandId_ifLayer
ifNotLayer, CommandId_ifNotLayer
ifLayerToggled, CommandId_ifLayerToggled
ifNotLayerToggled, CommandId_ifNotLayerToggled
ifPlaytime, CommandId_ifPlaytime
ifNotPlaytime, CommandId_ifNotPlaytime
ifAnyMod, CommandId_ifAnyMod
ifNotAnyMod, CommandId_ifNotAnyMod
ifShift, CommandId_ifShift
ifNotShift, CommandId_ifNotShift
ifCtrl, CommandId_ifCtrl
ifNotCtrl, CommandId_ifNotCtrl
ifAlt, CommandId_ifAlt
ifNotAlt, CommandId_ifNotAlt
ifGui, CommandId_ifGui
ifNotGui, CommandId_ifNotGui
ifCapsLockOn, CommandId_ifCapsLockOn
ifNotCapsLockOn, CommandId_ifNotCapsLockOn
ifNumLockOn, CommandId_ifNumLockOn
ifNotNumLockOn, CommandId_ifNotNumLockOn
ifScrollLockOn, CommandId_ifScrollLockOn
ifNotScrollLockOn, CommandId_ifNotScrollLockOn
ifRecording, CommandId_ifRecording
ifNotRecording, CommandId_ifNotRecording
ifRecordingId, CommandId_ifRecordingId
ifNotRecordingId, CommandId_ifNotRecordingId
ifNotPending, CommandId_ifNotPending
ifPending, CommandId_ifPending
ifKeyPendingAt, CommandId_ifKeyPendingAt
ifNotKeyPendingAt, CommandId_ifNotKeyPendingAt
ifKeyActive, CommandId_ifKeyActive
ifNotKeyActive, CommandId_ifNotKeyActive
ifPendingKeyReleased, CommandId_ifPendingKeyReleased
ifNotPendingKeyReleased, CommandId_ifNotPendingKeyReleased
ifKeyDefined, CommandId_ifKeyDefined
ifNotKeyDefined, CommandId_ifNotKeyDefined
ifModuleConnected, CommandId_ifModuleConnected
ifNotModuleConnected, CommandId_ifNotModuleConnected
ifHold, CommandId_ifHold
ifTap, CommandId_ifTap
ifSecondary, CommandId_ifSecondary
ifPrimary, CommandId_ifPrimary
ifShortcut, CommandId_ifShortcut
ifNotShortcut, CommandId_ifNotShortcut
ifGesture, CommandId_ifGesture
ifNotGesture, CommandId_ifNotGesture
ifRegEq, CommandId_ifRegEq
ifNotRegEq, CommandId_ifNotRegEq
ifRegGt, CommandId_ifRegGt
ifRegLt, CommandId_ifRegLt
mulReg, CommandId_mulReg
noOp, CommandId_noOp
notify, CommandId_notify
oneShot, CommandId_oneShot
overlayLayer, CommandId_overlayLayer
overlayKeymap, CommandId_overlayKeymap
printStatus, CommandId_printStatus
playMacro, CommandId_playMacro
pressKey, CommandId_pressKey
postponeKeys, CommandId_postponeKeys
postponeNext, CommandId_postponeNext
progressHue, CommandId_progressHue
powerMode, CommandId_powerMode
panic, CommandId_panic
recordMacro, CommandId_recordMacro
recordMacroBlind, CommandId_recordMacroBlind
recordMacroDelay, CommandId_recordMacroDelay
resolveNextKeyId, CommandId_resolveNextKeyId
releaseKey, CommandId_releaseKey
repeatFor, CommandId_repeatFor
resetTrackpoint, CommandId_resetTrackpoint
replaceLayer, CommandId_replaceLayer
replaceKeymap, CommandId_replaceKeymap
resolveNextKeyEq, CommandId_resolveNextKeyEq
resolveSecondary, CommandId_resolveSecondary
resetConfiguration, CommandId_resetConfiguration
reboot, CommandId_reboot
reconnect, CommandId_reconnect
set, CommandId_set
setVar, CommandId_setVar
setStatus, CommandId_setStatus
startRecording, CommandId_startRecording
startRecordingBlind, CommandId_startRecordingBlind
setLedTxt, CommandId_setLedTxt
statsRuntime, CommandId_statsRuntime
statsRecordKeyTiming, CommandId_statsRecordKeyTiming
statsLayerStack, CommandId_statsLayerStack
statsActiveKeys, CommandId_statsActiveKeys
statsActiveMacros, CommandId_statsActiveMacros
statsPostponerStack, CommandId_statsPostponerStack
statsVariables, CommandId_statsVariables
statsBattery, CommandId_statsBattery
switchKeymap, CommandId_switchKeymap
startMouse, CommandId_startMouse
stopMouse, CommandId_stopMouse
stopRecording, CommandId_stopRecording
stopAllMacros, CommandId_stopAllMacros
stopRecordingBlind, CommandId_stopRecordingBlind
suppressMods, CommandId_suppressMods
setReg, CommandId_setReg
subReg, CommandId_subReg
setStatusPart, CommandId_setStatusPart
switchKeymapLayer, CommandId_switchKeymapLayer
switchLayer, CommandId_switchLayer
switchHost, CommandId_switchHost
toggleKeymapLayer, CommandId_toggleKeymapLayer
toggleLayer, CommandId_toggleLayer
tapKey, CommandId_tapKey
tapKeySeq, CommandId_tapKeySeq
toggleKey, CommandId_toggleKey
trackpoint, CommandId_trackpoint
trace, CommandId_trace
testLeakage, CommandId_testLeakage
testSuite, CommandId_testSuite
unToggleLayer, CommandId_unToggleLayer
untoggleLayer, CommandId_untoggleLayer
unpairHost, CommandId_unpairHost
validateUserConfig, CommandId_validateUserConfig
validateMacros, CommandId_validateMacros
write, CommandId_write
while, CommandId_while
writeExpr, CommandId_writeExpr
yield, CommandId_yield
zephyr, CommandId_zephyr
"{", CommandId_openBrace
"}", CommandId_closeBrace
%%
Loading