Skip to content

descriptive labels and types for $macroArgs #1466

@mhantsch

Description

@mhantsch

Parse macros for declarations of macroArgs.
Display descriptive labels (instead of "$macroArg.x") in front of value fields.
Based on the type of each macroArg, allow only input of permitted values.

This is a first draft for this Agent feature.

Example:

// macroArg.1:scancode Scancode for solo activation
// macroArg.2:scancode Scancode for combo activation
// macroArg.3:keyid Key to check for combo
// macroArg.4:int Timeout in ms
ifShortcut timeoutIn $macroArg.4 &macroArg.3 final holdKey &macroArg.2
holdKey &macroArg.1

Agent would parse the comments and understand to show four arguments to be filled out.

  • Argument 1 is labelled "Scancode for solo activation" and needs a Scancode + Mod selection
  • Argument 2 is labelled "Scancode for combo activation" and also needs a Scancode + Mod selection.
  • Argument 3 is labelled "Key to check for combo" and needs a Key ID selection.
  • Argument 4 is labelled "Timeout in ms" and needs an integer.

Instead of "$macroArg.1", "$macroArg.2" etc. Agent would show the descriptions from the declaration.

For the value field, Agent would allow only allowed values according to the type:

  • For int, the value needs to match the regex /[0-9]+/
  • For float, the value needs to match the regex /[0-9\.]+/
  • For string, the value can be anything, but will be put between single quotes automatically, and any single quotes and escape characters will be escaped.
  • For keyid, a popup will allow only the selection of key legends, and the values field will internally be set to the KEYID for that legend.
  • For scancode, a popup will allow only the selection of scancodes (similar to Keypress action), and buttons for modifiers will be shown (again, similar to Keypress action). The value field will internally be set to the corresponding SHORTCUT.
  • For verbatim, the value can be anything, and it will be passed verbatim (= as entered) without any checks. This is identical to macroArg parameters which were added manually in Agent (although it will be labelled with the description instead of "$macroArg.x").

This feature works without any changes to firmware or config structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions