diff options
author | Akaash Suresh <casa.akaash@gmail.com> | 2020-01-02 11:52:23 -0600 |
---|---|---|
committer | Akaash Suresh <casa.akaash@gmail.com> | 2020-01-02 11:52:23 -0600 |
commit | 3650d59afe69484c7d8c489763e04ddd3d79c03b (patch) | |
tree | 71577d528142f51f3610c81486074eb5af079311 | |
parent | 8ec0b378bc5cd0f0154e24c4a765f91b60791f2c (diff) |
Merge upstream/master with userspace
-rw-r--r-- | keyboards/crkbd/keymaps/curry/config.h | 31 | ||||
-rw-r--r-- | keyboards/crkbd/keymaps/curry/keymap.c | 61 | ||||
-rw-r--r-- | keyboards/crkbd/keymaps/curry/rules.mk | 22 | ||||
-rw-r--r-- | keyboards/lily58/keymaps/curry/config.h | 7 | ||||
-rw-r--r-- | keyboards/lily58/keymaps/curry/keymap.c | 71 | ||||
-rw-r--r-- | keyboards/lily58/keymaps/curry/rules.mk | 17 | ||||
-rw-r--r-- | users/curry/.gitignore | 1 | ||||
-rw-r--r-- | users/curry/config.h | 116 | ||||
-rw-r--r-- | users/curry/curry.c | 131 | ||||
-rw-r--r-- | users/curry/curry.h | 57 | ||||
-rw-r--r-- | users/curry/oled.c | 162 | ||||
-rw-r--r-- | users/curry/process_records.c | 85 | ||||
-rw-r--r-- | users/curry/process_records.h | 104 | ||||
-rw-r--r-- | users/curry/rgb_stuff.c | 471 | ||||
-rw-r--r-- | users/curry/rgb_stuff.h | 32 | ||||
-rw-r--r-- | users/curry/rgblight_breathe_table.h | 118 | ||||
-rw-r--r-- | users/curry/rules.mk | 61 | ||||
-rw-r--r-- | users/curry/tap_dances.c | 3 | ||||
-rw-r--r-- | users/curry/tap_dances.h | 3 | ||||
-rw-r--r-- | users/curry/wrappers.h | 92 |
20 files changed, 1645 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/curry/config.h b/keyboards/crkbd/keymaps/curry/config.h new file mode 100644 index 0000000000..2bb61d3fe7 --- /dev/null +++ b/keyboards/crkbd/keymaps/curry/config.h @@ -0,0 +1,31 @@ +#pragma once + +#define MASTER_RIGHT +#define USE_SERIAL_PD2 + +#ifdef RGBLIGHT_ENABLE +# undef RGBLED_NUM +# define RGBLED_NUM 27 + +# define RGBLIGHT_HUE_STEP 8 +# define RGBLIGHT_SAT_STEP 8 +# define RGBLIGHT_VAL_STEP 5 +# define RGBLIGHT_LIMIT_VAL 120 +#endif + +#ifdef RGB_MATRIX_ENABLE +# define RGB_MATRIX_KEYPRESSES // reacts to keypresses +// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) +// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects +# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended +// # define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness) +// # define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness) +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 +# define RGB_MATRIX_HUE_STEP 8 +# define RGB_MATRIX_SAT_STEP 8 +# define RGB_MATRIX_VAL_STEP 5 +# define RGB_MATRIX_SPD_STEP 10 +#endif + +#define OLED_DISABLE_TIMEOUT +#define TAPPING_TERM_PER_KEY diff --git a/keyboards/crkbd/keymaps/curry/keymap.c b/keyboards/crkbd/keymaps/curry/keymap.c new file mode 100644 index 0000000000..23c7c46c7f --- /dev/null +++ b/keyboards/crkbd/keymaps/curry/keymap.c @@ -0,0 +1,61 @@ +#include "curry.h" + +#define LAYOUT_crkbd_base( \ + K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ + K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ + K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A \ + ) \ + LAYOUT_wrapper( \ + KC_GESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \ + M_LCTL, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, M_RALT, \ + OS_LSFT, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, OS_RSFT, \ + KC_GRV, OS_LALT, SP_LWER, ET_RAIS, KC_BSPC, OS_RGUI \ + ) +#define LAYOUT_crkbd_base_wrapper(...) LAYOUT_crkbd_base(__VA_ARGS__) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT_crkbd_base_wrapper( + _________________QWERTY_L1_________________, _________________QWERTY_R1_________________, + _________________QWERTY_L2_________________, _________________QWERTY_R2_________________, + _________________QWERTY_L3_________________, _________________QWERTY_R3_________________ + ), + + [_COLEMAK] = LAYOUT_crkbd_base_wrapper( + _________________COLEMAK_L1________________, _________________COLEMAK_R1________________, + _________________COLEMAK_L2________________, _________________COLEMAK_R2________________, + _________________COLEMAK_L3________________, _________________COLEMAK_R3________________ + ), + + [_DVORAK] = LAYOUT_crkbd_base_wrapper( + _________________DVORAK_L1_________________, _________________DVORAK_R1_________________, + _________________DVORAK_L2_________________, _________________DVORAK_R2_________________, + _________________DVORAK_L3_________________, _________________DVORAK_R3_________________ + ), + + [_MODS] = LAYOUT_wrapper( + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + KC_LSFT, ___________________BLANK___________________, ___________________BLANK___________________, KC_RSFT, + _______, _______, _______, _______, _______, _______ + ), + [_LOWER] = LAYOUT_wrapper( + _______, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_PIPE, + KC_F11, _________________LOWER_L2__________________, _________________LOWER_R2__________________, KC_F12, + _______, _________________LOWER_L3__________________, _________________LOWER_R3__________________, _______, + _______, _______, _______, _______, _______, _______ + ), + + [_RAISE] = LAYOUT_wrapper( \ + _______, _________________RAISE_L1__________________, _________________RAISE_R1__________________, _______, + _______, _________________RAISE_L2__________________, _________________RAISE_R2__________________, KC_BSLS, + _______, _________________RAISE_L3__________________, _________________RAISE_R3__________________, _______, + _______, _______, _______, _______, _______, _______ + ), + + [_ADJUST] = LAYOUT_wrapper( \ + KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET, + VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST, + MG_NKRO, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL, + _______, _______, _______, _______, TG_MODS, _______ + ) +}; diff --git a/keyboards/crkbd/keymaps/curry/rules.mk b/keyboards/crkbd/keymaps/curry/rules.mk new file mode 100644 index 0000000000..7f77b43f4c --- /dev/null +++ b/keyboards/crkbd/keymaps/curry/rules.mk @@ -0,0 +1,22 @@ +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. +SWAP_HANDS_ENABLE = no # Enable one-hand typing +RGB_MATRIX_ENABLE = WS2812 +TAP_DANCE_ENABLE = yes # Enable Tap Dance. +OLED_DRIVER_ENABLE = yes +BOOTLOADER = atmel-dfu +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend diff --git a/keyboards/lily58/keymaps/curry/config.h b/keyboards/lily58/keymaps/curry/config.h new file mode 100644 index 0000000000..229213b3ca --- /dev/null +++ b/keyboards/lily58/keymaps/curry/config.h @@ -0,0 +1,7 @@ +#pragma once + +#define MASTER_LEFT +#define USE_SERIAL_PD2 + +#define OLED_DISABLE_TIMEOUT +#define TAPPING_TERM_PER_KEY diff --git a/keyboards/lily58/keymaps/curry/keymap.c b/keyboards/lily58/keymaps/curry/keymap.c new file mode 100644 index 0000000000..3e2e0ae490 --- /dev/null +++ b/keyboards/lily58/keymaps/curry/keymap.c @@ -0,0 +1,71 @@ +#include "curry.h" + +#define LAYOUT_lily58_base( \ + K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ + K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ + K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, \ + K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A \ + ) \ + LAYOUT_wrapper( \ + KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_GRV, \ + KC_TAB, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, KC_BSLS, \ + KC_LCTL, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, KC_QUOT, \ + OS_LSFT, K31, K32, K33, K34, K35, KC_LBRC, KC_RBRC, K36, K37, K38, K39, K3A, OS_RSFT, \ + OS_LGUI, OS_LALT, LOWER, KC_SPC, KC_ENT, RAISE, KC_BSPC, OS_RGUI \ + ) +#define LAYOUT_lily58_base_wrapper(...) LAYOUT_lily58_base(__VA_ARGS__) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT_lily58_base_wrapper( + ________________NUMBER_LEFT________________, ________________NUMBER_RIGHT_______________, + _________________QWERTY_L1_________________, _________________QWERTY_R1_________________, + _________________QWERTY_L2_________________, _________________QWERTY_R2_________________, + _________________QWERTY_L3_________________, _________________QWERTY_R3_________________ + ), + + [_COLEMAK] = LAYOUT_lily58_base_wrapper( + ________________NUMBER_LEFT________________, ________________NUMBER_RIGHT_______________, + _________________COLEMAK_L1________________, _________________COLEMAK_R1________________, + _________________COLEMAK_L2________________, _________________COLEMAK_R2________________, + _________________COLEMAK_L3________________, _________________COLEMAK_R3________________ + ), + + [_DVORAK] = LAYOUT_lily58_base_wrapper( + ________________NUMBER_LEFT________________, ________________NUMBER_RIGHT_______________, + _________________DVORAK_L1_________________, _________________DVORAK_R1_________________, + _________________DVORAK_L2_________________, _________________DVORAK_R2_________________, + _________________DVORAK_L3_________________, _________________DVORAK_R3_________________ + ), + + [_MODS] = LAYOUT_wrapper( + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + KC_LSFT, ___________________BLANK___________________, _______, _______, ___________________BLANK___________________, KC_RSFT, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_LOWER] = LAYOUT_wrapper( \ + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + KC_F11, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F12, + _______, _________________LOWER_L2__________________, _________________LOWER_R2__________________, _______, + _______, _________________LOWER_L3__________________, _______, _______, _________________LOWER_R3__________________, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_RAISE] = LAYOUT_wrapper( \ + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + _______, _________________RAISE_L1__________________, _________________RAISE_R1__________________, _______, + _______, _________________RAISE_L2__________________, _________________RAISE_R2__________________, _______, + _______, _________________RAISE_L3__________________, _______, _______, _________________RAISE_R3__________________, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_ADJUST] = LAYOUT_wrapper( \ + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET, + VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST, + MG_NKRO, _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, RGB_IDL, + _______, _______, _______, _______, _______, _______, _______, _______ + ), +}; diff --git a/keyboards/lily58/keymaps/curry/rules.mk b/keyboards/lily58/keymaps/curry/rules.mk new file mode 100644 index 0000000000..4e73f47f49 --- /dev/null +++ b/keyboards/lily58/keymaps/curry/rules.mk @@ -0,0 +1,17 @@ +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. +SWAP_HANDS_ENABLE = no # Enable one-hand typing +TAP_DANCE_ENABLE = yes # Enable Tap Dance. +OLED_DRIVER_ENABLE = yes +BOOTLOADER = atmel-dfu +SPLIT_TRANSPORT = mirror diff --git a/users/curry/.gitignore b/users/curry/.gitignore new file mode 100644 index 0000000000..c6df8c0139 --- /dev/null +++ b/users/curry/.gitignore @@ -0,0 +1 @@ +secrets.c diff --git a/users/curry/config.h b/users/curry/config.h new file mode 100644 index 0000000000..ac4a8f0709 --- /dev/null +++ b/users/curry/config.h @@ -0,0 +1,116 @@ +#pragma once + +// Use custom magic number so that when switching branches, EEPROM always gets reset +#define EECONFIG_MAGIC_NUMBER (uint16_t)0x420 + +/* Set Polling rate to 1000Hz */ +#define USB_POLLING_INTERVAL_MS 1 + +#ifdef RGBLIGHT_ENABLE +# undef RGBLIGHT_ANIMATIONS +# if defined(__AVR__) && !defined(__AVR_AT90USB1286__) +# define RGBLIGHT_SLEEP +# define RGBLIGHT_EFFECT_BREATHING +# define RGBLIGHT_EFFECT_SNAKE +# define RGBLIGHT_EFFECT_KNIGHT +# else +# define RGBLIGHT_ANIMATIONS +# endif +#endif // RGBLIGHT_ENABLE + +#ifdef RGB_MATRIX_ENABLE +# define RGB_MATRIX_KEYPRESSES // reacts to keypresses (will slow down matrix scan by a lot) +// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) +# define RGB_MATRIX_FRAMEBUFFER_EFFECTS +// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects +# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended +// # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 +// # define EECONFIG_RGB_MATRIX (uint32_t *)16 + +# if defined(__AVR__) && !defined(__AVR_AT90USB1286__) +# define DISABLE_RGB_MATRIX_ALPHAS_MODS +# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# define DISABLE_RGB_MATRIX_BREATHING +# define DISABLE_RGB_MATRIX_BAND_SAT +# define DISABLE_RGB_MATRIX_BAND_VAL +# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# define DISABLE_RGB_MATRIX_CYCLE_ALL +# define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN +# define DISABLE_RGB_MATRIX_CYCLE_OUT_IN +// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# define DISABLE_RGB_MATRIX_DUAL_BEACON +# define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL +# define DISABLE_RGB_MATRIX_CYCLE_SPIRAL +# define DISABLE_RGB_MATRIX_RAINBOW_BEACON +# define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# define DISABLE_RGB_MATRIX_RAINDROPS +# define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +// # define DISABLE_RGB_MATRIX_TYPING_HEATMAP +# define DISABLE_RGB_MATRIX_DIGITAL_RAIN +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# define DISABLE_RGB_MATRIX_SPLASH +# define DISABLE_RGB_MATRIX_MULTISPLASH +# define DISABLE_RGB_MATRIX_SOLID_SPLASH +# define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH +# endif // AVR +#endif // RGB_MATRIX_ENABLE + +#ifndef ONESHOT_TAP_TOGGLE +# define ONESHOT_TAP_TOGGLE 2 +#endif // !ONESHOT_TAP_TOGGLE + +#ifndef ONESHOT_TIMEOUT +# define ONESHOT_TIMEOUT 3000 +#endif // !ONESHOT_TIMEOUT + +#ifndef QMK_KEYS_PER_SCAN +# define QMK_KEYS_PER_SCAN 4 +#endif // !QMK_KEYS_PER_SCAN + +// this makes it possible to do rolling combos (zx) with keys that +// convert to other keys on hold (z becomes ctrl when you hold it, +// and when this option isn't enabled, z rapidly followed by x +// actually sends Ctrl-x. That's bad.) +#define IGNORE_MOD_TAP_INTERRUPT +#undef PERMISSIVE_HOLD +//#define TAPPING_FORCE_HOLD +//#define RETRO_TAPPING + +#define FORCE_NKRO + +#ifndef TAPPING_TOGGLE +# define TAPPING_TOGGLE 1 +#endif + +#ifdef TAPPING_TERM +# undef TAPPING_TERM +#endif // TAPPING_TERM +#if defined(KEYBOARD_ergodox_ez) +# define TAPPING_TERM 185 +#elif defined(KEYBOARD_crkbd) +# define TAPPING_TERM 200 +#else +# define TAPPING_TERM 175 +#endif + +#define TAP_CODE_DELAY 5 + +/* Disable unused and unneeded features to reduce on firmware size */ +#ifdef LOCKING_SUPPORT_ENABLE +# undef LOCKING_SUPPORT_ENABLE +#endif +#ifdef LOCKING_RESYNC_ENABLE +# undef LOCKING_RESYNC_ENABLE +#endif diff --git a/users/curry/curry.c b/users/curry/curry.c new file mode 100644 index 0000000000..b6afa5ef2e --- /dev/null +++ b/users/curry/curry.c @@ -0,0 +1,131 @@ +#include "curry.h" + +userspace_config_t userspace_config; + +#define CURRY_UNICODE_MODE 1 + +void bootmagic_lite(void) { + matrix_scan(); +#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 + wait_ms(DEBOUNCING_DELAY * 2); +#elif defined(DEBOUNCE) && DEBOUNCE > 0 + wait_ms(DEBOUNCE * 2); +#else + wait_ms(30); +#endif + matrix_scan(); + if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { + bootloader_jump(); + } +} + +__attribute__((weak)) void keyboard_pre_init_keymap(void) {} + +void keyboard_pre_init_user(void) { + userspace_config.raw = eeconfig_read_user(); + keyboard_pre_init_keymap(); +} + +__attribute__((weak)) void matrix_init_keymap(void) {} + +// Call user matrix init, set default RGB colors and then +// call the keymap's init function +void matrix_init_user(void) { +#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) + set_unicode_input_mode(CURRY_UNICODE_MODE); + get_unicode_input_mode(); +#endif // UNICODE_ENABLE + matrix_init_keymap(); +} + +__attribute__((weak)) void keyboard_post_init_keymap(void) {} + +void keyboard_post_init_user(void) { +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) + keyboard_post_init_rgb(); +#endif + keyboard_post_init_keymap(); +} + +__attribute__((weak)) void shutdown_keymap(void) {} + +void rgb_matrix_update_pwm_buffers(void); + +// On RESET, set all RGB to red, shutdown the keymap. +void shutdown_user(void) { +#ifdef RGBLIGHT_ENABLE + rgblight_enable_noeeprom(); + rgblight_mode_noeeprom(1); + rgblight_setrgb_red(); +#endif // RGBLIGHT_ENABLE +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_set_color_all(0xFF, 0x00, 0x00); + rgb_matrix_update_pwm_buffers(); +#endif // RGB_MATRIX_ENABLE + shutdown_keymap(); +} + +__attribute__((weak)) void suspend_power_down_keymap(void) {} + +void suspend_power_down_user(void) { suspend_power_down_keymap(); } + +__attribute__((weak)) void suspend_wakeup_init_keymap(void) {} + +void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); } + +__attribute__((weak)) void matrix_scan_keymap(void) {} + +// No global matrix scan code, so just run keymap's matrix +// scan function +void matrix_scan_user(void) { + static bool has_ran_yet; + if (!has_ran_yet) { + has_ran_yet = true; + startup_user(); + } + +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) + matrix_scan_rgb(); +#endif // RGBLIGHT_ENABLE + + matrix_scan_keymap(); +} + +__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; } + +// On Layer change, run keymap's layer change check +layer_state_t layer_state_set_user(layer_state_t state) { + state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) + state = layer_state_set_rgb(state); +#endif // RGBLIGHT_ENABLE + return layer_state_set_keymap(state); +} + +__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; } + +// Runs state check and changes underglow color and animation +layer_state_t default_layer_state_set_user(layer_state_t state) { + return default_layer_state_set_keymap(state); +} + +__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {} + +// Any custom LED code goes here. +void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); } + +__attribute__((weak)) void eeconfig_init_keymap(void) {} + +void eeconfig_init_user(void) { + userspace_config.raw = 0; + userspace_config.rgb_layer_change = true; + eeconfig_update_user(userspace_config.raw); +#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) + set_unicode_input_mode(CURRY_UNICODE_MODE); + get_unicode_input_mode(); +#else + eeprom_update_byte(EECONFIG_UNICODEMODE, CURRY_UNICODE_MODE); +#endif + eeconfig_init_keymap(); + keyboard_init(); +} diff --git a/users/curry/curry.h b/users/curry/curry.h new file mode 100644 index 0000000000..985453c49b --- /dev/null +++ b/users/curry/curry.h @@ -0,0 +1,57 @@ +#pragma once + +#include QMK_KEYBOARD_H + +#include "version.h" +#include "eeprom.h" +#include "wrappers.h" +#include "process_records.h" + +#ifdef TAP_DANCE_ENABLE +# include "tap_dances.h" +#endif // TAP_DANCE_ENABLE +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) +# include "rgb_stuff.h" +#endif +#if defined(KEYBOARD_lily58_rev1) & defined(PROTOCOL_LUFA) +# include "lufa.h" +# include "split_util.h" +#endif + +/* Define layer names */ +enum userspace_layers { + _QWERTY = 0, + _NUMLOCK = 0, + _COLEMAK, + _DVORAK, + _MODS, + _LOWER, + _RAISE, + _ADJUST, +}; + +void matrix_init_keymap(void); +void shutdown_keymap(void); +void suspend_power_down_keymap(void); +void suspend_wakeup_init_keymap(void); +void matrix_scan_keymap(void); +layer_state_t layer_state_set_keymap(layer_state_t state); +layer_state_t default_layer_state_set_keymap(layer_state_t state); +void led_set_keymap(uint8_t usb_led); +void eeconfig_init_keymap(void); + +// clang-format off +typedef union { + uint32_t raw; + struct { + bool rgb_layer_change :1; + bool is_overwatch :1; + bool nuke_switch :1; + uint8_t unicode_mod :4; + bool swapped_numbers :1; + bool rgb_matrix_idle_anim :1; + }; +} userspace_config_t; +// clang-format on + +extern userspace_config_t userspace_config; diff --git a/users/curry/oled.c b/users/curry/oled.c new file mode 100644 index 0000000000..4eb23423eb --- /dev/null +++ b/users/curry/oled.c @@ -0,0 +1,162 @@ +#include "curry.h" + +#ifdef OLED_DRIVER_ENABLE +#define KEYLOGGER_LENGTH 5 +static uint32_t oled_timer = 0; +static char keylog_str[KEYLOGGER_LENGTH + 1] = {"\n"}; +static uint16_t log_timer = 0; +// clang-format off +static const char PROGMEM code_to_name[0xFF] = { +// 0 1 2 3 4 5 6 7 8 9 A B c D E F + ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x + '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x + ']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x + ' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx + 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx +}; + +void add_keylog(uint16_t keycode); + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; } + +void add_keylog(uint16_t keycode) { + if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { + keycode = keycode & 0xFF; + } else if (keycode > 0xFF) { + keycode = 0; + } + + for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) { + keylog_str[i] = keylog_str[i - 1]; + } + + if (keycode < (sizeof(code_to_name) / sizeof(char))) { + keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); + } + + log_timer = timer_read(); +} + +void render_keylogger_status(void) { + oled_write_P(PSTR("Keys"), false); + oled_write(keylog_str, false); +} + +void render_default_layer_state(void) { + oled_write_P(PSTR("Lyout"), false); + switch (get_highest_layer(default_layer_state)) { + case _QWERTY: + oled_write_P(PSTR(" QRTY"), false); + break; + case _COLEMAK: + oled_write_P(PSTR(" COLE"), false); + break; + case _DVORAK: + oled_write_P(PSTR(" DVRK"), false); + break; + } +} + +void render_layer_state(void) { + oled_write_P(PSTR("LAYER"), false); + oled_write_P(PSTR("Lower"), layer_state_is(_LOWER)); + oled_write_P(PSTR("Raise"), layer_state_is(_RAISE)); + oled_write_P(PSTR(" Mods"), layer_state_is(_MODS)); +} + +void render_keylock_status(uint8_t led_usb_state) { + oled_write_P(PSTR("Lock:"), false); + oled_write_P(PSTR(" "), false); + oled_write_P(PSTR("N"), led_usb_state & (1 << USB_LED_NUM_LOCK)); + oled_write_P(PSTR("C"), led_usb_state & (1 << USB_LED_CAPS_LOCK)); + oled_write_ln_P(PSTR("S"), led_usb_state & (1 << USB_LED_SCROLL_LOCK)); +} + +void render_mod_status(uint8_t modifiers) { + oled_write_P(PSTR("Mods:"), false); + oled_write_P(PSTR(" "), false); + oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT)); + oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL)); + oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT)); + oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI)); +} + +void render_bootmagic_status(void) { + /* Show Ctrl-Gui Swap options */ + static const char PROGMEM logo[][2][3] = { + {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}, + {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, + }; + oled_write_P(PSTR("BTMGK"), false); + oled_write_P(PSTR(" "), false); + oled_write_P(logo[0][0], !keymap_config.swap_lctl_lgui); + oled_write_P(logo[1][0], keymap_config.swap_lctl_lgui); + oled_write_P(PSTR(" "), false); + oled_write_P(logo[0][1], !keymap_config.swap_lctl_lgui); + oled_write_P(logo[1][1], keymap_config.swap_lctl_lgui); + oled_write_P(PSTR(" NKRO"), keymap_config.nkro); +} + +void render_user_status(void) { + oled_write_P(PSTR("USER:"), false); + oled_write_P(PSTR(" Anim"), userspace_config.rgb_matrix_idle_anim); + oled_write_P(PSTR(" Layr"), userspace_config.rgb_layer_change); + oled_write_P(PSTR(" Nuke"), userspace_config.nuke_switch); +} + +void render_status_main(void) { + /* Show Keyboard Layout */ + render_default_layer_state(); + render_keylock_status(host_keyboard_leds()); + render_bootmagic_status(); + render_user_status(); + + render_keylogger_status(); +} + +void render_status_secondary(void) { + /* Show Keyboard Layout */ + render_default_layer_state(); + render_layer_state(); + render_mod_status(get_mods() | get_oneshot_mods()); + + render_keylogger_status(); +} + +void oled_task_user(void) { + if (timer_elapsed32(oled_timer) > 30000) { + oled_off(); + return; + } +# ifndef SPLIT_KEYBOARD + else { + oled_on(); + } +# endif + if (is_keyboard_master()) { + render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) + } else { + render_status_secondary(); + } +} + +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + oled_timer = timer_read32(); + add_keylog(keycode); + } + return true; +} + +#endif diff --git a/users/curry/process_records.c b/users/curry/process_records.c new file mode 100644 index 0000000000..fd1d61ad9d --- /dev/null +++ b/users/curry/process_records.c @@ -0,0 +1,85 @@ +#include "curry.h" + +uint16_t copy_paste_timer; + +__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } + +__attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; } + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); + switch (keycode) { + case KC_MAKE: + if (!record->event.pressed) { + uint8_t temp_mod = mod_config(get_mods()); + uint8_t temp_osm = mod_config(get_oneshot_mods()); + clear_mods(); + clear_oneshot_mods(); + send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), TAP_CODE_DELAY); + if ((temp_mod | temp_osm) & MOD_MASK_SHIFT) { + send_string_with_delay_P(PSTR(":flash"), TAP_CODE_DELAY); + } + if ((temp_mod | temp_osm) & MOD_MASK_CTRL) { + send_string_with_delay_P(PSTR(" -j8 --output-sync"), TAP_CODE_DELAY); + } +#ifdef RGB_MATRIX_SPLIT_RIGHT + send_string_with_delay_P(PSTR(" RGB_MATRIX_SPLIT_RIGHT=yes"), TAP_CODE_DELAY); +# ifndef OLED_DRIVER_ENABLE + send_string_with_delay_P(PSTR(" OLED_DRIVER_ENABLE=no"), TAP_CODE_DELAY); +# endif +#endif + send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY); + } + + break; + + case VRSN: // Prints firmware version + if (record->event.pressed) { + send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY); + } + break; + + case KC_CCCV: // One key copy/paste + if (record->event.pressed) { + copy_paste_timer = timer_read(); + } else { + if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy + register_code(KC_LCTL); + tap_code(KC_C); + unregister_code(KC_LCTL); + } else { // Tap, paste + register_code(KC_LCTL); + tap_code(KC_V); + unregister_code(KC_LCTL); + } + } + break; +#ifdef UNICODE_ENABLE + case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ + if (record->event.pressed) { + send_unicode_hex_string |