]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/maxr1998/pulse4k/pulse4k.c
[Keyboard] Add Pulse 4k, a macropad by Maxr1998 (#6195)
[qmk_firmware.git] / keyboards / maxr1998 / pulse4k / pulse4k.c
1 /*
2 Copyright (C) 2019  Maxr1998 <max.rumpf1998@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
18 #include "pulse4k.h"
19 #include "rgblight.h"
20
21 enum combo_events {
22     LED_ADJUST
23 };
24
25 const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END};
26
27 combo_t key_combos[COMBO_COUNT] = {
28     [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
29 };
30
31 bool led_adjust_active = false;
32
33 void matrix_init_kb(void) {
34     matrix_init_user();
35 }
36
37 void process_combo_event(uint8_t combo_index, bool pressed) {
38     if (combo_index == LED_ADJUST) {
39         led_adjust_active = pressed;
40     }
41 }
42
43 void encoder_update_kb(uint8_t index, bool clockwise) {
44     if (index == 0) {
45         if (led_adjust_active) {
46             if (clockwise) {
47                 rgblight_increase_val();
48             } else {
49                 rgblight_decrease_val();
50             }
51         } else encoder_one_update(clockwise);
52     } else if (index == 1) {
53         if (led_adjust_active) {
54             if (clockwise) {
55                 rgblight_increase_hue();
56             } else {
57                 rgblight_decrease_hue();
58             }
59         } else encoder_two_update(clockwise);
60     }
61 }