aboutsummaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorrupa <rupa@lrrr.us>2020-08-20 20:07:09 -0400
committerGitHub <noreply@github.com>2020-08-20 17:07:09 -0700
commitdd763f2988f0804fc7a0ff03de5c2a1e5a29e450 (patch)
tree3cf79015d574a866ca0dcca86c15c79cd5abca80 /users
parent83c7c66e8caab77bfb97c937c371ceb165c58102 (diff)
downloadqmk_firmware-dd763f2988f0804fc7a0ff03de5c2a1e5a29e450.tar.gz
qmk_firmware-dd763f2988f0804fc7a0ff03de5c2a1e5a29e450.zip
[Keymap] userspace and keymap for rupa (#9786)
* first iteration of my keymap * * move to userspace * "script" modes * keymap bling * OM and RUPA keys and tryin to micro-optimize in process_records.c * woops swap shifted rupas forgot to add codepoint for OM * Apply suggestions from code review Co-authored-by: Drashna Jaelre <drashna@live.com> * add call to process_record_keymap, per review * fall through to process_record_keymap * license headers Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'users')
-rw-r--r--users/rupa/config.h8
-rwxr-xr-xusers/rupa/process_records.c72
-rwxr-xr-xusers/rupa/process_records.h21
-rw-r--r--users/rupa/rules.mk3
-rwxr-xr-xusers/rupa/rupa.c49
-rwxr-xr-xusers/rupa/rupa.h54
-rwxr-xr-xusers/rupa/unicode.c42
-rwxr-xr-xusers/rupa/unicode.h43
8 files changed, 292 insertions, 0 deletions
diff --git a/users/rupa/config.h b/users/rupa/config.h
new file mode 100644
index 000000000..902405204
--- /dev/null
+++ b/users/rupa/config.h
@@ -0,0 +1,8 @@
1#pragma once
2
3#define UNICODE_SELECTED_MODES UC_MAC, UC_LNX
4
5#define ONESHOT_TAP_TOGGLE 5
6#define ONESHOT_TIMEOUT 5000
7
8#define TAP_CODE_DELAY 5 //DEFAULT: 100
diff --git a/users/rupa/process_records.c b/users/rupa/process_records.c
new file mode 100755
index 000000000..2d7231010
--- /dev/null
+++ b/users/rupa/process_records.c
@@ -0,0 +1,72 @@
1/*
2Copyright 2020 rupa <rupa@lrrr.us> @rupa
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "rupa.h"
19
20font_t *translator = NULL;
21
22__attribute__((weak))
23bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
24 return true;
25}
26
27bool process_record_user(uint16_t keycode, keyrecord_t *record) {
28 bool is_shifted = get_mods()&MOD_MASK_SHIFT;
29 bool is_pressed = record->event.pressed;
30
31 switch(keycode) {
32 case VRSN:
33 if (is_pressed) {
34 send_string_with_delay_P(PSTR(
35 "# " QMK_KEYBOARD "/" QMK_KEYMAP ":" QMK_VERSION " " QMK_BUILDDATE "\n"
36 ), TAP_CODE_DELAY);
37 }
38 return false;
39
40 case LOD:
41 case RUPA:
42 if (is_pressed) {
43 if (keycode == LOD) {
44 send_unicode_string((is_shifted ? "¯\\_(ツ)_/¯" : "ಠ_ಠ"));
45 } else if (keycode == RUPA) {
46 send_unicode_string((is_shifted ? "Śrīrūpa" : "rūpa"));
47 }
48 }
49 return false;
50
51 // script modes
52 case U_FRACT:
53 case U_MONOS:
54 case U_SCRPT:
55 if (is_pressed) {
56 if (keycode == U_SCRPT) {
57 translator = (translator == &script_bold ? NULL : &script_bold);
58 } else if (keycode == U_FRACT) {
59 translator = (translator == &fraktu_bold ? NULL : &fraktu_bold);
60 } else if (keycode == U_MONOS) {
61 translator = (translator == &monosp_bold ? NULL : &monosp_bold);
62 }
63 }
64 return true;
65
66 default:
67 if (is_pressed && translator != NULL) {
68 return script_mode_translate(translator, is_shifted, keycode);
69 }
70 }
71 return process_record_keymap(keycode, record);
72}
diff --git a/users/rupa/process_records.h b/users/rupa/process_records.h
new file mode 100755
index 000000000..7c7fe491b
--- /dev/null
+++ b/users/rupa/process_records.h
@@ -0,0 +1,21 @@
1/*
2Copyright 2020 rupa <rupa@lrrr.us> @rupa
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19#include "rupa.h"
20
21bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
diff --git a/users/rupa/rules.mk b/users/rupa/rules.mk
new file mode 100644
index 000000000..c4f147d91
--- /dev/null
+++ b/users/rupa/rules.mk
@@ -0,0 +1,3 @@
1SRC += rupa.c \
2 process_records.c \
3 unicode.c
diff --git a/users/rupa/rupa.c b/users/rupa/rupa.c
new file mode 100755
index 000000000..60fec3caf
--- /dev/null
+++ b/users/rupa/rupa.c
@@ -0,0 +1,49 @@
1/*
2Copyright 2020 rupa <rupa@lrrr.us> @rupa
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <print.h>
19#include "rupa.h"
20
21// https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols
22font_t script_bold = {0x1D4D0, 0x1D4EA, 0x1D7CE}; // with bold numbers
23font_t fraktu_bold = {0x1D56C, 0x1D586, 0x1D7D8}; // with doublestruck numbers
24font_t monosp_bold = {0x1D670, 0x1D68A, 0x1D7F6};
25
26// Maps A-Z, a-z, and 0-9 to other unicode ranges. We also map space to EN
27// SPACE for some reason :)
28uint32_t map_alnum(font_t *f, bool is_shifted, uint32_t keycode) {
29 switch (keycode) {
30 case KC_SPACE:
31 return (is_shifted ? 0 : 0x2002); // EN SPACE
32 case KC_0:
33 return (is_shifted ? 0 : f->zero_glyph);
34 case KC_A ... KC_Z:
35 return (is_shifted ? f->upper_alpha : f->lower_alpha) + keycode - KC_A;
36 case KC_1 ... KC_9:
37 return (is_shifted ? 0 : f->zero_glyph + keycode - KC_1 + 1);
38 default:
39 return 0;
40 }
41}
42
43bool script_mode_translate(font_t *translator, bool is_shifted, uint32_t keycode) {
44 uint32_t translated = map_alnum(translator, is_shifted, keycode);
45 if (translated == 0) return true;
46 dprintf("script_mode_translate: %u => %d\n", keycode, translated);
47 register_unicode(translated);
48 return false;
49}
diff --git a/users/rupa/rupa.h b/users/rupa/rupa.h
new file mode 100755
index 000000000..9be3a2d62
--- /dev/null
+++ b/users/rupa/rupa.h
@@ -0,0 +1,54 @@
1/*
2Copyright 2020 rupa <rupa@lrrr.us> @rupa
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19#include QMK_KEYBOARD_H
20#include "version.h"
21#include "process_records.h"
22#include "unicode.h"
23
24enum userspace_layers {
25 _QWERTY = 0,
26 _RAISE,
27};
28
29enum userspace_custom_keycodes {
30 VRSN = SAFE_RANGE,
31 LOD,
32 RUPA,
33 U_FRACT,
34 U_MONOS,
35 U_SCRPT,
36};
37
38typedef struct font_t {
39 uint32_t upper_alpha;
40 uint32_t lower_alpha;
41 uint32_t zero_glyph;
42} font_t;
43
44font_t fraktu_bold;
45font_t monosp_bold;
46font_t script_bold;
47
48bool script_mode_translate(font_t *translator, bool is_shifted, uint32_t keycode);
49
50#define RAISE MO(_RAISE)
51#define OS_RGUI OSM(MOD_RGUI)
52#define OS_RALT OSM(MOD_RALT)
53#define OS_RCTL OSM(MOD_RCTL)
54#define OS_RSFT OSM(MOD_RSFT)
diff --git a/users/rupa/unicode.c b/users/rupa/unicode.c
new file mode 100755
index 000000000..89a0d4766
--- /dev/null
+++ b/users/rupa/unicode.c
@@ -0,0 +1,42 @@
1/*
2Copyright 2020 rupa <rupa@lrrr.us> @rupa
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "unicode.h"
19
20#if defined(UNICODEMAP_ENABLE)
21const uint32_t PROGMEM unicode_map[] = {
22 [CHEK] = 0x2713, // ✓
23 /*
24 [DI1] = 0x2680, // ⚀
25 [DI2] = 0x2681, // ⚁
26 [DI3] = 0x2682, // ⚂
27 [DI4] = 0x2683, // ⚃
28 [DI5] = 0x2684, // ⚄
29 [DI6] = 0x2685, // ⚅
30 */
31 [HAS] = 0x262D, // ☭
32 [IBNG] = 0x203D, // ‽
33 [IRNY] = 0x2E2E, // ⸮
34 [M4] = 0x2669, // ♩
35 [M8] = 0x266A, // ♪
36 [M8B] = 0x266B, // ♫
37 [M16] = 0x266C, // ♬
38 [OM] = 0x0950, // ॐ
39 [STB] = 0x2605, // ★
40 [STW] = 0x2606, // ☆
41};
42#endif
diff --git a/users/rupa/unicode.h b/users/rupa/unicode.h
new file mode 100755
index 000000000..0c067bd91
--- /dev/null
+++ b/users/rupa/unicode.h
@@ -0,0 +1,43 @@
1/*
2Copyright 2020 rupa <rupa@lrrr.us> @rupa
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19#include "rupa.h"
20
21#if defined(UNICODEMAP_ENABLE)
22enum unicode_names {
23 CHEK,
24 /*
25 DI1, // ⚀
26 DI2, // ⚁
27 DI3, // ⚂
28 DI4, // ⚃
29 DI5, // ⚄
30 DI6, // ⚅
31 */
32 HAS, // ☭
33 IBNG, // ‽
34 IRNY, // ⸮
35 M4, // ♩
36 M8, // ♪
37 M8B, // ♫
38 M16, // ♬
39 OM, // ॐ
40 STB, // ★
41 STW, // ☆
42};
43#endif