Generate UNICODE and UNICODEMAP constants using macros

pull/5289/head
Konstantin Đorđević 6 years ago
parent 2f07627a5d
commit ddb0f39ebf

@ -7,7 +7,7 @@
#ifdef TAP_DANCE_ENABLE #ifdef TAP_DANCE_ENABLE
#include "tap_dance.h" #include "tap_dance.h"
#endif #endif
#ifdef UNICODE_ENABLE #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE)
#include "unicode.h" #include "unicode.h"
#endif #endif

@ -5,5 +5,8 @@ endif
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += tap_dance.c SRC += tap_dance.c
endif endif
ifneq (,$(filter yes,$(UNICODE_ENABLE) $(UNICODEMAP_ENABLE))) # if either is yes
SRC += unicode.c
endif
EXTRAFLAGS += -flto EXTRAFLAGS += -flto

@ -0,0 +1,7 @@
#include "unicode.h"
#ifdef UNICODEMAP_ENABLE
const uint32_t PROGMEM unicode_map[] = {
FOREACH_UNICODE(X_ENTRY)
};
#endif

@ -2,10 +2,33 @@
#include "quantum.h" #include "quantum.h"
#define COMMA UC(0x002C) #define FOREACH_UNICODE(M) \
#define L_PAREN UC(0x0028) M(COMMA, 0x002C) \
#define R_PAREN UC(0x0029) M(L_PAREN, 0x0028) \
#define EQUALS UC(0x003D) M(R_PAREN, 0x0029) \
#define TIMES UC(0x00D7) M(EQUALS, 0x003D) \
#define DIVIDE UC(0x00F7) M(TIMES, 0x00D7) \
#define MINUS UC(0x2212) 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

Loading…
Cancel
Save