aboutsummaryrefslogtreecommitdiff
path: root/keyboards/jkdlab/binary_monkey/keymaps/ascii/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/jkdlab/binary_monkey/keymaps/ascii/keymap.c')
-rw-r--r--keyboards/jkdlab/binary_monkey/keymaps/ascii/keymap.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/keyboards/jkdlab/binary_monkey/keymaps/ascii/keymap.c b/keyboards/jkdlab/binary_monkey/keymaps/ascii/keymap.c
new file mode 100644
index 000000000..e10df7ce0
--- /dev/null
+++ b/keyboards/jkdlab/binary_monkey/keymaps/ascii/keymap.c
@@ -0,0 +1,70 @@
1/*
2 * Copyright 2021 JKDLAB. <jkdlab.co@gmail.com>
3 * Copyright 2021 Jaehee <ljh34210329@gmail.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License,
8 * or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see https://www.gnu.org/licenses/.
17 */
18
19#include QMK_KEYBOARD_H
20
21char ascii = 0;
22
23enum custom_keycodes {
24 BIN_0 = SAFE_RANGE,
25 BIN_1,
26 BIN_RETURN
27};
28
29enum layers {
30 _BASE = 0
31};
32
33const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
34 [_BASE] = LAYOUT(
35 BIN_0, BIN_1,
36 BIN_RETURN
37 )
38};
39
40bool process_record_user(uint16_t keycode, keyrecord_t* record) {
41 switch (keycode) {
42 case BIN_0:
43 if (record->event.pressed) {
44 ascii = ascii << 1;
45 }
46
47 return true;
48 case BIN_1:
49 if (record->event.pressed) {
50 ascii = ascii << 1;
51 ++ascii;
52 }
53
54 return true;
55 case BIN_RETURN:
56 if (record->event.pressed) {
57 char str[2] = { ascii & 127, '\0' };
58
59 send_string(str);
60
61 ascii = 0;
62 }
63
64 return true;
65 default:
66 return true;
67 }
68
69 return true;
70}