diff options
Diffstat (limited to 'keyboards')
21 files changed, 1492 insertions, 0 deletions
diff --git a/keyboards/nullbitsco/nibble/README.md b/keyboards/nullbitsco/nibble/README.md new file mode 100644 index 0000000000..92825847d6 --- /dev/null +++ b/keyboards/nullbitsco/nibble/README.md @@ -0,0 +1,19 @@ +# NIBBLE + +![NIBBLE](https://nullbits.co/static/img/nibble1.jpg) + +A unique, tweakable 65% keyboard kit built by nullbits. [More info at nullbits.co](https://nullbits.co/nibble/) + +* Keyboard Maintainer: [Jay Greco](https://github.com/jaygreco) +* Hardware Supported: NIBBLE Rev1, Pro Micro comaptible MCUs. +* Hardware Availability: [nullbits.co](https://nullbits.co/) + +Note: If you are seeing issues with MacOS and keyboard hangs after sleep, make sure `NO_USB_STARTUP_CHECK = yes` is set in your rules.mk. + +Adds experimental "Remote Keyboard" functionality, which forwards keystrokes from an external macropad, keyboard, or numpad over UART/TRRS, removing the need for an additional USB connection. + +Make example for this keyboard (after setting up your build environment): + + make nullbitsco/nibble:default + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/nullbitsco/nibble/big_led.c b/keyboards/nullbitsco/nibble/big_led.c new file mode 100644 index 0000000000..eb0d0a5071 --- /dev/null +++ b/keyboards/nullbitsco/nibble/big_led.c @@ -0,0 +1,67 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "big_led.h" + +void set_big_LED_r(uint8_t mode) { + switch(mode) { + case LED_ON: + setPinOutput(BIG_LED_R_PIN); + writePin(BIG_LED_R_PIN, GPIO_STATE_HIGH); + break; + + case LED_OFF: + setPinOutput(BIG_LED_R_PIN); + writePin(BIG_LED_R_PIN, GPIO_STATE_LOW); + break; + + default: + break; + } +} + +void set_big_LED_g(uint8_t mode) { + switch(mode) { + case LED_ON: + setPinOutput(BIG_LED_G_PIN); + writePin(BIG_LED_G_PIN, GPIO_STATE_HIGH); + break; + + case LED_OFF: + setPinOutput(BIG_LED_G_PIN); + writePin(BIG_LED_G_PIN, GPIO_STATE_LOW); + break; + + default: + break; + } +} + +void set_big_LED_b(uint8_t mode) { + switch(mode) { + case LED_ON: + setPinOutput(BIG_LED_B_PIN); + writePin(BIG_LED_B_PIN, GPIO_STATE_HIGH); + break; + + case LED_OFF: + setPinOutput(BIG_LED_B_PIN); + writePin(BIG_LED_B_PIN, GPIO_STATE_LOW); + break; + + default: + break; + } +}
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/big_led.h b/keyboards/nullbitsco/nibble/big_led.h new file mode 100644 index 0000000000..113aaaf106 --- /dev/null +++ b/keyboards/nullbitsco/nibble/big_led.h @@ -0,0 +1,34 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#pragma once + +#include "quantum.h" + +/* Optional big LED pins */ +#define BIG_LED_R_PIN D7 +#define BIG_LED_G_PIN C6 +#define BIG_LED_B_PIN D0 + +#define LED_ON 2 +#define LED_OFF 0 + +#define GPIO_STATE_LOW 0 +#define GPIO_STATE_HIGH 1 + +void + set_big_LED_r(uint8_t mode), + set_big_LED_g(uint8_t mode), + set_big_LED_b(uint8_t mode);
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/bitc_led.c b/keyboards/nullbitsco/nibble/bitc_led.c new file mode 100644 index 0000000000..60ffeea278 --- /dev/null +++ b/keyboards/nullbitsco/nibble/bitc_led.c @@ -0,0 +1,37 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "bitc_led.h" + +void set_bitc_LED(uint8_t mode) { + switch(mode) { + case LED_ON: + setPinOutput(PIN_LED); + writePin(PIN_LED, GPIO_STATE_HIGH); + break; + + case LED_DIM: + setPinInput(PIN_LED); + break; + + case LED_OFF: + setPinOutput(PIN_LED); + writePin(PIN_LED, GPIO_STATE_LOW); + break; + + default: + break; + } +}
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/bitc_led.h b/keyboards/nullbitsco/nibble/bitc_led.h new file mode 100644 index 0000000000..b3552a7d19 --- /dev/null +++ b/keyboards/nullbitsco/nibble/bitc_led.h @@ -0,0 +1,29 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#pragma once + +#include "quantum.h" + +#define LED_ON 2 +#define LED_DIM 1 +#define LED_OFF 0 + +#define GPIO_STATE_LOW 0 +#define GPIO_STATE_HIGH 1 + +#define PIN_LED F0 + +void set_bitc_LED(uint8_t mode);
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/config.h b/keyboards/nullbitsco/nibble/config.h new file mode 100644 index 0000000000..3e0adce454 --- /dev/null +++ b/keyboards/nullbitsco/nibble/config.h @@ -0,0 +1,61 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#pragma once + +#include "config_common.h" + +/* Used to set host for remote KB if VUSB detect doesn't work. */ +// #define KEYBOARD_HOST // Force host mode +// #define KEYBOARD_REMOTE // Force remote mode + +// Workaround for freezing after MacOS sleep +#define NO_USB_STARTUP_CHECK + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x6E61 +#define PRODUCT_ID 0x6060 + +#define DEVICE_VER 0x0001 +#define MANUFACTURER nullbits +#define PRODUCT NIBBLE + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 16 +#define MATRIX_MUX_COLS 4 + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 10 + +/* + * Keyboard Matrix Assignments + * The nibble uses a demultiplexer for the cols. + * to free up more IOs for awesomeness! + * See matrix.c for more details. +*/ +#define MATRIX_ROW_PINS { B1, B3, B2, B6, D4 } +#define MATRIX_COL_MUX_PINS { F4, F5, F6, F7 } +#define MATRIX_COL_PINS { } + +/* Optional SMT LED pins */ +#define RGB_DI_PIN E6 +#define RGBLED_NUM 10 +#define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_SLEEP + +/* Optional encoder pins */ +#define ENCODERS_PAD_A { B5 } +#define ENCODERS_PAD_B { B4 }
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/keymaps/default/keymap.c b/keyboards/nullbitsco/nibble/keymaps/default/keymap.c new file mode 100644 index 0000000000..6d453e7067 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/default/keymap.c @@ -0,0 +1,128 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include QMK_KEYBOARD_H + +#define _MA 0 +#define _FN 1 + +enum custom_keycodes { + KC_CUST = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_MA] = LAYOUT_ansi( + 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, + 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, + 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, + 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, + KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + [_FN] = LAYOUT_ansi( + 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, + RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // Send keystrokes to host keyboard, if connected (see readme) + process_record_remote_kb(keycode, record); + switch(keycode) { + case KC_CUST: //custom macro + if (record->event.pressed) { + } + break; + + case RM_1: //remote macro 1 + if (record->event.pressed) { + } + break; + + case RM_2: //remote macro 2 + if (record->event.pressed) { + } + break; + + case RM_3: //remote macro 3 + if (record->event.pressed) { + } + break; + + case RM_4: //remote macro 4 + if (record->event.pressed) { + } + break; + + } +return true; +} + +// RGB config, for changing RGB settings on non-VIA firmwares +void change_RGB(bool clockwise) { + bool shift = get_mods() & MOD_MASK_SHIFT; + bool alt = get_mods() & MOD_MASK_ALT; + bool ctrl = get_mods() & MOD_MASK_CTRL; + + if (clockwise) { + if (alt) { + rgblight_increase_hue(); + } else if (ctrl) { + rgblight_increase_val(); + } else if (shift) { + rgblight_increase_sat(); + } else { + rgblight_step(); + } + + } else { + if (alt) { + rgblight_decrease_hue(); + } else if (ctrl) { + rgblight_decrease_val(); + } else if (shift) { + rgblight_decrease_sat(); + } else { + rgblight_step_reverse(); + } + } +} + +void encoder_update_kb(uint8_t index, bool clockwise) { + if (layer_state_is(1)) { + //change RGB settings + change_RGB(clockwise); + } + else { + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } +} + +void matrix_init_user(void) { + // Initialize remote keyboard, if connected (see readme) + matrix_init_remote_kb(); +} + +void matrix_scan_user(void) { + // Scan and parse keystrokes from remote keyboard, if connected (see readme) + matrix_scan_remote_kb(); +}
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c b/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c new file mode 100644 index 0000000000..46f246d6ee --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c @@ -0,0 +1,128 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include QMK_KEYBOARD_H + +#define _MA 0 +#define _FN 1 + +enum custom_keycodes { + KC_CUST = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_MA] = LAYOUT_iso( + 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, + 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_DEL, + 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_NUHS, KC_ENT, KC_PGUP, + KC_F15, KC_LSFT, KC_NUBS, 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, + KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + [_FN] = LAYOUT_iso( + 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, + RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // Send keystrokes to host keyboard, if connected (see readme) + process_record_remote_kb(keycode, record); + switch(keycode) { + case KC_CUST: //custom macro + if (record->event.pressed) { + } + break; + + case RM_1: //remote macro 1 + if (record->event.pressed) { + } + break; + + case RM_2: //remote macro 2 + if (record->event.pressed) { + } + break; + + case RM_3: //remote macro 3 + if (record->event.pressed) { + } + break; + + case RM_4: //remote macro 4 + if (record->event.pressed) { + } + break; + + } +return true; +} + +// RGB config, for changing RGB settings on non-VIA firmwares +void change_RGB(bool clockwise) { + bool shift = get_mods() & MOD_MASK_SHIFT; + bool alt = get_mods() & MOD_MASK_ALT; + bool ctrl = get_mods() & MOD_MASK_CTRL; + + if (clockwise) { + if (alt) { + rgblight_increase_hue(); + } else if (ctrl) { + rgblight_increase_val(); + } else if (shift) { + rgblight_increase_sat(); + } else { + rgblight_step(); + } + + } else { + if (alt) { + rgblight_decrease_hue(); + } else if (ctrl) { + rgblight_decrease_val(); + } else if (shift) { + rgblight_decrease_sat(); + } else { + rgblight_step_reverse(); + } + } +} + +void encoder_update_kb(uint8_t index, bool clockwise) { + if (layer_state_is(1)) { + //change RGB settings + change_RGB(clockwise); + } + else { + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } +} + +void matrix_init_user(void) { + // Initialize remote keyboard, if connected (see readme) + matrix_init_remote_kb(); +} + +void matrix_scan_user(void) { + // Scan and parse keystrokes from remote keyboard, if connected (see readme) + matrix_scan_remote_kb(); +}
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/keymaps/via/config.h b/keyboards/nullbitsco/nibble/keymaps/via/config.h new file mode 100644 index 0000000000..961e2aed1a --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/via/config.h @@ -0,0 +1,21 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +// Custom config starts after VIA's EEPROM usage, +// dynamic keymaps start after this. +// Custom config Usage: +// 1 for enabled encoder modes (1 byte) +// 6 for 3x custom encoder settings, left, right, and press (18 bytes) +#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 new file mode 100644 index 0000000000..1e1b0c0369 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/via/keymap.c @@ -0,0 +1,164 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include QMK_KEYBOARD_H +#include "via_extras.h" + +#define _BASE 0 +#define _VIA1 1 +#define _VIA2 2 +#define _VIA3 3 + +#define KC_DISC_MUTE KC_F23 +#define KC_DISC_DEAF KC_F24 +#define NUM_CUST_KEYCODES (_NUM_CUST_KCS - SAFE_RANGE) +#define VIA_KEYCODE_RANGE 0x5F80 + +enum custom_keycodes { + PROG = SAFE_RANGE, + DISC_MUTE, + DISC_DEAF, + SUPER_ALT_TAB, + _NUM_CUST_KCS, +}; + +// Macro variables +bool is_alt_tab_active = false; +uint16_t alt_tab_timer = 0; +bool muted = false; +bool deafened = false; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT_all( + KC_NUBS, KC_GESC, 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, + 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, + 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, + 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, + KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_VIA1), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + [_VIA1] = LAYOUT_all( + _______, 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, + RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT + ), + + [_VIA2] = LAYOUT_all( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_VIA3] = LAYOUT_all( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + +}; + +void map_via_keycode(uint16_t * keycode) { + if (abs(*keycode - VIA_KEYCODE_RANGE) < NUM_CUST_KEYCODES) { //make into macro? + dprintf("VIA custom keycode found, mapping to QMK keycode.\n"); + uint16_t new_keycode = (*keycode - VIA_KEYCODE_RANGE) + SAFE_RANGE; + dprintf("VIA KC: %u QMK KC: %u\n", *keycode, new_keycode); + *keycode = new_keycode; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + map_via_keycode(&keycode); + // Send keystrokes to host keyboard, if connected (see readme) + process_record_remote_kb(keycode, record); + switch(keycode) { + case PROG: + if (record->event.pressed) { + rgblight_disable_noeeprom(); + bootloader_jump(); + } + break; + + case DISC_MUTE: + if (record->event.pressed) { + tap_code(KC_DISC_MUTE); + if (!rgblight_is_enabled()) break; + + if (muted) { + rgblight_enable_noeeprom(); + } else { + rgblight_timer_disable(); + uint8_t val = rgblight_get_val(); + rgblight_sethsv_range(255, 255, val, 0, 1); + } + muted = !muted; + } + break; + + case DISC_DEAF: + if (record->event.pressed) { + tap_code(KC_DISC_DEAF); + if (!rgblight_is_enabled()) break; + + if (deafened) { + rgblight_enable_noeeprom(); + } else { + rgblight_timer_disable(); + uint8_t val = rgblight_get_val(); + rgblight_sethsv_range(255, 255, val, 0, RGBLED_NUM-1); + } + deafened = !deafened; + } + break; + + case SUPER_ALT_TAB: + if (record->event.pressed) { + if (!is_alt_tab_active) { + is_alt_tab_active = true; + register_code(KC_LALT); + } + alt_tab_timer = timer_read(); + register_code(KC_TAB); + } else { + unregister_code(KC_TAB); + } + break; + + default: + break; + } +return true; +} + +void matrix_init_user(void) { + // Initialize remote keyboard, if connected (see readme) + matrix_init_remote_kb(); +} + +void matrix_scan_user(void) { + // Scan and parse keystrokes from remote keyboard, if connected (see readme) + matrix_scan_remote_kb(); + if (is_alt_tab_active) { + if (timer_elapsed(alt_tab_timer) > 1000) { + unregister_code(KC_LALT); + is_alt_tab_active = false; + } + } +}
\ No newline at end of file diff --git a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c new file mode 100644 index 0000000000..bdea1869c2 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c @@ -0,0 +1,133 @@ +/* Copyright 2020 Jay Greco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "nibble_encoder.h" + +uint8_t encoder_value = 0x20, + encoder_mode = ENC_MODE_VOLUME, + enabled_encoder_modes = 0x1F; + +uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior) { +#ifdef DYNAMIC_KEYMAP_ENABLE + void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2)); + uint16_t keycode = eeprom_read_byte(addr) << 8; + keycode |= eeprom_read_byte(addr + 1); + return keycode; +#else + return 0; +#endif +} + +void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code) { +#ifdef DYNAMIC_KEYMAP_ENABLE + void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2)); + eeprom_update_byte(addr, (uint8_t)(new_code >> 8)); + eeprom_update_byte(addr + 1, (uint8_t)(new_code & 0xFF)); +#endif +} + +void pre_encoder_mode_change(void) { + dprintf("Changing encoder mode: %u\n", encoder_mode); +} + +void post_encoder_mode_change(void) { + dprintf("Encoder mode: %u\n", encoder_mode); +} + +//??? +void change_encoder_mode(bool clockwise) { + pre_encoder_mode_change(); + if(enabled_encoder_modes == 0){ + enabled_encoder_modes = 0x1F; + } + do { + if(!clockwise){ + if (encoder_mode == 0){ + encoder_mode = _NUM_ENCODER_MODES - 1; + } else{ + encoder_mode = encoder_mode - 1; + } + } else { + encoder_mode = (encoder_mode + 1) % _NUM_ENCODER_MODES; + } + } while(((1 << encoder_mode) & enabled_encoder_modes) == 0); + post_encoder_mode_change(); +} + +uint16_t handle_encoder_cw(void) { + dprintf("Encoder mode: %u\n", encoder_mode); + uint16_t mapped_code = 0; + switch(encoder_mode){ + default: + break; + case ENC_MODE_VOLUME: + mapped_code = KC_VOLU; + break; + case ENC_MODE_MEDIA: + mapped_code = KC_MEDIA_NEXT_TRACK; + break; + case ENC_MODE_SCROLL: + mapped_code = KC_WH_D; + break; + case ENC_MODE_BACKLIGHT: + mapped_code = RGB_VAI; + break; +#ifdef DYNAMIC_KEYMAP_ENABLE + case ENC_MODE_CUSTOM0: + mapped_code = retrieve_custom_encoder_config(0, ENC_CUSTOM_CW); + break; + case ENC_MODE_CUSTOM1: + mapped_code = retrieve_custom_encoder_config(1, ENC_CUSTOM_CW); + break; |