From 699da22d5e1fea45cd90af49c63cdf1412d14dba Mon Sep 17 00:00:00 2001 From: Tobias Schulte Date: Thu, 26 Jun 2014 21:41:49 +0200 Subject: [PATCH 1/2] New TYPE__ macros for typing the key directly on key press I needed to introduce these, because I had a problem with typing "<>". On my PC configured to use German keyboard layout following happened: The key ">" was not processed by the OS when "<" was typed just before. The reason I think is, that normally on a German keyboard "<" and ">" are on the same key (the key right of the left "shift"). For "<" you press that key. For ">" you have to first release the key press and hold "shift", and press the key again. This was not possible with the KEYS__DEFAULT and KEYS__SHIFTED macros. Therefore I introduced the TYPE__ macros. They do all the work, i.e. send a press followed by a release to the OS. With these macros it is not possible any more to use repeating of keys at the OS level, but for me this is no problem, because I don't use this for normal keys. Maybe this is a problem with shortcut combinations, where multiple keys need to be pressed simultaniously. Since the ALT_GR macros where also doing all the work on key press, I renamed them to TYPE__, to reflect this. --- .../ergodox/layout/fragments/keys.part.h | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/firmware/keyboard/ergodox/layout/fragments/keys.part.h b/firmware/keyboard/ergodox/layout/fragments/keys.part.h index 22b1ae2a..f1759fa9 100644 --- a/firmware/keyboard/ergodox/layout/fragments/keys.part.h +++ b/firmware/keyboard/ergodox/layout/fragments/keys.part.h @@ -21,6 +21,12 @@ void P(name) (void) { KF(press)(value); } \ void R(name) (void) { KF(release)(value); } +#define TYPE__DEFAULT(name, value) \ + void P(name) (void) { KF(press)(value); \ + usb__kb__send_report(); \ + KF(release)(value); } \ + void R(name) (void) { } + /** macros/KEYS__SHIFTED/description * Define the functions for a "shifted" key (i.e. a key that sends a "shift" * along with the keycode) @@ -33,6 +39,15 @@ void R(name) (void) { KF(release)(value); \ KF(release)(KEYBOARD__LeftShift); } +#define TYPE__SHIFTED(name, value) \ + void P(name) (void) { KF(press)(KEYBOARD__LeftShift); \ + usb__kb__send_report(); \ + KF(press)(value); \ + usb__kb__send_report(); \ + KF(release)(value); \ + KF(release)(KEYBOARD__LeftShift); } \ + void R(name) (void) { } + /** macros/KEYS__ALT_GR/description * Define the functions for a "AltGr" key (i.e. a key that sends a "AltGr" * along with the keycode) @@ -45,12 +60,21 @@ void R(name) (void) { KF(release)(value); \ KF(release)(KEYBOARD__RightAlt); } +#define TYPE__ALT_GR(name, value) \ + void P(name) (void) { KF(press)(KEYBOARD__RightAlt); \ + usb__kb__send_report(); \ + KF(press)(value); \ + usb__kb__send_report(); \ + KF(release)(value); \ + KF(release)(KEYBOARD__RightAlt); } \ + void R(name) (void) { } + /** macros/KEYS__NON_DEAD/description * Define the functions for a normally dead key, to be non-dead. * * Needed by ".../lib/layout/keys.h" */ -#define KEYS__NON_DEAD(name, value) \ +#define TYPE__NON_DEAD(name, value) \ void P(name) (void) { KF(press)(value); \ usb__kb__send_report(); \ KF(release)(value); \ @@ -65,8 +89,9 @@ * * Needed by ".../lib/layout/keys.h" */ -#define KEYS__NON_DEAD_SHIFTED(name, value) \ +#define TYPE__NON_DEAD_SHIFTED(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__LeftShift); \ + usb__kb__send_report(); \ KF(press)(value); \ usb__kb__send_report(); \ KF(release)(value); \ @@ -82,8 +107,9 @@ * * Needed by ".../lib/layout/keys.h" */ -#define KEYS__NON_DEAD_ALT_GR(name, value) \ +#define TYPE__NON_DEAD_ALT_GR(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__RightAlt); \ + usb__kb__send_report(); \ KF(press)(value); \ usb__kb__send_report(); \ KF(release)(value); \ From 014c8b80746101efe34acfe72424e2f19c9070c0 Mon Sep 17 00:00:00 2001 From: Tobias Schulte Date: Thu, 26 Jun 2014 22:04:52 +0200 Subject: [PATCH 2/2] Documentation enhancements after comments from Ben. --- .../ergodox/layout/fragments/keys.part.h | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/firmware/keyboard/ergodox/layout/fragments/keys.part.h b/firmware/keyboard/ergodox/layout/fragments/keys.part.h index f1759fa9..2f1ac57d 100644 --- a/firmware/keyboard/ergodox/layout/fragments/keys.part.h +++ b/firmware/keyboard/ergodox/layout/fragments/keys.part.h @@ -21,6 +21,12 @@ void P(name) (void) { KF(press)(value); } \ void R(name) (void) { KF(release)(value); } +/** macros/TYPE__DEFAULT/description + * Define the functions for a default key (i.e. a normal key that presses and + * releases a keycode as you'd expect). Other than KEYS_DEFAULT, this does send + * a press and release event on key press and does not wait for the user + * releasing the key. + */ #define TYPE__DEFAULT(name, value) \ void P(name) (void) { KF(press)(value); \ usb__kb__send_report(); \ @@ -39,6 +45,12 @@ void R(name) (void) { KF(release)(value); \ KF(release)(KEYBOARD__LeftShift); } +/** macros/TYPE__SHIFTED/description + * Define the functions for a "shifted" key (i.e. a key that sends a "shift" + * along with the keycode). Other than KEYS_SHIFTED, this does send + * a press and release event on key press and does not wait for the user + * releasing the key. + */ #define TYPE__SHIFTED(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__LeftShift); \ usb__kb__send_report(); \ @@ -50,9 +62,7 @@ /** macros/KEYS__ALT_GR/description * Define the functions for a "AltGr" key (i.e. a key that sends a "AltGr" - * along with the keycode) - * - * Needed by ".../lib/layout/keys.h" + * along with the keycode). */ #define KEYS__ALT_GR(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__RightAlt); \ @@ -60,6 +70,12 @@ void R(name) (void) { KF(release)(value); \ KF(release)(KEYBOARD__RightAlt); } +/** macros/TYPE__ALT_GR/description + * Define the functions for a "AltGr" key (i.e. a key that sends a "AltGr" + * along with the keycode). Other than KEYS_SHIFTED, this does send + * a press and release event on key press and does not wait for the user + * releasing the key. + */ #define TYPE__ALT_GR(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__RightAlt); \ usb__kb__send_report(); \ @@ -69,10 +85,8 @@ KF(release)(KEYBOARD__RightAlt); } \ void R(name) (void) { } -/** macros/KEYS__NON_DEAD/description +/** macros/TYPE__NON_DEAD/description * Define the functions for a normally dead key, to be non-dead. - * - * Needed by ".../lib/layout/keys.h" */ #define TYPE__NON_DEAD(name, value) \ void P(name) (void) { KF(press)(value); \ @@ -84,10 +98,9 @@ KF(release)(KEYBOARD__Spacebar); } \ void R(name) (void) {} -/** macros/KEYS__NON_DEAD_SHIFTED/description - * Define the functions for a normally dead key, to be non-dead. - * - * Needed by ".../lib/layout/keys.h" +/** macros/TYPE__NON_DEAD_SHIFTED/description + * Define the functions for a normally dead key, which needs the "shift" + * key to be pressed, to be non-dead. */ #define TYPE__NON_DEAD_SHIFTED(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__LeftShift); \ @@ -102,10 +115,9 @@ KF(release)(KEYBOARD__Spacebar); } \ void R(name) (void) {} -/** macros/KEYS__NON_DEAD_ALT_GR/description - * Define the functions for a normally dead key, to be non-dead. - * - * Needed by ".../lib/layout/keys.h" +/** macros/TYPE__NON_DEAD_ALT_GR/description + * Define the functions for a normally dead key, which needs the "AltGr" + * key, to be non-dead. */ #define TYPE__NON_DEAD_ALT_GR(name, value) \ void P(name) (void) { KF(press)(KEYBOARD__RightAlt); \