Created
November 29, 2021 22:33
-
-
Save jeremytregunna/d73c2920354cdd843bedeb70af86546d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../config.h" | |
#define UNICODE_SELECTED_MODES UC_LNX, UC_WINC | |
#define QMK_KEYS_PER_SCAN 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2021 Glorious, LLC <[email protected]> | |
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 "rgb.h" | |
#define _QW _L1 | |
#define _MD _L3 | |
#define _MM _L2 | |
#define _WM _L0 | |
#define _L0 0 | |
#define _L1 1 | |
#define _L2 2 | |
#define _L3 3 | |
#define BACKLIGHT_TIMEOUT 5 | |
static uint16_t idle_timer = 0; | |
static uint8_t halfmin_counter = 0; | |
static bool led_on = true; | |
enum unicode_names { | |
UK_AGRV, // Accent grave | |
UK_AEGU, // Accent egu | |
UK_ACFX, // Accent circumflex | |
UK_ATLD, // Accent tilde | |
UK_UXCL, // Upside down ? | |
UK_MDOT, // Unicode dot | |
UK_GRIN, // Grinning face | |
UK_BEAM, // Beaming face | |
UK_ROFL, // Rolling on the floor laughing | |
UK_TJOY, // Tears of joy | |
UK_WINK, // Winking face | |
UK_LOVE, // Smiling face with hearts | |
UK_HRTE, // Smiling face with heart eyes | |
UK_KISS, // Face blowing kiss | |
UK_STAR, // Star struck | |
UK_THUP, // Thumbs up | |
UK_THDN, // Thumbs down | |
UK_PALM, // Man facepalming | |
}; | |
const uint32_t PROGMEM unicode_map[] = { | |
[UK_AGRV] = 0x300, | |
[UK_AEGU] = 0x301, | |
[UK_ACFX] = 0x302, | |
[UK_ATLD] = 0x303, | |
[UK_UXCL] = 0xBF, | |
[UK_MDOT] = 0x2022, | |
[UK_GRIN] = 0x1f600, | |
[UK_BEAM] = 0x1f601, | |
[UK_ROFL] = 0x1f923, | |
[UK_TJOY] = 0x1f602, | |
[UK_WINK] = 0x1f609, | |
[UK_LOVE] = 0x1f970, | |
[UK_HRTE] = 0x1f60d, | |
[UK_KISS] = 0x1f618, | |
[UK_STAR] = 0x1f929, | |
[UK_THUP] = 0x1f44d, | |
[UK_THDN] = 0x1f44e, | |
[UK_PALM] = 0x1f926, | |
}; | |
enum custom_keycodes { | |
CK_AGRV = X(UK_AGRV), | |
CK_AEGU = X(UK_AEGU), | |
CK_ACFX = X(UK_ACFX), | |
CK_ATLD = X(UK_ATLD), | |
CK_UXCL = X(UK_UXCL), | |
CK_MDOT = X(UK_MDOT), | |
CK_GRIN = X(UK_GRIN), | |
CK_BEAM = X(UK_BEAM), | |
CK_ROFL = X(UK_ROFL), | |
CK_TJOY = X(UK_TJOY), | |
CK_WINK = X(UK_WINK), | |
CK_LOVE = X(UK_LOVE), | |
CK_HRTE = X(UK_HRTE), | |
CK_KISS = X(UK_KISS), | |
CK_STAR = X(UK_STAR), | |
CK_THUP = X(UK_THUP), | |
CK_THDN = X(UK_THDN), | |
CK_PALM = X(UK_PALM), | |
}; | |
enum custom_macros { | |
MA_GCHM = SAFE_RANGE, | |
CA_FLAG, | |
CR_FLAG, | |
MA_DEAD, | |
}; | |
// clang-format off | |
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |
// ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Prt Rotary(Mute) | |
// ~ 1 2 3 4 5 6 7 8 9 0 - (=) BackSpc Home | |
// Tab Q W E R T Y U I O P [ ] \ PgUp | |
// Caps A S D F G H J K L ; " Enter PgDn | |
// Sh_L Z X C V B N M , . ? Sh_R Up End | |
// Ct_L Win_L Alt_L SPACE Alt_R FN Ct_R Left Down Right | |
// RGB LED layout | |
// | |
// led number, function of the key | |
// | |
// 67, Side led 01 0, ESC 6, F1 12, F2 18, F3 23, F4 28, F5 34, F6 39, F7 44, F8 50, F9 56, F10 61, F11 66, F12 69, Prt Rotary(Mute) 68, Side led 12 | |
// 70, Side led 02 1, ~ 7, 1 13, 2 19, 3 24, 4 29, 5 35, 6 40, 7 45, 8 51, 9 57, 0 62, -_ 78, (=+) 85, BackSpc 72, Del 71, Side led 13 | |
// 73, Side led 03 2, Tab 8, Q 14, W 20. E 25, R 30, T 36, Y 41, U 46, I 52, O 58, P 63, [{ 89, ]} 93, \| 75, PgUp 74, Side led 14 | |
// 76, Side led 04 3, Caps 9, A 15, S 21, D 26, F 31, G 37, H 42, J 47, K 53, L 59, ;: 64, '" 96, Enter 86, PgDn 77, Side led 15 | |
// 80, Side led 05 4, Sh_L 10, Z 16, X 22, C 27, V 32, B 38, N 43, M 48, ,< 54, .< 60, /? 90, Sh_R 94, Up 82, End 81, Side led 16 | |
// 83, Side led 06 5, Ct_L 11,Win_L 17, Alt_L 33, SPACE 49, Alt_R 55, FN 65, Ct_R 95, Left 97, Down 79, Right 84, Side led 17 | |
// 87, Side led 07 88, Side led 18 | |
// 91, Side led 08 92, Side led 19 | |
// The FN key by default maps to a momentary toggle to layer 1 to provide access to the RESET key (to put the board into bootloader mode). Without | |
// this mapping, you have to open the case to hit the button on the bottom of the PCB (near the USB cable attachment) while plugging in the USB | |
// cable to get the board into bootloader mode - definitely not fun when you're working on your QMK builds. Remove this and put it back to KC_RGUI | |
// if that's your preference. | |
// | |
// To put the keyboard in bootloader mode, use FN+backslash. If you accidentally put it into bootloader, you can just unplug the USB cable and | |
// it'll be back to normal when you plug it back in. | |
// | |
// This keyboard defaults to 6KRO instead of NKRO for compatibility reasons (some KVMs and BIOSes are incompatible with NKRO). | |
// Since this is, among other things, a "gaming" keyboard, a key combination to enable NKRO on the fly is provided for convenience. | |
// Press Fn+N to toggle between 6KRO and NKRO. This setting is persisted to the EEPROM and thus persists between restarts. | |
[_WM] = LAYOUT( | |
KC_ESC, 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_INS, KC_MUTE, | |
KC_GRV, 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_TAB, KC_Q, KC_D, KC_R, KC_W, KC_B, KC_J, KC_F, KC_U, KC_P, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, | |
KC_LCTL, KC_A, KC_S, KC_H, KC_T, KC_G, KC_Y, KC_N, KC_E, KC_O, KC_I, KC_QUOT, KC_ENT, KC_PGDN, | |
KC_LSFT, KC_Z, KC_X, KC_M, KC_C, KC_V, KC_K, KC_L, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, | |
MO(_MD), KC_LGUI, KC_LALT, KC_SPC, MO(_MD), TO(_QW), TO(_MM), KC_LEFT, KC_DOWN, KC_RGHT | |
), | |
[_QW] = LAYOUT( | |
KC_ESC, 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_INS, KC_MUTE, | |
KC_GRV, 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_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_PGUP, | |
KC_LCTL, 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_PGDN, | |
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_END, | |
MO(_MD), KC_LGUI, KC_LALT, KC_SPC, MO(_MD), TO(_WM), TO(_MM), KC_LEFT, KC_DOWN, KC_RGHT | |
), | |
[_MM] = LAYOUT( | |
MACRO00, MACRO01, MACRO02, MACRO03, MACRO04, MACRO05, MACRO06, MACRO07, MACRO08, MACRO09, MACRO10, MACRO11, MACRO12, MACRO13, _______, | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, _______, _______, KC_BTN1, KC_BTN3, KC_BTN2, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, _______, _______, _______, _______, | |
KC_LSFT, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, _______, _______, _______, RGB_MOD, _______, | |
_______, _______, _______, _______, MO(_MD), TO(_QW), TO(_WM), RGB_SPD, RGB_RMOD, RGB_SPI | |
), | |
[_MD] = LAYOUT( | |
RGB_TOG, DM_REC1, DM_REC2, DM_RSTP, _______, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, DM_PLY1, DM_PLY2, CMB_OFF, CMB_ON, KC_DEL, KC_PWR, | |
CK_AGRV, CA_FLAG, CR_FLAG, _______, _______, _______, CK_ACFX, _______, CK_MDOT, _______, _______, _______, _______, _______, MA_GCHM, | |
MA_DEAD, _______, CK_WINK, CK_AEGU, CK_ROFL, CK_TJOY, _______, _______, _______, _______, _______, CK_THDN, CK_THUP, RESET, RGB_VAI, | |
_______, _______, CK_STAR, _______, CK_PALM, CK_GRIN, CK_HRTE, _______, CK_KISS, CK_LOVE, _______, _______, _______, RGB_VAD, | |
_______, _______, _______, _______, _______, CK_BEAM, CK_ATLD, _______, _______, _______, CK_UXCL, _______, RGB_HUI, _______, | |
_______, _______, _______, NK_TOGG, _______, _______, _______, RGB_SAD, RGB_HUD, RGB_SAI | |
), | |
/* | |
[_] = LAYOUT( | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |
_______, _______, _______, _______, TO(_WM), _______, _______, _______, _______, _______ | |
), | |
*/ | |
}; | |
// clang-format on | |
#ifdef ENCODER_ENABLE | |
bool encoder_update_user(uint8_t index, bool clockwise) { | |
if (clockwise) { | |
tap_code(KC_VOLU); | |
} else { | |
tap_code(KC_VOLD); | |
} | |
return true; | |
} | |
#endif // ENCODER_ENABLE | |
bool process_record_user(uint16_t keycode, keyrecord_t* record) { | |
if (record->event.pressed) { | |
if (!led_on) { | |
rgblight_enable(); | |
led_on = true; | |
} | |
idle_timer = timer_read(); | |
halfmin_counter = 0; | |
} | |
switch (keycode) { | |
case CA_FLAG: | |
if (record->event.pressed) { | |
send_unicode_hex_string("1F1E8 1F1E6"); | |
} | |
return false; | |
case CR_FLAG: | |
if (record->event.pressed) { | |
send_unicode_hex_string("1F1E8 1F1F7"); | |
} | |
return false; | |
case MA_GCHM: | |
if (record->event.pressed) { | |
SEND_STRING(SS_LGUI(SS_TAP(X_D) SS_DELAY(100))); | |
SEND_STRING("google-chrome-stable"); | |
SEND_STRING(SS_TAP(X_ENT)); | |
} | |
return false; | |
case MA_DEAD: | |
if (record->event.pressed) { | |
SEND_STRING(SS_LGUI(SS_TAP(X_D) SS_DELAY(100))); | |
SEND_STRING("xdg-open /home/jtregunna/Documents/UponMyDeath.odt"); | |
SEND_STRING(SS_TAP(X_ENT)); | |
} | |
return false; | |
} | |
return true; | |
} | |
void matrix_scan_user(void) { | |
if (idle_timer == 0) { | |
idle_timer = timer_read(); | |
} | |
if (timer_elapsed(idle_timer) > 30000) { | |
halfmin_counter++; | |
idle_timer = 0; | |
} | |
if (halfmin_counter >= BACKLIGHT_TIMEOUT * 2) { | |
rgblight_disable(); | |
halfmin_counter = 0; | |
led_on = false; | |
} | |
} | |
static void rgb_matrix_canadian_flag(uint8_t led_min, uint8_t led_max) { | |
// carve out crimson areas | |
for (uint8_t i = 0; i < BARS_LED_COUNT; i++) { | |
RGB_MATRIX_INDICATOR_SET_COLOR(rgb_bars_design[i], 255, 0, 0); | |
} | |
// maple leaf | |
for (uint8_t i = 0; i < MAPLE_LEAF_LED_COUNT; i++) { | |
RGB_MATRIX_INDICATOR_SET_COLOR(rgb_maple_leaf_design[i], 255, 0, 0); | |
} | |
// set white colours | |
for (uint8_t i = 0; i < BACKGROUND_LED_COUNT; i++) { | |
RGB_MATRIX_INDICATOR_SET_COLOR(rgb_background_design[i], 255, 255, 255); | |
} | |
} | |
static void rgb_matrix_xmas_emma(uint8_t led_min, uint8_t led_max) { | |
for (uint8_t i = 0; i < XMAS_RED_COUNT; i++) { | |
RGB_MATRIX_INDICATOR_SET_COLOR(rgb_xmas_red_design[i], 255, 0, 0); | |
} | |
for (uint8_t i = 0; i < XMAS_GREEN_COUNT; i++) { | |
RGB_MATRIX_INDICATOR_SET_COLOR(rgb_xmas_green_design[i], 0, 255, 0); | |
} | |
} | |
void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { | |
switch(get_highest_layer(layer_state)) { | |
case _L0: | |
rgb_matrix_canadian_flag(led_min, led_max); | |
break; | |
case _L1: | |
rgb_matrix_xmas_emma(led_min, led_max); | |
//rgb_matrix_set_color_all(0, 255, 0); | |
break; | |
case _L2: | |
rgb_matrix_set_color_all(255, 0, 255); | |
break; | |
case _MD: | |
rgb_matrix_set_color_all(255, 165, 0); | |
break; | |
default: | |
rgb_matrix_set_color_all(0, 0, 0); | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __CANOOK_RGB_H__ | |
#define __CANOOK_RGB_H__ | |
#define MAPLE_LEAF_LED_COUNT 16 | |
uint8_t rgb_maple_leaf_design[MAPLE_LEAF_LED_COUNT] = { | |
39, 40, 45, 25, 36, 41, 46, 58, 31, 37, 42, 47, 53, 32, 38, 43, | |
}; | |
#define BARS_LED_COUNT 48 | |
uint8_t rgb_bars_design[BARS_LED_COUNT] = { | |
67, 70, 73, 76, 80, 83, 87, 91, 68, 71, 74, 77, 81, 84, 88, 92, | |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 72, | |
75, 86, 82, 79, 69, 85, 93, 96, 94, 97, 66, 89, 90, 95, | |
}; | |
#define BACKGROUND_LED_COUNT 34 | |
uint8_t rgb_background_design[BACKGROUND_LED_COUNT] = { | |
16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 35, | |
44, 48, 49, 50, 51, 52, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, | |
65, 78, | |
}; | |
#define XMAS_RED_COUNT 51 | |
uint8_t rgb_xmas_red_design[XMAS_RED_COUNT] = { | |
0, 6, 12, 18, 23, 28, 34, 39, 44, 50, 56, 61, 66, 69, | |
2, 8, 14, 20, 25, 30, 36, 41, 46, 52, 58, 63, 89, 93, 75, | |
4, 10, 16, 22, 27, 32, 38, 43, 48, 54, 60, 90, 94, 82, | |
67, 70, 73, 76, 80, 83, 87, 91, | |
}; | |
#define XMAS_GREEN_COUNT 47 | |
uint8_t rgb_xmas_green_design[XMAS_GREEN_COUNT] = { | |
1, 7, 13, 19, 24, 29, 35, 40, 45, 51, 57, 62, 78, 85, 72, | |
3, 9, 15, 21, 26, 31, 37, 42, 47, 53, 59, 64, 96, 86, | |
5, 11, 17, 33, 49, 55, 65, 95, 97, 79, | |
68, 71, 74, 77, 81, 84, 88, 92, | |
}; | |
#endif // !__CANOOK_RGB_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VIA_ENABLE = yes | |
UNICODEMAP_ENABLE = yes | |
DYNAMIC_MACRO_ENABLE = yes | |
COMMAND_ENABLE = no | |
ENCODER_ENABLE = yes | |
FORCE_NKRO = yes | |
SEQUENCER_ENABLE = yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment