diff options
| author | Jay Greco <jayv.greco@gmail.com> | 2021-02-09 06:50:16 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-09 14:50:16 +0000 |
| commit | 4107856b70eb686d2e151254ca73adf522312c49 (patch) | |
| tree | 81b52ea7b24328f7d7c7baaa328be126d06bef64 /keyboards | |
| parent | 627ceebef3ed19eceba3642a830ffbf44f4a9e04 (diff) | |
| download | qmk_firmware-4107856b70eb686d2e151254ca73adf522312c49.tar.gz qmk_firmware-4107856b70eb686d2e151254ca73adf522312c49.zip | |
Simplify NIBBLE encoder code and clean up keymaps (#11808)
* Simplify encoder code and clean up keymaps.
-Removed overly complex VIA encoder code. It wasn't adding any value and was confusing users who were trying to customize encoder functionality on VIA keymaps.
-Replaced KC_TILDE with KC_HOME in all keymaps, as KC_TILDE sends a left shift, which was confusing some folks as they tested their build.
-Move layer names to enum
* Change encoder_update_kb to encoder_update_user per PR feedback
Diffstat (limited to 'keyboards')
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/default/keymap.c | 20 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/iso/keymap.c | 8 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/oled/keymap.c | 78 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/config.h | 21 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/keymap.c | 30 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c | 133 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h | 50 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/rules.mk | 5 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/via_extras.c | 129 | ||||
| -rw-r--r-- | keyboards/nullbitsco/nibble/keymaps/via/via_extras.h | 39 |
10 files changed, 77 insertions, 436 deletions
diff --git a/keyboards/nullbitsco/nibble/keymaps/default/keymap.c b/keyboards/nullbitsco/nibble/keymaps/default/keymap.c index 6d453e706..787e8bd8f 100644 --- a/keyboards/nullbitsco/nibble/keymaps/default/keymap.c +++ b/keyboards/nullbitsco/nibble/keymaps/default/keymap.c | |||
| @@ -15,8 +15,10 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #include QMK_KEYBOARD_H | 16 | #include QMK_KEYBOARD_H |
| 17 | 17 | ||
| 18 | #define _MA 0 | 18 | enum layer_names { |
| 19 | #define _FN 1 | 19 | _MA, |
| 20 | _FN | ||
| 21 | }; | ||
| 20 | 22 | ||
| 21 | enum custom_keycodes { | 23 | enum custom_keycodes { |
| 22 | KC_CUST = SAFE_RANGE, | 24 | KC_CUST = SAFE_RANGE, |
| @@ -24,14 +26,14 @@ enum custom_keycodes { | |||
| 24 | 26 | ||
| 25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 27 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 26 | [_MA] = LAYOUT_ansi( | 28 | [_MA] = LAYOUT_ansi( |
| 27 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TILD, | 29 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, |
| 28 | KC_F13, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, | 30 | KC_F13, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, |
| 29 | KC_F14, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, | 31 | KC_F14, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, |
| 30 | KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, | 32 | KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, |
| 31 | KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT | 33 | KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT |
| 32 | ), | 34 | ), |
| 33 | [_FN] = LAYOUT_ansi( | 35 | [_FN] = LAYOUT_ansi( |
| 34 | RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_INS, | 36 | RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_END, |
| 35 | RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 37 | RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| 36 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 38 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| 37 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 39 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| @@ -68,7 +70,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 68 | if (record->event.pressed) { | 70 | if (record->event.pressed) { |
| 69 | } | 71 | } |
| 70 | break; | 72 | break; |
| 71 | 73 | ||
| 72 | } | 74 | } |
| 73 | return true; | 75 | return true; |
| 74 | } | 76 | } |
| @@ -100,10 +102,10 @@ void change_RGB(bool clockwise) { | |||
| 100 | } else { | 102 | } else { |
| 101 | rgblight_step_reverse(); | 103 | rgblight_step_reverse(); |
| 102 | } | 104 | } |
| 103 | } | 105 | } |
| 104 | } | 106 | } |
| 105 | 107 | ||
| 106 | void encoder_update_kb(uint8_t index, bool clockwise) { | 108 | void encoder_update_user(uint8_t index, bool clockwise) { |
| 107 | if (layer_state_is(1)) { | 109 | if (layer_state_is(1)) { |
| 108 | //change RGB settings | 110 | //change RGB settings |
| 109 | change_RGB(clockwise); | 111 | change_RGB(clockwise); |
| @@ -113,7 +115,7 @@ void encoder_update_kb(uint8_t index, bool clockwise) { | |||
| 113 | tap_code(KC_VOLU); | 115 | tap_code(KC_VOLU); |
| 114 | } else { | 116 | } else { |
| 115 | tap_code(KC_VOLD); | 117 | tap_code(KC_VOLD); |
| 116 | } | 118 | } |
| 117 | } | 119 | } |
| 118 | } | 120 | } |
| 119 | 121 | ||
| @@ -125,4 +127,4 @@ void matrix_init_user(void) { | |||
| 125 | void matrix_scan_user(void) { | 127 | void matrix_scan_user(void) { |
| 126 | // Scan and parse keystrokes from remote keyboard, if connected (see readme) | 128 | // Scan and parse keystrokes from remote keyboard, if connected (see readme) |
| 127 | matrix_scan_remote_kb(); | 129 | matrix_scan_remote_kb(); |
| 128 | } \ No newline at end of file | 130 | } |
diff --git a/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c b/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c index 7e78b1f63..214034ef8 100644 --- a/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c +++ b/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c | |||
| @@ -15,8 +15,10 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #include QMK_KEYBOARD_H | 16 | #include QMK_KEYBOARD_H |
| 17 | 17 | ||
| 18 | #define _MA 0 | 18 | enum layer_names { |
| 19 | #define _FN 1 | 19 | _MA, |
| 20 | _FN | ||
| 21 | }; | ||
| 20 | 22 | ||
| 21 | enum custom_keycodes { | 23 | enum custom_keycodes { |
| 22 | KC_CUST = SAFE_RANGE, | 24 | KC_CUST = SAFE_RANGE, |
| @@ -103,7 +105,7 @@ void change_RGB(bool clockwise) { | |||
| 103 | } | 105 | } |
| 104 | } | 106 | } |
| 105 | 107 | ||
| 106 | void encoder_update_kb(uint8_t index, bool clockwise) { | 108 | void encoder_update_user(uint8_t index, bool clockwise) { |
| 107 | if (layer_state_is(1)) { | 109 | if (layer_state_is(1)) { |
| 108 | //change RGB settings | 110 | //change RGB settings |
| 109 | change_RGB(clockwise); | 111 | change_RGB(clockwise); |
diff --git a/keyboards/nullbitsco/nibble/keymaps/oled/keymap.c b/keyboards/nullbitsco/nibble/keymaps/oled/keymap.c index 0b6a97442..b9630b8e8 100644 --- a/keyboards/nullbitsco/nibble/keymaps/oled/keymap.c +++ b/keyboards/nullbitsco/nibble/keymaps/oled/keymap.c | |||
| @@ -15,8 +15,10 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #include QMK_KEYBOARD_H | 16 | #include QMK_KEYBOARD_H |
| 17 | 17 | ||
| 18 | #define _MA 0 | 18 | enum layer_names { |
| 19 | #define _FN 1 | 19 | _MA, |
| 20 | _FN | ||
| 21 | }; | ||
| 20 | 22 | ||
| 21 | enum custom_keycodes { | 23 | enum custom_keycodes { |
| 22 | KC_CUST = SAFE_RANGE, | 24 | KC_CUST = SAFE_RANGE, |
| @@ -24,14 +26,14 @@ enum custom_keycodes { | |||
| 24 | 26 | ||
| 25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 27 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 26 | [_MA] = LAYOUT_ansi( | 28 | [_MA] = LAYOUT_ansi( |
| 27 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TILD, | 29 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, |
| 28 | KC_F13, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, | 30 | KC_F13, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, |
| 29 | KC_F14, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, | 31 | KC_F14, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, |
| 30 | KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, | 32 | KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, |
| 31 | KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT | 33 | KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT |
| 32 | ), | 34 | ), |
| 33 | [_FN] = LAYOUT_ansi( | 35 | [_FN] = LAYOUT_ansi( |
| 34 | RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_INS, | 36 | RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_END, |
| 35 | RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 37 | RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| 36 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 38 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| 37 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 39 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| @@ -44,37 +46,37 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_ | |||
| 44 | 46 | ||
| 45 | static void render_logo(void) { | 47 | static void render_logo(void) { |
| 46 | static const char PROGMEM nibble_logo[] = { | 48 | static const char PROGMEM nibble_logo[] = { |
| 47 | 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 49 | 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 48 | 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, | 50 | 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, |
| 49 | 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, | 51 | 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, |
| 50 | 0x1f, 0x1f, 0x1f, 0x3f, 0x3e, 0xfe, 0xfe, 0xfc, 0xf8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfe, | 52 | 0x1f, 0x1f, 0x1f, 0x3f, 0x3e, 0xfe, 0xfe, 0xfc, 0xf8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfe, |
| 51 | 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x3f, 0x3e, 0xfe, 0xfe, | 53 | 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x3f, 0x3e, 0xfe, 0xfe, |
| 52 | 0xfc, 0xf8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, | 54 | 0xfc, 0xf8, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, |
| 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0xff, 0xff, 0xff, | 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0xff, 0xff, 0xff, |
| 54 | 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x0c, 0x00, | 56 | 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x0c, 0x00, |
| 55 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x0f, 0x1f, 0x7f, 0xff, 0xfe, 0xf8, 0xf0, 0xc0, 0x80, | 57 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x0f, 0x1f, 0x7f, 0xff, 0xfe, 0xf8, 0xf0, 0xc0, 0x80, |
| 56 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, | 58 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, |
| 57 | 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, | 59 | 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, |
| 58 | 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xfc, 0xff, 0xff, 0xbf, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0xff, | 60 | 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xfc, 0xff, 0xff, 0xbf, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 59 | 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xff, 0xff, | 61 | 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xff, 0xff, |
| 60 | 0xff, 0xbf, 0x1f, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, | 62 | 0xff, 0xbf, 0x1f, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, |
| 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, | 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 62 | 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0x00, 0x00, | 64 | 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0x00, 0x00, |
| 63 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x1f, 0x7f, 0xff, | 65 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x1f, 0x7f, 0xff, |
| 64 | 0xfe, 0xfc, 0xf0, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, | 66 | 0xfe, 0xfc, 0xf0, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, |
| 65 | 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, | 67 | 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, |
| 66 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xe0, 0x00, 0x00, 0xff, | 68 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xe0, 0x00, 0x00, 0xff, |
| 67 | 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, | 69 | 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, |
| 68 | 0xff, 0xff, 0xff, 0xfe, 0xf8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, | 70 | 0xff, 0xff, 0xff, 0xfe, 0xf8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, |
| 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, | 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 70 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, | 72 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, |
| 71 | 0x00, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 73 | 0x00, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 72 | 0x03, 0x07, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, | 74 | 0x03, 0x07, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, |
| 73 | 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, | 75 | 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, |
| 74 | 0xf8, 0xf8, 0xf8, 0xf8, 0x7c, 0x7c, 0x7e, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x7f, | 76 | 0xf8, 0xf8, 0xf8, 0xf8, 0x7c, 0x7c, 0x7e, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x7f, |
| 75 | 0x7f, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x7c, 0x7c, 0x7e, | 77 | 0x7f, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x7c, 0x7c, 0x7e, |
| 76 | 0x3f, 0x3f, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x1f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, | 78 | 0x3f, 0x3f, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x1f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, |
| 77 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x30, 0x3f, 0x7f, 0xff, 0xff, 0xff, | 79 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x30, 0x3f, 0x7f, 0xff, 0xff, 0xff, |
| 78 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x30, 0x00 | 80 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x30, 0x00 |
| 79 | }; | 81 | }; |
| 80 | // Host Keyboard Layer Status | 82 | // Host Keyboard Layer Status |
| @@ -114,13 +116,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 114 | if (record->event.pressed) { | 116 | if (record->event.pressed) { |
| 115 | } | 117 | } |
| 116 | break; | 118 | break; |
| 117 | 119 | ||
| 118 | } | 120 | } |
| 119 | return true; | 121 | return true; |
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | 124 | ||
| 123 | void encoder_update_kb(uint8_t index, bool clockwise) { | 125 | void encoder_update_user(uint8_t index, bool clockwise) { |
| 124 | if (clockwise) { | 126 | if (clockwise) { |
| 125 | tap_code(KC_VOLU); | 127 | tap_code(KC_VOLU); |
| 126 | } else { | 128 | } else { |
| @@ -136,4 +138,4 @@ void matrix_init_user(void) { | |||
| 136 | void matrix_scan_user(void) { | 138 | void matrix_scan_user(void) { |
| 137 | // Scan and parse keystrokes from remote keyboard, if connected (see readme) | 139 | // Scan and parse keystrokes from remote keyboard, if connected (see readme) |
| 138 | matrix_scan_remote_kb(); | 140 | matrix_scan_remote_kb(); |
| 139 | } \ No newline at end of file | 141 | } |
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/config.h b/keyboards/nullbitsco/nibble/keymaps/via/config.h deleted file mode 100644 index 961e2aed1..000000000 --- a/keyboards/nullbitsco/nibble/keymaps/via/config.h +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | /* Copyright 2020 Jay Greco | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | // Custom config starts after VIA's EEPROM usage, | ||
| 17 | // dynamic keymaps start after this. | ||
| 18 | // Custom config Usage: | ||
| 19 | // 1 for enabled encoder modes (1 byte) | ||
| 20 | // 6 for 3x custom encoder settings, left, right, and press (18 bytes) | ||
| 21 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 19 \ No newline at end of file | ||
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/keymap.c b/keyboards/nullbitsco/nibble/keymaps/via/keymap.c index f72ffc56e..5b2f3b4f2 100644 --- a/keyboards/nullbitsco/nibble/keymaps/via/keymap.c +++ b/keyboards/nullbitsco/nibble/keymaps/via/keymap.c | |||
| @@ -14,12 +14,13 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include QMK_KEYBOARD_H | 16 | #include QMK_KEYBOARD_H |
| 17 | #include "via_extras.h" | ||
| 18 | 17 | ||
| 19 | #define _BASE 0 | 18 | enum layer_names { |
| 20 | #define _VIA1 1 | 19 | _BASE, |
| 21 | #define _VIA2 2 | 20 | _VIA1, |
| 22 | #define _VIA3 3 | 21 | _VIA2, |
| 22 | _VIA3 | ||
| 23 | }; | ||
| 23 | 24 | ||
| 24 | #define KC_DISC_MUTE KC_F23 | 25 | #define KC_DISC_MUTE KC_F23 |
| 25 | #define KC_DISC_DEAF KC_F24 | 26 | #define KC_DISC_DEAF KC_F24 |
| @@ -50,7 +51,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 50 | ), | 51 | ), |
| 51 | 52 | ||
| 52 | [_VIA1] = LAYOUT_all( | 53 | [_VIA1] = LAYOUT_all( |
| 53 | RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_INS, | 54 | RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_END, |
| 54 | RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 55 | RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| 55 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 56 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| 56 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 57 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
| @@ -100,7 +101,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 100 | if (record->event.pressed) { | 101 | if (record->event.pressed) { |
| 101 | tap_code(KC_DISC_MUTE); | 102 | tap_code(KC_DISC_MUTE); |
| 102 | if (!rgblight_is_enabled()) break; | 103 | if (!rgblight_is_enabled()) break; |
| 103 | 104 | ||
| 104 | if (muted) { | 105 | if (muted) { |
| 105 | rgblight_enable_noeeprom(); | 106 | rgblight_enable_noeeprom(); |
| 106 | } else { | 107 | } else { |
| @@ -133,7 +134,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 133 | if (!is_alt_tab_active) { | 134 | if (!is_alt_tab_active) { |
| 134 | is_alt_tab_active = true; | 135 | is_alt_tab_active = true; |
| 135 | register_code(KC_LALT); | 136 | register_code(KC_LALT); |
| 136 | } | 137 | } |
| 137 | alt_tab_timer = timer_read(); | 138 | alt_tab_timer = timer_read(); |
| 138 | register_code(KC_TAB); | 139 | register_code(KC_TAB); |
| 139 | } else { | 140 | } else { |
| @@ -142,11 +143,20 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 142 | break; | 143 | break; |
| 143 | 144 | ||
| 144 | default: | 145 | default: |
| 145 | break; | 146 | break; |
| 146 | } | 147 | } |
| 147 | return true; | 148 | return true; |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 151 | void encoder_update_user(uint8_t index, bool clockwise) { | ||
| 152 | // Encoder is mapped to volume functions by default | ||
| 153 | if (clockwise) { | ||
| 154 | tap_code(KC_VOLU); | ||
| 155 | } else { | ||
| 156 | tap_code(KC_VOLD); | ||
| 157 | } | ||
| 158 | } | ||
| 159 | |||
| 150 | void matrix_init_user(void) { | 160 | void matrix_init_user(void) { |
| 151 | // Initialize remote keyboard, if connected (see readme) | 161 | // Initialize remote keyboard, if connected (see readme) |
| 152 | matrix_init_remote_kb(); | 162 | matrix_init_remote_kb(); |
| @@ -161,4 +171,4 @@ void matrix_scan_user(void) { | |||
| 161 | is_alt_tab_active = false; | 171 | is_alt_tab_active = false; |
| 162 | } | 172 | } |
| 163 | } | 173 | } |
| 164 | } \ No newline at end of file | 174 | } |
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c deleted file mode 100644 index bdea1869c..000000000 --- a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c +++ /dev/null | |||
| @@ -1,133 +0,0 @@ | |||
| 1 | /* Copyright 2020 Jay Greco | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "nibble_encoder.h" | ||
| 17 | |||
| 18 | uint8_t encoder_value = 0x20, | ||
| 19 | encoder_mode = ENC_MODE_VOLUME, | ||
| 20 | enabled_encoder_modes = 0x1F; | ||
| 21 | |||
| 22 | uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior) { | ||
| 23 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 24 | void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2)); | ||
| 25 | uint16_t keycode = eeprom_read_byte(addr) << 8; | ||
| 26 | keycode |= eeprom_read_byte(addr + 1); | ||
| 27 | return keycode; | ||
| 28 | #else | ||
| 29 | return 0; | ||
| 30 | #endif | ||
| 31 | } | ||
| 32 | |||
| 33 | void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code) { | ||
| 34 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 35 | void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2)); | ||
| 36 | eeprom_update_byte(addr, (uint8_t)(new_code >> 8)); | ||
| 37 | eeprom_update_byte(addr + 1, (uint8_t)(new_code & 0xFF)); | ||
| 38 | #endif | ||
| 39 | } | ||
| 40 | |||
| 41 | void pre_encoder_mode_change(void) { | ||
| 42 | dprintf("Changing encoder mode: %u\n", encoder_mode); | ||
| 43 | } | ||
| 44 | |||
| 45 | void post_encoder_mode_change(void) { | ||
| 46 | dprintf("Encoder mode: %u\n", encoder_mode); | ||
| 47 | } | ||
| 48 | |||
| 49 | //??? | ||
| 50 | void change_encoder_mode(bool clockwise) { | ||
| 51 | pre_encoder_mode_change(); | ||
| 52 | if(enabled_encoder_modes == 0){ | ||
| 53 | enabled_encoder_modes = 0x1F; | ||
| 54 | } | ||
| 55 | do { | ||
| 56 | if(!clockwise){ | ||
| 57 | if (encoder_mode == 0){ | ||
| 58 | encoder_mode = _NUM_ENCODER_MODES - 1; | ||
| 59 | } else{ | ||
| 60 | encoder_mode = encoder_mode - 1; | ||
| 61 | } | ||
| 62 | } else { | ||
| 63 | encoder_mode = (encoder_mode + 1) % _NUM_ENCODER_MODES; | ||
| 64 | } | ||
| 65 | } while(((1 << encoder_mode) & enabled_encoder_modes) == 0); | ||
| 66 | post_encoder_mode_change(); | ||
| 67 | } | ||
| 68 | |||
| 69 | uint16_t handle_encoder_cw(void) { | ||
| 70 | dprintf("Encoder mode: %u\n", encoder_mode); | ||
| 71 | uint16_t mapped_code = 0; | ||
| 72 | switch(encoder_mode){ | ||
| 73 | default: | ||
| 74 | break; | ||
| 75 | case ENC_MODE_VOLUME: | ||
| 76 | mapped_code = KC_VOLU; | ||
| 77 | break; | ||
| 78 | case ENC_MODE_MEDIA: | ||
| 79 | mapped_code = KC_MEDIA_NEXT_TRACK; | ||
| 80 | break; | ||
| 81 | case ENC_MODE_SCROLL: | ||
| 82 | mapped_code = KC_WH_D; | ||
| 83 | break; | ||
| 84 | case ENC_MODE_BACKLIGHT: | ||
| 85 | mapped_code = RGB_VAI; | ||
| 86 | break; | ||
| 87 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 88 | case ENC_MODE_CUSTOM0: | ||
| 89 | mapped_code = retrieve_custom_encoder_config(0, ENC_CUSTOM_CW); | ||
| 90 | break; | ||
| 91 | case ENC_MODE_CUSTOM1: | ||
| 92 | mapped_code = retrieve_custom_encoder_config(1, ENC_CUSTOM_CW); | ||
| 93 | break; | ||
| 94 | case ENC_MODE_CUSTOM2: | ||
| 95 | mapped_code = retrieve_custom_encoder_config(2, ENC_CUSTOM_CW); | ||
| 96 | break; | ||
| 97 | #endif | ||
| 98 | } | ||
| 99 | return mapped_code; | ||
| 100 | } | ||
| 101 | |||
| 102 | uint16_t handle_encoder_ccw(void) { | ||
| 103 | dprintf("Encoder mode: %u\n", encoder_mode); | ||
| 104 | uint16_t mapped_code = 0; | ||
| 105 | switch(encoder_mode){ | ||
| 106 | default: | ||
| 107 | break; | ||
| 108 | case ENC_MODE_VOLUME: | ||
| 109 | mapped_code = KC_VOLD; | ||
| 110 | break; | ||
| 111 | case ENC_MODE_MEDIA: | ||
| 112 | mapped_code = KC_MEDIA_PREV_TRACK; | ||
| 113 | break; | ||
| 114 | case ENC_MODE_SCROLL: | ||
| 115 | mapped_code = KC_WH_U; | ||
| 116 | break; | ||
| 117 | case ENC_MODE_BACKLIGHT: | ||
| 118 | mapped_code = RGB_VAD; | ||
| 119 | break; | ||
| 120 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 121 | case ENC_MODE_CUSTOM0: | ||
| 122 | mapped_code = retrieve_custom_encoder_config(0, ENC_CUSTOM_CCW); | ||
| 123 | break; | ||
| 124 | case ENC_MODE_CUSTOM1: | ||
| 125 | mapped_code = retrieve_custom_encoder_config(1, ENC_CUSTOM_CCW); | ||
| 126 | break; | ||
| 127 | case ENC_MODE_CUSTOM2: | ||
| 128 | mapped_code = retrieve_custom_encoder_config(2, ENC_CUSTOM_CCW); | ||
| 129 | break; | ||
| 130 | #endif | ||
| 131 | } | ||
| 132 | return mapped_code; | ||
| 133 | } | ||
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h deleted file mode 100644 index fc1e61434..000000000 --- a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | /* Copyright 2020 Jay Greco | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | #include "eeprom.h" | ||
| 20 | |||
| 21 | #define EEPROM_ENABLED_ENCODER_MODES (VIA_EEPROM_CUSTOM_CONFIG_ADDR) | ||
| 22 | #define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+1) | ||
| 23 | |||
| 24 | enum encoder_modes { | ||
| 25 | ENC_MODE_VOLUME, | ||
| 26 | ENC_MODE_MEDIA, | ||
| 27 | ENC_MODE_SCROLL, | ||
| 28 | ENC_MODE_BRIGHTNESS, | ||
| 29 | ENC_MODE_BACKLIGHT, | ||
| 30 | ENC_MODE_CUSTOM0, | ||
| 31 | ENC_MODE_CUSTOM1, | ||
| 32 | ENC_MODE_CUSTOM2, | ||
| 33 | _NUM_ENCODER_MODES, | ||
| 34 | }; | ||
| 35 | |||
| 36 | enum custom_encoder_behavior { | ||
| 37 | ENC_CUSTOM_CW = 0, | ||
| 38 | ENC_CUSTOM_CCW, | ||
| 39 | ENC_CUSTOM_PRESS | ||
| 40 | }; | ||
| 41 | |||
| 42 | uint16_t | ||
| 43 | retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior), | ||
| 44 | handle_encoder_cw(void), | ||
| 45 | handle_encoder_ccw(void); | ||
| 46 | |||
| 47 | void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code), | ||
| 48 | pre_encoder_mode_change(void), | ||
| 49 | post_encoder_mode_change(void), | ||
| 50 | change_encoder_mode(bool clockwise); \ No newline at end of file | ||
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/rules.mk b/keyboards/nullbitsco/nibble/keymaps/via/rules.mk index ee197efc0..036bd6d1c 100644 --- a/keyboards/nullbitsco/nibble/keymaps/via/rules.mk +++ b/keyboards/nullbitsco/nibble/keymaps/via/rules.mk | |||
| @@ -1,4 +1 @@ | |||
| 1 | VIA_ENABLE = yes | VIA_ENABLE = yes \ No newline at end of file | |
| 2 | |||
| 3 | SRC += keymaps/via/nibble_encoder.c | ||
| 4 | SRC += keymaps/via/via_extras.c \ No newline at end of file | ||
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/via_extras.c b/keyboards/nullbitsco/nibble/keymaps/via/via_extras.c deleted file mode 100644 index 067296b76..000000000 --- a/keyboards/nullbitsco/nibble/keymaps/via/via_extras.c +++ /dev/null | |||
| @@ -1,129 +0,0 @@ | |||
| 1 | /* Copyright 2020 Jay Greco | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "via_extras.h" | ||
| 18 | |||
| 19 | // Encoder Behavior | ||
| 20 | extern uint8_t encoder_value; | ||
| 21 | extern uint8_t encoder_mode; | ||
| 22 | extern uint8_t enabled_encoder_modes; | ||
| 23 | |||
| 24 | void raw_hid_receive_kb( uint8_t *data, uint8_t length ) | ||
| 25 | { | ||
| 26 | uint8_t *command_id = &(data[0]); | ||
| 27 | uint8_t *command_data = &(data[1]); | ||
| 28 | dprintf("raw hid recv! command_id: %u\n",*command_id); | ||
| 29 | switch ( *command_id ) | ||
| 30 | { | ||
| 31 | case id_get_keyboard_value: | ||
| 32 | { | ||
| 33 | switch( command_data[0]) | ||
| 34 | { | ||
| 35 | case id_encoder_modes: | ||
| 36 | { | ||
| 37 | command_data[1] = enabled_encoder_modes; | ||
| 38 | dprintf("[read] enabled_encoder_modes: %u\n", enabled_encoder_modes); | ||
| 39 | } | ||
| 40 | break; | ||
| 41 | |||
| 42 | case id_encoder_custom: | ||
| 43 | { | ||
| 44 | uint8_t custom_encoder_idx = command_data[1]; | ||
| 45 | uint16_t keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_CW); | ||
| 46 | command_data[2] = keycode >> 8; | ||
| 47 | command_data[3] = keycode & 0xFF; | ||
| 48 | keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_CCW); | ||
| 49 | command_data[4] = keycode >> 8; | ||
| 50 | command_data[5] = keycode & 0xFF; | ||
| 51 | keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_PRESS); | ||
| 52 | command_data[6] = keycode >> 8; | ||
| 53 | command_data[7] = keycode & 0xFF; | ||
| 54 | } | ||
| 55 | break; | ||
| 56 | |||
| 57 | default: | ||
| 58 | { | ||
| 59 | *command_id = id_unhandled; | ||
| 60 | } | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | break; | ||
| 65 | case id_set_keyboard_value: | ||
| 66 | { | ||
| 67 | switch(command_data[0]){ | ||
| 68 | case id_encoder_modes: | ||
| 69 | { | ||
| 70 | enabled_encoder_modes = command_data[1]; | ||
| 71 | dprintf("[write] enabled_encoder_modes: %u\n", enabled_encoder_modes); | ||
| 72 | eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes); | ||
| 73 | } | ||
| 74 | break; | ||
| 75 | |||
| 76 | case id_encoder_custom: | ||
| 77 | { | ||
| 78 | uint8_t custom_encoder_idx = command_data[1]; | ||
| 79 | uint8_t encoder_behavior = command_data[2]; | ||
| 80 | uint16_t keycode = (command_data[3] << 8) | command_data[4]; | ||
| 81 | set_custom_encoder_config(custom_encoder_idx, encoder_behavior, keycode); | ||
| 82 | } | ||
| 83 | break; | ||
| 84 | |||
| 85 | default: | ||
| 86 | { | ||
| 87 | *command_id = id_unhandled; | ||
| 88 | } | ||
| 89 | break; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | break; | ||
| 93 | |||
| 94 | default: | ||
| 95 | { | ||
| 96 | // Unhandled message. | ||
| 97 | *command_id = id_unhandled; | ||
| 98 | } | ||
| 99 | break; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | void encoder_update_kb(uint8_t index, bool clockwise) { | ||
| 104 | if (layer_state_is(1)) { | ||
| 105 | change_encoder_mode(clockwise); | ||
| 106 | return; | ||
| 107 | } | ||
| 108 | uint16_t mapped_code = 0; | ||
| 109 | if (clockwise) { | ||
| 110 | mapped_code = handle_encoder_cw(); | ||
| 111 | } else { | ||
| 112 | mapped_code = handle_encoder_ccw(); | ||
| 113 | } | ||
| 114 | if(mapped_code != 0){ | ||
| 115 | tap_code16(mapped_code); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | void custom_config_load(void){ | ||
| 120 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 121 | enabled_encoder_modes = eeprom_read_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES); | ||
| 122 | #endif | ||
| 123 | } | ||
| 124 | |||
| 125 | void via_init_kb(void) | ||
| 126 | { | ||
| 127 | dprintf("VIA is enabled.\n"); | ||
| 128 | custom_config_load(); | ||
| 129 | } | ||
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/via_extras.h b/keyboards/nullbitsco/nibble/keymaps/via/via_extras.h deleted file mode 100644 index 83c3c1312..000000000 --- a/keyboards/nullbitsco/nibble/keymaps/via/via_extras.h +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | /* Copyright 2020 Jay Greco | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include "nibble_encoder.h" | ||
| 19 | #include "via.h" | ||
| 20 | #include "raw_hid.h" | ||
| 21 | #include "dynamic_keymap.h" | ||
| 22 | #include "tmk_core/common/eeprom.h" | ||
| 23 | |||
| 24 | enum nibble_keyboard_value_id { | ||
| 25 | id_encoder_modes = 0x80, | ||
| 26 | id_unused_mode_1, | ||
| 27 | id_encoder_custom, | ||
| 28 | id_unused_mode_2 | ||
| 29 | }; | ||
| 30 | |||
| 31 | // Encoder Behavior | ||
| 32 | extern uint8_t encoder_value, | ||
| 33 | encoder_mode, | ||
| 34 | enabled_encoder_modes; | ||
| 35 | |||
| 36 | void raw_hid_receive_kb(uint8_t *data, uint8_t length), | ||
| 37 | encoder_update_kb(uint8_t index, bool clockwise), | ||
| 38 | custom_config_load(void), | ||
| 39 | via_init_kb(void); \ No newline at end of file | ||
