Skip to content

Commit

Permalink
feat(keymap): Add binding get/set, layer movement
Browse files Browse the repository at this point in the history
* Add keymap API for getting/setting a bindings
  in keymap layers.
* Add layer move support via intemediary ordering array.
* Add settings storage for keymap changes.
  • Loading branch information
petejohanson committed Jul 4, 2024
1 parent 43fb25d commit e1abc20
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 4 deletions.
12 changes: 12 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ rsource "src/split/Kconfig"
#Basic Keyboard Setup
endmenu

menu "Keymaps"

config ZMK_KEYMAP_LAYER_REORDERING
bool "Layer Reordering Support"

config ZMK_KEYMAP_SETTINGS_STORAGE
bool "Settings Save/Load"
depends on SETTINGS
depends on ZMK_BEHAVIOR_LOCAL_IDS

endmenu # Keymaps

rsource "src/studio/Kconfig"

menu "Display/LED Options"
Expand Down
22 changes: 22 additions & 0 deletions app/include/zmk/keymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ int zmk_keymap_layer_toggle(uint8_t layer);
int zmk_keymap_layer_to(uint8_t layer);
const char *zmk_keymap_layer_name(uint8_t layer);

const struct zmk_behavior_binding *zmk_keymap_get_layer_binding_at_idx(uint8_t layer,
uint8_t binding_idx);
int zmk_keymap_set_layer_binding_at_idx(uint8_t layer, uint8_t binding_idx,
const struct zmk_behavior_binding binding);

#if IS_ENABLED(CONFIG_ZMK_KEYMAP_LAYER_REORDERING)

int zmk_keymap_move_layer(uint8_t layer, uint8_t dest);

#endif

/**
* @brief Check if there are any unsaved keymap changes.
*
* @retval 0 if there are no changes.
* @retval 1 if there are changes.
*/
int zmk_keymap_check_unsaved_changes(void);

int zmk_keymap_save_changes(void);
int zmk_keymap_discard_changes(void);

int zmk_keymap_position_state_changed(uint8_t source, uint32_t position, bool pressed,
int64_t timestamp);

Expand Down
Loading

0 comments on commit e1abc20

Please sign in to comment.