diff --git a/common.mk b/common.mk index 09561cba..f6e9f262 100644 --- a/common.mk +++ b/common.mk @@ -22,7 +22,7 @@ ifdef BOOTMAGIC_ENABLE OPT_DEFS += -DBOOTMAGIC_ENABLE endif -ifdef MOUSEKEY_ENABLE +ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) SRC += $(COMMON_DIR)/mousekey.c OPT_DEFS += -DMOUSEKEY_ENABLE OPT_DEFS += -DMOUSE_ENABLE @@ -69,11 +69,6 @@ ifdef KEYMAP_SECTION_ENABLE EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x endif -ifdef KEYMAP_EX_ENABLE - SRC += $(COMMON_DIR)/keymap_ex.c - OPT_DEFS += -DKEYMAP_EX_ENABLE -endif - ifdef LED_MATRIX_ENABLE SRC += $(COMMON_DIR)/led_matrix.c OPT_DEFS += -DLED_MATRIX_ENABLE diff --git a/common/keyboard.c b/common/keyboard.c index 6b3f6427..7928741a 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -32,7 +32,6 @@ along with this program. If not, see . #include "eeconfig.h" #include "backlight.h" #include "breathing_led.h" -#include "keymap_ex.h" #ifdef MOUSEKEY_ENABLE # include "mousekey.h" #endif @@ -85,10 +84,6 @@ void keyboard_init(void) #ifdef BREATHING_LED_ENABLE breathing_led_init(); #endif - -#ifdef KEYMAP_EX_ENABLE - keymap_ex_init(); -#endif } /* diff --git a/common/keymap_ex.c b/common/keymap_ex.c deleted file mode 100644 index 99859c06..00000000 --- a/common/keymap_ex.c +++ /dev/null @@ -1,114 +0,0 @@ -/* -Copyright 2013 Kai Ryu - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include -#include -#include "eeconfig.h" -#include "keymap_ex.h" -#include "debug.h" - -#ifdef KEYMAP_EX_ENABLE - -void keymap_ex_init(void) { - if (!check_keymap_in_eeprom()) { - write_keymap_to_eeprom(); - } -} - -void keymap_ex_disable(void) { - eeprom_write_word((void*)EECONFIG_KEYMAP_CHECKSUM, eeprom_read_word((void*)EECONFIG_KEYMAP_CHECKSUM) + 1); -} - -bool check_keymap_in_eeprom(void) { - uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); - uint16_t checksum = EECONFIG_MAGIC_NUMBER; - for (uint16_t i = 0; i < KEYMAP_SIZE; i += 2) { - checksum += eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i)); - } -#ifdef DEBUG - eeprom_write_word((void*)(EECONFIG_KEYMAP_DEBUG), checksum); -#endif - return (checksum_in_eeprom == checksum); -} - -void write_keymap_to_eeprom(void) { - uint16_t checksum = EECONFIG_MAGIC_NUMBER; - const uint16_t *fn_actions = fn_actions_pointer(); - const uint8_t *keymaps = keymaps_pointer(); - // write fn_actions - if (fn_actions != NULL) { - uint16_t fn_actions_count_in_flash = fn_actions_count(); - for (uint16_t i = 0; i < FN_ACTIONS_COUNT; i++) { - uint16_t fn_action = 0; - if (i < fn_actions_count_in_flash) { - fn_action = pgm_read_word(fn_actions + i); - } - eeconfig_write_keymap_fn_action(i, fn_action); - checksum += fn_action; - } - } - // write keymaps - if (keymaps != NULL) { - uint16_t keys_count_in_flash = keys_count(); - for (uint16_t i = 0; i < KEYS_COUNT; i++) { - uint8_t keymap = 0; - if (i < keys_count_in_flash) { - keymap = pgm_read_byte(keymaps + i); - } - eeconfig_write_keymap_key_by_index(i, keymap); - uint16_t keymap_word = keymap; - if (i & 1) { - keymap_word = keymap << 8; - } - checksum += keymap_word; - } - } - // write checksum - eeprom_write_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum, checksum); -} - -uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col) { - //return eeprom_read_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col]); - return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col))); -} - -void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key) { - //return eeprom_write_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col], key); - return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col)), key); -} - -uint8_t eeconfig_read_keymap_key_by_index(uint16_t index) { - //return eeprom_read_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index); - return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index)); -} - -void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key) { - //return eeprom_write_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index, key); - return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index), key); -} - -uint16_t eeconfig_read_keymap_fn_action(uint8_t index) { - //return eeprom_read_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index]); - return eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index))); -} - -void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action) { - //return eeprom_write_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index], fn_action); - return eeprom_write_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index)), fn_action); -} - -#endif diff --git a/common/keymap_ex.h b/common/keymap_ex.h deleted file mode 100644 index ee6ff8c6..00000000 --- a/common/keymap_ex.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2013 Kai Ryu - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef KEYMAP_EX_H -#define KEYMAP_EX_H - -#ifdef KEYMAP_EX_ENABLE - -#include -#include - -#define EECONFIG_KEYMAP_EX 0x10 -#ifndef FN_ACTIONS_COUNT -#define FN_ACTIONS_COUNT 32 -#endif -#ifndef KEYMAPS_COUNT -#define KEYMAPS_COUNT 8 -#endif - -typedef struct { - uint16_t checksum; - uint16_t fn_actions[FN_ACTIONS_COUNT]; - uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; -} keymap_ex_t; - -#define EECONFIG_KEYMAP_DEBUG (EECONFIG_KEYMAP_EX - sizeof(uint16_t)) -#define EECONFIG_KEYMAP_CHECKSUM (EECONFIG_KEYMAP_EX) -#define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t)) -#define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT) - -#define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) -#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT) -#define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) -#define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)) - -void keymap_ex_init(void); -void keymap_ex_disable(void); -bool check_keymap_in_eeprom(void); -void write_keymap_to_eeprom(void); -uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col); -void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key); -uint8_t eeconfig_read_keymap_key_by_index(uint16_t index); -void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key); -uint16_t eeconfig_read_keymap_fn_action(uint8_t index); -void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action); - -const uint8_t* keymaps_pointer(void); -const uint16_t* fn_actions_pointer(void); -uint16_t keys_count(void); -uint16_t fn_actions_count(void); - -#endif - -#endif diff --git a/keyboard/gh60/Makefile b/keyboard/gh60/Makefile index 56da7779..bb939a84 100644 --- a/keyboard/gh60/Makefile +++ b/keyboard/gh60/Makefile @@ -136,7 +136,6 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support #PS2_USE_BUSYWAIT = yes BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -KEYMAP_EX_ENABLE = yes # External keymap in eeprom KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor BREATHING_LED_ENABLE = yes # Enable breathing backlight diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc index 0ddce925..81ababb4 100644 --- a/keyboard/gh60/Makefile.pjrc +++ b/keyboard/gh60/Makefile.pjrc @@ -104,7 +104,6 @@ COMMAND_ENABLE = yes # Commands for debug and configuration #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -KEYMAP_EX_ENABLE = yes # External keymap in eeprom KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor diff --git a/keyboard/gh60/keymap_common.c b/keyboard/gh60/keymap_common.c index ae934eea..7b6379f6 100644 --- a/keyboard/gh60/keymap_common.c +++ b/keyboard/gh60/keymap_common.c @@ -16,34 +16,15 @@ along with this program. If not, see . */ #include "keymap_common.h" + /* translates key to keycode */ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) { -#ifndef KEYMAP_EX_ENABLE return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); -#else - return eeconfig_read_keymap_key(layer, key.row, key.col); -#endif } /* translates Fn keycode to action */ action_t keymap_fn_to_action(uint8_t keycode) { - return (action_t) { -#ifndef KEYMAP_EX_ENABLE - .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) -#else - .code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode)) -#endif - }; + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; } - -#ifdef KEYMAP_EX_ENABLE -const uint8_t* keymaps_pointer(void) { - return (const uint8_t*)keymaps; -} - -const uint16_t* fn_actions_pointer(void) { - return fn_actions; -} -#endif diff --git a/keyboard/gh60/keymap_common.h b/keyboard/gh60/keymap_common.h index e94f013c..2105caab 100644 --- a/keyboard/gh60/keymap_common.h +++ b/keyboard/gh60/keymap_common.h @@ -28,18 +28,10 @@ along with this program. If not, see . #include "print.h" #include "debug.h" #include "keymap.h" -#include "keymap_ex.h" -/* -#ifdef KEYMAP_EX_ENABLE -extern const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; -extern const uint16_t fn_actions[FN_ACTIONS_COUNT]; -#else -*/ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; extern const uint16_t fn_actions[]; -//#endif /* GH60 keymap definition macro @@ -50,13 +42,13 @@ extern const uint16_t fn_actions[]; K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ - K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \ + K40, K41, K42, K45, K4A, K4B, K4C, K4D \ ) { \ { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \ { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \ { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \ { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \ - { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \ + { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \ } /* ANSI valiant. No extra keys for ISO */ @@ -71,22 +63,7 @@ extern const uint16_t fn_actions[]; K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \ K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO, K3D, \ - K40, K41, K42, K45, NO, K4A, K4B, K4C, K4D \ -) - - -#define KEYMAP_HHKB( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \ - K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3C, \ K40, K41, K42, K45, K4A, K4B, K4C, K4D \ -) KEYMAP( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \ - K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ - K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \ ) #endif diff --git a/keyboard/gh60/keymap_poker.c b/keyboard/gh60/keymap_poker.c index f2035b43..7a612ee4 100644 --- a/keyboard/gh60/keymap_poker.c +++ b/keyboard/gh60/keymap_poker.c @@ -102,13 +102,3 @@ const uint16_t PROGMEM fn_actions[] = { [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout }; - -#ifdef KEYMAP_EX_ENABLE -uint16_t keys_count(void) { - return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS; -} - -uint16_t fn_actions_count(void) { - return sizeof(fn_actions) / sizeof(fn_actions[0]); -} -#endif