Rename functions for left handed device configurations

Some devices require more than just flipping around the buttons, such as
tablets.
When it comes to devices like tablets, because the position of the palm rest is
on the right, the entire tablet has to be flipped around in order to be usable
by lefties. As such, this requires that we reverse the coordinates of the
tablets in addition to flipping the buttons on the tablet. As such, renaming
these functions so that they aren't specific to devices where only the buttons
are flipped seems appropriate.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Stephen Chandler Paul 2015-01-06 21:20:22 -05:00 committed by Peter Hutterer
parent cb2f2ed613
commit 2af608cf02
11 changed files with 85 additions and 86 deletions

View file

@ -1310,7 +1310,7 @@ tp_change_to_left_handed(struct evdev_device *device)
{
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 */
@ -1319,7 +1319,7 @@ tp_change_to_left_handed(struct evdev_device *device)
/* 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 {

View file

@ -119,8 +119,8 @@ evdev_pointer_notify_button(struct evdev_device *device,
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)
@ -822,13 +822,13 @@ evdev_left_handed_has(struct libinput_device *device)
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
@ -836,9 +836,9 @@ evdev_left_handed_set(struct libinput_device *device, int left_handed)
{
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;
}
@ -850,7 +850,7 @@ evdev_left_handed_get(struct libinput_device *device)
/* 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
@ -863,14 +863,14 @@ 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;
}
@ -1064,7 +1064,7 @@ fallback_dispatch_create(struct libinput_device *device)
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);
@ -1477,7 +1477,7 @@ evdev_configure_device(struct evdev_device *device)
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;
}

View file

@ -144,15 +144,15 @@ struct evdev_device {
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 */
@ -332,7 +332,7 @@ static inline uint32_t
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)

View file

@ -1599,7 +1599,7 @@ libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput
}
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;
@ -1608,28 +1608,28 @@ libinput_device_config_buttons_has_left_handed(struct libinput_device *device)
}
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);

View file

@ -2102,33 +2102,32 @@ libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput
/**
* @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.
@ -2137,13 +2136,13 @@ libinput_device_config_buttons_has_left_handed(struct libinput_device *device);
* @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
@ -2154,12 +2153,12 @@ libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
* @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
@ -2170,12 +2169,12 @@ libinput_device_config_buttons_get_left_handed(struct libinput_device *device);
* @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

View file

@ -7,10 +7,10 @@ global:
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;

View file

@ -577,13 +577,13 @@ START_TEST(pointer_left_handed_defaults)
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
@ -595,7 +595,7 @@ START_TEST(pointer_left_handed)
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);
@ -645,7 +645,7 @@ START_TEST(pointer_left_handed_during_click)
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);
@ -670,7 +670,7 @@ START_TEST(pointer_left_handed_during_click_multiple_buttons)
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 */

View file

@ -408,16 +408,16 @@ START_TEST(touch_no_left_handed)
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

View file

@ -1917,7 +1917,7 @@ START_TEST(touchpad_left_handed)
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);
@ -1962,7 +1962,7 @@ START_TEST(touchpad_left_handed_clickpad)
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);
@ -2013,7 +2013,7 @@ START_TEST(touchpad_left_handed_clickfinger)
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);
@ -2056,7 +2056,7 @@ START_TEST(touchpad_left_handed_tapping)
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);
@ -2087,7 +2087,7 @@ START_TEST(touchpad_left_handed_tapping_2fg)
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);
@ -2123,7 +2123,7 @@ START_TEST(touchpad_left_handed_delayed)
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);
@ -2140,7 +2140,7 @@ START_TEST(touchpad_left_handed_delayed)
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);
@ -2173,7 +2173,7 @@ START_TEST(touchpad_left_handed_clickpad_delayed)
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);
@ -2192,7 +2192,7 @@ START_TEST(touchpad_left_handed_clickpad_delayed)
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);

View file

@ -146,7 +146,7 @@ print_device_notify(struct libinput_event *ev)
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");

View file

@ -262,5 +262,5 @@ tools_device_apply_config(struct libinput_device *device,
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);
}