aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Grosse <ste3ls@gmail.com>2019-09-03 17:35:43 +0200
committerDrashna Jaelre <drashna@live.com>2019-09-03 08:35:43 -0700
commit55bae0a5b48a004288013f2fa7cbfd49dfb16273 (patch)
tree7aa1ae1c55ded4b2d1e28888e16625672bf43f46
parentdab4967f1bebc9a70374ed3e1fe7906828b280c2 (diff)
downloadqmk_firmware-55bae0a5b48a004288013f2fa7cbfd49dfb16273.tar.gz
qmk_firmware-55bae0a5b48a004288013f2fa7cbfd49dfb16273.zip
[Keymap] Satan GH60 with command prompt animation, react to keypresses (#6636)
Co-Authored-By: fauxpark <fauxpark@gmail.com> Signed-off-by: Benjamin Große <benjamin@midokura.com>
-rw-r--r--keyboards/gh60/satan/keymaps/gipsy-king/config.h10
-rw-r--r--keyboards/gh60/satan/keymaps/gipsy-king/keymap.c161
-rw-r--r--keyboards/gh60/satan/keymaps/gipsy-king/readme.md1
-rw-r--r--keyboards/gh60/satan/keymaps/gipsy-king/rules.mk7
4 files changed, 179 insertions, 0 deletions
diff --git a/keyboards/gh60/satan/keymaps/gipsy-king/config.h b/keyboards/gh60/satan/keymaps/gipsy-king/config.h
new file mode 100644
index 000000000..0368fa812
--- /dev/null
+++ b/keyboards/gh60/satan/keymaps/gipsy-king/config.h
@@ -0,0 +1,10 @@
1#undef RGBLED_NUM
2#define RGBLED_NUM 17
3#undef RGBLIGHT_HUE_STEP
4#define RGBLIGHT_HUE_STEP 5
5#undef RGBLIGHT_SAT_STEP
6#define RGBLIGHT_SAT_STEP 5
7#undef RGBLIGHT_VAL_STEP
8#define RGBLIGHT_VAL_STEP 5
9
10#undef RGBLIGHT_ANIMATIONS
diff --git a/keyboards/gh60/satan/keymaps/gipsy-king/keymap.c b/keyboards/gh60/satan/keymaps/gipsy-king/keymap.c
new file mode 100644
index 000000000..6e0345d9a
--- /dev/null
+++ b/keyboards/gh60/satan/keymaps/gipsy-king/keymap.c
@@ -0,0 +1,161 @@
1#include QMK_KEYBOARD_H
2#include "rgblight.h"
3
4enum layer_names {
5 _BL,
6 _FL
7};
8
9/**
10 * HHKB style.
11 * Esc on capslock, space-hold is fn.
12 * Fn layer has hjkl arrows, home on backspace, rgb stuff.
13 */
14const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
15 [_BL] = LAYOUT_60_ansi(
16 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,
17 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,
18 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
19 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
20 _______, KC_LCTL, KC_LALT, LT(_FL,KC_SPC), KC_LGUI, KC_RALT, KC_RCTL, _______
21 ),
22
23 [_FL] = LAYOUT_60_ansi(
24 RESET, 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_HOME,
25 RGB_MOD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, BL_DEC, BL_INC, BL_TOGG,
26 _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______,
27 _______, RGB_TOG, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______,
28 _______, _______, _______, _______, _______, _______, _______, _______
29 )
30};
31
32/**
33 * Terminal Prompt
34 * Mimicks a terminal prompt. On keystrokes, the led bar is filled. Backspace
35 * removes from bar. Enter clears bar. After some timeout, the bar is also cleared.
36 * A blinking cursor is displayed at the right of the bar.
37 * This can't be defined as an animation, because animations only are called on an
38 * interval, not on keypress. In the future all animations could be enhanced to
39 * react to keystrokes in QMK.
40 */
41
42uint8_t cursor_pos;
43
44uint16_t interval_time = 10; // maybe too short...
45uint16_t reset_time = 10000;
46uint16_t last_timer = 0;
47uint16_t timer_pos = 0;
48uint16_t reset_timer = 0;
49
50void reset_chars(void);
51void add_char(bool space);
52void remove_char(void);
53void animate_cursor(uint16_t);
54
55// animate, like the built-in animations, with timer_* functions
56void matrix_scan_user(void) {
57 if (timer_elapsed(reset_timer) > reset_time) {
58 reset_chars();
59 reset_timer = timer_read();
60 return;
61 }
62 if (timer_elapsed(last_timer) < interval_time) {
63 return;
64 }
65 last_timer += interval_time;
66 timer_pos += 4;
67 if (timer_pos >= 255) {
68 timer_pos = 0;
69 last_timer = timer_read();
70 }
71 animate_cursor(timer_pos);
72}
73
74bool process_record_user(uint16_t keycode, keyrecord_t *record) {
75 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
76 keycode = keycode & 0xFF;
77 }
78 switch (keycode) {
79 case KC_A ... KC_Z:
80 case KC_1 ... KC_0:
81 case KC_LBRC:
82 case KC_RBRC:
83 case KC_SCLN:
84 case KC_QUOT:
85 case KC_COMM:
86 case KC_DOT:
87 case KC_SLSH:
88 case KC_BSLS:
89 if (record->event.pressed) {
90 add_char(false);
91 }
92 break;
93 case KC_ENTER:
94 case KC_ESC:
95 if (record->event.pressed) {
96 reset_chars();
97 }
98 break;
99 case KC_BSPC:
100 if (record->event.pressed) {
101 remove_char();
102 }
103 break;
104 case KC_SPACE:
105 if (!record->event.pressed) {
106 add_char(true);
107 }
108 break;
109 }
110 reset_timer = timer_read();
111 return true;
112}
113
114void keyboard_post_init_user(void) {
115 // reset the bar and animation
116 rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
117 cursor_pos = 0;
118 reset_chars();
119 reset_timer = last_timer = timer_read();
120}
121
122
123void reset_chars(void) {
124 // flush the whole thing, gets rid of previous animations
125 for (uint8_t i = 0; i < RGBLED_NUM; i++) {
126 // don't flicker the cursor if bar was empty on reset_timer
127 if (i == 0 && cursor_pos == 0) {
128 continue;
129 }
130 rgblight_sethsv_at(0, 0, 0, i);
131 }
132 cursor_pos = 0;
133}
134
135void add_char(bool space) {
136 if (cursor_pos == RGBLED_NUM - 1) {
137 cursor_pos = 0;
138 reset_chars();
139 return;
140 }
141
142 if (space) {
143 rgblight_sethsv_at(0, 0, 0, cursor_pos);
144 } else {
145 rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), cursor_pos);
146 }
147 cursor_pos += 1;
148}
149
150void remove_char(void) {
151 if (cursor_pos == 0) return;
152
153 rgblight_sethsv_at(0, 0, 0, cursor_pos);
154 rgblight_sethsv_at(0, 0, 0, cursor_pos - 1);
155 cursor_pos -= 1;
156}
157
158void animate_cursor(uint16_t pos) {
159 uint16_t value = pos < 196 ? fmin(255, pos * 16) : (255 - (pos * 2));
160 rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), value, cursor_pos);
161}
diff --git a/keyboards/gh60/satan/keymaps/gipsy-king/readme.md b/keyboards/gh60/satan/keymaps/gipsy-king/readme.md
new file mode 100644
index 000000000..c366147df
--- /dev/null
+++ b/keyboards/gh60/satan/keymaps/gipsy-king/readme.md
@@ -0,0 +1 @@
# default Satan GH60 layout
diff --git a/keyboards/gh60/satan/keymaps/gipsy-king/rules.mk b/keyboards/gh60/satan/keymaps/gipsy-king/rules.mk
new file mode 100644
index 000000000..12ab55fae
--- /dev/null
+++ b/keyboards/gh60/satan/keymaps/gipsy-king/rules.mk
@@ -0,0 +1,7 @@
1BOOTMAGIC_ENABLE = no
2EXTRAKEY_ENABLE = no
3CONSOLE_ENABLE = no
4COMMAND_ENABLE = no
5NKRO_ENABLE = no
6UNICODE_ENABLE = yes
7SLEEP_LED_ENABLE = yes