From d14a00c44e6048e2126d6e14b4e849984674b168 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 30 Jun 2021 17:04:08 +0900 Subject: [PATCH] core: Fix keymap.h header for C++ --- tmk_core/common/keymap.c | 8 -------- tmk_core/common/keymap.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 617a1f70..f9b8ca12 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -171,10 +171,6 @@ static action_t keycode_to_action(uint8_t keycode) * Legacy keymap support * Consider using new keymap API instead. */ -extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; -extern const uint8_t fn_layer[]; -extern const uint8_t fn_keycode[]; - __attribute__ ((weak)) uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) { @@ -223,10 +219,6 @@ action_t keymap_fn_to_action(uint8_t keycode) #else -/* user keymaps should be defined somewhere */ -extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; -extern const action_t fn_actions[]; - __attribute__ ((weak)) uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h index 659ea357..0a9c5d48 100644 --- a/tmk_core/common/keymap.h +++ b/tmk_core/common/keymap.h @@ -23,6 +23,10 @@ along with this program. If not, see . #include "action.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifdef BOOTMAGIC_ENABLE /* NOTE: Not portable. Bit field order depends on implementation */ typedef union { @@ -40,6 +44,8 @@ typedef union { } keymap_config_t; #endif +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const action_t fn_actions[]; /* translates key to keycode */ uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key); @@ -54,6 +60,10 @@ action_t keymap_fn_to_action(uint8_t keycode); * Legacy keymap * Consider using new keymap API above instead. */ +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint8_t fn_layer[]; +extern const uint8_t fn_keycode[]; + /* keycode of key */ __attribute__ ((deprecated)) uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); @@ -65,6 +75,16 @@ uint8_t keymap_fn_layer(uint8_t fn_bits); /* keycode to send when release Fn key without using */ __attribute__ ((deprecated)) uint8_t keymap_fn_keycode(uint8_t fn_bits); + +#else + +/* user keymaps should be defined somewhere */ +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const action_t fn_actions[]; +#endif + +#ifdef __cplusplus +} #endif #endif