aboutsummaryrefslogtreecommitdiff
path: root/keyboards/crkbd/keymaps/hvp/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/crkbd/keymaps/hvp/keymap.c')
-rw-r--r--keyboards/crkbd/keymaps/hvp/keymap.c183
1 files changed, 183 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/hvp/keymap.c b/keyboards/crkbd/keymaps/hvp/keymap.c
new file mode 100644
index 000000000..b66c360e1
--- /dev/null
+++ b/keyboards/crkbd/keymaps/hvp/keymap.c
@@ -0,0 +1,183 @@
1#include QMK_KEYBOARD_H
2#include "hvp.c"
3
4#ifdef RGBLIGHT_ENABLE
5//Following line allows macro to read current RGB settings
6extern rgblight_config_t rgblight_config;
7#endif
8
9extern uint8_t is_master;
10
11// Each layer gets a name for readability, which is then used in the keymap matrix below.
12// The underscores don't mean anything - you can have a layer called STUFF or any other name.
13// Layer names don't all need to be of the same length, obviously, and you can also skip them
14// entirely and just use numbers.
15#define _QWERTY 0
16#define _LOWER 1
17#define _RAISE 2
18#define _ADJUST 3
19
20enum custom_keycodes {
21 QWERTY = SAFE_RANGE,
22 LOWER,
23 RAISE,
24 ADJUST
25};
26
27const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
28 [_QWERTY] = LAYOUT( \
29 //,-----------------------------------------. ,-----------------------------------------.
30 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,KC_BSPC,\
31 //|------+------+------+------+------+------| |------+------+------+------+------+------|
32 LT(_ADJUST, KC_ESC), KC_A, KC_S, KC_D, LT(_RAISE,KC_F), MT(MOD_LCTL,KC_G), KC_H, KC_J, KC_K, KC_L,TD(TD1),TD(TD2),\
33 //|------+------+------+------+------+------| |------+------+------+------+------+------|
34 KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M,KC_COMM,KC_DOT,TD(TD3),KC_SFTENT,\
35 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
36 KC_LGUI, LOWER,MT(MOD_LSFT, KC_SPC), LT(_RAISE,KC_ENT), RAISE,KC_LALT \
37 //`--------------------' `--------------------'
38 ),
39
40 [_RAISE] = LAYOUT( \
41 //,-----------------------------------------. ,-----------------------------------------.
42 KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,KC_BSPC,\
43 //|------+------+------+------+------+------| |------+------+------+------+------+------|
44 KC_ESC, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT,KC_DOWN,KC_UP, KC_RIGHT,KC_NO, KC_DEL,\
45 //|------+------+------+------+------+------| |------+------+------+------+------+------|
46 KC_LCTL, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_NO, KC_NO,\
47 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
48 KC_LGUI, LOWER,MT(MOD_LSFT, KC_SPC), LT(_RAISE,KC_ENT), RAISE,KC_LALT \
49 //`--------------------' `--------------------'
50 ),
51
52 [_LOWER] = LAYOUT( \
53 //,-----------------------------------------. ,-----------------------------------------.
54 KC_TAB,KC_EXLM,KC_AT,KC_HASH,KC_DLR,KC_PERC, KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_BSPC,\
55 //|------+------+------+------+------+------| |------+------+------+------+------+------|
56 KC_ESC, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_MINS,KC_EQL,KC_LCBR,KC_RCBR,KC_PIPE,KC_GRV,\
57 //|------+------+------+------+------+------| |------+------+------+------+------+------|
58 KC_LCTL, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_UNDS,KC_PLUS,KC_LBRC,KC_RBRC,KC_BSLS,KC_TILD,\
59 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
60 KC_LGUI, LOWER,MT(MOD_LSFT, KC_SPC), LT(_RAISE,KC_ENT), RAISE,KC_LALT \
61 //`--------------------' `--------------------'
62 ),
63
64 [_ADJUST] = LAYOUT( \
65 //,-----------------------------------------. ,-----------------------------------------.
66 KC_F1,KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,\
67 //|------+------+------+------+------+------| |------+------+------+------+------+------|
68 KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\
69 //|------+------+------+------+------+------| |------+------+------+------+------+------|
70 RESET,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, KC_MPLY, KC_MNXT, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT,\
71 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
72 KC_LGUI, LOWER,MT(MOD_LSFT, KC_SPC), LT(_RAISE,KC_ENT), RAISE,KC_LALT \
73 //`--------------------' `--------------------'
74 )
75};
76
77int RGB_current_mode;
78
79// Setting ADJUST layer RGB back to default
80void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
81 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
82 layer_on(layer3);
83 } else {
84 layer_off(layer3);
85 }
86}
87
88void matrix_init_user(void) {
89 #ifdef RGBLIGHT_ENABLE
90 RGB_current_mode = rgblight_config.mode;
91 #endif
92 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
93 #ifdef SSD1306OLED
94 iota_gfx_init(!has_usb()); // turns on the display
95 #endif
96}
97
98//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
99#ifdef SSD1306OLED
100
101// When add source files to SRC in rules.mk, you can use functions.
102const char *read_layer_state(void);
103const char *read_logo(void);
104void set_keylog(uint16_t keycode, keyrecord_t *record);
105const char *read_keylog(void);
106const char *read_keylogs(void);
107
108// const char *read_mode_icon(bool swap);
109// const char *read_host_led_state(void);
110// void set_timelog(void);
111// const char *read_timelog(void);
112
113void matrix_scan_user(void) {
114 iota_gfx_task();
115}
116
117void matrix_render_user(struct CharacterMatrix *matrix) {
118 if (is_master) {
119 // If you want to change the display of OLED, you need to change here
120 matrix_write_ln(matrix, read_layer_state());
121 matrix_write_ln(matrix, read_keylog());
122 //matrix_write_ln(matrix, read_keylogs());
123 //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
124 //matrix_write_ln(matrix, read_host_led_state());
125 //matrix_write_ln(matrix, read_timelog());
126 } else {
127 matrix_write(matrix, read_logo());
128 }
129}
130
131void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
132 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
133 memcpy(dest->display, source->display, sizeof(dest->display));
134 dest->dirty = true;
135 }
136}
137
138void iota_gfx_task_user(void) {
139 struct CharacterMatrix matrix;
140 matrix_clear(&matrix);
141 matrix_render_user(&matrix);
142 matrix_update(&display, &matrix);
143}
144#endif//SSD1306OLED
145
146bool process_record_user(uint16_t keycode, keyrecord_t *record) {
147 if (record->event.pressed) {
148#ifdef SSD1306OLED
149 set_keylog(keycode, record);
150#endif
151 // set_timelog();
152 }
153
154 switch (keycode) {
155 case LOWER:
156 if (record->event.pressed) {
157 layer_on(_LOWER);
158 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
159 } else {
160 layer_off(_LOWER);
161 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
162 }
163 return false;
164 case RAISE:
165 if (record->event.pressed) {
166 layer_on(_RAISE);
167 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
168 } else {
169 layer_off(_RAISE);
170 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
171 }
172 return false;
173 case ADJUST:
174 if (record->event.pressed) {
175 layer_on(_ADJUST);
176 } else {
177 layer_off(_ADJUST);
178 }
179 return false;
180 break;
181 }
182 return true;
183} \ No newline at end of file