Skip to content

Commit

Permalink
Merge branch 'merge_preparation'
Browse files Browse the repository at this point in the history
  • Loading branch information
kareltucek committed Aug 12, 2021
2 parents 1d646d3 + 20bdb9c commit d3e0f1b
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 356 deletions.
414 changes: 223 additions & 191 deletions MACRO_DOCS.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ Some measurements:
2. Run `scripts/make-release.js`.
3. Now, the created tarball `scripts/uhk-firmware-VERSION.tar.gz` can be flashed with UHK Agent.

### Extended macro engine

To build with extended macro engine, use `make CUSTOM_CFLAGS=-DEXTENDED_MACROS` or `scripts/make-release.js --extendedMacros`. For usage, see [MACRO_DOCS.md](MACRO_DOCS.md).

## Contributing

If you wish some functionality, feel free to fire tickets with feature requests. If you wish something already present on the tracker (e.g., in 'idea' tickets), say so in comments. (Feel totally free to harass me over desired functionality :-).) If you feel brave, fork the repo, implement the desired functionality and post a PR.
Expand Down
9 changes: 9 additions & 0 deletions right/src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ uint8_t CurrentWatch = 0;
static uint32_t lastWatch = 0;
static uint32_t watchInterval = 500;

static void printReport(usb_basic_keyboard_report_t *report)
{
Macros_SetStatusNum(report->modifiers);
for (int i = 0; i < 6; i++) {
Macros_SetStatusNum(report->scancodes[i]);
}
Macros_SetStatusString("\n", NULL);
}

void ShowNumberExp(int32_t a)
{
char b[3];
Expand Down
13 changes: 6 additions & 7 deletions right/src/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ uint8_t FindKeymapByAbbreviation(uint8_t length, const char *abbrev) {

bool SwitchKeymapByAbbreviation(uint8_t length, const char *abbrev)
{
for (uint8_t i=0; i<AllKeymapsCount; i++) {
keymap_reference_t *keymap = AllKeymaps + i;
if (keymap->abbreviationLen == length && memcmp(keymap->abbreviation, abbrev, length) == 0) {
SwitchKeymapById(i);
return true;
}
uint8_t keymapId = FindKeymapByAbbreviation(length, abbrev);

if (keymapId != 0xFF) {
return true;
} else {
return false;
}
return false;
}

// The factory keymap is initialized before it gets overwritten by the default keymap of the EEPROM.
Expand Down
6 changes: 6 additions & 0 deletions right/src/macro_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include "led_display.h"
#include "debug.h"

/**
* Future possible extensions:
* - generalize change to always handle "in" and "out" events
* - add onKeymapLayerChange, onKeymapKeyPress, onKeyPress, onLayerChange events. These would be indexed when keymap is changed and kept at hand, so we could run them without any performance impact.
*/

void MacroEvent_OnInit()
{
const char* s = "$onInit";
Expand Down
25 changes: 14 additions & 11 deletions right/src/macro_set_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static const char* proceedByDot(const char* cmd, const char *cmdEnd)

static void moduleNavigationMode(const char* arg1, const char *textEnd, module_configuration_t* module)
{
layer_id_t layerId = ParseLayerId(arg1, textEnd);
layer_id_t layerId = Macros_ParseLayerId(arg1, textEnd);
navigation_mode_t modeId = ParseNavigationModeId(NextTok(arg1, textEnd), textEnd);

module->navigationModes[layerId] = modeId;
Expand Down Expand Up @@ -86,23 +86,23 @@ static void mouseKeys(const char* arg1, const char *textEnd)
const char* arg3 = NextTok(arg2, textEnd);

if (TokenMatches(arg2, textEnd, "initialSpeed")) {
state->initialSpeed = ParseInt32(arg3, textEnd);
state->initialSpeed = Macros_ParseInt(arg3, textEnd, NULL);
}
else if (TokenMatches(arg2, textEnd, "baseSpeed")) {
state->baseSpeed = ParseInt32(arg3, textEnd);
state->baseSpeed = Macros_ParseInt(arg3, textEnd, NULL);
}
else if (TokenMatches(arg2, textEnd, "initialAcceleration")) {
state->acceleration = ParseInt32(arg3, textEnd);
state->acceleration = Macros_ParseInt(arg3, textEnd, NULL);
}
else if (TokenMatches(arg2, textEnd, "deceleratedSpeed")) {
state->deceleratedSpeed = ParseInt32(arg3, textEnd);
state->deceleratedSpeed = Macros_ParseInt(arg3, textEnd, NULL);
}
else if (TokenMatches(arg2, textEnd, "acceleratedSpeed")) {
state->acceleratedSpeed = ParseInt32(arg3, textEnd);
state->acceleratedSpeed = Macros_ParseInt(arg3, textEnd, NULL);
}
/* axis skew */
else if (TokenMatches(arg1, textEnd, "axisSkew")) {
//module->axisSkew = ParseInt32(arg3, textEnd);
//module->axisSkew = Macros_ParseInt(arg3, textEnd, NULL);
// TODO
}
else {
Expand Down Expand Up @@ -140,22 +140,25 @@ bool MacroSetCommand(const char* arg1, const char *textEnd)
mouseKeys(proceedByDot(arg1, textEnd), textEnd);
}
else if (TokenMatches(arg1, textEnd, "compensateDiagonalSpeed")) {
CompensateDiagonalSpeed = ParseInt32(arg2, textEnd);
CompensateDiagonalSpeed = Macros_ParseInt(arg2, textEnd, NULL);
}
else if (TokenMatches(arg1, textEnd, "stickyMods")) {
stickyMods(arg2, textEnd);
}
else if (TokenMatches(arg1, textEnd, "debounceDelay")) {
uint16_t time = ParseInt32(arg2, textEnd);
uint16_t time = Macros_ParseInt(arg2, textEnd, NULL);

DebounceTimePress = time;
DebounceTimeRelease = time;
}
else if (TokenMatches(arg1, textEnd, "keystrokeDelay")) {
KeystrokeDelay = ParseInt32(arg2, textEnd);
KeystrokeDelay = Macros_ParseInt(arg2, textEnd, NULL);
}
else if (TokenMatches(arg1, textEnd, "chording")) {
Chording = Macros_ParseInt(arg2, textEnd, NULL);
}
else if (TokenMatches(arg1, textEnd, "emergencyKey")) {
uint16_t key = ParseInt32(arg2, textEnd);
uint16_t key = Macros_ParseInt(arg2, textEnd, NULL);
EmergencyKey = Utils_KeyIdToKeyState(key);
}
else {
Expand Down
14 changes: 6 additions & 8 deletions right/src/macro_shortcut_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,14 @@ lookup_record_t lookup_table[] = {
{"mouseBtnLeft", MouseButton_Left, scType_mouseBtn},
{"mouseBtnRight", MouseButton_Right, scType_mouseBtn},
{"mouseBtnMiddle", MouseButton_Middle, scType_mouseBtn},
{"mouseBtn1", MouseButton_Left, scType_mouseBtn},
{"mouseBtn2", MouseButton_Right, scType_mouseBtn},
{"mouseBtn3", MouseButton_Middle, scType_mouseBtn},
{"mouseBtn4", MouseButton_4, scType_mouseBtn},
{"mouseBtn5", MouseButton_5, scType_mouseBtn},
{"mouseBtn6", MouseButton_6, scType_mouseBtn},
{"mouseBtn7", MouseButton_7, scType_mouseBtn},
{"mouseBtn8", MouseButton_8, scType_mouseBtn},
};

size_t lookup_size = sizeof(lookup_table)/sizeof(lookup_table[0]);
Expand All @@ -340,15 +345,9 @@ static void sortLookup()
}
}

static void initialize()
void ShortcutParser_initialize()
{
static bool initialized = false;
if (initialized) {
return;
}

sortLookup();
initialized = true;
}


Expand Down Expand Up @@ -463,7 +462,6 @@ static macro_action_t parseAbbrev(const char* str, const char* strEnd)
macro_action_t MacroShortcutParser_Parse(const char* str, const char* strEnd)
{
macro_action_t action;
initialize();

if (FindChar('-', str, strEnd) == strEnd) {
//"-" notation not used
Expand Down
2 changes: 2 additions & 0 deletions right/src/macro_shortcut_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

// Functions:

void ShortcutParser_initialize();

macro_action_t MacroShortcutParser_Parse(const char* str, const char* strEnd);
uint8_t MacroShortcutParser_CharacterToScancode(char character);
bool MacroShortcutParser_CharacterToShift(char character);
Expand Down
Loading

0 comments on commit d3e0f1b

Please sign in to comment.