{
struct tp_dispatch *tp = (struct tp_dispatch *)device->dispatch;
- if (device->buttons.want_left_handed == device->buttons.left_handed)
+ if (device->left_handed.want_enabled == device->left_handed.enabled)
return;
if (tp->buttons.state & 0x3) /* BTN_LEFT|BTN_RIGHT */
/* tapping and clickfinger aren't affected by left-handed config,
* so checking physical buttons is enough */
- device->buttons.left_handed = device->buttons.want_left_handed;
+ device->left_handed.enabled = device->left_handed.want_enabled;
}
struct model_lookup_t {
pointer_notify_button(&device->base, time, button, state);
if (state == LIBINPUT_BUTTON_STATE_RELEASED &&
- device->buttons.change_to_left_handed)
- device->buttons.change_to_left_handed(device);
+ device->left_handed.change_to_enabled)
+ device->left_handed.change_to_enabled(device);
if (state == LIBINPUT_BUTTON_STATE_RELEASED &&
device->scroll.change_scroll_method)
static void
evdev_change_to_left_handed(struct evdev_device *device)
{
- if (device->buttons.want_left_handed == device->buttons.left_handed)
+ if (device->left_handed.want_enabled == device->left_handed.enabled)
return;
if (evdev_any_button_down(device))
return;
- device->buttons.left_handed = device->buttons.want_left_handed;
+ device->left_handed.enabled = device->left_handed.want_enabled;
}
static enum libinput_config_status
{
struct evdev_device *evdev_device = (struct evdev_device *)device;
- evdev_device->buttons.want_left_handed = left_handed ? true : false;
+ evdev_device->left_handed.want_enabled = left_handed ? true : false;
- evdev_device->buttons.change_to_left_handed(evdev_device);
+ evdev_device->left_handed.change_to_enabled(evdev_device);
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
/* return the wanted configuration, even if it hasn't taken
* effect yet! */
- return evdev_device->buttons.want_left_handed;
+ return evdev_device->left_handed.want_enabled;
}
static int
evdev_init_left_handed(struct evdev_device *device,
void (*change_to_left_handed)(struct evdev_device *))
{
- device->buttons.config_left_handed.has = evdev_left_handed_has;
- device->buttons.config_left_handed.set = evdev_left_handed_set;
- device->buttons.config_left_handed.get = evdev_left_handed_get;
- device->buttons.config_left_handed.get_default = evdev_left_handed_get_default;
- device->base.config.left_handed = &device->buttons.config_left_handed;
- device->buttons.left_handed = false;
- device->buttons.want_left_handed = false;
- device->buttons.change_to_left_handed = change_to_left_handed;
+ device->left_handed.config.has = evdev_left_handed_has;
+ device->left_handed.config.set = evdev_left_handed_set;
+ device->left_handed.config.get = evdev_left_handed_get;
+ device->left_handed.config.get_default = evdev_left_handed_get_default;
+ device->base.config.left_handed = &device->left_handed.config;
+ device->left_handed.enabled = false;
+ device->left_handed.want_enabled = false;
+ device->left_handed.change_to_enabled = change_to_left_handed;
return 0;
}
dispatch->interface = &fallback_interface;
- if (evdev_device->buttons.want_left_handed &&
+ if (evdev_device->left_handed.want_enabled &&
evdev_init_left_handed(evdev_device,
evdev_change_to_left_handed) == -1) {
free(dispatch);
has_button ? " button" : "");
/* want left-handed config option */
- device->buttons.want_left_handed = true;
+ device->left_handed.want_enabled = true;
/* want natural-scroll config option */
device->scroll.natural_scrolling_enabled = true;
}
uint8_t key_count[KEY_CNT];
struct {
- struct libinput_device_config_left_handed config_left_handed;
+ struct libinput_device_config_left_handed config;
/* left-handed currently enabled */
- bool left_handed;
+ bool enabled;
/* set during device init if we want left_handed config,
* used at runtime to delay the effect until buttons are up */
- bool want_left_handed;
+ bool want_enabled;
/* Checks if buttons are down and commits the setting */
- void (*change_to_left_handed)(struct evdev_device *device);
- } buttons;
+ void (*change_to_enabled)(struct evdev_device *device);
+ } left_handed;
int dpi; /* HW resolution */
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
evdev_to_left_handed(struct evdev_device *device,
uint32_t button)
{
- if (device->buttons.left_handed) {
+ if (device->left_handed.enabled) {
if (button == BTN_LEFT)
return BTN_RIGHT;
else if (button == BTN_RIGHT)
}
LIBINPUT_EXPORT int
-libinput_device_config_buttons_has_left_handed(struct libinput_device *device)
+libinput_device_config_left_handed_is_available(struct libinput_device *device)
{
if (!device->config.left_handed)
return 0;
}
LIBINPUT_EXPORT enum libinput_config_status
-libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
- int left_handed)
+libinput_device_config_left_handed_set(struct libinput_device *device,
+ int left_handed)
{
- if (!libinput_device_config_buttons_has_left_handed(device))
+ if (!libinput_device_config_left_handed_is_available(device))
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
return device->config.left_handed->set(device, left_handed);
}
LIBINPUT_EXPORT int
-libinput_device_config_buttons_get_left_handed(struct libinput_device *device)
+libinput_device_config_left_handed_get(struct libinput_device *device)
{
- if (!libinput_device_config_buttons_has_left_handed(device))
+ if (!libinput_device_config_left_handed_is_available(device))
return 0;
return device->config.left_handed->get(device);
}
LIBINPUT_EXPORT int
-libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device)
+libinput_device_config_left_handed_get_default(struct libinput_device *device)
{
- if (!libinput_device_config_buttons_has_left_handed(device))
+ if (!libinput_device_config_left_handed_is_available(device))
return 0;
return device->config.left_handed->get_default(device);
/**
* @ingroup config
*
- * Check if a device has a button configuration that supports left-handed
- * usage.
+ * Check if a device has a configuration that supports left-handed usage.
*
* @param device The device to configure
* @return Non-zero if the device can be set to left-handed, or zero
* otherwise
*
- * @see libinput_device_config_buttons_set_left_handed
- * @see libinput_device_config_buttons_get_left_handed
- * @see libinput_device_config_buttons_get_default_left_handed
+ * @see libinput_device_config_left_handed_set
+ * @see libinput_device_config_left_handed_get
+ * @see libinput_device_config_left_handed_get_default
*/
int
-libinput_device_config_buttons_has_left_handed(struct libinput_device *device);
+libinput_device_config_left_handed_is_available(struct libinput_device *device);
/**
* @ingroup config
*
- * Set the left-handed configuration of the device. A device in left-handed
- * mode sends a left button event instead of the right button and vice
- * versa.
+ * Set the left-handed configuration of the device. For example, a pointing
+ * device may reverse it's buttons and send a right button click when the
+ * left button is pressed, and vice versa.
*
- * The exact button behavior is device-dependent. On a mouse and most
- * pointing devices, left and right buttons are swapped but the middle
- * button is unmodified. On a touchpad, physical buttons (if present) are
- * swapped. On a clickpad, the top and bottom software-emulated buttons are
- * swapped where present, the main area of the touchpad remains a left
- * button. Tapping and clickfinger behavior is not affected by this setting.
+ * The exact behavior is device-dependent. On a mouse and most pointing
+ * devices, left and right buttons are swapped but the middle button is
+ * unmodified. On a touchpad, physical buttons (if present) are swapped. On a
+ * clickpad, the top and bottom software-emulated buttons are swapped where
+ * present, the main area of the touchpad remains a left button. Tapping and
+ * clickfinger behavior is not affected by this setting.
*
* Changing the left-handed configuration of a device may not take effect
* until all buttons have been logically released.
* @param left_handed Zero to disable, non-zero to enable left-handed mode
* @return A configuration status code
*
- * @see libinput_device_config_buttons_has_left_handed
- * @see libinput_device_config_buttons_get_left_handed
- * @see libinput_device_config_buttons_get_default_left_handed
+ * @see libinput_device_config_left_handed_is_available
+ * @see libinput_device_config_left_handed_get
+ * @see libinput_device_config_left_handed_get_default
*/
enum libinput_config_status
-libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
- int left_handed);
+libinput_device_config_left_handed_set(struct libinput_device *device,
+ int left_handed);
/**
* @ingroup config
* @return Zero if the device is in right-handed mode, non-zero if the
* device is in left-handed mode
*
- * @see libinput_device_config_buttons_has_left_handed
- * @see libinput_device_config_buttons_set_left_handed
- * @see libinput_device_config_buttons_get_default_left_handed
+ * @see libinput_device_config_left_handed_is_available
+ * @see libinput_device_config_left_handed_set
+ * @see libinput_device_config_left_handed_get_default
*/
int
-libinput_device_config_buttons_get_left_handed(struct libinput_device *device);
+libinput_device_config_left_handed_get(struct libinput_device *device);
/**
* @ingroup config
* @return Zero if the device is in right-handed mode by default, or non-zero
* if the device is in left-handed mode by default
*
- * @see libinput_device_config_buttons_has_left_handed
- * @see libinput_device_config_buttons_set_left_handed
- * @see libinput_device_config_buttons_get_left_handed
+ * @see libinput_device_config_left_handed_is_available
+ * @see libinput_device_config_left_handed_set
+ * @see libinput_device_config_left_handed_get
*/
int
-libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device);
+libinput_device_config_left_handed_get_default(struct libinput_device *device);
/**
* @ingroup config
libinput_device_config_accel_get_speed;
libinput_device_config_accel_is_available;
libinput_device_config_accel_set_speed;
- libinput_device_config_buttons_get_default_left_handed;
- libinput_device_config_buttons_get_left_handed;
- libinput_device_config_buttons_has_left_handed;
- libinput_device_config_buttons_set_left_handed;
+ libinput_device_config_left_handed_get_default;
+ libinput_device_config_left_handed_get;
+ libinput_device_config_left_handed_is_available;
+ libinput_device_config_left_handed_set;
libinput_device_config_calibration_get_default_matrix;
libinput_device_config_calibration_get_matrix;
libinput_device_config_calibration_has_matrix;
struct libinput_device *d = dev->libinput_device;
int rc;
- rc = libinput_device_config_buttons_has_left_handed(d);
+ rc = libinput_device_config_left_handed_is_available(d);
ck_assert_int_ne(rc, 0);
- rc = libinput_device_config_buttons_get_left_handed(d);
+ rc = libinput_device_config_left_handed_get(d);
ck_assert_int_eq(rc, 0);
- rc = libinput_device_config_buttons_get_default_left_handed(d);
+ rc = libinput_device_config_left_handed_get_default(d);
ck_assert_int_eq(rc, 0);
}
END_TEST
struct libinput *li = dev->libinput;
enum libinput_config_status status;
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
libinput_dispatch(li);
/* Change while button is down, expect correct release event */
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_button_click(dev, BTN_LEFT, 0);
litest_button_click(dev, BTN_LEFT, 1);
libinput_dispatch(li);
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
/* No left-handed until all buttons were down */
enum libinput_config_status status;
int rc;
- rc = libinput_device_config_buttons_has_left_handed(d);
+ rc = libinput_device_config_left_handed_is_available(d);
ck_assert_int_eq(rc, 0);
- rc = libinput_device_config_buttons_get_left_handed(d);
+ rc = libinput_device_config_left_handed_get(d);
ck_assert_int_eq(rc, 0);
- rc = libinput_device_config_buttons_get_default_left_handed(d);
+ rc = libinput_device_config_left_handed_get_default(d);
ck_assert_int_eq(rc, 0);
- status = libinput_device_config_buttons_set_left_handed(d, 0);
+ status = libinput_device_config_left_handed_set(d, 0);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
}
END_TEST
struct libinput *li = dev->libinput;
enum libinput_config_status status;
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
struct libinput *li = dev->libinput;
enum libinput_config_status status;
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
struct libinput *li = dev->libinput;
enum libinput_config_status status;
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
libinput_device_config_tap_set_enabled(dev->libinput_device,
LIBINPUT_CONFIG_TAP_ENABLED);
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
libinput_device_config_tap_set_enabled(dev->libinput_device,
LIBINPUT_CONFIG_TAP_ENABLED);
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
litest_button_click(dev, BTN_LEFT, 1);
libinput_dispatch(li);
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_button_click(dev, BTN_LEFT, 0);
litest_button_click(dev, BTN_LEFT, 1);
libinput_dispatch(li);
- status = libinput_device_config_buttons_set_left_handed(d, 0);
+ status = libinput_device_config_left_handed_set(d, 0);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_button_click(dev, BTN_RIGHT, 0);
litest_button_click(dev, BTN_LEFT, 1);
libinput_dispatch(li);
- status = libinput_device_config_buttons_set_left_handed(d, 1);
+ status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_button_click(dev, BTN_LEFT, 0);
litest_button_click(dev, BTN_LEFT, 1);
libinput_dispatch(li);
- status = libinput_device_config_buttons_set_left_handed(d, 0);
+ status = libinput_device_config_left_handed_set(d, 0);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_button_click(dev, BTN_LEFT, 0);
if (libinput_device_config_tap_get_finger_count((dev)))
printf(" tap");
- if (libinput_device_config_buttons_has_left_handed((dev)))
+ if (libinput_device_config_left_handed_is_available((dev)))
printf(" left");
if (libinput_device_config_scroll_has_natural_scroll((dev)))
printf(" scroll-nat");
libinput_device_config_scroll_set_natural_scroll_enabled(device,
options->natural_scroll);
if (options->left_handed != -1)
- libinput_device_config_buttons_set_left_handed(device, options->left_handed);
+ libinput_device_config_left_handed_set(device, options->left_handed);
}