aboutsummaryrefslogtreecommitdiff
path: root/keyboards/angel64/rev1/keymaps/kakunpc/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/angel64/rev1/keymaps/kakunpc/keymap.c')
-rw-r--r--keyboards/angel64/rev1/keymaps/kakunpc/keymap.c196
1 files changed, 196 insertions, 0 deletions
diff --git a/keyboards/angel64/rev1/keymaps/kakunpc/keymap.c b/keyboards/angel64/rev1/keymaps/kakunpc/keymap.c
new file mode 100644
index 000000000..6c5184c1b
--- /dev/null
+++ b/keyboards/angel64/rev1/keymaps/kakunpc/keymap.c
@@ -0,0 +1,196 @@
1/* Copyright 2019 kakunpc
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#define USE_LED_RIPPLE_EFFECT
17// #define RANDOM_RIPPLE_EFFECT
18
19#include QMK_KEYBOARD_H
20#include "lufa.h"
21
22#ifdef USE_LED_RIPPLE_EFFECT
23struct keybuf {
24 char col, row;
25 char frame;
26};
27struct keybuf keybufs[256];
28unsigned char keybuf_begin, keybuf_end;
29
30unsigned char r = 0;
31unsigned char g = 112;
32unsigned char b = 255;
33int col, row;
34#endif
35
36
37enum layers{
38 BASE = 0,
39 COMMAND
40};
41
42#define KC_COMMAND_NUM LT(COMMAND,KC_F13)
43#define KC_COMMAND_KANA LT(COMMAND,KC_F14)
44#define KC_COMMAND LT(COMMAND,KC_SPC)
45
46const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
47 [BASE] = LAYOUT_all(
48 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
49 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
50 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
51 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
52 KC_LCTL, KC_LALT, KC_LGUI, KC_COMMAND_NUM, KC_SPC, KC_SPC, KC_SPC, KC_COMMAND_KANA, KC_RALT, MO(COMMAND),KC_RCTL),
53 [COMMAND] = LAYOUT_all(
54 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_BSPC,
55 KC_NO, KC_NO, KC_UP, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
56 KC_CAPS, KC_LEFT, KC_DOWN, KC_RIGHT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
57 KC_LSFT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
58 KC_LCTL, KC_NO, KC_NO, _______, KC_NO, RGB_MOD, KC_NO, _______, KC_NO, _______, KC_NO),
59};
60
61
62bool process_record_user(uint16_t keycode, keyrecord_t *record) {
63#ifdef USE_LED_RIPPLE_EFFECT
64 col = record->event.key.col;
65 row = record->event.key.row;
66 if (record->event.pressed) {
67 int end = keybuf_end;
68 keybufs[end].col = col;
69 keybufs[end].row = row;
70 keybufs[end].frame = 0;
71 keybuf_end ++;
72 }
73#endif
74 return true;
75}
76
77void keyboard_post_init_user(void) {
78#ifdef USE_LED_RIPPLE_EFFECT
79 rgblight_enable_noeeprom();
80 rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
81#endif
82}
83
84#ifdef USE_LED_RIPPLE_EFFECT
85int scan_count = -10;
86int keys[] = { 14, 14, 13, 12, 11 };
87int keys_sum[] = { 0, 14, 28, 41, 53 };
88unsigned char rgb[14][5][3];
89int row_max = 12;
90int ToIndex(char _col, char _row) {
91 return (_col * row_max) + _row;
92}
93
94void led_ripple_effect(void){
95 if (scan_count == -1) {
96 rgblight_enable_noeeprom();
97 rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
98 } else if (scan_count >= 0 && scan_count < 5) {
99 for (unsigned char c=keybuf_begin; c!=keybuf_end; c++) {
100 int i = c;
101 // FIXME:
102
103 int index = ToIndex(keybufs[i].col,keybufs[i].row);
104 int coll = 0;
105 for(int s = 4; s >= 0; --s){
106 if( index >= keys_sum[s]){
107 coll = s;
108 break;
109 }
110 }
111 int roww = MAX(0,index - keys_sum[coll]);
112
113 int y = scan_count;
114 int dist_y = abs(y - coll);
115 for (int x=0; x<keys[y]; x++) {
116 int dist = abs(x - roww) + dist_y;
117 if (dist <= keybufs[i].frame) {
118 int elevation = MAX(0, (8 + dist - keybufs[i].frame)) << 2;
119 if (elevation) {
120 if ((rgb[x][y][0] != 255) && r) { rgb[x][y][0] = MIN(255, elevation + rgb[x][y][0]); }
121 if ((rgb[x][y][1] != 255) && g) { rgb[x][y][1] = MIN(255, elevation + rgb[x][y][1]); }
122 if ((rgb[x][y][2] != 255) && b) { rgb[x][y][2] = MIN(255, elevation + rgb[x][y][2]); }
123 }
124 }
125 }
126 }
127 } else if (scan_count == 5) {
128 for (unsigned char c=keybuf_begin; c!=keybuf_end; c++) {
129 int i = c;
130 if (keybufs[i].frame < 64) {
131 keybufs[i].frame ++;
132 } else {
133 keybuf_begin ++;
134 }
135 }
136 } else if (scan_count >= 6 && scan_count <= 10) {
137 int y = scan_count - 6;
138 for (int x=0; x<keys[y]; x++) {
139 int at = keys_sum[y] + x;
140 led[at].r = rgb[x][y][0];
141 led[at].g = rgb[x][y][1];
142 led[at].b = rgb[x][y][2];
143 }
144 rgblight_set();
145 } else if (scan_count == 11) {
146 memset(rgb, 0, sizeof(rgb));
147 }
148 scan_count++;
149 if (scan_count >= 12) { scan_count = 0; }
150}
151
152#endif
153
154void matrix_scan_user(void) {
155#ifdef USE_LED_RIPPLE_EFFECT
156#ifdef RANDOM_RIPPLE_EFFECT
157 static int timer = 0;
158 static int timeout = 300;
159 timer++;
160 if(timer > timeout){
161 int end = keybuf_end;
162 col = rand() % 6;
163 row = rand() % 12;
164 keybufs[end].col = col;
165 keybufs[end].row = row;
166 keybufs[end].frame = 0;
167 keybuf_end ++;
168 timer = rand() % timeout;
169 }
170#endif
171 led_ripple_effect();
172#endif
173}
174
175#ifdef OLED_ENABLE
176bool oled_task_user(void) {
177 oled_write_P(PSTR("Layer: "), false);
178 switch (biton32(layer_state)) {
179 case BASE:
180 oled_write_P(PSTR("Default\n"), false);
181 break;
182 case COMMAND:
183 oled_write_P(PSTR("COMMAND\n"), false);
184 break;
185 default:
186 // Or use the write_ln shortcut over adding 'n' to the end of your string
187 oled_write_ln_P(PSTR("Undefined"), false);
188 }
189
190 // Host Keyboard LED Status
191 oled_write_P(IS_HOST_LED_ON(USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
192 oled_write_P(IS_HOST_LED_ON(USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
193 oled_write_P(IS_HOST_LED_ON(USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
194 return false;
195}
196#endif