aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-11-05 02:37:04 +0000
committerQMK Bot <hello@qmk.fm>2021-11-05 02:37:04 +0000
commit7e814c09fb5f52764b6d83d09051784189296abf (patch)
tree660f8a6eac79d5ea3e64aa260b140d9e997138c9
parent833bcbac68d480a8407a680f3964b58e6b4d14e2 (diff)
parent2ac2695cb5fac5402e9a9834c55dce9d34ed0da5 (diff)
downloadqmk_firmware-7e814c09fb5f52764b6d83d09051784189296abf.tar.gz
qmk_firmware-7e814c09fb5f52764b6d83d09051784189296abf.zip
Merge remote-tracking branch 'origin/master' into develop
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/README.md18
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/config.h100
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.c25
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.h80
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/keymap.c268
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/rgb_matrix_user.inc44
-rw-r--r--keyboards/massdrop/ctrl/keymaps/foxx1337/rules.mk6
7 files changed, 541 insertions, 0 deletions
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/README.md b/keyboards/massdrop/ctrl/keymaps/foxx1337/README.md
new file mode 100644
index 000000000..4827d2bdb
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/README.md
@@ -0,0 +1,18 @@
1# Massdrop CTRL default layout with raw HID protocol
2
3This represents my current layout, with filtered out effects, personal defaults,
4added inactivity timeout (for rgbmatrix) and a HID protocol example.
5
6To test that this is working, there's a user application I'm using to help with
7development on [my GitHub](https://github.com/foxx1337/rawhid_io).
8
9Currently all the HID operations defined in the protocol are callable from the
10user application:
11
12- hello: gets the string "CTRLHID 1.0.0"
13- lights: toggles the rgbmatrix on/off
14- led n #RRGGBB: colors the specified led. Valid n from 0 to 117 (87-117 are on
15 the edge)
16- leds start #RRGGBB #RRGGBB #RRGGBB ...: colors the range of leds from start
17- mode n: switches to the specific rgbmatrix mode. Use the last one, 11, to test
18 the led operations listed above
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/config.h b/keyboards/massdrop/ctrl/keymaps/foxx1337/config.h
new file mode 100644
index 000000000..160ddf6d1
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/config.h
@@ -0,0 +1,100 @@
1/*
2 * Copyright 2021 foxx1337 at yahoo dot com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#define FORCE_NKRO // NKRO by default requires to be turned on, this forces it on during keyboard startup regardless of EEPROM setting. NKRO can still be turned off but will be turned on again if the keyboard reboots.
21
22#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
23#define RGB_MATRIX_KEYPRESSES // reacts to keypresses
24
25#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
26#define RGB_MATRIX_KEYPRESSES // reacts to keypresses
27// #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
28#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_REACTIVE // Sets the default mode, if none has been set
29#define RGB_MATRIX_STARTUP_HUE 12
30#define RGB_MATRIX_STARTUP_SPD (UINT8_MAX / 2 + 32)
31#define RGB_MATRIX_STARTUP_VAL 96
32// #define RGBLIGHT_HUE_STEP 12 // Units to step when in/decreasing hue
33// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation
34// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness)
35// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
36// #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
37// #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)
38// #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)
39// #define RGBLIGHT_ANIMATIONS // Run RGB animations
40// #define RGBLIGHT_ANIMATIONS // Enable all additional animation modes.
41// #define RGBLIGHT_EFFECT_ALTERNATING // Enable alternating animation mode.
42// #define RGBLIGHT_EFFECT_BREATHING // Enable breathing animation mode.
43// #define RGBLIGHT_EFFECT_CHRISTMAS // Enable christmas animation mode.
44// #define RGBLIGHT_EFFECT_KNIGHT // Enable knight animation mode.
45// #define RGBLIGHT_EFFECT_RAINBOW_MOOD // Enable rainbow mood animation mode.
46// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL // Enable rainbow swirl animation mode.
47// #define RGBLIGHT_EFFECT_RGB_TEST // Enable RGB test animation mode.
48// #define RGBLIGHT_EFFECT_SNAKE // Enable snake animation mode.
49// #define RGBLIGHT_EFFECT_STATIC_GRADIENT // Enable static gradient mode.
50
51// #define RGBLIGHT_EFFECT_BREATHE_CENTER // If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7
52// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // The maximum brightness for the breathing mode. Valid values are 1 to 255
53// #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 // How long to wait between light changes for the "Christmas" animation, in milliseconds
54// #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2 // The number of LEDs to group the red/green colors by for the "Christmas" animation
55// #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM // The number of LEDs to have the "Knight" animation travel
56// #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3 // The number of LEDs to light up for the "Knight" animation
57// #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 // The number of LEDs to start the "Knight" animation from the start of the strip by
58// #define RGBLIGHT_RAINBOW_SWIRL_RANGE 255 // Range adjustment for the rainbow swirl effect to get different swirls
59// #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 // The number of LEDs to light up for the "Snake" animation
60
61// This list in in the correct mode order. Next mode is the following line, previous mode is previous line. Loops around.
62// #define DISABLE_RGB_MATRIX_SOLID_COLOR // Static single hue, no speed support
63// #define DISABLE_RGB_MATRIX_ALPHAS_MODS // Static dual hue, speed is hue for secondary hue
64#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN // Static gradient top to bottom, speed controls how much gradient changes
65#define DISABLE_RGB_MATRIX_BREATHING // Single hue brightness cycling animation
66#define DISABLE_RGB_MATRIX_BAND_SAT // Single hue band fading saturation scrolling left to right
67#define DISABLE_RGB_MATRIX_BAND_VAL // Single hue band fading brightness scrolling left to right
68#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT // Single hue 3 blade spinning pinwheel fades saturation
69#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL // Single hue 3 blade spinning pinwheel fades brightness
70#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT // Single hue spinning spiral fades saturation
71#define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL // Single hue spinning spiral fades brightness
72#define DISABLE_RGB_MATRIX_CYCLE_ALL // Full keyboard solid hue cycling through full gradient
73#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT // Full gradient scrolling left to right
74#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN // Full gradient scrolling top to bottom
75#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN // Full gradient scrolling out to in
76#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL // Full dual gradients scrolling out to in
77#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON // Full gradent Chevron shapped scrolling left to right
78#define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL // Full gradient spinning pinwheel around center of keyboard
79#define DISABLE_RGB_MATRIX_CYCLE_SPIRAL // Full gradient spinning spiral around center of keyboard
80#define DISABLE_RGB_MATRIX_DUAL_BEACON // Full gradient spinning around center of keyboard
81#define DISABLE_RGB_MATRIX_RAINBOW_BEACON // Full tighter gradient spinning around center of keyboard
82#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS // Full dual gradients spinning two halfs of keyboard
83// #define DISABLE_RGB_MATRIX_RAINDROPS // Randomly changes a single key's hue
84// #define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS // Randomly changes a single key's hue and saturation
85// =================================================== Requires RGB_MATRIX_FRAMEBUFFER_EFFECTS =============================================================
86#define DISABLE_RGB_MATRIX_TYPING_HEATMAP // How hot is your WPM!
87#define DISABLE_RGB_MATRIX_DIGITAL_RAIN // That famous computer simulation
88// =================================================== RGB_MATRIX_KEYPRESSES OR RGB_MATRIX_KEYRELEASES =====================================================
89// #define DISABLE_RGB_MATRIX_SOLID_REACTIVE // Static single hue, pulses keys hit to shifted hue then fades to current hue
90//#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE // Pulses keys hit to hue & value then fades value out
91#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out
92//#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out
93//#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out
94#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out
95//#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out
96#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out
97#define DISABLE_RGB_MATRIX_SPLASH // Full gradient & value pulse away from a single key hit then fades value out
98#define DISABLE_RGB_MATRIX_MULTISPLASH // Full gradient & value pulse away from multiple key hits then fades value out
99#define DISABLE_RGB_MATRIX_SOLID_SPLASH // Hue & value pulse away from a single key hit then fades value out
100#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH // Hue & value pulse away from multiple key hits then fades value out
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.c b/keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.c
new file mode 100644
index 000000000..fd7dd6b69
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.c
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2021 foxx1337 at yahoo dot com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include QMK_KEYBOARD_H
19#include "hid_protocol.h"
20
21uint8_t raw_hid_buffer[RAW_EPSIZE];
22
23void raw_hid_perform_send(void) {
24 raw_hid_send(raw_hid_buffer, RAW_EPSIZE);
25}
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.h b/keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.h
new file mode 100644
index 000000000..ff214aaad
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/hid_protocol.h
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2021 foxx1337 at yahoo dot com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <color.h>
21#include <raw_hid.h>
22
23#define CTRL_HID_GREETING_VERSION "CTRLHID 1.0.0"
24
25enum ctrl_hid_codes {
26 // Signals end of message. Not really that useful.
27 CTRL_HID_EOM = 0x00,
28 CTRL_HID_OK,
29 CTRL_HID_NOK,
30
31 /**
32 * to hid: CTRL_HID_HELLO
33 * from hid: CTRL_HID_HELLO, "CTRLHID 1.0.0", CTRL_HID_EOM
34 **/
35 CTRL_HID_HELLO,
36
37 /**
38 * to hid: CTRL_HID_LIGHTS_TOGGLE
39 * from hid: CTRL_HID_LIGHTS_TOGGLE, CTRL_HID_OK, is_led_timeout, CTRL_HID_EOM
40 *
41 * Toggles all the leds on the keyboard. is_led_timeout will be 1 if the new
42 * state is off, 0 if leds are on.
43 **/
44 CTRL_HID_LIGHTS_TOGGLE,
45
46 /**
47 * to hid: CTRL_HID_LED, led_id, r, g, b
48 * from hid: CTRL_HID_LED, CTRL_HID_OK, CTRL_HID_EOM
49 * on error: CTRL_HID_LED, CTRL_HID_NOK, num_leds, CTRL_HID_EOM
50 *
51 * Sets the specific led to r, g, b. It's only visible when the hid_effect mode is active.
52 **/
53 CTRL_HID_LED,
54
55 /**
56 * to hid: CTRL_HID_LEDS, start, count, r0, g0, b0, ..., r[count-1], g[count-1], b[count-1]
57 * from hid: CTRL_HID_LEDS, CTRL_HID_OK, affected_leds, CTRL_HID_EOM
58 *
59 * Sets affected_leds leds following start to the corresponding r, g, b value.
60 * It's only visible when the hid_effect mode is active.
61 **/
62 CTRL_HID_LEDS,
63
64 /**
65 * to hid: CTRL_HID_RGBMATRIX_MODE, mode
66 * from hid: CTRL_HID_RGBMATRIX_MODE, CTRL_HID_OK, CTRL_HID_EOM
67 * on error: CTRL_HID_RGBMATRIX_MODE, CTRL_HID_NOK, mode_max, CTRL_HID_EOM
68 *
69 * Changes light mode. mode_max is hid_effect for CTRL_HID_LED and CTRL_HID_LEDS.
70 */
71 CTRL_HID_RGBMATRIX_MODE
72};
73
74extern uint8_t raw_hid_buffer[RAW_EPSIZE];
75
76// Defined in rgb_matrix_user.inc
77// It's 119 for Massdrop CTRL, 0 - 118.
78extern RGB rgb_matrix_led_state[DRIVER_LED_TOTAL];
79
80void raw_hid_perform_send(void);
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/keymap.c b/keyboards/massdrop/ctrl/keymaps/foxx1337/keymap.c
new file mode 100644
index 000000000..299251e45
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/keymap.c
@@ -0,0 +1,268 @@
1/*
2 * Copyright 2021 foxx1337 at yahoo dot com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include QMK_KEYBOARD_H
19#include "hid_protocol.h"
20
21enum ctrl_keycodes {
22 U_T_AUTO = SAFE_RANGE, //USB Extra Port Toggle Auto Detect / Always Active
23 U_T_AGCR, //USB Toggle Automatic GCR control
24 DBG_TOG, //DEBUG Toggle On / Off
25 DBG_MTRX, //DEBUG Toggle Matrix Prints
26 DBG_KBD, //DEBUG Toggle Keyboard Prints
27 DBG_MOU, //DEBUG Toggle Mouse Prints
28 MD_BOOT, //Restart into bootloader after hold timeout
29};
30
31#define TIMEOUT_ACTIVITY 300000 // 300 seconds before lights go off
32
33uint32_t time_last_activity;
34bool is_led_timeout;
35led_flags_t led_state;
36
37keymap_config_t keymap_config;
38
39const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
40 [0] = LAYOUT(
41 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, \
42 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, \
43 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, \
44 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, \
45 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, \
46 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
47 ),
48 [1] = LAYOUT(
49 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, \
50 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU, \
51 _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \
52 _______, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, \
53 _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, _______, _______, _______, _______, _______, _______, \
54 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
55 ),
56 /*
57 [X] = LAYOUT(
58 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
59 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
60 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
61 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
62 _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______, \
63 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
64 ),
65 */
66};
67
68void change_led_state(bool is_off) {
69 is_led_timeout = is_off;
70
71 if (is_led_timeout) {
72 led_state = rgb_matrix_get_flags();
73 if (led_state != LED_FLAG_NONE) {
74 rgb_matrix_set_flags(LED_FLAG_NONE);
75 rgb_matrix_disable_noeeprom();
76 }
77 } else {
78 if (led_state != LED_FLAG_NONE) {
79 rgb_matrix_set_flags(led_state);
80 rgb_matrix_enable_noeeprom();
81 }
82 }
83}
84
85// Runs just one time when the keyboard initializes.
86void matrix_init_user(void) {
87 time_last_activity = timer_read32();
88};
89
90// Runs constantly in the background, in a loop.
91void matrix_scan_user(void) {
92 if (!is_led_timeout && timer_elapsed32(time_last_activity) > TIMEOUT_ACTIVITY) {
93 change_led_state(true);
94 }
95};
96
97#define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT)
98#define MODS_CTRL (get_mods() & MOD_MASK_CTRL)
99#define MODS_ALT (get_mods() & MOD_MASK_ALT)
100
101bool process_record_user(uint16_t keycode, keyrecord_t *record) {
102 static uint32_t key_timer;
103
104 time_last_activity = timer_read32();
105 if (is_led_timeout) {
106 change_led_state(false);
107 }
108
109 switch (keycode) {
110 case U_T_AUTO:
111 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
112 TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
113 }
114 return false;
115 case U_T_AGCR:
116 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
117 TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
118 }
119 return false;
120 case DBG_TOG:
121 if (record->event.pressed) {
122 TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
123 }
124 return false;
125 case DBG_MTRX:
126 if (record->event.pressed) {
127 TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
128 }
129 return false;
130 case DBG_KBD:
131 if (record->event.pressed) {
132 TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
133 }
134 return false;
135 case DBG_MOU:
136 if (record->event.pressed) {
137 TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
138 }
139 return false;
140 case MD_BOOT:
141 if (record->event.pressed) {
142 key_timer = timer_read32();
143 } else {
144 if (timer_elapsed32(key_timer) >= 500) {
145 reset_keyboard();
146 }
147 }
148 return false;
149 case RGB_TOG:
150 if (record->event.pressed) {
151 switch (rgb_matrix_get_flags()) {
152 case LED_FLAG_ALL: {
153 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER);
154 rgb_matrix_set_color_all(0, 0, 0);
155 }
156 break;
157 case LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER: {
158 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
159 rgb_matrix_set_color_all(0, 0, 0);
160 }
161 break;
162 case LED_FLAG_UNDERGLOW: {
163 rgb_matrix_set_flags(LED_FLAG_NONE);
164 rgb_matrix_disable_noeeprom();
165 }
166 break;
167 default: {
168 rgb_matrix_set_flags(LED_FLAG_ALL);
169 rgb_matrix_enable_noeeprom();
170 }
171 break;
172 }
173 }
174 return false;
175 default:
176 return true; //Process all other keycodes normally
177 }
178}
179
180void raw_hid_say_hello(void) {
181 const char *ctrl = CTRL_HID_GREETING_VERSION;
182 uint8_t i = 0;
183 while (ctrl[i] != 0 && i + 2 < RAW_EPSIZE) {
184 raw_hid_buffer[1 + i] = ctrl[i];
185 i++;
186 }
187 raw_hid_buffer[i] = CTRL_HID_EOM;
188}
189
190void raw_hid_lights_toggle(void) {
191 change_led_state(!is_led_timeout);
192
193 raw_hid_buffer[1] = CTRL_HID_OK;
194 raw_hid_buffer[2] = (uint8_t) is_led_timeout;
195 raw_hid_buffer[3] = CTRL_HID_EOM;
196}
197
198void raw_hid_led(uint8_t *data) {
199 //rgb_matrix_set_color(data[1], data[2], data[3], data[4]);
200 const uint8_t led = data[1];
201
202 if (led >= DRIVER_LED_TOTAL) {
203 raw_hid_buffer[1] = CTRL_HID_NOK;
204 raw_hid_buffer[2] = DRIVER_LED_TOTAL;
205 raw_hid_buffer[3] = CTRL_HID_EOM;
206 return;
207 }
208
209 rgb_matrix_led_state[led].r = data[2];
210 rgb_matrix_led_state[led].g = data[3];
211 rgb_matrix_led_state[led].b = data[4];
212
213 raw_hid_buffer[1] = CTRL_HID_OK;
214 raw_hid_buffer[2] = CTRL_HID_EOM;
215}
216
217void raw_hid_leds(uint8_t *data) {
218 const uint8_t first_led = data[1];
219 const uint8_t number_leds = data[2];
220
221 uint8_t i = 0;
222 while (i < number_leds && first_led + i < DRIVER_LED_TOTAL && i * 3 + 5 < RAW_EPSIZE) {
223 rgb_matrix_led_state[first_led + i].r = data[3 + i * 3 + 0];
224 rgb_matrix_led_state[first_led + i].g = data[3 + i * 3 + 1];
225 rgb_matrix_led_state[first_led + i].b = data[3 + i * 3 + 2];
226 i++;
227 }
228
229 raw_hid_buffer[1] = CTRL_HID_OK;
230 raw_hid_buffer[2] = i;
231 raw_hid_buffer[3] = CTRL_HID_EOM;
232}
233
234void raw_hid_rgbmatrix_mode(uint8_t *data) {
235 const uint8_t mode = data[1];
236 if (mode >= RGB_MATRIX_EFFECT_MAX) {
237 raw_hid_buffer[1] = CTRL_HID_NOK;
238 raw_hid_buffer[2] = RGB_MATRIX_EFFECT_MAX - 1;
239 raw_hid_buffer[3] = CTRL_HID_EOM;
240 return;
241 }
242 rgb_matrix_mode_noeeprom(mode);
243
244 raw_hid_buffer[1] = CTRL_HID_OK;
245 raw_hid_buffer[2] = CTRL_HID_EOM;
246}
247
248void raw_hid_receive(uint8_t *data, uint8_t length) {
249 switch (*data) {
250 case CTRL_HID_HELLO:
251 raw_hid_say_hello();
252 break;
253 case CTRL_HID_LIGHTS_TOGGLE:
254 raw_hid_lights_toggle();
255 break;
256 case CTRL_HID_LED:
257 raw_hid_led(data);
258 break;
259 case CTRL_HID_LEDS:
260 raw_hid_leds(data);
261 break;
262 case CTRL_HID_RGBMATRIX_MODE:
263 raw_hid_rgbmatrix_mode(data);
264 break;
265 }
266
267 raw_hid_perform_send();
268}
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/rgb_matrix_user.inc b/keyboards/massdrop/ctrl/keymaps/foxx1337/rgb_matrix_user.inc
new file mode 100644
index 000000000..cca598e3b
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/rgb_matrix_user.inc
@@ -0,0 +1,44 @@
1/*
2 * Copyright 2021 foxx1337 at yahoo dot com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// !!! DO NOT ADD #pragma once !!! //
19
20// Step 1.
21// Declare custom effects using the RGB_MATRIX_EFFECT macro
22// (note the lack of semicolon after the macro!)
23RGB_MATRIX_EFFECT(hid_effect)
24
25// Step 2.
26// Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
27#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
28
29RGB rgb_matrix_led_state[DRIVER_LED_TOTAL];
30
31// e.g: A simple effect, self-contained within a single method
32static bool hid_effect(effect_params_t* params) {
33 RGB_MATRIX_USE_LIMITS(led_min, led_max);
34
35 for (uint8_t i = led_min; i < led_max; i++) {
36 rgb_matrix_set_color(i,
37 rgb_matrix_led_state[i].r,
38 rgb_matrix_led_state[i].g,
39 rgb_matrix_led_state[i].b);
40 }
41 return led_max < DRIVER_LED_TOTAL;
42}
43
44#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/keyboards/massdrop/ctrl/keymaps/foxx1337/rules.mk b/keyboards/massdrop/ctrl/keymaps/foxx1337/rules.mk
new file mode 100644
index 000000000..ba6cb8f4b
--- /dev/null
+++ b/keyboards/massdrop/ctrl/keymaps/foxx1337/rules.mk
@@ -0,0 +1,6 @@
1# Build Options
2CONSOLE_ENABLE = no # Console for debug
3RAW_ENABLE = yes # Raw device
4RGB_MATRIX_CUSTOM_USER = yes # Custom rgb matrix effect
5
6SRC += hid_protocol.c