Adding OPCODE "Insert Row" to KLM
* Insert Row OPCODE requires a row taken from the provided key * Insert Row will insert provided key if the row insert was successful. * Provide "UNUSED" key for an empty row insert.
This commit is contained in:
parent
a276ceedb3
commit
2777c05907
2 changed files with 51 additions and 1 deletions
|
|
@ -474,6 +474,13 @@ void KeyboardLayoutManager::OpCodeSwitch(key_set change_keys)
|
|||
//SwapKey(change_keys[chg_key_idx]);
|
||||
break;
|
||||
|
||||
case KEYBOARD_OPCODE_INSERT_ROW:
|
||||
if(InsertRow(change_keys[chg_key_idx].row))
|
||||
{
|
||||
SwapKey(change_keys[chg_key_idx]);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEYBOARD_OPCODE_REMOVE_ROW:
|
||||
RemoveRow(change_keys[chg_key_idx].row);
|
||||
break;
|
||||
|
|
@ -733,6 +740,47 @@ void KeyboardLayoutManager::RemoveKey(keyboard_led rmv_key)
|
|||
}
|
||||
}
|
||||
|
||||
bool KeyboardLayoutManager::InsertRow(uint8_t ins_row)
|
||||
{
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Check row is valid to Insert |
|
||||
\*---------------------------------------------------------------------*/
|
||||
if(ins_row >= rows)
|
||||
{
|
||||
LOG_DEBUG("[%s] Inserting row %d failed as rows currently = %d", KLM_CLASS_NAME, ins_row, rows);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Loop through to find the first key in the row to insert |
|
||||
\*---------------------------------------------------------------------*/
|
||||
unsigned int key_idx = 0;
|
||||
|
||||
for(/*key_idx*/; key_idx < keymap.size(); key_idx++)
|
||||
{
|
||||
if(ins_row > keymap[key_idx].row)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] Attempting to insert row %d before %s at index %d",
|
||||
KLM_CLASS_NAME, ins_row, keymap[key_idx].name, key_idx);
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Loop through the remaining rows and adjust row number |
|
||||
\*---------------------------------------------------------------------*/
|
||||
if(ins_row <= keymap[key_idx].row)
|
||||
{
|
||||
for(/*key_idx*/; key_idx < keymap.size(); key_idx++)
|
||||
{
|
||||
keymap[key_idx].row++;
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] Insert row %d successful", KLM_CLASS_NAME, ins_row);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeyboardLayoutManager::RemoveRow(uint8_t rmv_row)
|
||||
{
|
||||
/*---------------------------------------------------------------------*\
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ enum KEYBOARD_OPCODE
|
|||
KEYBOARD_OPCODE_SWAP_ONLY = 1,
|
||||
KEYBOARD_OPCODE_REMOVE_SHIFT_LEFT = 2,
|
||||
KEYBOARD_OPCODE_INS_SHFT_ADJACENT = 3,
|
||||
KEYBOARD_OPCODE_REMOVE_ROW = 4,
|
||||
KEYBOARD_OPCODE_INSERT_ROW = 4,
|
||||
KEYBOARD_OPCODE_REMOVE_ROW = 5,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
|
@ -131,6 +132,7 @@ private:
|
|||
void OpCodeSwitch(key_set change_keys);
|
||||
void InsertKey(keyboard_led key);
|
||||
void InsertKeys(std::vector<keyboard_led> keys);
|
||||
bool InsertRow(uint8_t row);
|
||||
void SwapKey(keyboard_led keys);
|
||||
void SwapKeys(std::vector<keyboard_led> keys);
|
||||
void RemoveKey(keyboard_led keys);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue