mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 08:51:27 +00:00
Implement clickfinger_button_map support.
This commit is contained in:
parent
818ea17389
commit
5be5a50051
|
@ -249,6 +249,7 @@ sway_cmd input_cmd_seat;
|
||||||
sway_cmd input_cmd_accel_profile;
|
sway_cmd input_cmd_accel_profile;
|
||||||
sway_cmd input_cmd_calibration_matrix;
|
sway_cmd input_cmd_calibration_matrix;
|
||||||
sway_cmd input_cmd_click_method;
|
sway_cmd input_cmd_click_method;
|
||||||
|
sway_cmd input_cmd_clickfinger_button_map;
|
||||||
sway_cmd input_cmd_drag;
|
sway_cmd input_cmd_drag;
|
||||||
sway_cmd input_cmd_drag_lock;
|
sway_cmd input_cmd_drag_lock;
|
||||||
sway_cmd input_cmd_dwt;
|
sway_cmd input_cmd_dwt;
|
||||||
|
|
|
@ -149,6 +149,7 @@ struct input_config {
|
||||||
int accel_profile;
|
int accel_profile;
|
||||||
struct calibration_matrix calibration_matrix;
|
struct calibration_matrix calibration_matrix;
|
||||||
int click_method;
|
int click_method;
|
||||||
|
int clickfinger_button_map;
|
||||||
int drag;
|
int drag;
|
||||||
int drag_lock;
|
int drag_lock;
|
||||||
int dwt;
|
int dwt;
|
||||||
|
|
|
@ -11,6 +11,7 @@ static const struct cmd_handler input_handlers[] = {
|
||||||
{ "accel_profile", input_cmd_accel_profile },
|
{ "accel_profile", input_cmd_accel_profile },
|
||||||
{ "calibration_matrix", input_cmd_calibration_matrix },
|
{ "calibration_matrix", input_cmd_calibration_matrix },
|
||||||
{ "click_method", input_cmd_click_method },
|
{ "click_method", input_cmd_click_method },
|
||||||
|
{ "clickfinger_button_map", input_cmd_clickfinger_button_map },
|
||||||
{ "drag", input_cmd_drag },
|
{ "drag", input_cmd_drag },
|
||||||
{ "drag_lock", input_cmd_drag_lock },
|
{ "drag_lock", input_cmd_drag_lock },
|
||||||
{ "dwt", input_cmd_dwt },
|
{ "dwt", input_cmd_dwt },
|
||||||
|
|
27
sway/commands/input/clickfinger_button_map.c
Normal file
27
sway/commands/input/clickfinger_button_map.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
|
struct cmd_results *input_cmd_clickfinger_button_map(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "clickfinger_button_map", EXPECTED_AT_LEAST, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
if (!ic) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "No input device defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(argv[0], "lrm") == 0) {
|
||||||
|
ic->clickfinger_button_map = LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM;
|
||||||
|
} else if (strcasecmp(argv[0], "lmr") == 0) {
|
||||||
|
ic->clickfinger_button_map = LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR;
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
"Expected 'clickfinger_button_map <lrm|lmr>'");
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ struct input_config *new_input_config(const char* identifier) {
|
||||||
input->dwtp = INT_MIN;
|
input->dwtp = INT_MIN;
|
||||||
input->send_events = INT_MIN;
|
input->send_events = INT_MIN;
|
||||||
input->click_method = INT_MIN;
|
input->click_method = INT_MIN;
|
||||||
|
input->clickfinger_button_map = INT_MIN;
|
||||||
input->middle_emulation = INT_MIN;
|
input->middle_emulation = INT_MIN;
|
||||||
input->natural_scroll = INT_MIN;
|
input->natural_scroll = INT_MIN;
|
||||||
input->accel_profile = INT_MIN;
|
input->accel_profile = INT_MIN;
|
||||||
|
@ -55,6 +56,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
|
||||||
if (src->click_method != INT_MIN) {
|
if (src->click_method != INT_MIN) {
|
||||||
dst->click_method = src->click_method;
|
dst->click_method = src->click_method;
|
||||||
}
|
}
|
||||||
|
if (src->clickfinger_button_map != INT_MIN) {
|
||||||
|
dst->clickfinger_button_map = src->clickfinger_button_map;
|
||||||
|
}
|
||||||
if (src->drag != INT_MIN) {
|
if (src->drag != INT_MIN) {
|
||||||
dst->drag = src->drag;
|
dst->drag = src->drag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,16 @@ static bool set_click_method(struct libinput_device *device,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool set_clickfinger_button_map(struct libinput_device *device,
|
||||||
|
enum libinput_config_clickfinger_button_map map) {
|
||||||
|
if (libinput_device_config_click_get_clickfinger_button_map(device) == map) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sway_log(SWAY_DEBUG, "clickfinger_set_button_map(%d)", map);
|
||||||
|
log_status(libinput_device_config_click_set_clickfinger_button_map(device, map));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool set_middle_emulation(struct libinput_device *dev,
|
static bool set_middle_emulation(struct libinput_device *dev,
|
||||||
enum libinput_config_middle_emulation_state mid) {
|
enum libinput_config_middle_emulation_state mid) {
|
||||||
if (!libinput_device_config_middle_emulation_is_available(dev) ||
|
if (!libinput_device_config_middle_emulation_is_available(dev) ||
|
||||||
|
@ -281,6 +291,9 @@ bool sway_input_configure_libinput_device(struct sway_input_device *input_device
|
||||||
if (ic->click_method != INT_MIN) {
|
if (ic->click_method != INT_MIN) {
|
||||||
changed |= set_click_method(device, ic->click_method);
|
changed |= set_click_method(device, ic->click_method);
|
||||||
}
|
}
|
||||||
|
if (ic->clickfinger_button_map != INT_MIN) {
|
||||||
|
changed |= set_clickfinger_button_map(device, ic->clickfinger_button_map);
|
||||||
|
}
|
||||||
if (ic->middle_emulation != INT_MIN) {
|
if (ic->middle_emulation != INT_MIN) {
|
||||||
changed |= set_middle_emulation(device, ic->middle_emulation);
|
changed |= set_middle_emulation(device, ic->middle_emulation);
|
||||||
}
|
}
|
||||||
|
@ -356,6 +369,8 @@ void sway_input_reset_libinput_device(struct sway_input_device *input_device) {
|
||||||
libinput_device_config_left_handed_get_default(device));
|
libinput_device_config_left_handed_get_default(device));
|
||||||
changed |= set_click_method(device,
|
changed |= set_click_method(device,
|
||||||
libinput_device_config_click_get_default_method(device));
|
libinput_device_config_click_get_default_method(device));
|
||||||
|
changed |= set_clickfinger_button_map(device,
|
||||||
|
libinput_device_config_click_get_default_clickfinger_button_map(device));
|
||||||
changed |= set_middle_emulation(device,
|
changed |= set_middle_emulation(device,
|
||||||
libinput_device_config_middle_emulation_get_default_enabled(device));
|
libinput_device_config_middle_emulation_get_default_enabled(device));
|
||||||
changed |= set_scroll_method(device,
|
changed |= set_scroll_method(device,
|
||||||
|
|
|
@ -992,6 +992,18 @@ static json_object *describe_libinput_device(struct libinput_device *device) {
|
||||||
}
|
}
|
||||||
json_object_object_add(object, "click_method",
|
json_object_object_add(object, "click_method",
|
||||||
json_object_new_string(click_method));
|
json_object_new_string(click_method));
|
||||||
|
|
||||||
|
const char *button_map = "unknown";
|
||||||
|
switch (libinput_device_config_click_get_clickfinger_button_map(device)) {
|
||||||
|
case LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM:
|
||||||
|
button_map = "lrm";
|
||||||
|
break;
|
||||||
|
case LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR:
|
||||||
|
button_map = "lmr";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
json_object_object_add(object, "clickfinger_button_map",
|
||||||
|
json_object_new_string(button_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libinput_device_config_middle_emulation_is_available(device)) {
|
if (libinput_device_config_middle_emulation_is_available(device)) {
|
||||||
|
@ -1109,9 +1121,9 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
|
||||||
struct xkb_keymap *keymap = keyboard->keymap;
|
struct xkb_keymap *keymap = keyboard->keymap;
|
||||||
struct xkb_state *state = keyboard->xkb_state;
|
struct xkb_state *state = keyboard->xkb_state;
|
||||||
|
|
||||||
json_object_object_add(object, "repeat_delay",
|
json_object_object_add(object, "repeat_delay",
|
||||||
json_object_new_int(keyboard->repeat_info.delay));
|
json_object_new_int(keyboard->repeat_info.delay));
|
||||||
json_object_object_add(object, "repeat_rate",
|
json_object_object_add(object, "repeat_rate",
|
||||||
json_object_new_int(keyboard->repeat_info.rate));
|
json_object_new_int(keyboard->repeat_info.rate));
|
||||||
|
|
||||||
json_object *layouts_arr = json_object_new_array();
|
json_object *layouts_arr = json_object_new_array();
|
||||||
|
|
|
@ -154,6 +154,7 @@ sway_sources = files(
|
||||||
'commands/input/accel_profile.c',
|
'commands/input/accel_profile.c',
|
||||||
'commands/input/calibration_matrix.c',
|
'commands/input/calibration_matrix.c',
|
||||||
'commands/input/click_method.c',
|
'commands/input/click_method.c',
|
||||||
|
'commands/input/clickfinger_button_map.c',
|
||||||
'commands/input/drag.c',
|
'commands/input/drag.c',
|
||||||
'commands/input/drag_lock.c',
|
'commands/input/drag_lock.c',
|
||||||
'commands/input/dwt.c',
|
'commands/input/dwt.c',
|
||||||
|
|
|
@ -143,6 +143,12 @@ The following commands may only be used in the configuration file.
|
||||||
*input* <identifier> click_method none|button_areas|clickfinger
|
*input* <identifier> click_method none|button_areas|clickfinger
|
||||||
Changes the click method for the specified device.
|
Changes the click method for the specified device.
|
||||||
|
|
||||||
|
*input* <identifier> clickfinger_button_map lrm|lmr
|
||||||
|
Specifies which button mapping to use for clickfinger. _lrm_ treats 1 finger as
|
||||||
|
left click, 2 fingers as right click, and 3 fingers as middle click. _lmr_
|
||||||
|
treats 1 finger as left click, 2 fingers as middle click, and 3 fingers as
|
||||||
|
right click.
|
||||||
|
|
||||||
*input* <identifier> drag enabled|disabled
|
*input* <identifier> drag enabled|disabled
|
||||||
Enables or disables tap-and-drag for specified input device.
|
Enables or disables tap-and-drag for specified input device.
|
||||||
|
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ following properties will be included for devices that support them:
|
||||||
: Whether tap to click is enabled. It can be _enabled_ or _disabled_
|
: Whether tap to click is enabled. It can be _enabled_ or _disabled_
|
||||||
|- tap_button_map
|
|- tap_button_map
|
||||||
: string
|
: string
|
||||||
: The finger to button mapping in use. It can be _lmr_ or _lrm_
|
: The finger to button mapping in use for tapping. It can be _lmr_ or _lrm_
|
||||||
|- tap_drag
|
|- tap_drag
|
||||||
: string
|
: string
|
||||||
: Whether tap-and-drag is enabled. It can be _enabled_ or _disabled_
|
: Whether tap-and-drag is enabled. It can be _enabled_ or _disabled_
|
||||||
|
@ -1190,6 +1190,9 @@ following properties will be included for devices that support them:
|
||||||
|- click_method
|
|- click_method
|
||||||
: string
|
: string
|
||||||
: The click method in use. It can be _none_, _button_areas_, or _clickfinger_
|
: The click method in use. It can be _none_, _button_areas_, or _clickfinger_
|
||||||
|
|- click_button_map
|
||||||
|
: string
|
||||||
|
: The finger to button mapping in use for clickfinger. It can be _lmr_ or _lrm_
|
||||||
|- middle_emulation
|
|- middle_emulation
|
||||||
: string
|
: string
|
||||||
: Whether middle emulation is enabled. It can be _enabled_ or _disabled_
|
: Whether middle emulation is enabled. It can be _enabled_ or _disabled_
|
||||||
|
|
Loading…
Reference in a new issue