aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Đorđević <vomindoraan@gmail.com>2019-02-11 23:21:41 +0100
committerKonstantin Đorđević <vomindoraan@gmail.com>2019-03-02 15:15:55 +0100
commitddb0f39ebf317c7a23c69ed45efb1882746a01b0 (patch)
tree1395072c58d02ebcda3d87c0c28401581695062c
parent2f07627a5dd38ab1370804f4feb1972250928803 (diff)
downloadqmk_firmware-ddb0f39ebf317c7a23c69ed45efb1882746a01b0.tar.gz
qmk_firmware-ddb0f39ebf317c7a23c69ed45efb1882746a01b0.zip
Generate UNICODE and UNICODEMAP constants using macros
-rw-r--r--users/konstantin/konstantin.h2
-rw-r--r--users/konstantin/rules.mk3
-rw-r--r--users/konstantin/unicode.c7
-rw-r--r--users/konstantin/unicode.h37
4 files changed, 41 insertions, 8 deletions
diff --git a/users/konstantin/konstantin.h b/users/konstantin/konstantin.h
index d8b00c4c8..c32d674e8 100644
--- a/users/konstantin/konstantin.h
+++ b/users/konstantin/konstantin.h
@@ -7,7 +7,7 @@
7#ifdef TAP_DANCE_ENABLE 7#ifdef TAP_DANCE_ENABLE
8 #include "tap_dance.h" 8 #include "tap_dance.h"
9#endif 9#endif
10#ifdef UNICODE_ENABLE 10#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE)
11 #include "unicode.h" 11 #include "unicode.h"
12#endif 12#endif
13 13
diff --git a/users/konstantin/rules.mk b/users/konstantin/rules.mk
index 8913e5755..6bda030fb 100644
--- a/users/konstantin/rules.mk
+++ b/users/konstantin/rules.mk
@@ -5,5 +5,8 @@ endif
5ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) 5ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
6 SRC += tap_dance.c 6 SRC += tap_dance.c
7endif 7endif
8ifneq (,$(filter yes,$(UNICODE_ENABLE) $(UNICODEMAP_ENABLE))) # if either is yes
9 SRC += unicode.c
10endif
8 11
9EXTRAFLAGS += -flto 12EXTRAFLAGS += -flto
diff --git a/users/konstantin/unicode.c b/users/konstantin/unicode.c
new file mode 100644
index 000000000..3b6164bc5
--- /dev/null
+++ b/users/konstantin/unicode.c
@@ -0,0 +1,7 @@
1#include "unicode.h"
2
3#ifdef UNICODEMAP_ENABLE
4 const uint32_t PROGMEM unicode_map[] = {
5 FOREACH_UNICODE(X_ENTRY)
6 };
7#endif
diff --git a/users/konstantin/unicode.h b/users/konstantin/unicode.h
index 09af7e1c7..d76f2a170 100644
--- a/users/konstantin/unicode.h
+++ b/users/konstantin/unicode.h
@@ -2,10 +2,33 @@
2 2
3#include "quantum.h" 3#include "quantum.h"
4 4
5#define COMMA UC(0x002C) 5#define FOREACH_UNICODE(M) \
6#define L_PAREN UC(0x0028) 6 M(COMMA, 0x002C) \
7#define R_PAREN UC(0x0029) 7 M(L_PAREN, 0x0028) \
8#define EQUALS UC(0x003D) 8 M(R_PAREN, 0x0029) \
9#define TIMES UC(0x00D7) 9 M(EQUALS, 0x003D) \
10#define DIVIDE UC(0x00F7) 10 M(TIMES, 0x00D7) \
11#define MINUS UC(0x2212) 11 M(DIVIDE, 0x00F7) \
12 M(MINUS, 0x2212)
13
14#define UC_KEYCODE(name, code) name = UC(code),
15
16#define X_NAME(name, code) X_ ## name,
17#define X_ENTRY(name, code) [X_ ## name] = code,
18#define X_KEYCODE(name, code) name = X(X_ ## name),
19
20#if defined(UNICODE_ENABLE)
21 enum unicode_keycodes {
22 FOREACH_UNICODE(UC_KEYCODE)
23 };
24#elif defined(UNICODEMAP_ENABLE)
25 enum unicode_names {
26 FOREACH_UNICODE(X_NAME)
27 };
28
29 extern const uint32_t PROGMEM unicode_map[];
30
31 enum unicode_keycodes {
32 FOREACH_UNICODE(X_KEYCODE)
33 };
34#endif