Commit 522a1dca authored by Peter Hutterer's avatar Peter Hutterer

evdev: switch the model flags to use the quirks directly

Anything that merely requires a once-off check during initialization can just
use the quirks directly, no need to copy them over to the model flags.

Fixes #146Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 8a5c0b98
......@@ -565,7 +565,7 @@ fallback_init_debounce(struct fallback_dispatch *dispatch)
struct evdev_device *device = dispatch->device;
char timer_name[64];
if (device->model_flags & EVDEV_MODEL_BOUNCING_KEYS) {
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_BOUNCING_KEYS)) {
dispatch->debounce.state = DEBOUNCE_STATE_DISABLED;
return;
}
......
......@@ -1301,7 +1301,8 @@ fallback_keyboard_pair_tablet_mode(struct evdev_device *keyboard,
(EVDEV_TAG_TRACKPOINT|EVDEV_TAG_INTERNAL_KEYBOARD)) == 0)
return;
if (keyboard->model_flags & EVDEV_MODEL_TABLET_MODE_NO_SUSPEND)
if (evdev_device_has_model_quirk(keyboard,
QUIRK_MODEL_TABLET_MODE_NO_SUSPEND))
return;
if ((tablet_mode_switch->tags & EVDEV_TAG_TABLET_MODE_SWITCH) == 0)
......
......@@ -615,7 +615,8 @@ tp_init_softbuttons(struct tp_dispatch *tp,
* On touchpads with visible markings we reduce the size of the
* middle button since users have a visual guide.
*/
if (tp->device->model_flags & EVDEV_MODEL_TOUCHPAD_VISIBLE_MARKER) {
if (evdev_device_has_model_quirk(device,
QUIRK_MODEL_TOUCHPAD_VISIBLE_MARKER)) {
mm.x = width/2 - 5; /* 10mm wide */
edges = evdev_device_mm_to_units(device, &mm);
mb_le = edges.x;
......@@ -739,14 +740,13 @@ static enum libinput_config_click_method
tp_click_get_default_method(struct tp_dispatch *tp)
{
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 |
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON;
if (device->model_flags & clickfinger_models)
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_CHROMEBOOK) ||
evdev_device_has_model_quirk(device, QUIRK_MODEL_SYSTEM76_BONOBO) ||
evdev_device_has_model_quirk(device, QUIRK_MODEL_SYSTEM76_GALAGO) ||
evdev_device_has_model_quirk(device, QUIRK_MODEL_SYSTEM76_KUDU) ||
evdev_device_has_model_quirk(device, QUIRK_MODEL_CLEVO_W740SU) ||
evdev_device_has_model_quirk(device, QUIRK_MODEL_APPLE_TOUCHPAD_ONEBUTTON))
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
if (!tp->buttons.is_clickpad)
......@@ -862,7 +862,8 @@ tp_init_middlebutton_emulation(struct tp_dispatch *tp,
if (!libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE)) {
enable_by_default = true;
want_config_option = false;
} else if (device->model_flags & EVDEV_MODEL_ALPS_TOUCHPAD) {
} else if (evdev_device_has_model_quirk(device,
QUIRK_MODEL_ALPS_TOUCHPAD)) {
enable_by_default = true;
want_config_option = true;
} else
......
......@@ -2605,7 +2605,8 @@ evdev_tag_touchpad(struct evdev_device *device,
switch (bustype) {
case BUS_USB:
if (device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD)
if (evdev_device_has_model_quirk(device,
QUIRK_MODEL_APPLE_TOUCHPAD))
evdev_tag_touchpad_internal(device);
break;
case BUS_BLUETOOTH:
......@@ -2756,7 +2757,8 @@ tp_init_slots(struct tp_dispatch *tp,
* for single-finger movement. See fdo bug 91135
*/
if (tp->semi_mt ||
device->model_flags & EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD) {
evdev_device_has_model_quirk(tp->device,
QUIRK_MODEL_HP_PAVILION_DM4_TOUCHPAD)) {
tp->num_slots = 1;
tp->slot = 0;
tp->has_mt = false;
......@@ -2841,7 +2843,7 @@ tp_init_accel(struct tp_dispatch *tp)
tp->accel.y_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_y;
tp->accel.xy_scale_coeff = 1.0 * res_x/res_y;
if (tp->device->model_flags & EVDEV_MODEL_LENOVO_X230 ||
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_LENOVO_X230) ||
tp->device->model_flags & EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81)
filter = create_pointer_accelerator_filter_lenovo_x230(dpi, use_v_avg);
else if (libevdev_get_id_bustype(device->evdev) == BUS_BLUETOOTH)
......@@ -2875,7 +2877,8 @@ tp_scroll_get_methods(struct tp_dispatch *tp)
/* Any movement with more than one finger has random cursor
* jumps. Don't allow for 2fg scrolling on this device, see
* fdo bug 91135 */
if (tp->device->model_flags & EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD)
if (evdev_device_has_model_quirk(tp->device,
QUIRK_MODEL_HP_PAVILION_DM4_TOUCHPAD))
return LIBINPUT_CONFIG_SCROLL_EDGE;
if (tp->ntouches >= 2)
......
......@@ -2105,7 +2105,8 @@ tablet_init(struct tablet_dispatch *tablet,
tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
if (device->model_flags & EVDEV_MODEL_TABLET_NO_PROXIMITY_OUT)
if (evdev_device_has_model_quirk(device,
QUIRK_MODEL_TABLET_NO_PROXIMITY_OUT))
want_proximity_quirk = true;
if (want_proximity_quirk)
......
......@@ -1270,33 +1270,11 @@ evdev_read_model_flags(struct evdev_device *device)
enum evdev_device_model model;
} model_map[] = {
#define MODEL(name) { QUIRK_MODEL_##name, EVDEV_MODEL_##name }
MODEL(LENOVO_X230),
MODEL(CHROMEBOOK),
MODEL(SYSTEM76_BONOBO),
MODEL(SYSTEM76_GALAGO),
MODEL(SYSTEM76_KUDU),
MODEL(CLEVO_W740SU),
MODEL(APPLE_TOUCHPAD),
MODEL(WACOM_TOUCHPAD),
MODEL(ALPS_TOUCHPAD),
MODEL(SYNAPTICS_SERIAL_TOUCHPAD),
MODEL(BOUNCING_KEYS),
MODEL(CYBORG_RAT),
MODEL(HP_STREAM11_TOUCHPAD),
MODEL(LENOVO_T450_TOUCHPAD),
MODEL(TOUCHPAD_VISIBLE_MARKER),
MODEL(TRACKBALL),
MODEL(APPLE_MAGICMOUSE),
MODEL(HP8510_TOUCHPAD),
MODEL(HP6910_TOUCHPAD),
MODEL(HP_ZBOOK_STUDIO_G3),
MODEL(HP_PAVILION_DM4_TOUCHPAD),
MODEL(APPLE_TOUCHPAD_ONEBUTTON),
MODEL(LOGITECH_MARBLE_MOUSE),
MODEL(TABLET_NO_PROXIMITY_OUT),
MODEL(TABLET_NO_TILT),
MODEL(TABLET_MODE_NO_SUSPEND),
MODEL(LENOVO_CARBON_X1_6TH),
MODEL(LENOVO_SCROLLPOINT),
#undef MODEL
{ 0, 0 },
......@@ -1944,7 +1922,7 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
*
* Disable the event codes to avoid stuck buttons.
*/
if (device->model_flags & EVDEV_MODEL_CYBORG_RAT) {
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_CYBORG_RAT)) {
libevdev_disable_event_code(device->evdev, EV_KEY, 0x118);
libevdev_disable_event_code(device->evdev, EV_KEY, 0x119);
libevdev_disable_event_code(device->evdev, EV_KEY, 0x11a);
......@@ -1953,43 +1931,43 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
* emulates a full 2/3 button mouse for us. Ignore anything from the
* ABS interface
*/
if (device->model_flags & EVDEV_MODEL_APPLE_MAGICMOUSE)
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_APPLE_MAGICMOUSE))
libevdev_disable_event_type(device->evdev, EV_ABS);
/* Claims to have double/tripletap but doesn't actually send it
* https://bugzilla.redhat.com/show_bug.cgi?id=1351285 and
* https://bugs.freedesktop.org/show_bug.cgi?id=98538
*/
if (device->model_flags &
(EVDEV_MODEL_HP8510_TOUCHPAD|EVDEV_MODEL_HP6910_TOUCHPAD)) {
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_HP8510_TOUCHPAD) ||
evdev_device_has_model_quirk(device, QUIRK_MODEL_HP6910_TOUCHPAD)) {
libevdev_disable_event_code(device->evdev, EV_KEY, BTN_TOOL_DOUBLETAP);
libevdev_disable_event_code(device->evdev, EV_KEY, BTN_TOOL_TRIPLETAP);
}
/* Touchpad is a clickpad but INPUT_PROP_BUTTONPAD is not set, see
* fdo bug 97147. Remove when RMI4 is commonplace */
if (device->model_flags & EVDEV_MODEL_HP_STREAM11_TOUCHPAD)
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_HP_STREAM11_TOUCHPAD))
libevdev_enable_property(device->evdev,
INPUT_PROP_BUTTONPAD);
/* Touchpad claims to have 4 slots but only ever sends 2
* https://bugs.freedesktop.org/show_bug.cgi?id=98100 */
if (device->model_flags & EVDEV_MODEL_HP_ZBOOK_STUDIO_G3)
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_HP_ZBOOK_STUDIO_G3))
libevdev_set_abs_maximum(device->evdev, ABS_MT_SLOT, 1);
/* Logitech Marble Mouse claims to have a middle button */
if (device->model_flags & EVDEV_MODEL_LOGITECH_MARBLE_MOUSE)
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_LOGITECH_MARBLE_MOUSE))
libevdev_disable_event_code(device->evdev, EV_KEY, BTN_MIDDLE);
/* Aiptek tablets have tilt but don't send events */
if (device->model_flags & EVDEV_MODEL_TABLET_NO_TILT) {
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_TABLET_NO_TILT)) {
libevdev_disable_event_code(device->evdev, EV_ABS, ABS_TILT_X);
libevdev_disable_event_code(device->evdev, EV_ABS, ABS_TILT_Y);
}
/* Lenovo Carbon X1 6th gen sends bogus ABS_MT_TOOL_TYPE events for
* MT_TOOL_PALM */
if (device->model_flags & EVDEV_MODEL_LENOVO_CARBON_X1_6TH)
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_LENOVO_CARBON_X1_6TH))
libevdev_disable_event_code(device->evdev,
EV_ABS,
ABS_MT_TOOL_TYPE);
......
......@@ -36,6 +36,7 @@
#include "libinput-private.h"
#include "timer.h"
#include "filter.h"
#include "quirks.h"
/* The fake resolution value for abs devices without resolution */
#define EVDEV_FAKE_RESOLUTION 1
......@@ -98,38 +99,23 @@ enum evdev_middlebutton_event {
MIDDLEBUTTON_EVENT_ALL_UP,
};
/**
* model flags are used as shortcut for quirks that need to be checked
* multiple times in timing-sensitive paths. For quirks that need to be
* checked only once, use the quirk directly.
*/
enum evdev_device_model {
EVDEV_MODEL_DEFAULT = 0,
EVDEV_MODEL_LENOVO_X230 = (1 << 0),
EVDEV_MODEL_CHROMEBOOK = (1 << 1),
EVDEV_MODEL_SYSTEM76_BONOBO = (1 << 2),
EVDEV_MODEL_SYSTEM76_GALAGO = (1 << 3),
EVDEV_MODEL_SYSTEM76_KUDU = (1 << 4),
EVDEV_MODEL_CLEVO_W740SU = (1 << 5),
EVDEV_MODEL_APPLE_TOUCHPAD = (1 << 6),
EVDEV_MODEL_WACOM_TOUCHPAD = (1 << 7),
EVDEV_MODEL_ALPS_TOUCHPAD = (1 << 8),
EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD = (1 << 9),
EVDEV_MODEL_TEST_DEVICE = (1 << 10),
EVDEV_MODEL_BOUNCING_KEYS = (1 << 11),
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = (1 << 12),
EVDEV_MODEL_LENOVO_CARBON_X1_6TH = (1 << 13),
EVDEV_MODEL_CYBORG_RAT = (1 << 14),
EVDEV_MODEL_HP_STREAM11_TOUCHPAD = (1 << 16),
EVDEV_MODEL_LENOVO_T450_TOUCHPAD = (1 << 17),
EVDEV_MODEL_TOUCHPAD_VISIBLE_MARKER = (1 << 18),
EVDEV_MODEL_TRACKBALL = (1 << 19),
EVDEV_MODEL_APPLE_MAGICMOUSE = (1 << 20),
EVDEV_MODEL_HP8510_TOUCHPAD = (1 << 21),
EVDEV_MODEL_HP6910_TOUCHPAD = (1 << 22),
EVDEV_MODEL_HP_ZBOOK_STUDIO_G3 = (1 << 23),
EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD = (1 << 24),
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = (1 << 25),
EVDEV_MODEL_LOGITECH_MARBLE_MOUSE = (1 << 26),
EVDEV_MODEL_TABLET_NO_PROXIMITY_OUT = (1 << 27),
EVDEV_MODEL_TABLET_NO_TILT = (1 << 29),
EVDEV_MODEL_TABLET_MODE_NO_SUSPEND = (1 << 30),
EVDEV_MODEL_LENOVO_SCROLLPOINT = (1 << 31),
EVDEV_MODEL_WACOM_TOUCHPAD = (1 << 1),
EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD = (1 << 2),
EVDEV_MODEL_LENOVO_T450_TOUCHPAD = (1 << 4),
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = (1 << 5),
EVDEV_MODEL_LENOVO_SCROLLPOINT = (1 << 6),
/* udev tags, not true quirks */
EVDEV_MODEL_TEST_DEVICE = (1 << 20),
EVDEV_MODEL_TRACKBALL = (1 << 21),
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = (1 << 22),
};
enum evdev_button_scroll_state {
......@@ -353,6 +339,30 @@ struct evdev_device *
evdev_device_create(struct libinput_seat *seat,
struct udev_device *device);
static inline struct libinput *
evdev_libinput_context(const struct evdev_device *device)
{
return device->base.seat->libinput;
}
static inline bool
evdev_device_has_model_quirk(struct evdev_device *device,
enum quirk model_quirk)
{
struct quirks_context *quirks;
struct quirks *q;
bool result = false;
assert(quirk_get_name(model_quirk) != NULL);
quirks = evdev_libinput_context(device)->quirks;
q = quirks_fetch_for_device(quirks, device->udev_device);
quirks_get_bool(q, model_quirk, &result);
quirks_unref(q);
return result;
}
void
evdev_transform_absolute(struct evdev_device *device,
struct device_coords *point);
......@@ -693,12 +703,6 @@ evdev_hysteresis(const struct device_coords *in,
return result;
}
static inline struct libinput *
evdev_libinput_context(const struct evdev_device *device)
{
return device->base.seat->libinput;
}
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
static inline void
evdev_log_msg_va(struct evdev_device *device,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment