aboutsummaryrefslogtreecommitdiffstats
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)
downloadfirmware-ddb0f39ebf317c7a23c69ed45efb1882746a01b0.tar.gz
firmware-ddb0f39ebf317c7a23c69ed45efb1882746a01b0.tar.bz2
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 @@
#ifdef TAP_DANCE_ENABLE
#include "tap_dance.h"
#endif
-#ifdef UNICODE_ENABLE
+#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE)
#include "unicode.h"
#endif
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
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += tap_dance.c
endif
+ifneq (,$(filter yes,$(UNICODE_ENABLE) $(UNICODEMAP_ENABLE))) # if either is yes
+ SRC += unicode.c
+endif
EXTRAFLAGS += -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 @@
+#include "unicode.h"
+
+#ifdef UNICODEMAP_ENABLE
+ const uint32_t PROGMEM unicode_map[] = {
+ FOREACH_UNICODE(X_ENTRY)
+ };
+#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 @@
#include "quantum.h"
-#define COMMA UC(0x002C)
-#define L_PAREN UC(0x0028)
-#define R_PAREN UC(0x0029)
-#define EQUALS UC(0x003D)
-#define TIMES UC(0x00D7)
-#define DIVIDE UC(0x00F7)
-#define MINUS UC(0x2212)
+#define FOREACH_UNICODE(M) \
+ M(COMMA, 0x002C) \
+ M(L_PAREN, 0x0028) \
+ M(R_PAREN, 0x0029) \
+ M(EQUALS, 0x003D) \
+ M(TIMES, 0x00D7) \
+ M(DIVIDE, 0x00F7) \
+ M(MINUS, 0x2212)
+
+#define UC_KEYCODE(name, code) name = UC(code),
+
+#define X_NAME(name, code) X_ ## name,
+#define X_ENTRY(name, code) [X_ ## name] = code,
+#define X_KEYCODE(name, code) name = X(X_ ## name),
+
+#if defined(UNICODE_ENABLE)
+ enum unicode_keycodes {
+ FOREACH_UNICODE(UC_KEYCODE)
+ };
+#elif defined(UNICODEMAP_ENABLE)
+ enum unicode_names {
+ FOREACH_UNICODE(X_NAME)
+ };
+
+ extern const uint32_t PROGMEM unicode_map[];
+
+ enum unicode_keycodes {
+ FOREACH_UNICODE(X_KEYCODE)
+ };
+#endif
d='n288' href='#n288'>288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354