Skip to content

Commit

Permalink
Add keyboard key event
Browse files Browse the repository at this point in the history
+ Triggered on key_press events
+ TODO: decide what data is passed to the callback
+ TODO: decide when the callback is called
  • Loading branch information
sdilts committed Mar 31, 2020
1 parent 907c475 commit b4b02b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions heart/include/hrt/hrt_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ struct hrt_seat {
};

struct hrt_seat_callbacks {
// TODO: these need parameters
void (*button_event)();
void (*wheel_event)();
bool (*keyboard_key_event)();
// TODO: I don't know if we need this event:
// bool (*keyboard_modifier_event)();
};

struct hrt_input {
Expand Down
4 changes: 4 additions & 0 deletions heart/src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ static void seat_handle_key(struct wl_listener *listener, void *data) {

bool handled = false;

if(event->state == WLR_KEY_PRESSED) {
seat->callbacks->keyboard_key_event();
}

if(!handled && event->state == WLR_KEY_PRESSED) {
handled = execute_hardcoded_bindings(server, raw_keysyms, raw_modifiers, raw_keysyms_len);
}
Expand Down
6 changes: 6 additions & 0 deletions heart/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ void output_callback(struct hrt_output *output) {
puts("Output callback called");
}

bool keyboard_callback() {
puts("Keyboard callback called");
return false;
}

static const struct hrt_output_callbacks output_callbacks = {
.output_added = &output_callback,
.output_removed = &output_callback,
Expand All @@ -21,6 +26,7 @@ static const struct hrt_output_callbacks output_callbacks = {
static const struct hrt_seat_callbacks seat_callbacks = {
.button_event = &cursor_callback,
.wheel_event = &cursor_callback,
.keyboard_key_event = &keyboard_callback,
};

int main(int argc, char *argv[]) {
Expand Down

0 comments on commit b4b02b6

Please sign in to comment.