A sample implementation of keymap-in-eeprom
This commit is contained in:
parent
d8b992585e
commit
0f31162554
@ -133,6 +133,7 @@ Optional. Note that ***comment out*** to disable them.
|
|||||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||||
#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||||
|
#KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
|
||||||
|
|
||||||
### 3. Programmer
|
### 3. Programmer
|
||||||
Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`.
|
Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`.
|
||||||
|
@ -118,9 +118,10 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
|||||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||||
|
KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
|
||||||
|
|
||||||
|
|
||||||
# Optimize size but this may cause error "relocation truncated to fit"
|
# Optimize size but this may cause error "relocation truncated to fit"
|
||||||
|
@ -88,11 +88,12 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
|||||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||||
MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
||||||
CONSOLE_ENABLE = yes # Console for debug
|
CONSOLE_ENABLE = yes # Console for debug
|
||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||||
|
KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
|
||||||
|
|
||||||
|
|
||||||
# Search Path
|
# Search Path
|
||||||
@ -102,15 +103,3 @@ VPATH += $(TOP_DIR)
|
|||||||
include $(TOP_DIR)/protocol/pjrc.mk
|
include $(TOP_DIR)/protocol/pjrc.mk
|
||||||
include $(TOP_DIR)/common.mk
|
include $(TOP_DIR)/common.mk
|
||||||
include $(TOP_DIR)/rules.mk
|
include $(TOP_DIR)/rules.mk
|
||||||
|
|
||||||
plain: OPT_DEFS += -DKEYMAP_PLAIN
|
|
||||||
plain: all
|
|
||||||
|
|
||||||
poker: OPT_DEFS += -DKEYMAP_POKER
|
|
||||||
poker: all
|
|
||||||
|
|
||||||
poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
|
|
||||||
poker_set: all
|
|
||||||
|
|
||||||
poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
|
|
||||||
poker_bit: all
|
|
||||||
|
@ -31,6 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define MATRIX_ROWS 5
|
#define MATRIX_ROWS 5
|
||||||
#define MATRIX_COLS 14
|
#define MATRIX_COLS 14
|
||||||
|
|
||||||
|
/* keymap in eeprom */
|
||||||
|
#define FN_ACTIONS_COUNT 32
|
||||||
|
#define KEYMAPS_COUNT 8
|
||||||
|
|
||||||
/* define if matrix has ghost */
|
/* define if matrix has ghost */
|
||||||
//#define MATRIX_HAS_GHOST
|
//#define MATRIX_HAS_GHOST
|
||||||
|
|
||||||
|
@ -20,11 +20,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
/* translates key to keycode */
|
/* translates key to keycode */
|
||||||
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
||||||
{
|
{
|
||||||
|
#ifndef KEYMAP_IN_EEPROM_ENABLE
|
||||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
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 */
|
/* translates Fn keycode to action */
|
||||||
action_t keymap_fn_to_action(uint8_t keycode)
|
action_t keymap_fn_to_action(uint8_t keycode)
|
||||||
{
|
{
|
||||||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
return (action_t) {
|
||||||
|
#ifndef KEYMAP_IN_EEPROM_ENABLE
|
||||||
|
.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)])
|
||||||
|
#else
|
||||||
|
.code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode))
|
||||||
|
#endif
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
|
const uint8_t* keymaps_pointer(void) {
|
||||||
|
return (const uint8_t*)keymaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint16_t* fn_actions_pointer(void) {
|
||||||
|
return fn_actions;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
#include "keymap_in_eeprom.h"
|
||||||
|
|
||||||
|
|
||||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||||
|
@ -102,3 +102,13 @@ const uint16_t PROGMEM fn_actions[] = {
|
|||||||
[7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
|
[7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
|
||||||
[8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
|
[8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef KEYMAP_IN_EEPROM_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
|
||||||
|
Reference in New Issue
Block a user