diff options
author | Mikael Manukyan <arm.localhost@gmail.com> | 2021-08-17 14:10:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 07:10:46 +1000 |
commit | 857716794b233f3d4ac078c85a5a142091264aa6 (patch) | |
tree | fe6f4680f62d1700fe7edf08ac76df51ef78eaec | |
parent | 8db1d221172afe10fc2d0c4c7ce1742e0a6436d4 (diff) | |
download | qmk_firmware-857716794b233f3d4ac078c85a5a142091264aa6.tar.gz qmk_firmware-857716794b233f3d4ac078c85a5a142091264aa6.zip |
gmmk/pro/mike1808 keymap (#13398)
* Add gmmk/pro/mike1808 keymap
* Add licenses
* Update readme
* Add underglow support for rgb matrix layers
* Change FN to TT
* Fix rgb layer disabling during rgb settings change
* also clean up some code
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/.gitignore | 1 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/README.md | 19 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/config.h | 31 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/encoder.c | 111 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/encoder.h | 35 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/fun.c | 49 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/keymap.c | 127 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/mike1808.c | 68 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/mike1808.h | 111 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/process_record.c | 119 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/process_record.h | 26 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.c | 71 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.h | 100 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/rules.mk | 25 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/utils.c | 64 | ||||
-rw-r--r-- | keyboards/gmmk/pro/keymaps/mike1808/utils.h | 32 |
16 files changed, 989 insertions, 0 deletions
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/.gitignore b/keyboards/gmmk/pro/keymaps/mike1808/.gitignore new file mode 100644 index 000000000..03b2b4666 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/.gitignore | |||
@@ -0,0 +1 @@ | |||
secrets.h | |||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/README.md b/keyboards/gmmk/pro/keymaps/mike1808/README.md new file mode 100644 index 000000000..cb1723988 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/README.md | |||
@@ -0,0 +1,19 @@ | |||
1 | QMK layout for gmmk/pro | ||
2 | ======================= | ||
3 | |||
4 | ## Secrets | ||
5 | The format is the same as [drashna's](../../../../users/drashna/readme_secrets.md) secrets implementation. Create a `secret.h` and define your secrets like this: | ||
6 | |||
7 | ```c | ||
8 | static const char* secrets[] = {"secret1", "secret2", "secret3", "secret4", "secret5"}; | ||
9 | ``` | ||
10 | |||
11 | ## Rotary encoder knob | ||
12 | You can hookup your encoder functions by defining new encoder states in [encoder.h](./encoder.h), then in [encoder.c](./encoder.c) assign static variable `state` your new state depending on your desired condition and add callbacks to `encoder_mapping` array. | ||
13 | |||
14 | ## RGB Matrix Ledmaps | ||
15 | RGB Matrix ledmaps is the future allowing you assign colors to individual keys on every keymap layer. | ||
16 | |||
17 | You can see some examples of my usage in the bottom of [keymap.c](./keymap.c). | ||
18 | |||
19 | Color defines are just HSV colors wrapped in curly braces, like `#define RED { HSV_RED }`. | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/config.h b/keyboards/gmmk/pro/keymaps/mike1808/config.h new file mode 100644 index 000000000..1205b8817 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/config.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #define COMBO_COUNT 1 | ||
18 | #define COMBO_TERM 100 | ||
19 | |||
20 | #define RGB_MATRIX_KEYPRESSES | ||
21 | #define RGB_DISABLE_WHEN_USB_SUSPENDED true | ||
22 | #define RGB_DISABLE_TIMEOUT 90000 | ||
23 | |||
24 | #define MACRO_TIMER 5 | ||
25 | |||
26 | #define TAPPING_TOGGLE 3 | ||
27 | |||
28 | #define WPM_SMOOTHING 0.1 | ||
29 | |||
30 | // this is for macOS so keyboard can work after sleep | ||
31 | #define NO_USB_STARTUP_CHECK | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/encoder.c b/keyboards/gmmk/pro/keymaps/mike1808/encoder.c new file mode 100644 index 000000000..049f4df7e --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/encoder.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #include "encoder.h" | ||
17 | #include "mike1808.h" | ||
18 | #include "print.h" | ||
19 | #include "utils.h" | ||
20 | #include "process_record.h" | ||
21 | #include "rgb_matrix_ledmaps.h" | ||
22 | |||
23 | static uint8_t state = ENCODER_DEFAULT; | ||
24 | |||
25 | // clang-format off | ||
26 | const encoder_callback encoder_mapping[][2] = { | ||
27 | [ENCODER_VOLUME] = {&volume_up, &volume_down}, | ||
28 | #ifdef RGB_MATRIX_ENABLE | ||
29 | [ENCODER_RGB_HUE] = {&rgb_matrix_increase_hue_noeeprom, &rgb_matrix_decrease_hue_noeeprom}, | ||
30 | [ENCODER_RGB_SAT] = {&rgb_matrix_increase_sat_noeeprom, &rgb_matrix_decrease_sat_noeeprom}, | ||
31 | [ENCODER_RGB_VAL] = {&rgb_matrix_increase_val_noeeprom, &rgb_matrix_decrease_val_noeeprom}, | ||
32 | [ENCODER_RGB_EFFECT] = {&rgb_matrix_step_noeeprom, &rgb_matrix_step_reverse_noeeprom}, | ||
33 | [ENCODER_RGB_EFFECT_SPEED] = {&rgb_matrix_increase_speed_noeeprom, &rgb_matrix_decrease_speed_noeeprom}, | ||
34 | #endif // RGB_MATRIX_ENABLE | ||
35 | }; | ||
36 | |||
37 | // clang-format on | ||
38 | |||
39 | void volume_up() { tap_code(KC_VOLU); } | ||
40 | |||
41 | void volume_down() { tap_code(KC_VOLD); } | ||
42 | |||
43 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
44 | dprintf("current encoder state is: %d\n", state); | ||
45 | |||
46 | if (clockwise) { | ||
47 | (*encoder_mapping[state][0])(); | ||
48 | } else { | ||
49 | (*encoder_mapping[state][1])(); | ||
50 | } | ||
51 | |||
52 | return true; | ||
53 | } | ||
54 | |||
55 | void handle_rgb_key(bool pressed) { | ||
56 | dprintf("handle_rgb_key %d\f", pressed); | ||
57 | |||
58 | if (pressed) { | ||
59 | rgb_matrix_layers_disable(); | ||
60 | } else { | ||
61 | rgb_matrix_layers_enable(); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | static KeyPressState *rgb_state; | ||
66 | |||
67 | void keyboard_post_init_encoder() { | ||
68 | rgb_state = NewKeyPressState(handle_rgb_key); | ||
69 | } | ||
70 | |||
71 | bool process_record_encoder(uint16_t keycode, keyrecord_t *record) { | ||
72 | #ifdef RGB_MATRIX_ENABLE | ||
73 | switch (keycode) { | ||
74 | case KC_RGB_ENC_HUE ... KC_RGB_ENC_EFFECT: | ||
75 | if (record->event.pressed) { | ||
76 | # ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
77 | // disable layers so we can adjust RGB effects | ||
78 | rgb_state->press(rgb_state); | ||
79 | # endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
80 | |||
81 | switch (keycode) { | ||
82 | case KC_RGB_ENC_HUE: | ||
83 | state = ENCODER_RGB_HUE; | ||
84 | break; | ||
85 | case KC_RGB_ENC_SAT: | ||
86 | state = ENCODER_RGB_SAT; | ||
87 | break; | ||
88 | case KC_RGB_ENC_VAL: | ||
89 | state = ENCODER_RGB_VAL; | ||
90 | break; | ||
91 | case KC_RGB_ENC_EFFECT_SPEED: | ||
92 | state = ENCODER_RGB_EFFECT_SPEED; | ||
93 | break; | ||
94 | case KC_RGB_ENC_EFFECT: | ||
95 | state = ENCODER_RGB_EFFECT; | ||
96 | break; | ||
97 | } | ||
98 | } else { | ||
99 | # ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
100 | rgb_state->release(rgb_state); | ||
101 | # endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
102 | state = ENCODER_DEFAULT; | ||
103 | store_rgb_state_to_eeprom(); | ||
104 | } | ||
105 | |||
106 | return false; | ||
107 | } | ||
108 | #endif // RGB_MATRIX_ENABLE | ||
109 | |||
110 | return true; | ||
111 | } | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/encoder.h b/keyboards/gmmk/pro/keymaps/mike1808/encoder.h new file mode 100644 index 000000000..204922730 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/encoder.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | // To add a new functionality define a new state here and then assign | ||
18 | // the handler to the `encoder_callback` | ||
19 | #include "quantum.h" | ||
20 | |||
21 | enum encoder_state { | ||
22 | ENCODER_VOLUME = 0, | ||
23 | ENCODER_RGB_HUE, | ||
24 | ENCODER_RGB_SAT, | ||
25 | ENCODER_RGB_VAL, | ||
26 | ENCODER_RGB_EFFECT_SPEED, | ||
27 | ENCODER_RGB_EFFECT, | ||
28 | }; | ||
29 | |||
30 | typedef void (*encoder_callback)(void); | ||
31 | |||
32 | #define ENCODER_DEFAULT ENCODER_VOLUME | ||
33 | |||
34 | void volume_up(void); | ||
35 | void volume_down(void); | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/fun.c b/keyboards/gmmk/pro/keymaps/mike1808/fun.c new file mode 100644 index 000000000..f553874eb --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/fun.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #include "mike1808.h" | ||
17 | #include "print.h" | ||
18 | |||
19 | static bool wpm_rgb_enabled = false; | ||
20 | static uint8_t rgb_mode; | ||
21 | |||
22 | void rgb_matrix_indicators_keymap(void) { | ||
23 | if (wpm_rgb_enabled && rgb_matrix_is_enabled()) { | ||
24 | uint8_t wpm = get_current_wpm(); | ||
25 | dprintf("WPM = %d\n", wpm); | ||
26 | HSV hsv = rgb_matrix_get_hsv(); | ||
27 | hsv.h = wpm; | ||
28 | RGB rgb = hsv_to_rgb(hsv); | ||
29 | rgb_matrix_set_color_all(rgb.r, rgb.g, rgb.b); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | bool process_record_fun(uint16_t keycode, keyrecord_t *record) { | ||
34 | if (record->event.pressed && keycode == KC_WPM_RGB) { | ||
35 | if (wpm_rgb_enabled) { | ||
36 | wpm_rgb_enabled = false; | ||
37 | rgb_matrix_mode(rgb_mode); | ||
38 | } else { | ||
39 | wpm_rgb_enabled = true; | ||
40 | rgb_mode = rgb_matrix_get_mode(); | ||
41 | rgb_matrix_enable(); | ||
42 | rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR); | ||
43 | } | ||
44 | |||
45 | return false; | ||
46 | } | ||
47 | |||
48 | return true; | ||
49 | } | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/keymap.c b/keyboards/gmmk/pro/keymaps/mike1808/keymap.c new file mode 100644 index 000000000..30c59e941 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/keymap.c | |||
@@ -0,0 +1,127 @@ | |||
1 | /* Copyright 2021 Glorious, LLC <salman@pcgamingrace.com>, Mikael Manukyan <arm.localhost@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 | #include "mike1808.h" | ||
17 | |||
18 | const uint16_t PROGMEM jk_combo[] = {KC_J, KC_K, COMBO_END}; | ||
19 | |||
20 | combo_t key_combos[COMBO_COUNT] = { | ||
21 | [JK_ESC] = COMBO(jk_combo, KC_ESC), | ||
22 | }; | ||
23 | |||
24 | // clang-format off | ||
25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
26 | |||
27 | // ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Prt Rotary(Mute) | ||
28 | // ~ 1 2 3 4 5 6 7 8 9 0 - (=) BackSpc Del | ||
29 | // Tab Q W E R T Y U I O P [ ] \ PgUp | ||
30 | // Caps A S D F G H J K L ; " Enter PgDn | ||
31 | // Sh_L Z X C V B N M , . ? Sh_R Up End | ||
32 | // Ct_L Win_L Alt_L SPACE Alt_R FN Ct_R Left Down Right | ||
33 | [LINUX] = LAYOUT( | ||
34 | 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_DEL, KC_MUTE, | ||
35 | 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, | ||
36 | 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, | ||
37 | KC_ESC, 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, | ||
38 | 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, | ||
39 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, TT_FN, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT | ||
40 | ), | ||
41 | |||
42 | [WINDOWS] = LAYOUT( | ||
43 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
44 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
45 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
46 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
47 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
48 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
49 | ), | ||
50 | |||
51 | [MACOS] = LAYOUT( | ||
52 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
53 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
54 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
55 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
56 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
57 | _______, KC_LALT, KC_LGUI, _______, _______, _______, _______, _______, _______, _______ | ||
58 | ), | ||
59 | |||
60 | [FUNCTIONS] = LAYOUT( | ||
61 | _______, KC_SEC1, KC_SEC2, KC_SEC3, KC_SEC4, KC_SEC5, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_PSCR, _______, | ||
62 | _______, KC_LINX, KC_MAC, KC_WIN, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, | ||
63 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_RST, _______, | ||
64 | KC_CAPS, _______, _______, _______, _______, OS_GIT, _______, _______, _______, _______, _______, _______, _______, _______, | ||
65 | _______, KC_RGBH, KC_RGBS, KC_RGBV, KC_RGBE, KC_RGBP, KC_WRGB, _______, _______, _______, _______, _______, KC_PGUP, _______, | ||
66 | _______, _______, _______, RGB_TOG, _______, _______, _______, KC_HOME, KC_PGDN, KC_END | ||
67 | ), | ||
68 | |||
69 | [GIT] = LAYOUT( | ||
70 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
71 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
72 | _______, _______, _______, G_DIFF, _______, _______, _______, _______, _______, _______, G_PULL, G_PUSH, _______, _______, _______, | ||
73 | _______, G_ADD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
74 | _______, _______, _______, G_CHECK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
75 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
76 | ), | ||
77 | }; | ||
78 | |||
79 | #ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
80 | |||
81 | #define ______ {0, 0, 0} | ||
82 | |||
83 | const ledmap PROGMEM ledmaps[] = { | ||
84 | // LU = Left Underglow, RU = Right Underglow | ||
85 | // LU_1 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Prt Rotary(Mute) RU_1 | ||
86 | // LU_2 ~ 1 2 3 4 5 6 7 8 9 0 - (=) BackSpc Del RU_2 | ||
87 | // LU_3 Tab Q W E R T Y U I O P [ ] \ PgUp RU_3 | ||
88 | // LU_4 Caps A S D F G H J K L ; " Enter PgDn RU_4 | ||
89 | // LU_5 Sh_L Z X C V B N M , . ? Sh_R Up End RU_5 | ||
90 | // LU_6 Ct_L Win_L Alt_L SPACE Alt_R FN Ct_R Left Down Right RU_6 | ||
91 | [LINUX] = RGB_MATRIX_LAYOUT_LEDMAP( | ||
92 | PURPLE, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
93 | PURPLE, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
94 | PURPLE, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
95 | PURPLE, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
96 | PURPLE, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
97 | PURPLE, ______, RED, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE | ||
98 | ), | ||
99 | [WINDOWS] = RGB_MATRIX_LAYOUT_LEDMAP( | ||
100 | GREEN, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
101 | GREEN, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
102 | GREEN, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
103 | GREEN, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
104 | GREEN, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
105 | GREEN, ______, RED, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE | ||
106 | ), | ||
107 | [MACOS] = RGB_MATRIX_LAYOUT_LEDMAP( | ||
108 | YELLOW, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
109 | YELLOW, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
110 | YELLOW, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
111 | YELLOW, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
112 | YELLOW, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
113 | YELLOW, ______, ______, RED, ______, ______, ______, ______, ______, ______, ______, PURPLE | ||
114 | ), | ||
115 | |||
116 | [FUNCTIONS] = RGB_MATRIX_LAYOUT_LEDMAP( | ||
117 | CYAN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, ______, ______, ______, ______, GREEN, GREEN, GREEN, GREEN, ______, PURPLE, | ||
118 | CYAN, ______, GOLD, GOLD, GOLD, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, GOLD, PURPLE, | ||
119 | CYAN, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, TEAL, ______, PURPLE, | ||
120 | CYAN, TURQ, ______, ______, ______, ______, TURQ, ______, ______, ______, ______, ______, ______, ______, ______, PURPLE, | ||
121 | CYAN, ______, RED, RED, RED, RED, RED, RED, ______, ______, ______, ______, ______, RED, ______, PURPLE, | ||
122 | CYAN, ______, ______, BLUE, ______, ______, ______, ______, ______, ______, ______, PURPLE | ||
123 | ), | ||
124 | }; | ||
125 | |||
126 | #endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
127 | // clang-format on | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/mike1808.c b/keyboards/gmmk/pro/keymaps/mike1808/mike1808.c new file mode 100644 index 000000000..881384609 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/mike1808.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #include "mike1808.h" | ||
17 | |||
18 | #if (__has_include("secrets.h") && !defined(NO_SECRETS)) | ||
19 | # include "secrets.h" | ||
20 | #else | ||
21 | // `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware | ||
22 | // And I'm not familiar enough to know which is better or why... | ||
23 | static const char *const secret[] = {"test1", "test2", "test3", "test4", "test5"}; | ||
24 | #endif | ||
25 | |||
26 | // userspace_config_t userspace_config; | ||
27 | |||
28 | bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { | ||
29 | switch (keycode) { | ||
30 | case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo | ||
31 | if (!record->event.pressed) { | ||
32 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
33 | send_string_with_delay(secrets[keycode - KC_SECRET_1], MACRO_TIMER); | ||
34 | } | ||
35 | return false; | ||
36 | break; | ||
37 | } | ||
38 | return true; | ||
39 | } | ||
40 | |||
41 | void suspend_power_down_user(void) { | ||
42 | #ifdef RGB_MATRIX_ENABLE | ||
43 | rgb_matrix_set_suspend_state(true); | ||
44 | #endif // RGB_MATRIX_ENABLE | ||
45 | } | ||
46 | |||
47 | void suspend_wakeup_init_user(void) { | ||
48 | #ifdef RGB_MATRIX_ENABLE | ||
49 | rgb_matrix_set_suspend_state(false); | ||
50 | #endif // RGB_MATRIX_ENABLE | ||
51 | } | ||
52 | |||
53 | #ifdef RGB_MATRIX_ENABLE | ||
54 | void rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { | ||
55 | // Turn on sideglow when CAPS LOCK is activated | ||
56 | if (host_keyboard_led_state().caps_lock) { | ||
57 | HSV hsv = {CAPS_LOCK_COLOR}; | ||
58 | hsv.v = rgb_matrix_get_val(); | ||
59 | RGB rgb = hsv_to_rgb(hsv); | ||
60 | |||
61 | for (uint8_t i = led_min; i < led_max; i++) { | ||
62 | if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) { | ||
63 | RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b); | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | #endif // RGB_MATRIX_ENABLE | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/mike1808.h b/keyboards/gmmk/pro/keymaps/mike1808/mike1808.h new file mode 100644 index 000000000..bc010108f --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/mike1808.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #pragma once | ||
17 | #include QMK_KEYBOARD_H | ||
18 | #include "rgb_matrix_ledmaps.h" | ||
19 | |||
20 | enum layout_names { | ||
21 | LINUX = 0, // Base Layout: The main keyboard layout that has all the characters | ||
22 | WINDOWS, // Base ayout for Windows | ||
23 | MACOS, // Base Layout for MacOS | ||
24 | FUNCTIONS, // Function Layout: The function key activated layout with default functions and | ||
25 | // some added ones | ||
26 | GIT, // GIT Layout: GIT shortcuts and macros | ||
27 | SECRETS, // Layer with secrets | ||
28 | }; | ||
29 | |||
30 | enum custom_keycodes { | ||
31 | KC_CCCV = SAFE_RANGE, // Hold to copy, tap to paste | ||
32 | KC_LINUX, | ||
33 | KC_MAC, | ||
34 | KC_WIN, | ||
35 | |||
36 | KC_SECRET_1, | ||
37 | KC_SECRET_2, | ||
38 | KC_SECRET_3, | ||
39 | KC_SECRET_4, | ||
40 | KC_SECRET_5, | ||
41 | |||
42 | KC_RGB_ENC_HUE, | ||
43 | KC_RGB_ENC_SAT, | ||
44 | KC_RGB_ENC_VAL, | ||
45 | KC_RGB_ENC_EFFECT_SPEED, | ||
46 | KC_RGB_ENC_EFFECT, | ||
47 | |||
48 | KC_WPM_RGB, | ||
49 | }; | ||
50 | |||
51 | enum git_macros { | ||
52 | // The start of this enum should always be equal to end of ctrl_keycodes + 1 | ||
53 | G_INIT = KC_WPM_RGB + 1, // git init | ||
54 | G_CLONE, // git clone | ||
55 | G_CONF, // git config --global | ||
56 | G_ADD, // git add | ||
57 | G_DIFF, // git diff | ||
58 | G_RESET, // git reset | ||
59 | G_REBAS, // git rebase | ||
60 | G_BRANH, // git branch | ||
61 | G_CHECK, // git checkout | ||
62 | G_MERGE, // git merge | ||
63 | G_REMTE, // git remote add | ||
64 | G_FETCH, // git fetch | ||
65 | G_PULL, // git pull | ||
66 | G_PUSH, // git push | ||
67 | G_COMM, // git commit | ||
68 | G_STAT, // git status | ||
69 | G_LOG, // git log | ||
70 | NEW_SAFE_RANGE, | ||
71 | }; | ||
72 | |||
73 | enum combos { | ||
74 | JK_ESC, // jk to ESC for Vim | ||
75 | }; | ||
76 | |||
77 | #define KC_SEC1 KC_SECRET_1 | ||
78 | #define KC_SEC2 KC_SECRET_2 | ||
79 | #define KC_SEC3 KC_SECRET_3 | ||
80 | #define KC_SEC4 KC_SECRET_4 | ||
81 | #define KC_SEC5 KC_SECRET_5 | ||
82 | |||
83 | #define KC_RGBH KC_RGB_ENC_HUE | ||
84 | #define KC_RGBS KC_RGB_ENC_SAT | ||
85 | #define KC_RGBV KC_RGB_ENC_VAL | ||
86 | #define KC_RGBE KC_RGB_ENC_EFFECT | ||
87 | #define KC_RGBP KC_RGB_ENC_EFFECT_SPEED | ||
88 | |||
89 | #define KC_WRGB KC_WPM_RGB | ||
90 | |||
91 | #define KC_LINX KC_LINUX | ||
92 | |||
93 | #define KC_RESET RESET | ||
94 | #define KC_RST KC_RESET | ||
95 | |||
96 | #define OS_GIT OSL(GIT) | ||
97 | #define TT_FN TT(FUNCTIONS) | ||
98 | |||
99 | #define OS_LGUI OSM(MOD_LGUI) | ||
100 | #define OS_RGUI OSM(MOD_RGUI) | ||
101 | #define OS_LSFT OSM(MOD_LSFT) | ||
102 | #define OS_RSFT OSM(MOD_RSFT) | ||
103 | #define OS_LCTL OSM(MOD_LCTL) | ||
104 | #define OS_RCTL OSM(MOD_RCTL) | ||
105 | #define OS_LALT OSM(MOD_LALT) | ||
106 | #define OS_RALT OSM(MOD_RALT) | ||
107 | #define OS_MEH OSM(MOD_MEH) | ||
108 | #define OS_HYPR OSM(MOD_HYPR) | ||
109 | |||
110 | #define CAPS_LOCK_COLOR HSV_RED | ||
111 | |||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/process_record.c b/keyboards/gmmk/pro/keymaps/mike1808/process_record.c new file mode 100644 index 000000000..ac0164e73 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/process_record.c | |||
@@ -0,0 +1,119 @@ | |||
1 | /* Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>, | ||
2 | Mikael Manukyan <arm.localhost@gmail.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 | #include "mike1808.h" | ||
18 | #include "print.h" | ||
19 | #include "process_record.h" | ||
20 | |||
21 | uint16_t copy_paste_timer; | ||
22 | |||
23 | __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { | ||
24 | return true; | ||
25 | } | ||
26 | __attribute__((weak)) bool process_record_encoder(uint16_t keycode, keyrecord_t *record) { | ||
27 | return true; | ||
28 | } | ||
29 | __attribute__((weak)) bool process_record_fun(uint16_t keycode, keyrecord_t *record) { | ||
30 | return true; | ||
31 | } | ||
32 | |||
33 | __attribute__((weak)) void keyboard_post_init_encoder(void) { return; } | ||
34 | |||
35 | static const char *git_commands[] = { | ||
36 | "git init ", "git clone ", "git config --global ", "git add ", | ||
37 | "git diff ", "git reset ", "git rebase ", "git branch -b \"", | ||
38 | "git checkout ", "git merge ", "git remote add ", "git fetch ", | ||
39 | "git pull ", "git push ", "git commit ", "git status ", | ||
40 | "git log ", | ||
41 | }; | ||
42 | |||
43 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
44 | // If console is enabled, it will print the matrix position and status of each key pressed | ||
45 | #ifdef KEYLOGGER_ENABLE | ||
46 | uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %b, time: %5u, int: %b, count: %u\n", | ||
47 | keycode, record->event.key.col, record->event.key.row, record->event.pressed, | ||
48 | record->event.time, record->tap.interrupted, record->tap.count); | ||
49 | #endif // KEYLOGGER_ENABLE | ||
50 | switch (keycode) { | ||
51 | case KC_LINUX ... KC_WIN: | ||
52 | if (record->event.pressed) { | ||
53 | dprintf("set_single_persistent_default_layer %d\n", keycode - KC_LINUX + LINUX); | ||
54 | set_single_persistent_default_layer(keycode - KC_LINUX + LINUX); | ||
55 | return false; | ||
56 | } | ||
57 | |||
58 | break; | ||
59 | |||
60 | case KC_CCCV: // One key copy/paste | ||
61 | if (record->event.pressed) { | ||
62 | copy_paste_timer = timer_read(); | ||
63 | } else { | ||
64 | if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy | ||
65 | if (layer_state_is(MACOS)) { | ||
66 | tap_code16(LGUI(KC_C)); | ||
67 | } else { | ||
68 | tap_code16(LCTL(KC_C)); | ||
69 | } | ||
70 | } else { // Tap, paste | ||
71 | if (layer_state_is(MACOS)) { | ||
72 | tap_code16(LGUI(KC_V)); | ||
73 | } else { | ||
74 | tap_code16(LCTL(KC_V)); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | break; | ||
79 | |||
80 | case G_INIT ... G_LOG: | ||
81 | if (record->event.pressed) { | ||
82 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
83 | send_string_with_delay(git_commands[keycode - G_INIT], MACRO_TIMER); | ||
84 | return false; | ||
85 | } | ||
86 | break; | ||
87 | #ifdef RGB_MATRIX_ENABLE | ||
88 | case RGB_TOG: | ||
89 | if (record->event.pressed) { | ||
90 | switch (rgb_matrix_get_flags()) { | ||
91 | case LED_FLAG_ALL: { | ||
92 | rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER); | ||
93 | rgb_matrix_set_color_all(0, 0, 0); | ||
94 | } break; | ||
95 | case LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER: { | ||
96 | rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); | ||
97 | rgb_matrix_set_color_all(0, 0, 0); | ||
98 | } break; | ||
99 | case LED_FLAG_UNDERGLOW: { | ||
100 | // This line is for LED idle timer. It disables the toggle so you can turn | ||
101 | // off LED completely if you like | ||
102 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
103 | rgb_matrix_disable(); | ||
104 | } break; | ||
105 | default: { | ||
106 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
107 | rgb_matrix_enable(); | ||
108 | } break; | ||
109 | } | ||
110 | } | ||
111 | return false; | ||
112 | #endif // RGB_MATRIX_ENABLE | ||
113 | } | ||
114 | |||
115 | return process_record_encoder(keycode, record) && process_record_secrets(keycode, record) && | ||
116 | process_record_fun(keycode, record); | ||
117 | } | ||
118 | |||
119 | void keyboard_post_init_user() { keyboard_post_init_encoder(); } | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/process_record.h b/keyboards/gmmk/pro/keymaps/mike1808/process_record.h new file mode 100644 index 000000000..102175165 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/process_record.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #pragma once | ||
17 | #include "mike1808.h" | ||
18 | |||
19 | |||
20 | bool process_record_secrets(uint16_t keycode, keyrecord_t *record); | ||
21 | |||
22 | bool process_record_encoder(uint16_t keycode, keyrecord_t *record); | ||
23 | |||
24 | bool process_record_fun(uint16_t keycode, keyrecord_t *record); | ||
25 | |||
26 | void keyboard_post_init_encoder(void); | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.c b/keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.c new file mode 100644 index 000000000..6f4d333ed --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #include "rgb_matrix_ledmaps.h" | ||
17 | |||
18 | __attribute__((weak)) void rgb_matrix_indicators_keymap(void) { return; } | ||
19 | __attribute__((weak)) void rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { | ||
20 | return; | ||
21 | } | ||
22 | |||
23 | #ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
24 | |||
25 | static bool enabled = true; | ||
26 | |||
27 | #endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
28 | |||
29 | void rgb_matrix_indicators_user(void) { rgb_matrix_indicators_keymap(); } | ||
30 | void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { | ||
31 | #ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
32 | if (rgb_matrix_is_enabled() && enabled) { | ||
33 | set_layer_rgb(led_min, led_max, get_highest_layer(layer_state | default_layer_state)); | ||
34 | } | ||
35 | |||
36 | #endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
37 | rgb_matrix_indicators_advanced_keymap(led_min, led_max); | ||
38 | } | ||
39 | |||
40 | #ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
41 | |||
42 | void set_layer_rgb(uint8_t led_min, uint8_t led_max, int layer) { | ||
43 | const ledmap *l = &(ledmaps[layer]); | ||
44 | |||
45 | uint8_t val = rgb_matrix_get_val(); | ||
46 | |||
47 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { | ||
48 | HSV hsv = { | ||
49 | .h = (*l)[i][0], | ||
50 | .s = (*l)[i][1], | ||
51 | .v = val, | ||
52 | }; | ||
53 | |||
54 | if (hsv.h || hsv.s) { | ||
55 | RGB rgb = hsv_to_rgb(hsv); | ||
56 | RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b); | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | void rgb_matrix_layers_enable() { | ||
62 | dprintf("ledmaps are enabled\n"); | ||
63 | enabled = true; | ||
64 | } | ||
65 | |||
66 | void rgb_matrix_layers_disable() { | ||
67 | dprintf("ledmaps are disabled\n"); | ||
68 | enabled = false; | ||
69 | } | ||
70 | |||
71 | #endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.h b/keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.h new file mode 100644 index 000000000..eace217d1 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/rgb_matrix_ledmaps.h | |||
@@ -0,0 +1,100 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #pragma once | ||
17 | |||
18 | #include "quantum.h" | ||
19 | |||
20 | #ifdef RGB_MATRIX_LEDMAPS_ENABLED | ||
21 | |||
22 | // no association keycode | ||
23 | # define XXX \ | ||
24 | { 0, 0, 0 } | ||
25 | |||
26 | // clang-format off | ||
27 | # define RGB_MATRIX_LAYOUT_LEDMAP( \ | ||
28 | ul1, k13, k26, k36, k31, k33, k07, k63, k71, k76, ka6, ka7, ka3, ka5, k97, k01, ur1, \ | ||
29 | ul2, k16, k17, k27, k37, k47, k46, k56, k57, k67, k77, k87, k86, k66, ka1, k65, ur2, \ | ||
30 | ul3, k11, k10, k20, k30, k40, k41, k51, k50, k60, k70, k80, k81, k61, ka2, k15, ur3, \ | ||
31 | ul4, k21, k12, k22, k32, k42, k43, k53, k52, k62, k72, k82, k83, ka4, k25, ur4, \ | ||
32 | ul5, k00, k14, k24, k34, k44, k45, k55, k54, k64, k74, k85, k91, k35, k75, ur5, \ | ||
33 | ul6, k06, k90, k93, k94, k95, k92, k04, k03, k73, k05, ur6 \ | ||
34 | ) \ | ||
35 | { \ | ||
36 | k13, k16, k11, k21, k00, k06, k26, k17, \ | ||
37 | k10, k12, k14, k90, k36, k27, k20, k22, \ | ||
38 | k24, k93, k31, k37, k30, k32, k34, k33, \ | ||
39 | k47, k40, k42, k44, k07, k46, k41, k43, \ | ||
40 | k45, k94, k63, k56, k51, k53, k55, k71, \ | ||
41 | k57, k50, k52, k54, k76, k67, k60, k62, \ | ||
42 | k64, k95, ka6, k77, k70, k72, k74, k92, \ | ||
43 | ka7, k87, k80, k82, k85, ka3, k86, k81, \ | ||
44 | k83, k04, ka5, ul1, ur1, k97, ul2, ur2, \ | ||
45 | k65, ul2, ur2, k15, ul3, ur3, k66, k05, \ | ||
46 | ul3, ur3, k75, ul4, ur4, ka1, k25, ul5, \ | ||
47 | ur5, k61, k91, ul6, ur6, ka2, k35, k03, \ | ||
48 | ka4, k73 \ | ||
49 | } | ||
50 | // clang-format on | ||
51 | typedef uint8_t ledmap[DRIVER_LED_TOTAL][3]; | ||
52 | extern const ledmap ledmaps[]; | ||
53 | |||
54 | void set_layer_rgb(uint8_t led_min, uint8_t led_max, int layer); | ||
55 | |||
56 | void rgb_matrix_layers_enable(void); | ||
57 | void rgb_matrix_layers_disable(void); | ||
58 | |||
59 | // Just a handy defines to make our ledmaps look better | ||
60 | # define RED \ | ||
61 | { HSV_RED } | ||
62 | # define CORAL \ | ||
63 | { HSV_CORAL } | ||
64 | # define ORANGE \ | ||
65 | { HSV_ORANGE } | ||
66 | # define GOLDEN \ | ||
67 | { HSV_GOLDENROD } | ||
68 | # define GOLD \ | ||
69 | { HSV_GOLD } | ||
70 | # define YELLOW \ | ||
71 | { HSV_YELLOW } | ||
72 | # define CHART \ | ||
73 | { HSV_CHARTREUSE } | ||
74 | # define GREEN \ | ||
75 | { HSV_GREEN } | ||
76 | # define SPRING \ | ||
77 | { HSV_SPRINGGREEN } | ||
78 | # define TURQ \ | ||
79 | { HSV_TURQUOISE } | ||
80 | # define TEAL \ | ||
81 | { HSV_TEAL } | ||
82 | # define CYAN \ | ||
83 | { HSV_CYAN } | ||
84 | # define AZURE \ | ||
85 | { HSV_AZURE } | ||
86 | # define BLUE \ | ||
87 | { HSV_BLUE } | ||
88 | # define PURPLE \ | ||
89 | { HSV_PURPLE } | ||
90 | # define MAGENT \ | ||
91 | { HSV_MAGENTA } | ||
92 | # define PINK \ | ||
93 | { HSV_PINK } | ||
94 | # define BLACK \ | ||
95 | { HSV_BLACK } | ||
96 | |||
97 | #endif // RGB_MATRIX_LEDMAPS_ENABLED | ||
98 | |||
99 | void rgb_matrix_indicators_keymap(void); | ||
100 | void rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max); | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/rules.mk b/keyboards/gmmk/pro/keymaps/mike1808/rules.mk new file mode 100644 index 000000000..a6d4e6259 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/rules.mk | |||
@@ -0,0 +1,25 @@ | |||
1 | VIA_ENABLE = no | ||
2 | |||
3 | COMBO_ENABLE = yes | ||
4 | COMMAND_ENABLE = yes | ||
5 | RGB_MATRIX_ENABLE = yes | ||
6 | RAW_ENABLE = no | ||
7 | CONSOLE_ENABLE = yes | ||
8 | |||
9 | WPM_ENABLE = no | ||
10 | |||
11 | RGB_MATRIX_LEDMAPS = yes | ||
12 | |||
13 | SRC += utils.c | ||
14 | SRC += mike1808.c | ||
15 | SRC += process_record.c | ||
16 | SRC += encoder.c | ||
17 | |||
18 | ifeq ($(strip $(WPM_ENABLE)), yes) | ||
19 | SRC += fun.c | ||
20 | endif | ||
21 | |||
22 | ifeq ($(strip $(RGB_MATRIX_LEDMAPS)), yes) | ||
23 | SRC += rgb_matrix_ledmaps.c | ||
24 | OPT_DEFS += -DRGB_MATRIX_LEDMAPS_ENABLED | ||
25 | endif | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/utils.c b/keyboards/gmmk/pro/keymaps/mike1808/utils.c new file mode 100644 index 000000000..35ae20b12 --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/utils.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #include "utils.h" | ||
17 | |||
18 | void store_rgb_state_to_eeprom() { | ||
19 | uint8_t mode = rgb_matrix_get_mode(); | ||
20 | uint8_t speed = rgb_matrix_get_speed(); | ||
21 | HSV color = rgb_matrix_get_hsv(); | ||
22 | |||
23 | rgb_matrix_mode(mode); | ||
24 | rgb_matrix_set_speed(speed); | ||
25 | rgb_matrix_sethsv(color.h, color.s, color.v); | ||
26 | } | ||
27 | |||
28 | void press(KeyPressState *self) { | ||
29 | self->_count++; | ||
30 | |||
31 | dprintf("KPS: press: %d\n", self->_count); | ||
32 | |||
33 | // pressed the first time | ||
34 | if (self->_count == 1) { | ||
35 | self->hander(true); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | void release(KeyPressState *self) { | ||
40 | self->_count--; | ||
41 | |||
42 | dprintf("KPS: release: %d\n", self->_count); | ||
43 | |||
44 | // all keys are relased | ||
45 | if (self->_count == 0) { | ||
46 | self->hander(false); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | void reset(KeyPressState *self) { | ||
51 | self->_count = 0; | ||
52 | } | ||
53 | |||
54 | KeyPressState *NewKeyPressState(key_press_handler handler) { | ||
55 | KeyPressState *kps = (KeyPressState *)(malloc(sizeof(KeyPressState))); | ||
56 | |||
57 | kps->_count = 0; | ||
58 | kps->press = press; | ||
59 | kps->release = release; | ||
60 | kps->reset = reset; | ||
61 | kps->hander = handler; | ||
62 | |||
63 | return kps; | ||
64 | } | ||
diff --git a/keyboards/gmmk/pro/keymaps/mike1808/utils.h b/keyboards/gmmk/pro/keymaps/mike1808/utils.h new file mode 100644 index 000000000..49d0745cf --- /dev/null +++ b/keyboards/gmmk/pro/keymaps/mike1808/utils.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* Copyright 2021 Mikael Manukyan <arm.localhost@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 | #pragma once | ||
17 | #include "quantum.h" | ||
18 | |||
19 | void store_rgb_state_to_eeprom(void); | ||
20 | |||
21 | typedef void (*key_press_handler)(bool); | ||
22 | |||
23 | typedef struct KeyPressState KeyPressState; | ||
24 | struct KeyPressState { | ||
25 | int _count; | ||
26 | void (*press)(KeyPressState *self); | ||
27 | void (*release)(KeyPressState *self); | ||
28 | void (*reset)(KeyPressState *self); | ||
29 | key_press_handler hander; | ||
30 | }; | ||
31 | |||
32 | KeyPressState *NewKeyPressState(key_press_handler); | ||