diff options
-rw-r--r-- | sway/ipc-server.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index bde20931..8d92b919 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -667,20 +667,39 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) { | |||
667 | 667 | ||
668 | json_object_object_add(sb_obj, "event_state_mask", modifiers); | 668 | json_object_object_add(sb_obj, "event_state_mask", modifiers); |
669 | 669 | ||
670 | // TODO: implement bindcode | 670 | json_object *input_codes = json_object_new_array(); |
671 | json_object_object_add(sb_obj, "input_code", json_object_new_int(0)); | 671 | int input_code = 0; |
672 | |||
673 | json_object *symbols = json_object_new_array(); | 672 | json_object *symbols = json_object_new_array(); |
674 | uint32_t keysym; | 673 | json_object *symbol = NULL; |
675 | char buffer[64]; | 674 | |
676 | for (i = 0; i < sb->keys->length; ++i) { | 675 | if (sb->bindcode) { // bindcode: populate input_codes |
677 | keysym = *(uint32_t *)sb->keys->items[i]; | 676 | uint32_t keycode; |
678 | if (xkb_keysym_get_name(keysym, buffer, 64) > 0) { | 677 | for (i = 0; i < sb->keys->length; ++i) { |
679 | json_object_array_add(symbols, json_object_new_string(buffer)); | 678 | keycode = *(uint32_t *)sb->keys->items[i]; |
679 | json_object_array_add(input_codes, json_object_new_int(keycode)); | ||
680 | if (i == 0) { | ||
681 | input_code = keycode; | ||
682 | } | ||
683 | } | ||
684 | } else { // bindsym: populate symbols | ||
685 | uint32_t keysym; | ||
686 | char buffer[64]; | ||
687 | for (i = 0; i < sb->keys->length; ++i) { | ||
688 | keysym = *(uint32_t *)sb->keys->items[i]; | ||
689 | if (xkb_keysym_get_name(keysym, buffer, 64) > 0) { | ||
690 | json_object *str = json_object_new_string(buffer); | ||
691 | json_object_array_add(symbols, str); | ||
692 | if (i == 0) { | ||
693 | symbol = str; | ||
694 | } | ||
695 | } | ||
680 | } | 696 | } |
681 | } | 697 | } |
682 | 698 | ||
699 | json_object_object_add(sb_obj, "input_codes", input_codes); | ||
700 | json_object_object_add(sb_obj, "input_code", json_object_new_int(input_code)); | ||
683 | json_object_object_add(sb_obj, "symbols", symbols); | 701 | json_object_object_add(sb_obj, "symbols", symbols); |
702 | json_object_object_add(sb_obj, "symbol", symbol); | ||
684 | json_object_object_add(sb_obj, "input_type", json_object_new_string("keyboard")); | 703 | json_object_object_add(sb_obj, "input_type", json_object_new_string("keyboard")); |
685 | 704 | ||
686 | ipc_event_binding(sb_obj); | 705 | ipc_event_binding(sb_obj); |