the-via / app

GNU General Public License v3.0
765 stars 173 forks source link

Writing a macro manually when `protocol < 11` doesn't allow {+KC_xyz} #165

Closed kivikakk closed 6 months ago

kivikakk commented 1 year ago

Hi there! I noticed I was unable to manually write a macro like the following for my "Keychron Q10 ANSI Knob":

{+KC_LALT}{KC_P0}{KC_P2}{KC_P5}{KC_P5}{-KC_LALT}

Recording it is fine (and produces the above sequence when read), but I can't write that myself and save it; I get:

Whoops! Invalid keycodes detected inside {}: +KC_LALT

I figure it must be because the invalid keycode detection at work here is this code:

https://github.com/the-via/app/blob/3467ca79f07ca7f98513e7e9992112c79ee83bbe/src/utils/macro-api/macro-api.ts#L52-L57

Whereas macro-api.v11.ts has this extra .replace:

https://github.com/the-via/app/blob/3467ca79f07ca7f98513e7e9992112c79ee83bbe/src/utils/macro-api/macro-api.v11.ts#L67-L73

I think it should be safe to add the .replace to the pre-11 one, too, though I can't be sure. Does that sound about right?

I'm happy to open a PR with the change if so; just wanted to sound it out first. I'd also be happy to write a state machine-based parser for the macro language, which might be a little easier to modify and maintain, if there's any interest.

jandhollander commented 11 months ago

I have the same problem on my Keychron K10 PRO

Lathe26 commented 11 months ago

Same issue seen on Keychron K8 Pro, using firmware v1.02 ANSI.

Used web version of app on 2023-08-14. It's unclear what release version is, but the HTML's section contains the following string: <style data-styled="active" data-styled-version="6.0.0-beta.6"></style>