From e335d62eda6f9c295c1717cf7511dfb74a436f03 Mon Sep 17 00:00:00 2001 From: jack <0x6A73@pm.me> Date: Wed, 23 Mar 2022 23:23:40 -0600 Subject: [Keyboard] Add keyboard level encoder function for GMMK Pro (#16721) --- keyboards/gmmk/pro/pro.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/keyboards/gmmk/pro/pro.c b/keyboards/gmmk/pro/pro.c index 816d089a58..6aed1d6e18 100644 --- a/keyboards/gmmk/pro/pro.c +++ b/keyboards/gmmk/pro/pro.c @@ -14,3 +14,17 @@ * along with this program. If not, see . */ #include "pro.h" + +#ifdef ENCODER_ENABLE +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { + return false; + } + if (clockwise) { + tap_code_delay(KC_VOLU, 10); + } else { + tap_code_delay(KC_VOLD, 10); + } + return false; +} +#endif -- cgit v1.2.3 From 980a1b05629e351d19ff9ddc1bb5a1d38bab6414 Mon Sep 17 00:00:00 2001 From: Nathan Johnson Date: Thu, 24 Mar 2022 00:24:02 -0500 Subject: [Keymap] ergodox: updating osx_whiskey_tango_foxtrot_capslock to use process_record_user (#16715) --- .../osx_whiskey_tango_foxtrot_capslock/keymap.c | 45 +++++++++++++++++++++- .../osx_whiskey_tango_foxtrot_capslock/rules.mk | 2 + 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/rules.mk diff --git a/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/keymap.c b/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/keymap.c index 54e1183e9f..2285aa4a94 100644 --- a/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/keymap.c +++ b/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/keymap.c @@ -15,6 +15,10 @@ enum layer_names { typedef enum onoff_t {OFF, ON} onoff; +#define caps_led_on ergodox_right_led_2_on +#define caps_led_off ergodox_right_led_2_off + + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Keymap 0: Basic layer * @@ -123,7 +127,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ // MEDIA AND TENKEY [MDIA] = LAYOUT_ergodox( - KC_NO, KC_NO, KC_MUTE, KC_VOLD, KC_VOLU, KC_F14, KC_F15, + QK_BOOT, KC_NO, KC_MUTE, KC_VOLD, KC_VOLU, KC_F14, KC_F15, KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, @@ -142,6 +146,45 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS ), }; +#ifndef NO_FAKE_CAPS +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + static onoff caps_state = OFF; + + switch (keycode) { + case KC_CAPS: + if (record->event.pressed) { + if (caps_state == OFF) { + caps_led_on(); + caps_state = ON; + } else { + caps_led_off(); + caps_state = OFF; + } + } + break; + default: + if (keycode < KC_A || keycode > KC_Z) { + // This isn't an alpha or a KC_CAPS, continue on as usual. + return true; + } + if (record->event.pressed) { + bool shifted = (caps_state == ON && get_mods() == 0); + if (shifted) { + register_code(KC_LSFT); + } + register_code(keycode); + if (shifted) { + unregister_code(KC_LSFT); + } + } else { + unregister_code(keycode); + } + break; + } + // If we get here, we've already handled the keypresses. + return false; +} +#endif // Runs constantly in the background, in a loop. void matrix_scan_user(void) { diff --git a/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/rules.mk b/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/rules.mk new file mode 100644 index 0000000000..e8242c2695 --- /dev/null +++ b/layouts/community/ergodox/osx_whiskey_tango_foxtrot_capslock/rules.mk @@ -0,0 +1,2 @@ +# uncomment below to disable fake capslock +# OPT_DEFS += -DNO_FAKE_CAPS -- cgit v1.2.3