|
|
|
|
@@ -128,11 +128,10 @@ struct xf86libinput {
|
|
|
|
|
uint32_t capabilities;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
int vdist;
|
|
|
|
|
int hdist;
|
|
|
|
|
|
|
|
|
|
double vdist_fraction;
|
|
|
|
|
double hdist_fraction;
|
|
|
|
|
struct scroll_axis {
|
|
|
|
|
int dist;
|
|
|
|
|
double fraction;
|
|
|
|
|
} v, h;
|
|
|
|
|
} scroll;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
@@ -398,7 +397,7 @@ xf86libinput_shared_disable(struct xf86libinput_device *shared_device)
|
|
|
|
|
|
|
|
|
|
libinput_device_set_user_data(device, NULL);
|
|
|
|
|
libinput_path_remove_device(device);
|
|
|
|
|
device = libinput_device_unref(device);
|
|
|
|
|
libinput_device_unref(device);
|
|
|
|
|
shared_device->device = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -461,19 +460,34 @@ xf86libinput_set_area_ratio(struct xf86libinput *driver_data,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns true if the device has one or more of the given capabilities or
|
|
|
|
|
* if the device isn't a subdevice
|
|
|
|
|
*/
|
|
|
|
|
static inline bool
|
|
|
|
|
subdevice_has_capabilities(DeviceIntPtr dev, uint32_t capabilities)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
struct xf86libinput *driver_data = pInfo->private;
|
|
|
|
|
|
|
|
|
|
if (!xf86libinput_is_subdevice(pInfo))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return !!(driver_data->capabilities & capabilities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
|
|
|
|
BOOL checkonly);
|
|
|
|
|
static void
|
|
|
|
|
LibinputInitProperty(DeviceIntPtr dev);
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigSendEvents(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
struct xf86libinput *driver_data = pInfo->private;
|
|
|
|
|
struct libinput_device *device = driver_data->shared_device->device;
|
|
|
|
|
unsigned int scroll_button;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_send_events_get_modes(device) != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED &&
|
|
|
|
|
libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
@@ -481,6 +495,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set SendEventsMode %u\n",
|
|
|
|
|
driver_data->options.sendevents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigNaturalScroll(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_has_natural_scroll(device) &&
|
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(device,
|
|
|
|
|
@@ -488,6 +513,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set NaturalScrolling to %d\n",
|
|
|
|
|
driver_data->options.natural_scrolling);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigAccel(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_accel_is_available(device) &&
|
|
|
|
|
libinput_device_config_accel_set_speed(device,
|
|
|
|
|
@@ -516,6 +552,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
}
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR, "Failed to set profile %s\n", profile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
LibinputApplyConfigTap(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) > 0 &&
|
|
|
|
|
libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
@@ -552,6 +599,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set Tapping Drag to %d\n",
|
|
|
|
|
driver_data->options.tap_drag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigCalibration(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_TOUCH|CAP_TABLET))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_calibration_has_matrix(device) &&
|
|
|
|
|
libinput_device_config_calibration_set_matrix(device,
|
|
|
|
|
@@ -564,6 +622,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
driver_data->options.matrix[4], driver_data->options.matrix[5],
|
|
|
|
|
driver_data->options.matrix[6], driver_data->options.matrix[7],
|
|
|
|
|
driver_data->options.matrix[8]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigLeftHanded(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_left_handed_is_available(device) &&
|
|
|
|
|
libinput_device_config_left_handed_set(device,
|
|
|
|
|
@@ -571,6 +640,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set LeftHanded to %d\n",
|
|
|
|
|
driver_data->options.left_handed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigScrollMethod(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_set_method(device,
|
|
|
|
|
driver_data->options.scroll_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
|
|
|
|
|
@@ -591,12 +671,25 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_get_methods(device) & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
|
|
|
|
|
unsigned int scroll_button;
|
|
|
|
|
|
|
|
|
|
scroll_button = btn_xorg2linux(driver_data->options.scroll_button);
|
|
|
|
|
if (libinput_device_config_scroll_set_button(device, scroll_button) != LIBINPUT_CONFIG_STATUS_SUCCESS)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set ScrollButton to %u\n",
|
|
|
|
|
driver_data->options.scroll_button);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigClickMethod(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_click_set_method(device,
|
|
|
|
|
driver_data->options.click_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
|
|
|
|
|
@@ -614,6 +707,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
"Failed to set click method to %s\n",
|
|
|
|
|
method);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigMiddleEmulation(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_middle_emulation_is_available(device) &&
|
|
|
|
|
libinput_device_config_middle_emulation_set_enabled(device,
|
|
|
|
|
@@ -621,6 +725,17 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set MiddleEmulation to %d\n",
|
|
|
|
|
driver_data->options.middle_emulation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigDisableWhileTyping(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_dwt_is_available(device) &&
|
|
|
|
|
libinput_device_config_dwt_set_enabled(device,
|
|
|
|
|
@@ -628,13 +743,43 @@ LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set DisableWhileTyping to %d\n",
|
|
|
|
|
driver_data->options.disable_while_typing);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputApplyConfigRotation(DeviceIntPtr dev,
|
|
|
|
|
struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_rotation_is_available(device) &&
|
|
|
|
|
libinput_device_config_rotation_set_angle(device, driver_data->options.rotation_angle) != LIBINPUT_CONFIG_STATUS_SUCCESS)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Failed to set RotationAngle to %.2f\n",
|
|
|
|
|
driver_data->options.rotation_angle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
LibinputApplyConfig(DeviceIntPtr dev)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
struct xf86libinput *driver_data = pInfo->private;
|
|
|
|
|
struct libinput_device *device = driver_data->shared_device->device;
|
|
|
|
|
|
|
|
|
|
LibinputApplyConfigSendEvents(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigNaturalScroll(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigAccel(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigTap(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigCalibration(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigLeftHanded(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigScrollMethod(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigClickMethod(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigMiddleEmulation(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigDisableWhileTyping(dev, driver_data, device);
|
|
|
|
|
LibinputApplyConfigRotation(dev, driver_data, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
@@ -790,8 +935,8 @@ xf86libinput_init_pointer(InputInfoPtr pInfo)
|
|
|
|
|
XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y),
|
|
|
|
|
min, max, res * 1000, 0, res * 1000, Relative);
|
|
|
|
|
|
|
|
|
|
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0);
|
|
|
|
|
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0);
|
|
|
|
|
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0);
|
|
|
|
|
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0);
|
|
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
@@ -838,8 +983,8 @@ xf86libinput_init_pointer_absolute(InputInfoPtr pInfo)
|
|
|
|
|
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
|
|
|
|
|
min, max, res * 1000, 0, res * 1000, Absolute);
|
|
|
|
|
|
|
|
|
|
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0);
|
|
|
|
|
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0);
|
|
|
|
|
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0);
|
|
|
|
|
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0);
|
|
|
|
|
|
|
|
|
|
driver_data->has_abs = TRUE;
|
|
|
|
|
|
|
|
|
|
@@ -912,11 +1057,13 @@ xf86libinput_init_touch(InputInfoPtr pInfo)
|
|
|
|
|
{
|
|
|
|
|
DeviceIntPtr dev = pInfo->dev;
|
|
|
|
|
struct xf86libinput *driver_data = pInfo->private;
|
|
|
|
|
struct libinput_device *device = driver_data->shared_device->device;
|
|
|
|
|
int min, max, res;
|
|
|
|
|
unsigned char btnmap[MAX_BUTTONS + 1];
|
|
|
|
|
Atom btnlabels[MAX_BUTTONS];
|
|
|
|
|
Atom axislabels[TOUCHPAD_NUM_AXES];
|
|
|
|
|
int nbuttons = 7;
|
|
|
|
|
int ntouches = TOUCH_MAX_SLOTS;
|
|
|
|
|
|
|
|
|
|
init_button_map(btnmap, ARRAY_SIZE(btnmap));
|
|
|
|
|
init_button_labels(btnlabels, ARRAY_SIZE(btnlabels));
|
|
|
|
|
@@ -940,7 +1087,13 @@ xf86libinput_init_touch(InputInfoPtr pInfo)
|
|
|
|
|
xf86InitValuatorAxisStruct(dev, 1,
|
|
|
|
|
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y),
|
|
|
|
|
min, max, res * 1000, 0, res * 1000, Absolute);
|
|
|
|
|
InitTouchClassDeviceStruct(dev, TOUCH_MAX_SLOTS, XIDirectTouch, 2);
|
|
|
|
|
|
|
|
|
|
#if HAVE_LIBINPUT_TOUCH_COUNT
|
|
|
|
|
ntouches = libinput_device_touch_get_touch_count(device);
|
|
|
|
|
if (ntouches == 0) /* unknown - mtdev */
|
|
|
|
|
ntouches = TOUCH_MAX_SLOTS;
|
|
|
|
|
#endif
|
|
|
|
|
InitTouchClassDeviceStruct(dev, ntouches, XIDirectTouch, 2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1411,40 +1564,58 @@ xf86libinput_handle_key(InputInfoPtr pInfo, struct libinput_event_keyboard *even
|
|
|
|
|
* e.g. a 2 degree click angle requires 8 clicks before a legacy event is
|
|
|
|
|
* sent, but each of those clicks will send XI2.1 smooth scroll data for
|
|
|
|
|
* compatible clients.
|
|
|
|
|
*
|
|
|
|
|
* Starting with kernel v5.0 we should get REL_WHEEL_HI_RES from those
|
|
|
|
|
* devices for the fine-grained scrolling and REL_WHEEL for the normal one,
|
|
|
|
|
* so the use-case above shouldn't matter anymore.
|
|
|
|
|
*/
|
|
|
|
|
static inline double
|
|
|
|
|
get_scroll_fraction(struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_event_pointer *event,
|
|
|
|
|
enum libinput_pointer_axis axis)
|
|
|
|
|
get_wheel_scroll_value(struct xf86libinput *driver_data,
|
|
|
|
|
struct libinput_event_pointer *event,
|
|
|
|
|
enum libinput_pointer_axis axis)
|
|
|
|
|
{
|
|
|
|
|
double *fraction;
|
|
|
|
|
struct scroll_axis *s;
|
|
|
|
|
double f;
|
|
|
|
|
double angle;
|
|
|
|
|
int discrete;
|
|
|
|
|
|
|
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
|
|
|
|
fraction = &driver_data->scroll.hdist_fraction;
|
|
|
|
|
s = &driver_data->scroll.h;
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
|
|
|
|
fraction = &driver_data->scroll.vdist_fraction;
|
|
|
|
|
s = &driver_data->scroll.v;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*fraction != 0.0)
|
|
|
|
|
return *fraction;
|
|
|
|
|
|
|
|
|
|
/* Calculate the angle per single scroll event */
|
|
|
|
|
angle = libinput_event_pointer_get_axis_value(event, axis);
|
|
|
|
|
discrete = libinput_event_pointer_get_axis_value_discrete(event, axis);
|
|
|
|
|
|
|
|
|
|
/* We only need to guess the fraction on the first set of
|
|
|
|
|
* scroll events until a discrete value arrives. Once known, we
|
|
|
|
|
* re-use the fraction until the device goes away.
|
|
|
|
|
*/
|
|
|
|
|
if (s->fraction != 0.0)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* if we get a discrete of 0, assume REL_WHEEL_HI_RES exists and
|
|
|
|
|
* normal scroll events are sent correctly, so skip all the
|
|
|
|
|
* guesswork.
|
|
|
|
|
*/
|
|
|
|
|
if (discrete == 0) {
|
|
|
|
|
s->fraction = 1.0;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate the angle per single scroll event */
|
|
|
|
|
angle /= discrete;
|
|
|
|
|
|
|
|
|
|
/* We only do magic for click angles smaller than 10 degrees */
|
|
|
|
|
if (angle >= 10) {
|
|
|
|
|
*fraction = 1.0;
|
|
|
|
|
return 1.0;
|
|
|
|
|
s->fraction = 1.0;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Figure out something that gets close to 15 degrees (the general
|
|
|
|
|
@@ -1455,9 +1626,10 @@ get_scroll_fraction(struct xf86libinput *driver_data,
|
|
|
|
|
*/
|
|
|
|
|
f = round(15.0/angle);
|
|
|
|
|
|
|
|
|
|
*fraction = f;
|
|
|
|
|
s->fraction = f;
|
|
|
|
|
|
|
|
|
|
return f;
|
|
|
|
|
out:
|
|
|
|
|
return s->dist/s->fraction * discrete;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
|
@@ -1474,11 +1646,7 @@ calculate_axis_value(struct xf86libinput *driver_data,
|
|
|
|
|
|
|
|
|
|
source = libinput_event_pointer_get_axis_source(event);
|
|
|
|
|
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
|
|
|
|
|
double scroll_fraction;
|
|
|
|
|
|
|
|
|
|
value = libinput_event_pointer_get_axis_value_discrete(event, axis);
|
|
|
|
|
scroll_fraction = get_scroll_fraction(driver_data, event, axis);
|
|
|
|
|
value *= driver_data->scroll.vdist/scroll_fraction;
|
|
|
|
|
value = get_wheel_scroll_value(driver_data, event, axis);
|
|
|
|
|
} else {
|
|
|
|
|
value = libinput_event_pointer_get_axis_value(event, axis);
|
|
|
|
|
}
|
|
|
|
|
@@ -1551,7 +1719,7 @@ xf86libinput_handle_touch(InputInfoPtr pInfo,
|
|
|
|
|
if ((driver_data->capabilities & CAP_TOUCH) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
slot = libinput_event_touch_get_slot(event);
|
|
|
|
|
slot = libinput_event_touch_get_seat_slot(event);
|
|
|
|
|
|
|
|
|
|
switch (event_type) {
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
|
|
|
|
@@ -1938,7 +2106,7 @@ static inline DeviceIntPtr
|
|
|
|
|
xf86libinput_find_device_for_tool(InputInfoPtr pInfo,
|
|
|
|
|
struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
struct xf86libinput *dev = pInfo->private;
|
|
|
|
|
struct xf86libinput *dev;
|
|
|
|
|
struct xf86libinput *driver_data = pInfo->private;
|
|
|
|
|
struct xf86libinput_device *shared_device = driver_data->shared_device;
|
|
|
|
|
uint64_t serial = libinput_tablet_tool_get_serial(tool);
|
|
|
|
|
@@ -2538,9 +2706,9 @@ xf86libinput_parse_calibration_option(InputInfoPtr pInfo,
|
|
|
|
|
libinput_device_config_calibration_get_matrix(device, matrix);
|
|
|
|
|
memcpy(matrix_out, matrix, sizeof(matrix));
|
|
|
|
|
|
|
|
|
|
str = xf86CheckStrOption(pInfo->options,
|
|
|
|
|
"CalibrationMatrix",
|
|
|
|
|
NULL);
|
|
|
|
|
str = xf86SetStrOption(pInfo->options,
|
|
|
|
|
"CalibrationMatrix",
|
|
|
|
|
NULL);
|
|
|
|
|
if (!str)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -2768,7 +2936,7 @@ xf86libinput_parse_draglock_option(InputInfoPtr pInfo,
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
|
|
str = xf86CheckStrOption(pInfo->options, "DragLockButtons",NULL);
|
|
|
|
|
str = xf86SetStrOption(pInfo->options, "DragLockButtons", NULL);
|
|
|
|
|
if (draglock_init_from_string(&driver_data->draglock, str) != 0)
|
|
|
|
|
xf86IDrvMsg(pInfo, X_ERROR,
|
|
|
|
|
"Invalid DragLockButtons option: \"%s\"\n",
|
|
|
|
|
@@ -3247,8 +3415,8 @@ xf86libinput_pre_init(InputDriverPtr drv,
|
|
|
|
|
* affect touchpad scroll speed. For wheels it doesn't matter as
|
|
|
|
|
* we're using the discrete value only.
|
|
|
|
|
*/
|
|
|
|
|
driver_data->scroll.vdist = 15;
|
|
|
|
|
driver_data->scroll.hdist = 15;
|
|
|
|
|
driver_data->scroll.v.dist = 15;
|
|
|
|
|
driver_data->scroll.h.dist = 15;
|
|
|
|
|
|
|
|
|
|
if (!is_subdevice) {
|
|
|
|
|
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
|
@@ -3470,13 +3638,13 @@ update_mode_prop_cb(ClientPtr client, pointer closure)
|
|
|
|
|
groups[idx] = mode;
|
|
|
|
|
|
|
|
|
|
driver_data->allow_mode_group_updates = true;
|
|
|
|
|
rc = XIChangeDeviceProperty(pInfo->dev,
|
|
|
|
|
prop_mode_groups,
|
|
|
|
|
XA_INTEGER, 8,
|
|
|
|
|
PropModeReplace,
|
|
|
|
|
val->size,
|
|
|
|
|
groups,
|
|
|
|
|
TRUE);
|
|
|
|
|
XIChangeDeviceProperty(pInfo->dev,
|
|
|
|
|
prop_mode_groups,
|
|
|
|
|
XA_INTEGER, 8,
|
|
|
|
|
PropModeReplace,
|
|
|
|
|
val->size,
|
|
|
|
|
groups,
|
|
|
|
|
TRUE);
|
|
|
|
|
driver_data->allow_mode_group_updates = false;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
@@ -4429,6 +4597,9 @@ LibinputInitTapProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL tap = driver_data->options.tapping;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -4455,6 +4626,9 @@ LibinputInitTapDragProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL drag = driver_data->options.tap_drag;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -4479,6 +4653,9 @@ LibinputInitTapDragLockProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL drag_lock = driver_data->options.tap_drag_lock;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -4504,6 +4681,9 @@ LibinputInitTapButtonmapProperty(DeviceIntPtr dev,
|
|
|
|
|
enum libinput_config_tap_button_map map;
|
|
|
|
|
BOOL data[2] = {0};
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
map = driver_data->options.tap_button_map;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
@@ -4554,6 +4734,9 @@ LibinputInitCalibrationProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
float calibration[9];
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TOUCH|CAP_TABLET))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_calibration_has_matrix(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -4591,6 +4774,9 @@ LibinputInitAccelProperty(DeviceIntPtr dev,
|
|
|
|
|
enum libinput_config_accel_profile profile;
|
|
|
|
|
BOOL profiles[2] = {FALSE};
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device) ||
|
|
|
|
|
driver_data->capabilities & CAP_TABLET)
|
|
|
|
|
return;
|
|
|
|
|
@@ -4678,6 +4864,9 @@ LibinputInitNaturalScrollProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL natural_scroll = driver_data->options.natural_scrolling;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_scroll_has_natural_scroll(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -4760,6 +4949,9 @@ LibinputInitLeftHandedProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL left_handed = driver_data->options.left_handed;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_left_handed_is_available(device) ||
|
|
|
|
|
driver_data->capabilities & CAP_TABLET)
|
|
|
|
|
return;
|
|
|
|
|
@@ -4787,6 +4979,9 @@ LibinputInitScrollMethodsProperty(DeviceIntPtr dev,
|
|
|
|
|
enum libinput_config_scroll_method method;
|
|
|
|
|
BOOL methods[3] = {FALSE};
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
scroll_methods = libinput_device_config_scroll_get_methods(device);
|
|
|
|
|
if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
|
|
|
|
|
return;
|
|
|
|
|
@@ -4874,6 +5069,9 @@ LibinputInitClickMethodsProperty(DeviceIntPtr dev,
|
|
|
|
|
enum libinput_config_click_method method;
|
|
|
|
|
BOOL methods[2] = {FALSE};
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
click_methods = libinput_device_config_click_get_methods(device);
|
|
|
|
|
if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE)
|
|
|
|
|
return;
|
|
|
|
|
@@ -4942,6 +5140,9 @@ LibinputInitMiddleEmulationProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL middle = driver_data->options.middle_emulation;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -4968,6 +5169,9 @@ LibinputInitDisableWhileTypingProperty(DeviceIntPtr dev,
|
|
|
|
|
{
|
|
|
|
|
BOOL dwt = driver_data->options.disable_while_typing;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_dwt_is_available(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -5000,6 +5204,9 @@ LibinputInitModeGroupProperties(DeviceIntPtr dev,
|
|
|
|
|
associations[MAX_BUTTONS] = {0};
|
|
|
|
|
int g, b, r, s;
|
|
|
|
|
|
|
|
|
|
if (!subdevice_has_capabilities(dev, CAP_TABLET_PAD))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
@@ -5133,7 +5340,7 @@ LibinputInitDragLockProperty(DeviceIntPtr dev,
|
|
|
|
|
break;
|
|
|
|
|
case DRAGLOCK_PAIRS:
|
|
|
|
|
sz = draglock_get_pairs(&driver_data->draglock,
|
|
|
|
|
dl_values, sizeof(dl_values));
|
|
|
|
|
dl_values, ARRAY_SIZE(dl_values));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
xf86IDrvMsg(dev->public.devicePrivate,
|
|
|
|
|
@@ -5238,19 +5445,6 @@ LibinputInitTabletAreaRatioProperty(DeviceIntPtr dev,
|
|
|
|
|
2, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
|
subdevice_filter_for_capabilities(DeviceIntPtr dev,
|
|
|
|
|
uint32_t capabilities)
|
|
|
|
|
{
|
|
|
|
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
|
|
|
struct xf86libinput *driver_data = pInfo->private;
|
|
|
|
|
|
|
|
|
|
if (!xf86libinput_is_subdevice(pInfo))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return !(driver_data->capabilities & capabilities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
LibinputInitProperty(DeviceIntPtr dev)
|
|
|
|
|
{
|
|
|
|
|
@@ -5263,35 +5457,21 @@ LibinputInitProperty(DeviceIntPtr dev)
|
|
|
|
|
|
|
|
|
|
prop_float = XIGetKnownProperty("FLOAT");
|
|
|
|
|
|
|
|
|
|
/* On a subdevice, we likely only have a keyboard, so filter out the
|
|
|
|
|
* properties for the capabilities we don't have */
|
|
|
|
|
if (!subdevice_filter_for_capabilities(dev, CAP_POINTER|CAP_TOUCH)) {
|
|
|
|
|
LibinputInitTapProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapDragProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapDragLockProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapButtonmapProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitNaturalScrollProperty(dev, driver_data, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!subdevice_filter_for_capabilities(dev, CAP_TOUCH|CAP_TABLET)) {
|
|
|
|
|
LibinputInitCalibrationProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitLeftHandedProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitAccelProperty(dev, driver_data, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!subdevice_filter_for_capabilities(dev, CAP_POINTER)) {
|
|
|
|
|
LibinputInitScrollMethodsProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitClickMethodsProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitMiddleEmulationProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitRotationAngleProperty(dev, driver_data, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!subdevice_filter_for_capabilities(dev, CAP_TABLET_PAD)) {
|
|
|
|
|
LibinputInitModeGroupProperties(dev, driver_data, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LibinputInitSendEventsProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapDragProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapDragLockProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitTapButtonmapProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitNaturalScrollProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitDisableWhileTypingProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitScrollMethodsProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitClickMethodsProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitMiddleEmulationProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitRotationAngleProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitAccelProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitCalibrationProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitLeftHandedProperty(dev, driver_data, device);
|
|
|
|
|
LibinputInitModeGroupProperties(dev, driver_data, device);
|
|
|
|
|
LibinputInitSendEventsProperty(dev, driver_data, device);
|
|
|
|
|
|
|
|
|
|
/* Device node property, read-only */
|
|
|
|
|
device_node = driver_data->path;
|
|
|
|
|
|