]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/ps2avrGB/keymaps/default/keymap.c
60929ac997411d0eda1c9a2180d05f4b79749bd3
[qmk_firmware.git] / keyboards / ps2avrGB / keymaps / default / keymap.c
1 /*
2 Copyright 2017 Luiz Ribeiro <luizribeiro@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 "ps2avrGB.h"
19 #include "action_layer.h"
20 #include "rgblight.h"
21
22 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
23     KC_KEYMAP(
24         ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, PSCR,HOME,END,
25         GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     DEL,
26         TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,     INS,
27         CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,           PGUP,
28         LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,          UP,  PGDN,
29         LCTL,LALT,LGUI,          SPC,                     RGUI,RALT,RCTL,LEFT,DOWN,RGHT
30     )
31 };
32
33 enum function_id {
34     RGBLED_TOGGLE,
35     RGBLED_STEP_MODE,
36     RGBLED_INCREASE_HUE,
37     RGBLED_DECREASE_HUE,
38     RGBLED_INCREASE_SAT,
39     RGBLED_DECREASE_SAT,
40     RGBLED_INCREASE_VAL,
41     RGBLED_DECREASE_VAL,
42 };
43
44 const uint16_t PROGMEM fn_actions[] = {
45     [0] = ACTION_FUNCTION(RGBLED_TOGGLE),
46     [1] = ACTION_FUNCTION(RGBLED_STEP_MODE),
47     [2] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
48     [3] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
49     [4] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
50     [5] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
51     [6] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
52     [7] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
53 };
54
55 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
56     switch (id) {
57         case RGBLED_TOGGLE:
58             if (record->event.pressed) {
59                 rgblight_toggle();
60             }
61             break;
62         case RGBLED_STEP_MODE:
63             if (record->event.pressed) {
64                 rgblight_step();
65             }
66             break;
67         case RGBLED_INCREASE_HUE:
68             if (record->event.pressed) {
69                 rgblight_increase_hue();
70             }
71             break;
72         case RGBLED_DECREASE_HUE:
73             if (record->event.pressed) {
74                 rgblight_decrease_hue();
75             }
76             break;
77         case RGBLED_INCREASE_SAT:
78             if (record->event.pressed) {
79                 rgblight_increase_sat();
80             }
81             break;
82         case RGBLED_DECREASE_SAT:
83             if (record->event.pressed) {
84                 rgblight_decrease_sat();
85             }
86             break;
87         case RGBLED_INCREASE_VAL:
88             if (record->event.pressed) {
89                 rgblight_increase_val();
90             }
91             break;
92         case RGBLED_DECREASE_VAL:
93             if (record->event.pressed) {
94                 rgblight_decrease_val();
95             }
96             break;
97     }
98 };