aboutsummaryrefslogtreecommitdiff
path: root/keyboards/yampad/keymaps/via/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/yampad/keymaps/via/keymap.c')
-rw-r--r--keyboards/yampad/keymaps/via/keymap.c163
1 files changed, 163 insertions, 0 deletions
diff --git a/keyboards/yampad/keymaps/via/keymap.c b/keyboards/yampad/keymaps/via/keymap.c
new file mode 100644
index 000000000..d22eb2617
--- /dev/null
+++ b/keyboards/yampad/keymaps/via/keymap.c
@@ -0,0 +1,163 @@
1/* MIT License
2
3Copyright (c) 2019 Mattia Dal Ben
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all
13copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21SOFTWARE.
22*/
23
24#include QMK_KEYBOARD_H
25
26// Each layer gets a name for readability, which is then used in the keymap matrix below.
27// The underscores don't mean anything - you can have a layer called STUFF or any other name.
28// Layer names don't all need to be of the same length, obviously, and you can also skip them
29// entirely and just use numbers.
30enum layers {
31 _BL,
32 _NV,
33 _FN
34};
35
36enum custom_keycodes {
37 KC_DBL0 = SAFE_RANGE,
38};
39
40const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
41/* Keymap _BL: (Base Layer) Default Layer
42 * ,-------------------.
43 * | NV | / | * |-/FN|
44 * |----|----|----|----|
45 * | 7 | 8 | 9 | |
46 * |----|----|----| + |
47 * | 4 | 5 | 6 | |
48 * |----|----|----|----|
49 * | 1 | 2 | 3 | |
50 * |----|----|----| En |
51 * | 0 | 00 | . | |
52 * `-------------------'
53 */
54 [_BL] = LAYOUT(
55 TG(_NV), KC_PSLS, KC_PAST, LT(_FN, KC_PMNS),
56 KC_P7, KC_P8, KC_P9,
57 KC_P4, KC_P5, KC_P6, KC_PPLS,
58 KC_P1, KC_P2, KC_P3,
59 KC_P0, KC_DBL0, KC_PDOT, KC_PENT
60 ),
61
62/* Keymap _NV: Navigation layer
63 * ,-------------------.
64 * |INS |HOME|PGUP| |
65 * |----|----|----|----|
66 * |DEL |END |PGDN| |
67 * |----|----|----| |
68 * | | | | |
69 * |----|----|----|----|
70 * | | UP | | |
71 * |----|----|----| |
72 * |LEFT|DOWN|RIGH| |
73 * `-------------------'
74 */
75 [_NV] = LAYOUT(
76 KC_INS, KC_HOME, KC_PGUP, TG(_NV),
77 KC_DEL, KC_END, KC_PGDN,
78 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
79 XXXXXXX, KC_UP, XXXXXXX,
80 KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX
81 ),
82
83/* Keymap _FN: RGB Function Layer
84 * ,-------------------.
85 * |RMOD|RGBP|RTOG| FN |
86 * |----|----|----|----|
87 * |HUD |HUI | | |
88 * |----|----|----| |
89 * |SAD |SAI | | |
90 * |----|----|----|----|
91 * |VAD |VAS | | |
92 * |----|----|----| |
93 * |RST | | | |
94 * `-------------------'
95 */
96 [_FN] = LAYOUT(
97 RGB_MOD, RGB_M_P, RGB_TOG, _______,
98 RGB_HUD, RGB_HUI, XXXXXXX,
99 RGB_SAD, RGB_SAI, XXXXXXX, XXXXXXX,
100 RGB_VAD, RGB_VAI, XXXXXXX,
101 RESET, XXXXXXX, XXXXXXX, XXXXXXX
102 ),
103};
104
105bool process_record_user(uint16_t keycode, keyrecord_t *record) {
106 switch (keycode) {
107 case KC_DBL0:
108 if (record->event.pressed) {
109 SEND_STRING("00");
110 } else {
111 // when keycode KC_DBL0 is released
112 }
113 break;
114
115 }
116 return true;
117};
118
119#ifdef OLED_ENABLE
120
121oled_rotation_t oled_init_user(oled_rotation_t rotation) {
122 return OLED_ROTATION_270; // flips the display 270 degrees
123}
124
125void oled_task_user(void) {
126 // Host Keyboard Layer Status
127 oled_write_P(PSTR("Layer"), false);
128 switch (get_highest_layer(layer_state)) {
129 case _BL:
130 oled_write_ln_P(PSTR(" BAS"), false);
131 break;
132 case _NV:
133 oled_write_ln_P(PSTR(" NAV"), false);
134 break;
135 case _FN:
136 oled_write_ln_P(PSTR(" RGB"), false);
137 break;
138 default:
139 // Or use the write_ln shortcut over adding '\n' to the end of your string
140 oled_write_ln_P(PSTR(" UND"), false);
141 }
142
143 // Host Keyboard LED Status
144 led_t led_state = host_keyboard_led_state();
145 oled_write_P(PSTR("-----"), false);
146 oled_write_P(PSTR("Stats"), false);
147 oled_write_P(led_state.num_lock ? PSTR("num:*") : PSTR("num:."), false);
148 oled_write_P(led_state.caps_lock ? PSTR("cap:*") : PSTR("cap:."), false);
149 oled_write_P(led_state.scroll_lock ? PSTR("scr:*") : PSTR("scr:."), false);
150
151 // Host Keyboard RGB backlight status
152 oled_write_P(PSTR("-----"), false);
153 oled_write_P(PSTR("Light"), false);
154
155 static char led_buf[30];
156 snprintf(led_buf, sizeof(led_buf) - 1, "RGB:%cM: %2d\nh: %2ds: %2dv: %2d\n",
157 rgblight_is_enabled() ? '*' : '.', (uint8_t)rgblight_get_mode(),
158 (uint8_t)(rgblight_get_hue() / RGBLIGHT_HUE_STEP),
159 (uint8_t)(rgblight_get_sat() / RGBLIGHT_SAT_STEP),
160 (uint8_t)(rgblight_get_val() / RGBLIGHT_VAL_STEP));
161 oled_write(led_buf, false);
162}
163#endif