aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author4saito5 <4saito5@gmail.com>2019-06-21 05:00:39 +0900
committerDrashna Jaelre <drashna@live.com>2019-06-20 13:00:39 -0700
commit7f23ad72c5c736b58bab16995e7b0a599268b56f (patch)
tree4db1e820c2c6d3be65baad4fc69b396afc66871b
parentaf34c548f94528c15cf1f963da4c1dcdbc408dfe (diff)
downloadqmk_firmware-7f23ad72c5c736b58bab16995e7b0a599268b56f.tar.gz
qmk_firmware-7f23ad72c5c736b58bab16995e7b0a599268b56f.zip
[Keymap] New keymap for crkbd (#6103)
* New keymap * Update keymap
-rwxr-xr-xkeyboards/crkbd/keymaps/thumb_ctrl/config.h44
-rwxr-xr-xkeyboards/crkbd/keymaps/thumb_ctrl/keymap.c253
-rwxr-xr-xkeyboards/crkbd/keymaps/thumb_ctrl/rules.mk31
3 files changed, 328 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/thumb_ctrl/config.h b/keyboards/crkbd/keymaps/thumb_ctrl/config.h
new file mode 100755
index 000000000..5670d8c64
--- /dev/null
+++ b/keyboards/crkbd/keymaps/thumb_ctrl/config.h
@@ -0,0 +1,44 @@
1/*
2This is the c configuration file for the keymap
3
4Copyright 2012 Jun Wako <wakojun@gmail.com>
5Copyright 2015 Jack Humbert
6
7This program is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23//#define USE_MATRIX_I2C
24
25/* Select hand configuration */
26
27#define MASTER_LEFT
28// #define MASTER_RIGHT
29// #define EE_HANDS
30
31#define SSD1306OLED
32
33#define USE_SERIAL_PD2
34
35#define TAPPING_FORCE_HOLD
36#define TAPPING_TERM 150
37
38#undef RGBLED_NUM
39#define RGBLIGHT_ANIMATIONS
40#define RGBLED_NUM 27
41#define RGBLIGHT_LIMIT_VAL 120
42#define RGBLIGHT_HUE_STEP 10
43#define RGBLIGHT_SAT_STEP 17
44#define RGBLIGHT_VAL_STEP 17
diff --git a/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c b/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c
new file mode 100755
index 000000000..c67958aa1
--- /dev/null
+++ b/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c
@@ -0,0 +1,253 @@
1#include QMK_KEYBOARD_H
2#include "bootloader.h"
3#ifdef PROTOCOL_LUFA
4 #include "lufa.h"
5 #include "split_util.h"
6#endif
7#ifdef SSD1306OLED
8 #include "ssd1306.h"
9#endif
10
11extern keymap_config_t keymap_config;
12
13#ifdef RGBLIGHT_ENABLE
14//Following line allows macro to read current RGB settings
15extern rgblight_config_t rgblight_config;
16#endif
17
18extern uint8_t is_master;
19
20// Each layer gets a name for readability, which is then used in the keymap matrix below.
21// The underscores don't mean anything - you can have a layer called STUFF or any other name.
22// Layer names don't all need to be of the same length, obviously, and you can also skip them
23// entirely and just use numbers.
24enum layer_names {
25 _QWERTY,
26 _LOWER,
27 _RAISE,
28 _ADJUST
29};
30
31enum custom_keycodes {
32 QWERTY = SAFE_RANGE,
33 LOWER,
34 RAISE,
35 ADJUST,
36 BACKLIT,
37 RGBRST
38};
39
40#define KC_ KC_TRNS
41#define KC______ KC_TRNS
42#define KC_XXXXX KC_NO
43#define KC_LOWER LOWER
44#define KC_RAISE RAISE
45#define KC_RST RESET
46#define KC_LRST RGBRST
47#define KC_LTOG RGB_TOG
48#define KC_LHUI RGB_HUI
49#define KC_LHUD RGB_HUD
50#define KC_LSAI RGB_SAI
51#define KC_LSAD RGB_SAD
52#define KC_LVAI RGB_VAI
53#define KC_LVAD RGB_VAD
54#define KC_LMOD RGB_MOD
55#define KC_CTLTB CTL_T(KC_TAB)
56#define KC_GUIEI GUI_T(KC_LANG2)
57#define KC_ALTKN ALT_T(KC_LANG1)
58#define KC_CTLEN CTL_T(KC_LANG2) // for Linux and Windows
59#define KC_GUIEN GUI_T(KC_LANG2) // for Mac
60#define KC_SFTJP SFT_T(KC_LANG1)
61#define KC_ALTSP ALT_T(KC_SPACE)
62#define KC_ALTDL ALT_T(KC_DEL)
63
64const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
65 [_QWERTY] = LAYOUT_kc(
66 //,-----------------------------------------. ,-----------------------------------------.
67 ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
68 //|------+------+------+------+------+------| |------+------+------+------+------+------|
69 CTLTB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
70 //|------+------+------+------+------+------| |------+------+------+------+------+------|
71 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
72 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
73 ALTSP, LOWER, GUIEN, SFTJP, RAISE, ALTDL
74 //`--------------------' `--------------------'
75 ),
76
77 [_LOWER] = LAYOUT_kc(
78 //,-----------------------------------------. ,-----------------------------------------.
79 , 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, ,
80 //|------+------+------+------+------+------| |------+------+------+------+------+------|
81 , HOME, END, PGDN, PGUP, F11, LEFT, DOWN, UP, RGHT, F12, PIPE,
82 //|------+------+------+------+------+------| |------+------+------+------+------+------|
83 , F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, ,
84 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
85 , , , , ,
86 //`--------------------' `--------------------'
87 ),
88
89 [_RAISE] = LAYOUT_kc(
90 //,-----------------------------------------. ,-----------------------------------------.
91 , EXLM, AT, HASH, DLR, PERC, CIRC, AMPR, ASTR, LPRN, RPRN, ,
92 //|------+------+------+------+------+------| |------+------+------+------+------+------|
93 , XXXXX, XXXXX, XXXXX, XXXXX, PSCR, GRV, MINS, PLUS, LCBR, RCBR, BSLS,
94 //|------+------+------+------+------+------| |------+------+------+------+------+------|
95 , XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, TILD, UNDS, EQL, LBRC, RBRC, ,
96 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
97 , , , , ,
98 //`--------------------' `--------------------'
99 ),
100
101 [_ADJUST] = LAYOUT_kc(
102 //,-----------------------------------------. ,-----------------------------------------.
103 RST, LRST, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX,
104 //|------+------+------+------+------+------| |------+------+------+------+------+------|
105 LTOG, LHUI, LSAI, LVAI, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX,
106 //|------+------+------+------+------+------| |------+------+------+------+------+------|
107 LMOD, LHUD, LSAD, LVAD, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX,
108 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
109 GUIEI, LOWER, SPC, ENT, RAISE, ALTKN
110 //`--------------------' `--------------------'
111 )
112};
113
114int RGB_current_mode;
115
116void persistent_default_layer_set(uint16_t default_layer) {
117 eeconfig_update_default_layer(default_layer);
118 default_layer_set(default_layer);
119}
120
121// Setting ADJUST layer RGB back to default
122void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
123 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
124 layer_on(layer3);
125 } else {
126 layer_off(layer3);
127 }
128}
129
130void matrix_init_user(void) {
131 #ifdef RGBLIGHT_ENABLE
132 RGB_current_mode = rgblight_config.mode;
133 #endif
134 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
135 #ifdef SSD1306OLED
136 iota_gfx_init(!has_usb()); // turns on the display
137 #endif
138}
139
140//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
141#ifdef SSD1306OLED
142
143// When add source files to SRC in rules.mk, you can use functions.
144const char *read_layer_state(void);
145const char *read_logo(void);
146void set_keylog(uint16_t keycode, keyrecord_t *record);
147const char *read_keylog(void);
148const char *read_keylogs(void);
149
150// const char *read_mode_icon(bool swap);
151// const char *read_host_led_state(void);
152// void set_timelog(void);
153// const char *read_timelog(void);
154
155void matrix_scan_user(void) {
156 iota_gfx_task();
157}
158
159void matrix_render_user(struct CharacterMatrix *matrix) {
160 if (is_master) {
161 // If you want to change the display of OLED, you need to change here
162 matrix_write_ln(matrix, read_layer_state());
163 matrix_write_ln(matrix, read_keylog());
164 matrix_write_ln(matrix, read_keylogs());
165 //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
166 //matrix_write_ln(matrix, read_host_led_state());
167 //matrix_write_ln(matrix, read_timelog());
168 } else {
169 matrix_write(matrix, read_logo());
170 }
171}
172
173void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
174 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
175 memcpy(dest->display, source->display, sizeof(dest->display));
176 dest->dirty = true;
177 }
178}
179
180void iota_gfx_task_user(void) {
181 struct CharacterMatrix matrix;
182 matrix_clear(&matrix);
183 matrix_render_user(&matrix);
184 matrix_update(&display, &matrix);
185}
186#endif//SSD1306OLED
187
188bool process_record_user(uint16_t keycode, keyrecord_t *record) {
189 if (record->event.pressed) {
190#ifdef SSD1306OLED
191 set_keylog(keycode, record);
192#endif
193 // set_timelog();
194 }
195
196 switch (keycode) {
197 case QWERTY:
198 if (record->event.pressed) {
199 persistent_default_layer_set(1UL<<_QWERTY);
200 }
201 return false;
202 break;
203 case LOWER:
204 if (record->event.pressed) {
205 layer_on(_LOWER);
206 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
207 } else {
208 layer_off(_LOWER);
209 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
210 }
211 return false;
212 break;
213 case RAISE:
214 if (record->event.pressed) {
215 layer_on(_RAISE);
216 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
217 } else {
218 layer_off(_RAISE);
219 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
220 }
221 return false;
222 break;
223 case ADJUST:
224 if (record->event.pressed) {
225 layer_on(_ADJUST);
226 } else {
227 layer_off(_ADJUST);
228 }
229 return false;
230 break;
231 case RGB_MOD:
232 #ifdef RGBLIGHT_ENABLE
233 if (record->event.pressed) {
234 rgblight_mode(RGB_current_mode);
235 rgblight_step();
236 RGB_current_mode = rgblight_config.mode;
237 }
238 #endif
239 return false;
240 break;
241 case RGBRST:
242 #ifdef RGBLIGHT_ENABLE
243 if (record->event.pressed) {
244 eeconfig_update_rgblight_default();
245 rgblight_enable();
246 RGB_current_mode = rgblight_config.mode;
247 }
248 #endif
249 break;
250 }
251 return true;
252}
253
diff --git a/keyboards/crkbd/keymaps/thumb_ctrl/rules.mk b/keyboards/crkbd/keymaps/thumb_ctrl/rules.mk
new file mode 100755
index 000000000..16deaf45d
--- /dev/null
+++ b/keyboards/crkbd/keymaps/thumb_ctrl/rules.mk
@@ -0,0 +1,31 @@
1
2# Build Options
3# change to "no" to disable the options, or define them in the Makefile in
4# the appropriate keymap folder that will get included automatically
5#
6BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
7MOUSEKEY_ENABLE = no # Mouse keys(+4700)
8EXTRAKEY_ENABLE = no # Audio control and System control(+450)
9CONSOLE_ENABLE = no # Console for debug(+400)
10COMMAND_ENABLE = no # Commands for debug and configuration
11NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
12BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
13MIDI_ENABLE = no # MIDI controls
14AUDIO_ENABLE = no # Audio output on port C6
15UNICODE_ENABLE = no # Unicode
16BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
17RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
18SWAP_HANDS_ENABLE = no # Enable one-hand typing
19
20# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
21SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
22
23# If you want to change the display of OLED, you need to change here
24SRC += ./lib/glcdfont.c \
25 ./lib/rgb_state_reader.c \
26 ./lib/layer_state_reader.c \
27 ./lib/logo_reader.c \
28 ./lib/keylogger.c \
29 # ./lib/mode_icon_reader.c \
30 # ./lib/host_led_state_reader.c \
31 # ./lib/timelogger.c \