mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 06:50:05 +01:00
tablet: use the AttrPressureRange quirk for tablets too
The Aiptek 8000U has a pressure offset above our default (%5) but no
meaningful way of detecting that. It doesn't provide distance or BTN_TOOL_PEN
either, so our heuristics can't hook onto anything. BTN_TOUCH is set by this
tablet but not at consistent pressure thresholds.
Work around this by shipping a quirk that ups it to 70. Aiptek
re-uses USB IDs because of course they do, so this applies to more than one
device. Let's see what breaks.
Fixes #462
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 72af32c89e)
This commit is contained in:
parent
0e7a92b4c1
commit
86d81a0ac7
2 changed files with 51 additions and 19 deletions
|
|
@ -5,3 +5,10 @@ MatchUdevType=tablet
|
||||||
MatchBus=usb
|
MatchBus=usb
|
||||||
MatchVendor=0x08CA
|
MatchVendor=0x08CA
|
||||||
AttrEventCodeDisable=ABS_TILT_X;ABS_TILT_Y;
|
AttrEventCodeDisable=ABS_TILT_X;ABS_TILT_Y;
|
||||||
|
|
||||||
|
[Aiptek 8000U pressure threshold]
|
||||||
|
MatchUdevType=tablet
|
||||||
|
MatchBus=usb
|
||||||
|
MatchVendor=0x08CA
|
||||||
|
MatchProduct=0x0010
|
||||||
|
AttrPressureRange=70:50
|
||||||
|
|
|
||||||
|
|
@ -1066,6 +1066,49 @@ axis_range_percentage(const struct input_absinfo *a, double percent)
|
||||||
return (a->maximum - a->minimum) * percent/100.0 + a->minimum;
|
return (a->maximum - a->minimum) * percent/100.0 + a->minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
tool_set_pressure_thresholds(struct tablet_dispatch *tablet,
|
||||||
|
struct libinput_tablet_tool *tool)
|
||||||
|
{
|
||||||
|
struct evdev_device *device = tablet->device;
|
||||||
|
const struct input_absinfo *pressure;
|
||||||
|
struct quirks_context *quirks = NULL;
|
||||||
|
struct quirks *q = NULL;
|
||||||
|
struct quirk_range r;
|
||||||
|
int lo = 0, hi = 1;
|
||||||
|
|
||||||
|
tool->pressure_offset = 0;
|
||||||
|
tool->has_pressure_offset = false;
|
||||||
|
|
||||||
|
pressure = libevdev_get_abs_info(device->evdev, ABS_PRESSURE);
|
||||||
|
if (!pressure)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
quirks = evdev_libinput_context(device)->quirks;
|
||||||
|
q = quirks_fetch_for_device(quirks, device->udev_device);
|
||||||
|
|
||||||
|
tool->pressure_offset = pressure->minimum;
|
||||||
|
|
||||||
|
/* 5 and 1% of the pressure range */
|
||||||
|
hi = axis_range_percentage(pressure, 5);
|
||||||
|
lo = axis_range_percentage(pressure, 1);
|
||||||
|
|
||||||
|
if (q && quirks_get_range(q, QUIRK_ATTR_PRESSURE_RANGE, &r)) {
|
||||||
|
if (r.lower >= r.upper) {
|
||||||
|
evdev_log_info(device,
|
||||||
|
"Invalid pressure range, using defaults\n");
|
||||||
|
} else {
|
||||||
|
hi = r.upper;
|
||||||
|
lo = r.lower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
tool->pressure_threshold.upper = hi;
|
||||||
|
tool->pressure_threshold.lower = lo;
|
||||||
|
|
||||||
|
quirks_unref(q);
|
||||||
|
}
|
||||||
|
|
||||||
static struct libinput_tablet_tool *
|
static struct libinput_tablet_tool *
|
||||||
tablet_get_tool(struct tablet_dispatch *tablet,
|
tablet_get_tool(struct tablet_dispatch *tablet,
|
||||||
enum libinput_tablet_tool_type type,
|
enum libinput_tablet_tool_type type,
|
||||||
|
|
@ -1116,8 +1159,6 @@ tablet_get_tool(struct tablet_dispatch *tablet,
|
||||||
/* If we didn't already have the new_tool in our list of tools,
|
/* If we didn't already have the new_tool in our list of tools,
|
||||||
* add it */
|
* add it */
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
const struct input_absinfo *pressure;
|
|
||||||
|
|
||||||
tool = zalloc(sizeof *tool);
|
tool = zalloc(sizeof *tool);
|
||||||
|
|
||||||
*tool = (struct libinput_tablet_tool) {
|
*tool = (struct libinput_tablet_tool) {
|
||||||
|
|
@ -1127,23 +1168,7 @@ tablet_get_tool(struct tablet_dispatch *tablet,
|
||||||
.refcount = 1,
|
.refcount = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
tool->pressure_offset = 0;
|
tool_set_pressure_thresholds(tablet, tool);
|
||||||
tool->has_pressure_offset = false;
|
|
||||||
tool->pressure_threshold.lower = 0;
|
|
||||||
tool->pressure_threshold.upper = 1;
|
|
||||||
|
|
||||||
pressure = libevdev_get_abs_info(tablet->device->evdev,
|
|
||||||
ABS_PRESSURE);
|
|
||||||
if (pressure) {
|
|
||||||
tool->pressure_offset = pressure->minimum;
|
|
||||||
|
|
||||||
/* 5 and 1% of the pressure range */
|
|
||||||
tool->pressure_threshold.upper =
|
|
||||||
axis_range_percentage(pressure, 5);
|
|
||||||
tool->pressure_threshold.lower =
|
|
||||||
axis_range_percentage(pressure, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
tool_set_bits(tablet, tool);
|
tool_set_bits(tablet, tool);
|
||||||
|
|
||||||
list_insert(tool_list, &tool->link);
|
list_insert(tool_list, &tool->link);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue