aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/massdrop/ctrl/keymaps/R167/keymap.c143
-rw-r--r--keyboards/massdrop/ctrl/keymaps/R167/readme.md14
2 files changed, 157 insertions, 0 deletions
diff --git a/keyboards/massdrop/ctrl/keymaps/R167/keymap.c b/keyboards/massdrop/ctrl/keymaps/R167/keymap.c
new file mode 100644
index 000000000..942a002d9
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/R167/keymap.c
@@ -0,0 +1,143 @@
1// Copyright 2021 Winston Durand (@R167)
2// SPDX-License-Identifier: MIT
3
4#include QMK_KEYBOARD_H
5
6enum ctrl_keycodes {
7 U_T_AUTO = SAFE_RANGE, // USB Extra Port Toggle Auto Detect / Always Active
8 U_T_AGCR, // USB Toggle Automatic GCR control
9 DBG_TOG, // DEBUG Toggle On / Off
10 DBG_MTRX, // DEBUG Toggle Matrix Prints
11 DBG_KBD, // DEBUG Toggle Keyboard Prints
12 DBG_MOU, // DEBUG Toggle Mouse Prints
13 MD_BOOT, // Restart into bootloader after hold timeout
14 SLEEP, // Macro to send CMD+ALT+Ejct & turn off lights
15};
16
17enum r167_layers {
18 _QWERTY = 0, // Standard querty layout
19 _FN, // Simple function keys
20};
21
22// clang-format off
23const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
24 [_QWERTY] = LAYOUT(
25 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,
26 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_EJCT, KC_HOME, KC_VOLU,
27 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_VOLD,
28 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,
29 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,
30 KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
31 ),
32 [_FN] = LAYOUT(
33 SLEEP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE,
34 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, SLEEP, KC_MPLY, _______, _______,
35 _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, _______,
36 _______, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______,
37 _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, _______, _______, _______, _______, _______, _______,
38 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
39 ), \
40 /*
41 [X] = LAYOUT(
42 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
43 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
44 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
45 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
46 _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
47 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
48 ),
49 */
50};
51// clang-format on
52
53#define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT)
54#define MODS_CTRL (get_mods() & MOD_MASK_CTRL)
55#define MODS_ALT (get_mods() & MOD_MASK_ALT)
56
57bool process_record_user(uint16_t keycode, keyrecord_t *record) {
58 static uint32_t key_timer;
59 static bool asleep = false;
60 if (asleep && record->event.pressed) {
61 asleep = false;
62 rgb_matrix_set_flags(LED_FLAG_ALL);
63 rgb_matrix_enable_noeeprom();
64 }
65
66 switch (keycode) {
67 case U_T_AUTO:
68 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
69 TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
70 }
71 return false;
72 case U_T_AGCR:
73 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
74 TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
75 }
76 return false;
77 case DBG_TOG:
78 if (record->event.pressed) {
79 TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
80 }
81 return false;
82 case DBG_MTRX:
83 if (record->event.pressed) {
84 TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
85 }
86 return false;
87 case DBG_KBD:
88 if (record->event.pressed) {
89 TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
90 }
91 return false;
92 case DBG_MOU:
93 if (record->event.pressed) {
94 TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
95 }
96 return false;
97 case MD_BOOT:
98 if (record->event.pressed) {
99 key_timer = timer_read32();
100 } else {
101 if (timer_elapsed32(key_timer) >= 500) {
102 reset_keyboard();
103 }
104 }
105 return false;
106 case RGB_TOG:
107 if (record->event.pressed) {
108 switch (rgb_matrix_get_flags()) {
109 case LED_FLAG_ALL: {
110 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
111 rgb_matrix_set_color_all(0, 0, 0);
112 } break;
113 case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): {
114 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
115 rgb_matrix_set_color_all(0, 0, 0);
116 } break;
117 case LED_FLAG_UNDERGLOW: {
118 rgb_matrix_set_flags(LED_FLAG_NONE);
119 rgb_matrix_disable_noeeprom();
120 } break;
121 default: {
122 rgb_matrix_set_flags(LED_FLAG_ALL);
123 rgb_matrix_enable_noeeprom();
124 } break;
125 }
126 }
127 return false;
128 case SLEEP:
129 if (record->event.pressed) {
130 // CMD+ALT+EJECT doesn't always reliably trigger. fall back mode
131 // tap_code16(G(A(KC_EJCT)));
132 tap_code16(LCTL(LGUI(KC_Q)));
133 asleep = true;
134 rgb_matrix_set_flags(LED_FLAG_NONE);
135 rgb_matrix_disable_noeeprom();
136 } else if (IS_RELEASED(record->event)) {
137 tap_code(KC_ESCAPE);
138 }
139 return false;
140 default:
141 return true; // Process all other keycodes normally
142 }
143}
diff --git a/keyboards/massdrop/ctrl/keymaps/R167/readme.md b/keyboards/massdrop/ctrl/keymaps/R167/readme.md
new file mode 100644
index 000000000..1b805ea6a
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/R167/readme.md
@@ -0,0 +1,14 @@
1![Layer 0](https://i.imgur.com/iRwr7si.png)
2
3![Layer 1](https://i.imgur.com/b2qwYdR.png)
4
5# R167 massdrop ctrl
6
7The main layer is a ~standard QWERTY layout with the ALT/GUI swap for macOS
8in addition to shifting the `Fn` key one to the right so cmd/alt line up nicely.
9Addionally, I rarely use PgUp/Dn, so I've remapped those to volume control.
10
11The most interesting bit is the shortcut `Fn + Esc` which triggers the macOS sleep
12shortcut (`CMD + ALT + Eject`) and then disables LEDs since the computer will wake up
13peripherals even while the display is asleep. Keyboard is returned to all LEDs on after
14pressing any key.