swayfx/sway/commands/seat/keyboard_grouping.c
Brian Ashworth 5d882cb5fc Add support for wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. This is useful for keyboards that
are split into multiple input devices despite appearing as one physical
keyboard in the user's mind.

This adds support for wlr_keyboard_groups to sway. There are two
keyboard groupings currently supported, which can be set on a per-seat
basis. The first keyboard grouping is none, which disables all grouping
and provides no functional change. The second is keymap, which groups
the keyboard devices in the seat by their keymap. With this grouping,
the effective layout and repeat info is also synced across keyboard
devices in the seat. Device specific bindings will still be executed as
normal, but everything else related to key and modifier events will be
handled by the keyboard group's keyboard.
2019-11-21 10:42:10 -05:00

27 lines
827 B
C

#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "stringop.h"
struct cmd_results *seat_cmd_keyboard_grouping(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "keyboard_grouping", EXPECTED_EQUAL_TO, 1))) {
return error;
}
if (!config->handler_context.seat_config) {
return cmd_results_new(CMD_INVALID, "No seat defined");
}
struct seat_config *seat_config = config->handler_context.seat_config;
if (strcmp(argv[0], "none") == 0) {
seat_config->keyboard_grouping = KEYBOARD_GROUP_NONE;
} else if (strcmp(argv[0], "keymap") == 0) {
seat_config->keyboard_grouping = KEYBOARD_GROUP_KEYMAP;
} else {
return cmd_results_new(CMD_INVALID,
"Expected syntax `keyboard_grouping none|keymap`");
}
return cmd_results_new(CMD_SUCCESS, NULL);
}