aboutsummaryrefslogtreecommitdiff
path: root/keyboards/massdrop/ctrl/keymaps/r-pufky/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/massdrop/ctrl/keymaps/r-pufky/keymap.c')
-rw-r--r--keyboards/massdrop/ctrl/keymaps/r-pufky/keymap.c138
1 files changed, 138 insertions, 0 deletions
diff --git a/keyboards/massdrop/ctrl/keymaps/r-pufky/keymap.c b/keyboards/massdrop/ctrl/keymaps/r-pufky/keymap.c
new file mode 100644
index 000000000..718338a4c
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/r-pufky/keymap.c
@@ -0,0 +1,138 @@
1/* Copyright 2020 Robert Pufky <rpufky@gmail.com>
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 QMK_KEYBOARD_H
18
19enum ctrl_keycodes {
20 U_T_AUTO = SAFE_RANGE, // USB Extra Port Toggle Auto Detect / Always Active
21 U_T_AGCR, // USB Toggle Automatic GCR control
22 DBG_TOG, // DEBUG Toggle On / Off
23 DBG_MTRX, // DEBUG Toggle Matrix Prints
24 DBG_KBD, // DEBUG Toggle Keyboard Prints
25 DBG_MOU, // DEBUG Toggle Mouse Prints
26 MD_BOOT, // Restart into bootloader after hold timeout
27};
28
29const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
30 [0] = LAYOUT(
31 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_PSCR, KC_SLCK, KC_PAUS,
32 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_INS, KC_HOME, KC_PGUP,
33 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_END, KC_PGDN,
34 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,
35 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,
36 KC_NLCK, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_F24, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
37 ),
38 [1] = LAYOUT(
39 KC_EJCT, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_MUTE, _______, _______,
40 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU,
41 _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD,
42 KC_CAPS, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______,
43 _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, _______, _______, _______, _______, _______, KC_BRIU,
44 _______, _______, _______, _______, _______, _______, _______, _______, KC_MRWD, KC_BRID, KC_MFFD
45 ),
46};
47
48// Runs just one time when the keyboard initializes.
49void matrix_init_user(void) {
50 // https://old.reddit.com/r/MechanicalKeyboards/comments/by8zv9/editing_rgb_backlighting_with_qmk/
51 // https://docs.qmk.fm/#/feature_rgblight?id=colors
52 rgblight_sethsv(HSV_BLUE);
53 // Disable underglow by default
54 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER);
55 rgb_matrix_set_color_all(0, 0, 0);
56};
57
58// Runs constantly in the background, in a loop.
59void matrix_scan_user(void) {
60};
61
62#define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT)
63#define MODS_CTRL (get_mods() & MOD_MASK_CTRL)
64#define MODS_ALT (get_mods() & MOD_MASK_ALT)
65
66bool process_record_user(uint16_t keycode, keyrecord_t *record) {
67 static uint32_t key_timer;
68
69 switch (keycode) {
70 case U_T_AUTO:
71 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
72 TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
73 }
74 return false;
75 case U_T_AGCR:
76 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
77 TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
78 }
79 return false;
80 case DBG_TOG:
81 if (record->event.pressed) {
82 TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
83 }
84 return false;
85 case DBG_MTRX:
86 if (record->event.pressed) {
87 TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
88 }
89 return false;
90 case DBG_KBD:
91 if (record->event.pressed) {
92 TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
93 }
94 return false;
95 case DBG_MOU:
96 if (record->event.pressed) {
97 TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
98 }
99 return false;
100 case MD_BOOT:
101 if (record->event.pressed) {
102 key_timer = timer_read32();
103 } else {
104 if (timer_elapsed32(key_timer) >= 500) {
105 reset_keyboard();
106 }
107 }
108 return false;
109 case RGB_TOG:
110 if (record->event.pressed) {
111 switch (rgb_matrix_get_flags()) {
112 case LED_FLAG_ALL: {
113 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER);
114 rgb_matrix_set_color_all(0, 0, 0);
115 }
116 break;
117 case LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER: {
118 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
119 rgb_matrix_set_color_all(0, 0, 0);
120 }
121 break;
122 case LED_FLAG_UNDERGLOW: {
123 rgb_matrix_set_flags(LED_FLAG_NONE);
124 rgb_matrix_disable_noeeprom();
125 }
126 break;
127 default: {
128 rgb_matrix_set_flags(LED_FLAG_ALL);
129 rgb_matrix_enable_noeeprom();
130 }
131 break;
132 }
133 }
134 return false;
135 default:
136 return true; //Process all other keycodes normally
137 }
138}