diff --git a/right/src/keymap.c b/right/src/keymap.c index 86e9a71..065afcc 100644 --- a/right/src/keymap.c +++ b/right/src/keymap.c @@ -28,9 +28,9 @@ void SwitchKeymapById(uint8_t index) bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev) { - for (uint8_t i=0; iabbreviationLen == length && strcmp(keymap->abbreviation, abbrev) == 0) { + if (keymap->abbreviationLen == length && memcmp(keymap->abbreviation, abbrev, length) == 0) { SwitchKeymapById(i); return true; } diff --git a/right/src/usb_commands/usb_command_apply_config.c b/right/src/usb_commands/usb_command_apply_config.c index 096e92c..bc337b7 100644 --- a/right/src/usb_commands/usb_command_apply_config.c +++ b/right/src/usb_commands/usb_command_apply_config.c @@ -45,14 +45,8 @@ void UsbCommand_ApplyConfig(void) } // Switch to the keymap of the updated configuration of the same name or the default keymap. - - for (uint8_t keymapId = 0; keymapId < AllKeymapsCount; keymapId++) { - if (AllKeymaps[keymapId].abbreviationLen == oldKeymapAbbreviationLen && - !memcmp(oldKeymapAbbreviation, AllKeymaps[keymapId].abbreviation, oldKeymapAbbreviationLen)) - { - SwitchKeymapById(keymapId); - return; - } + if (SwitchKeymapByAbbreviation(oldKeymapAbbreviationLen, oldKeymapAbbreviation)) { + return; } SwitchKeymapById(DefaultKeymapIndex);