瀏覽代碼

A sample implementation of keymap-in-eeprom

keymap_in_eeprom
Kai Ryu 10 年之前
父節點
當前提交
0f31162554

+ 1
- 0
doc/build.md 查看文件

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`.

+ 4
- 3
keyboard/gh60/Makefile 查看文件

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
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
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"

+ 4
- 15
keyboard/gh60/Makefile.pjrc 查看文件

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
COMMAND_ENABLE = yes # Commands for debug and configuration
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#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
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

+ 4
- 0
keyboard/gh60/config.h 查看文件

#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



+ 21
- 1
keyboard/gh60/keymap_common.c 查看文件

/* 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

+ 1
- 0
keyboard/gh60/keymap_common.h 查看文件

#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];

+ 10
- 0
keyboard/gh60/keymap_poker.c 查看文件

[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