Skip to content

Commit

Permalink
feat: secondary input handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Otrebor671 committed Oct 28, 2024
1 parent ec70b32 commit abb42d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions firmware/main/modules/keyboard/keyboard_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ static int IDLE_TIMEOUT_S = 30;

static const char* TAG = "keyboard";
static input_callback_t input_callback = NULL;
static input_callback_t secondary_input_callback = NULL;
esp_timer_handle_t idle_timer;
static bool is_idle = false;
static bool lock_input = false;
Expand Down Expand Up @@ -81,6 +82,9 @@ static void button_event_cb(void* arg, void* data) {
return;
}

if (secondary_input_callback) {
secondary_input_callback(button_name, button_event);
}
if (input_callback) {
input_callback(button_name, button_event);
return;
Expand All @@ -90,6 +94,11 @@ static void button_event_cb(void* arg, void* data) {
void keyboard_module_set_input_callback(input_callback_t input_cb) {
input_callback = input_cb;
}

void keyboard_module_set_secondary_input_callback(input_callback_t input_cb) {
secondary_input_callback = input_cb;
}

void keyboard_module_begin() {
#if !defined(CONFIG_KEYBOARD_DEBUG)
esp_log_level_set(TAG, ESP_LOG_NONE);
Expand Down
3 changes: 2 additions & 1 deletion firmware/main/modules/keyboard/keyboard_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ void keyboard_module_reset_idle_timer();

void keyboard_module_set_lock(bool lock);

void keyboard_module_set_input_callback(input_callback_t input_cb);
void keyboard_module_set_input_callback(input_callback_t input_cb);
void keyboard_module_set_secondary_input_callback(input_callback_t input_cb);

0 comments on commit abb42d2

Please sign in to comment.