diff options
| -rw-r--r-- | common/keymap.c | 86 | ||||
| -rw-r--r-- | common/keymap.h | 21 | ||||
| -rw-r--r-- | converter/pc98_usb/config.h | 3 | ||||
| -rw-r--r-- | converter/sun_usb/config.h | 14 | ||||
| -rw-r--r-- | keyboard/gh60/config.h | 24 | ||||
| -rw-r--r-- | keyboard/hhkb/config.h | 3 | ||||
| -rw-r--r-- | keyboard/hhkb/config_iwrap.h | 3 |
7 files changed, 82 insertions, 72 deletions
diff --git a/common/keymap.c b/common/keymap.c index aa8d944a7..ace3f49b6 100644 --- a/common/keymap.c +++ b/common/keymap.c | |||
| @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | 26 | ||
| 27 | static action_t keycode_to_action(uint8_t keycode); | 27 | static action_t keycode_to_action(uint8_t keycode); |
| 28 | 28 | ||
| 29 | #ifdef USE_KEYMAP_V2 | 29 | |
| 30 | /* converts key to action */ | 30 | /* converts key to action */ |
| 31 | action_t action_for_key(uint8_t layer, key_t key) | 31 | action_t action_for_key(uint8_t layer, key_t key) |
| 32 | { | 32 | { |
| @@ -38,42 +38,20 @@ action_t action_for_key(uint8_t layer, key_t key) | |||
| 38 | return keycode_to_action(keycode); | 38 | return keycode_to_action(keycode); |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | #else | ||
| 42 | /* | ||
| 43 | * legacy keymap support | ||
| 44 | */ | ||
| 45 | /* translation for legacy keymap */ | ||
| 46 | action_t action_for_key(uint8_t layer, key_t key) | ||
| 47 | { | ||
| 48 | /* convert from legacy keycode to action */ | ||
| 49 | /* layer 16-31 indicate 'overlay' but not supported in legacy keymap */ | ||
| 50 | uint8_t keycode = keymap_get_keycode((layer & OVERLAY_MASK), key.row, key.col); | ||
| 51 | action_t action; | ||
| 52 | switch (keycode) { | ||
| 53 | case KC_FN0 ... KC_FN31: | ||
| 54 | { | ||
| 55 | uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); | ||
| 56 | uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); | ||
| 57 | if (key) { | ||
| 58 | action.code = ACTION_KEYMAP_TAP_KEY(layer, key); | ||
| 59 | } else { | ||
| 60 | action.code = ACTION_KEYMAP_MOMENTARY(layer); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | return action; | ||
| 64 | default: | ||
| 65 | return keycode_to_action(keycode); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | #endif | ||
| 69 | 41 | ||
| 70 | 42 | ||
| 43 | /* Macro */ | ||
| 71 | __attribute__ ((weak)) | 44 | __attribute__ ((weak)) |
| 72 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; } | 45 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 46 | { | ||
| 47 | return MACRO_NONE; | ||
| 48 | } | ||
| 73 | 49 | ||
| 50 | /* Function */ | ||
| 74 | __attribute__ ((weak)) | 51 | __attribute__ ((weak)) |
| 75 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {} | 52 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 76 | 53 | { | |
| 54 | } | ||
| 77 | 55 | ||
| 78 | 56 | ||
| 79 | 57 | ||
| @@ -83,14 +61,9 @@ static action_t keycode_to_action(uint8_t keycode) | |||
| 83 | action_t action; | 61 | action_t action; |
| 84 | switch (keycode) { | 62 | switch (keycode) { |
| 85 | case KC_A ... KC_EXSEL: | 63 | case KC_A ... KC_EXSEL: |
| 64 | case KC_LCTRL ... KC_RGUI: | ||
| 86 | action.code = ACTION_KEY(keycode); | 65 | action.code = ACTION_KEY(keycode); |
| 87 | break; | 66 | break; |
| 88 | case KC_LCTRL ... KC_LGUI: | ||
| 89 | action.code = ACTION_LMOD(keycode); | ||
| 90 | break; | ||
| 91 | case KC_RCTRL ... KC_RGUI: | ||
| 92 | action.code = ACTION_RMOD(keycode); | ||
| 93 | break; | ||
| 94 | case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: | 67 | case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: |
| 95 | action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); | 68 | action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); |
| 96 | break; | 69 | break; |
| @@ -109,3 +82,40 @@ static action_t keycode_to_action(uint8_t keycode) | |||
| 109 | } | 82 | } |
| 110 | return action; | 83 | return action; |
| 111 | } | 84 | } |
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | #ifdef USE_LEGACY_KEYMAP | ||
| 89 | /* | ||
| 90 | * Legacy keymap support | ||
| 91 | * Consider using new keymap API instead. | ||
| 92 | */ | ||
| 93 | __attribute__ ((weak)) | ||
| 94 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | ||
| 95 | { | ||
| 96 | return keymap_get_keycode(layer, key.row, key.col); | ||
| 97 | } | ||
| 98 | |||
| 99 | |||
| 100 | /* Legacy keymap support */ | ||
| 101 | __attribute__ ((weak)) | ||
| 102 | action_t keymap_fn_to_action(uint8_t keycode) | ||
| 103 | { | ||
| 104 | action_t action = { .code = ACTION_NO }; | ||
| 105 | switch (keycode) { | ||
| 106 | case KC_FN0 ... KC_FN31: | ||
| 107 | { | ||
| 108 | uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); | ||
| 109 | uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); | ||
| 110 | if (key) { | ||
| 111 | action.code = ACTION_KEYMAP_TAP_KEY(layer, key); | ||
| 112 | } else { | ||
| 113 | action.code = ACTION_KEYMAP_MOMENTARY(layer); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | return action; | ||
| 117 | default: | ||
| 118 | return action; | ||
| 119 | } | ||
| 120 | } | ||
| 121 | #endif | ||
diff --git a/common/keymap.h b/common/keymap.h index 0c483483f..7efd91f70 100644 --- a/common/keymap.h +++ b/common/keymap.h | |||
| @@ -23,24 +23,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "action.h" | 23 | #include "action.h" |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | #ifdef USE_KEYMAP_V2 | 26 | /* translates key to keycode */ |
| 27 | /* translates key to keycode | ||
| 28 | * layer: 0-15 for base layers | ||
| 29 | * 16-31 for overlays | ||
| 30 | */ | ||
| 31 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); | 27 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); |
| 28 | |||
| 32 | /* translates Fn keycode to action */ | 29 | /* translates Fn keycode to action */ |
| 33 | action_t keymap_fn_to_action(uint8_t keycode); | 30 | action_t keymap_fn_to_action(uint8_t keycode); |
| 34 | #else | 31 | |
| 35 | #warning "You are using LEGACY KEYAMP. Consider using NEW KEYMAP." | 32 | |
| 33 | |||
| 34 | #ifdef USE_LEGACY_KEYMAP | ||
| 36 | /* | 35 | /* |
| 37 | * legacy keymap support | 36 | * Legacy keymap |
| 37 | * Consider using new keymap API above instead. | ||
| 38 | */ | 38 | */ |
| 39 | /* keycode of key */ | 39 | /* keycode of key */ |
| 40 | __attribute__ ((deprecated)) | ||
| 40 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); | 41 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); |
| 42 | |||
| 41 | /* layer to move during press Fn key */ | 43 | /* layer to move during press Fn key */ |
| 44 | __attribute__ ((deprecated)) | ||
| 42 | uint8_t keymap_fn_layer(uint8_t fn_bits); | 45 | uint8_t keymap_fn_layer(uint8_t fn_bits); |
| 46 | |||
| 43 | /* keycode to send when release Fn key without using */ | 47 | /* keycode to send when release Fn key without using */ |
| 48 | __attribute__ ((deprecated)) | ||
| 44 | uint8_t keymap_fn_keycode(uint8_t fn_bits); | 49 | uint8_t keymap_fn_keycode(uint8_t fn_bits); |
| 45 | #endif | 50 | #endif |
| 46 | 51 | ||
diff --git a/converter/pc98_usb/config.h b/converter/pc98_usb/config.h index 4f91c07ce..b8d676e4c 100644 --- a/converter/pc98_usb/config.h +++ b/converter/pc98_usb/config.h | |||
| @@ -30,9 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #define MATRIX_ROWS 16 | 30 | #define MATRIX_ROWS 16 |
| 31 | #define MATRIX_COLS 8 | 31 | #define MATRIX_COLS 8 |
| 32 | 32 | ||
| 33 | /* To use new keymap framework */ | ||
| 34 | #define USE_KEYMAP_V2 | ||
| 35 | |||
| 36 | /* key combination for command */ | 33 | /* key combination for command */ |
| 37 | #define IS_COMMAND() ( \ | 34 | #define IS_COMMAND() ( \ |
| 38 | host_get_first_key() == KC_CANCEL \ | 35 | host_get_first_key() == KC_CANCEL \ |
diff --git a/converter/sun_usb/config.h b/converter/sun_usb/config.h index 65ce9daf6..32303cd32 100644 --- a/converter/sun_usb/config.h +++ b/converter/sun_usb/config.h | |||
| @@ -25,12 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define PRODUCT Sun keyboard converter | 25 | #define PRODUCT Sun keyboard converter |
| 26 | #define DESCRIPTION converts Sun keyboard protocol into USB | 26 | #define DESCRIPTION converts Sun keyboard protocol into USB |
| 27 | 27 | ||
| 28 | |||
| 29 | /* matrix size */ | 28 | /* matrix size */ |
| 30 | #define MATRIX_ROWS 16 | 29 | #define MATRIX_ROWS 16 |
| 31 | #define MATRIX_COLS 8 | 30 | #define MATRIX_COLS 8 |
| 32 | 31 | ||
| 33 | |||
| 34 | /* key combination for command */ | 32 | /* key combination for command */ |
| 35 | #define IS_COMMAND() ( \ | 33 | #define IS_COMMAND() ( \ |
| 36 | keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ | 34 | keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ |
| @@ -38,6 +36,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 38 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | 36 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ |
| 39 | ) | 37 | ) |
| 40 | 38 | ||
| 39 | /* legacy keymap support */ | ||
| 40 | #define USE_LEGACY_KEYMAP | ||
| 41 | |||
| 42 | /* Boot Section Size in *BYTEs* | ||
| 43 | * Teensy halfKay 512 | ||
| 44 | * Teensy++ halfKay 1024 | ||
| 45 | * Atmel DFU loader 4096 | ||
| 46 | * LUFA bootloader 4096 | ||
| 47 | * USBaspLoader 2048 | ||
| 48 | */ | ||
| 49 | #define BOOTLOADER_SIZE 4096 | ||
| 50 | |||
| 41 | 51 | ||
| 42 | /* Serial(USART) configuration | 52 | /* Serial(USART) configuration |
| 43 | * asynchronous, negative logic, 1200baud, no flow control | 53 | * asynchronous, negative logic, 1200baud, no flow control |
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index be4d72384..cd98395eb 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h | |||
| @@ -25,20 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define DEVICE_VER 0x0001 | 25 | #define DEVICE_VER 0x0001 |
| 26 | #define MANUFACTURER geekhack | 26 | #define MANUFACTURER geekhack |
| 27 | #define PRODUCT GH60 | 27 | #define PRODUCT GH60 |
| 28 | /* message strings */ | ||
| 29 | #define DESCRIPTION t.m.k. keyboard firmware for GH60 | 28 | #define DESCRIPTION t.m.k. keyboard firmware for GH60 |
| 30 | 29 | ||
| 31 | |||
| 32 | /* Boot Section Size in *BYTEs* | ||
| 33 | * Teensy halfKay 512 | ||
| 34 | * Teensy++ halfKay 1024 | ||
| 35 | * Atmel DFU loader 4096 | ||
| 36 | * LUFA bootloader 4096 | ||
| 37 | * USBaspLoader 2048 | ||
| 38 | */ | ||
| 39 | #define BOOTLOADER_SIZE 4096 | ||
| 40 | |||
| 41 | |||
| 42 | /* matrix size */ | 30 | /* matrix size */ |
| 43 | #define MATRIX_ROWS 5 | 31 | #define MATRIX_ROWS 5 |
| 44 | #define MATRIX_COLS 14 | 32 | #define MATRIX_COLS 14 |
| @@ -49,14 +37,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 49 | /* Set 0 if need no debouncing */ | 37 | /* Set 0 if need no debouncing */ |
| 50 | #define DEBOUNCE 5 | 38 | #define DEBOUNCE 5 |
| 51 | 39 | ||
| 52 | /* To use new keymap framework */ | ||
| 53 | #define USE_KEYMAP_V2 | ||
| 54 | |||
| 55 | /* key combination for command */ | 40 | /* key combination for command */ |
| 56 | #define IS_COMMAND() ( \ | 41 | #define IS_COMMAND() ( \ |
| 57 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | 42 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ |
| 58 | ) | 43 | ) |
| 59 | 44 | ||
| 45 | /* Boot Section Size in *BYTEs* | ||
| 46 | * Teensy halfKay 512 | ||
| 47 | * Teensy++ halfKay 1024 | ||
| 48 | * Atmel DFU loader 4096 | ||
| 49 | * LUFA bootloader 4096 | ||
| 50 | * USBaspLoader 2048 | ||
| 51 | */ | ||
| 52 | #define BOOTLOADER_SIZE 4096 | ||
| 53 | |||
| 60 | /* | 54 | /* |
| 61 | * Boot magic keys | 55 | * Boot magic keys |
| 62 | * call some function by pressing key when pluging cable or powering on. | 56 | * call some function by pressing key when pluging cable or powering on. |
diff --git a/keyboard/hhkb/config.h b/keyboard/hhkb/config.h index 3bfeb45ed..ef2958981 100644 --- a/keyboard/hhkb/config.h +++ b/keyboard/hhkb/config.h | |||
| @@ -44,9 +44,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | #define MATRIX_ROWS 8 | 44 | #define MATRIX_ROWS 8 |
| 45 | #define MATRIX_COLS 8 | 45 | #define MATRIX_COLS 8 |
| 46 | 46 | ||
| 47 | /* To use new keymap framework */ | ||
| 48 | #define USE_KEYMAP_V2 | ||
| 49 | |||
| 50 | /* | 47 | /* |
| 51 | * Boot magic keys | 48 | * Boot magic keys |
| 52 | * call some function by pressing key when pluging cable or powering on. | 49 | * call some function by pressing key when pluging cable or powering on. |
diff --git a/keyboard/hhkb/config_iwrap.h b/keyboard/hhkb/config_iwrap.h index 2c18cd817..7a4ec3711 100644 --- a/keyboard/hhkb/config_iwrap.h +++ b/keyboard/hhkb/config_iwrap.h | |||
| @@ -41,9 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 41 | #define MATRIX_ROWS 8 | 41 | #define MATRIX_ROWS 8 |
| 42 | #define MATRIX_COLS 8 | 42 | #define MATRIX_COLS 8 |
| 43 | 43 | ||
| 44 | /* To use new keymap framework */ | ||
| 45 | #define USE_KEYMAP_V2 | ||
| 46 | |||
| 47 | /* key combination for command */ | 44 | /* key combination for command */ |
| 48 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) | 45 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) |
| 49 | 46 | ||
