mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 14:48:09 +02:00
evdev: allow for multiple LIBINPUT_MODEL_* flags per device
On some devices we need to set more than one flag, i.e. make it into actual flags. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Hallelujah-expressed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
f5abded2e5
commit
aacf40341d
5 changed files with 30 additions and 42 deletions
|
|
@ -641,22 +641,19 @@ static enum libinput_config_click_method
|
||||||
tp_click_get_default_method(struct tp_dispatch *tp)
|
tp_click_get_default_method(struct tp_dispatch *tp)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = tp->device;
|
struct evdev_device *device = tp->device;
|
||||||
|
uint32_t clickfinger_models = EVDEV_MODEL_CHROMEBOOK |
|
||||||
|
EVDEV_MODEL_SYSTEM76_BONOBO |
|
||||||
|
EVDEV_MODEL_SYSTEM76_GALAGO |
|
||||||
|
EVDEV_MODEL_SYSTEM76_KUDU |
|
||||||
|
EVDEV_MODEL_CLEVO_W740SU;
|
||||||
|
|
||||||
if (!tp->buttons.is_clickpad)
|
if (!tp->buttons.is_clickpad)
|
||||||
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
||||||
else if (libevdev_get_id_vendor(tp->device->evdev) == VENDOR_ID_APPLE)
|
else if (libevdev_get_id_vendor(tp->device->evdev) == VENDOR_ID_APPLE)
|
||||||
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
|
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
|
||||||
|
|
||||||
switch (device->model) {
|
if (device->model_flags & clickfinger_models)
|
||||||
case EVDEV_MODEL_CHROMEBOOK:
|
|
||||||
case EVDEV_MODEL_SYSTEM76_BONOBO:
|
|
||||||
case EVDEV_MODEL_SYSTEM76_GALAGO:
|
|
||||||
case EVDEV_MODEL_SYSTEM76_KUDU:
|
|
||||||
case EVDEV_MODEL_CLEVO_W740SU:
|
|
||||||
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
|
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
return LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||||
}
|
}
|
||||||
|
|
@ -688,7 +685,7 @@ tp_init_middlebutton_emulation(struct tp_dispatch *tp,
|
||||||
if (!libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE)) {
|
if (!libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE)) {
|
||||||
enable_by_default = true;
|
enable_by_default = true;
|
||||||
want_config_option = false;
|
want_config_option = false;
|
||||||
} else if (device->model == EVDEV_MODEL_ALPS_TOUCHPAD) {
|
} else if (device->model_flags & EVDEV_MODEL_ALPS_TOUCHPAD) {
|
||||||
enable_by_default = true;
|
enable_by_default = true;
|
||||||
want_config_option = true;
|
want_config_option = true;
|
||||||
} else
|
} else
|
||||||
|
|
|
||||||
|
|
@ -1224,7 +1224,7 @@ evdev_tag_touchpad(struct evdev_device *device,
|
||||||
*/
|
*/
|
||||||
bustype = libevdev_get_id_bustype(device->evdev);
|
bustype = libevdev_get_id_bustype(device->evdev);
|
||||||
if (bustype == BUS_USB) {
|
if (bustype == BUS_USB) {
|
||||||
if (device->model == EVDEV_MODEL_APPLE_TOUCHPAD)
|
if (device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD)
|
||||||
device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
|
device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
|
||||||
} else if (bustype != BUS_BLUETOOTH)
|
} else if (bustype != BUS_BLUETOOTH)
|
||||||
device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
|
device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
|
||||||
|
|
@ -1350,14 +1350,10 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal)
|
||||||
tp->accel.x_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_x;
|
tp->accel.x_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_x;
|
||||||
tp->accel.y_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_y;
|
tp->accel.y_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_y;
|
||||||
|
|
||||||
switch (tp->device->model) {
|
if (tp->device->model_flags & EVDEV_MODEL_LENOVO_X230)
|
||||||
case EVDEV_MODEL_LENOVO_X230:
|
|
||||||
profile = touchpad_lenovo_x230_accel_profile;
|
profile = touchpad_lenovo_x230_accel_profile;
|
||||||
break;
|
else
|
||||||
default:
|
|
||||||
profile = touchpad_accel_profile_linear;
|
profile = touchpad_accel_profile_linear;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evdev_device_init_pointer_acceleration(tp->device, profile) == -1)
|
if (evdev_device_init_pointer_acceleration(tp->device, profile) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1460,7 +1456,7 @@ tp_init_palmdetect(struct tp_dispatch *tp,
|
||||||
|
|
||||||
/* Wacom doesn't have internal touchpads,
|
/* Wacom doesn't have internal touchpads,
|
||||||
* Apple touchpads are always big enough to warrant palm detection */
|
* Apple touchpads are always big enough to warrant palm detection */
|
||||||
if (device->model == EVDEV_MODEL_WACOM_TOUCHPAD)
|
if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Enable palm detection on touchpads >= 70 mm. Anything smaller
|
/* Enable palm detection on touchpads >= 70 mm. Anything smaller
|
||||||
|
|
|
||||||
11
src/evdev.c
11
src/evdev.c
|
|
@ -1525,8 +1525,8 @@ evdev_read_dpi_prop(struct evdev_device *device)
|
||||||
return dpi;
|
return dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline enum evdev_device_model
|
static inline uint32_t
|
||||||
evdev_read_model(struct evdev_device *device)
|
evdev_read_model_flags(struct evdev_device *device)
|
||||||
{
|
{
|
||||||
const struct model_map {
|
const struct model_map {
|
||||||
const char *property;
|
const char *property;
|
||||||
|
|
@ -1544,15 +1544,16 @@ evdev_read_model(struct evdev_device *device)
|
||||||
{ NULL, EVDEV_MODEL_DEFAULT },
|
{ NULL, EVDEV_MODEL_DEFAULT },
|
||||||
};
|
};
|
||||||
const struct model_map *m = model_map;
|
const struct model_map *m = model_map;
|
||||||
|
uint32_t model_flags = 0;
|
||||||
|
|
||||||
while (m->property) {
|
while (m->property) {
|
||||||
if (!!udev_device_get_property_value(device->udev_device,
|
if (!!udev_device_get_property_value(device->udev_device,
|
||||||
m->property))
|
m->property))
|
||||||
break;
|
model_flags |= m->model;
|
||||||
m++;
|
m++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m->model;
|
return model_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
@ -2146,7 +2147,7 @@ evdev_device_create(struct libinput_seat *seat,
|
||||||
device->scroll.direction = 0;
|
device->scroll.direction = 0;
|
||||||
device->scroll.wheel_click_angle =
|
device->scroll.wheel_click_angle =
|
||||||
evdev_read_wheel_click_prop(device);
|
evdev_read_wheel_click_prop(device);
|
||||||
device->model = evdev_read_model(device);
|
device->model_flags = evdev_read_model_flags(device);
|
||||||
device->dpi = DEFAULT_MOUSE_DPI;
|
device->dpi = DEFAULT_MOUSE_DPI;
|
||||||
|
|
||||||
/* at most 5 SYN_DROPPED log-messages per 30s */
|
/* at most 5 SYN_DROPPED log-messages per 30s */
|
||||||
|
|
|
||||||
22
src/evdev.h
22
src/evdev.h
|
|
@ -95,16 +95,16 @@ enum evdev_middlebutton_event {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum evdev_device_model {
|
enum evdev_device_model {
|
||||||
EVDEV_MODEL_DEFAULT,
|
EVDEV_MODEL_DEFAULT = 0,
|
||||||
EVDEV_MODEL_LENOVO_X230,
|
EVDEV_MODEL_LENOVO_X230 = (1 << 0),
|
||||||
EVDEV_MODEL_CHROMEBOOK,
|
EVDEV_MODEL_CHROMEBOOK = (1 << 1),
|
||||||
EVDEV_MODEL_SYSTEM76_BONOBO,
|
EVDEV_MODEL_SYSTEM76_BONOBO = (1 << 2),
|
||||||
EVDEV_MODEL_SYSTEM76_GALAGO,
|
EVDEV_MODEL_SYSTEM76_GALAGO = (1 << 3),
|
||||||
EVDEV_MODEL_SYSTEM76_KUDU,
|
EVDEV_MODEL_SYSTEM76_KUDU = (1 << 4),
|
||||||
EVDEV_MODEL_CLEVO_W740SU,
|
EVDEV_MODEL_CLEVO_W740SU = (1 << 5),
|
||||||
EVDEV_MODEL_APPLE_TOUCHPAD,
|
EVDEV_MODEL_APPLE_TOUCHPAD = (1 << 6),
|
||||||
EVDEV_MODEL_WACOM_TOUCHPAD,
|
EVDEV_MODEL_WACOM_TOUCHPAD = (1 << 7),
|
||||||
EVDEV_MODEL_ALPS_TOUCHPAD,
|
EVDEV_MODEL_ALPS_TOUCHPAD = (1 << 8),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mt_slot {
|
struct mt_slot {
|
||||||
|
|
@ -221,7 +221,7 @@ struct evdev_device {
|
||||||
int dpi; /* HW resolution */
|
int dpi; /* HW resolution */
|
||||||
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
|
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
|
||||||
|
|
||||||
enum evdev_device_model model;
|
uint32_t model_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
|
#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
|
||||||
|
|
|
||||||
|
|
@ -25,18 +25,12 @@ KERNELS=="*input*", \
|
||||||
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:fwversion:$env{LIBINPUT_MODEL_FIRMWARE_VERSION}'"
|
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:fwversion:$env{LIBINPUT_MODEL_FIRMWARE_VERSION}'"
|
||||||
# End of touchpad firmware detection
|
# End of touchpad firmware detection
|
||||||
|
|
||||||
# Matches below are exclusive, if one matches we skip the rest
|
|
||||||
# hwdb matches:
|
|
||||||
#
|
|
||||||
# libinput:touchpad:<modalias>
|
# libinput:touchpad:<modalias>
|
||||||
ENV{ID_INPUT_TOUCHPAD}=="1", \
|
ENV{ID_INPUT_TOUCHPAD}=="1", \
|
||||||
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:", \
|
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:"
|
||||||
GOTO="libinput_model_quirks_end"
|
|
||||||
|
|
||||||
# libinput:name:<name>:dmi:<dmi string>
|
# libinput:name:<name>:dmi:<dmi string>
|
||||||
KERNELS=="input*", \
|
KERNELS=="input*", \
|
||||||
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'", \
|
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'"
|
||||||
GOTO="libinput_model_quirks_end"
|
|
||||||
|
|
||||||
|
|
||||||
LABEL="libinput_model_quirks_end"
|
LABEL="libinput_model_quirks_end"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue