diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 4865f11dfc..d0562265b8 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -111,11 +111,15 @@ void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t c } uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column) { + uint16_t keycode_temp; + if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS) return KC_NO; void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column); // Big endian, so we can read/write EEPROM directly from host if we want - uint16_t keycode = eeprom_read_byte(address) << 8; - keycode |= eeprom_read_byte(address + 1); + /*uint16_t keycode = eeprom_read_byte(address) << 8; + keycode |= eeprom_read_byte(address + 1);*/ + keycode_temp=eeprom_read_word(address); + uint16_t keycode=((keycode_temp&0XFF)<<8)|((keycode_temp>>8)&0XFF); return keycode; } diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 91e47a72ee..f29b8c91c2 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -194,8 +194,19 @@ action_t action_for_keycode(uint16_t keycode) { // translates key to keycode __attribute__((weak)) uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { + static uint8_t layerTemp=0xFF; + static uint8_t rowTemp=0xFF; + static uint8_t colTemp=0xFF; + static uint16_t keycodeTemp=0; + if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) { - return keycode_at_keymap_location(layer, key.row, key.col); + if( (layer!=layerTemp) || (key.row!=rowTemp) || (key.col!=colTemp) ) + { + layerTemp=layer;rowTemp=key.row;colTemp=key.col; + keycodeTemp=keycode_at_keymap_location(layer, key.row, key.col); + } + return keycodeTemp; + //return keycode_at_keymap_location(layer, key.row, key.col); } #ifdef ENCODER_MAP_ENABLE else if (key.row == KEYLOC_ENCODER_CW && key.col < NUM_ENCODERS) {