Export smooth scroll settings as an XInput property.

A new property "Evdev Scrolling Distance" is created that holds three values
(vertical, horizontal and dial).

Signed-off-by: Peter De Wachter <pdewacht@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:
Peter De Wachter
2012-10-03 22:08:12 +02:00
committed by Peter Hutterer
parent c3251deb4b
commit d171b3d919
3 changed files with 77 additions and 16 deletions

View File

@@ -87,4 +87,8 @@
*/
#define EVDEV_PROP_FUNCTION_KEYS "Evdev Function Keys"
/* Smooth scroll */
/* INT32, 3 values (vertical, horizontal, dial) */
#define EVDEV_PROP_SCROLL_DISTANCE "Evdev Scrolling Distance"
#endif

View File

@@ -229,14 +229,15 @@ need quirks.
.TP 7
.BI "Option \*qVertScrollDelta\*q \*q" integer \*q
The amount of motion considered one unit of scrolling vertically.
Default: "1".
Default: "1". Property: "Evdev Scrolling Distance".
.TP 7
.BI "Option \*qHorizScrollDelta\*q \*q" integer \*q
The amount of motion considered one unit of scrolling horizontally.
Default: "1".
Default: "1". Property: "Evdev Scrolling Distance".
.TP 7
.BI "Option \*qDialDelta\*q \*q" integer \*q
The amount of motion considered one unit of turning the dial. Default: "1".
Property: "Evdev Scrolling Distance".
.SH SUPPORTED PROPERTIES
The following properties are provided by the
@@ -277,6 +278,9 @@ value.
.TP 7
.BI "Evdev Wheel Emulation Timeout"
1 16-bit positive value.
.TP 7
.BI "Evdev Scrolling Distance"
3 32-bit values: vertical, horizontal and dial.
.SH AUTHORS
Kristian Høgsberg, Peter Hutterer

View File

@@ -140,6 +140,7 @@ static Atom prop_axis_label;
static Atom prop_btn_label;
static Atom prop_device;
static Atom prop_virtual;
static Atom prop_scroll_dist;
/* All devices the evdev driver has allocated and knows about.
* MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK)
@@ -1619,6 +1620,42 @@ out:
return !Success;
}
static int
EvdevSetScrollValuators(DeviceIntPtr device)
{
#ifdef HAVE_SMOOTH_SCROLLING
InputInfoPtr pInfo;
EvdevPtr pEvdev;
int axnum;
pInfo = device->public.devicePrivate;
pEvdev = pInfo->private;
axnum = pEvdev->rel_axis_map[REL_WHEEL];
if (axnum != -1) {
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
-pEvdev->smoothScroll.vert_delta,
SCROLL_FLAG_PREFERRED);
}
axnum = pEvdev->rel_axis_map[REL_DIAL];
if (axnum != -1) {
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
-pEvdev->smoothScroll.dial_delta,
SCROLL_FLAG_NONE);
}
axnum = pEvdev->rel_axis_map[REL_HWHEEL];
if (axnum != -1) {
SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL,
pEvdev->smoothScroll.horiz_delta,
SCROLL_FLAG_NONE);
}
#endif
return Success;
}
static int
EvdevAddRelValuatorClass(DeviceIntPtr device)
{
@@ -1703,22 +1740,10 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
xf86InitValuatorAxisStruct(device, axnum, atoms[axnum], -1, -1, 1, 0, 1,
Relative);
xf86InitValuatorDefaults(device, axnum);
#ifdef HAVE_SMOOTH_SCROLLING
if (axis == REL_WHEEL)
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
-pEvdev->smoothScroll.vert_delta,
SCROLL_FLAG_PREFERRED);
else if (axis == REL_DIAL)
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
-pEvdev->smoothScroll.dial_delta,
SCROLL_FLAG_NONE);
else if (axis == REL_HWHEEL)
SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL,
pEvdev->smoothScroll.horiz_delta,
SCROLL_FLAG_NONE);
#endif
}
EvdevSetScrollValuators(device);
free(atoms);
return Success;
@@ -2917,6 +2942,22 @@ EvdevInitProperty(DeviceIntPtr dev)
PropModeReplace, pEvdev->num_buttons, atoms, FALSE);
XISetDevicePropertyDeletable(dev, prop_btn_label, FALSE);
}
#ifdef HAVE_SMOOTH_SCROLLING
{
int smooth_scroll_values[3] = {
pEvdev->smoothScroll.vert_delta,
pEvdev->smoothScroll.horiz_delta,
pEvdev->smoothScroll.dial_delta
};
prop_scroll_dist = MakeAtom(EVDEV_PROP_SCROLL_DISTANCE,
strlen(EVDEV_PROP_SCROLL_DISTANCE), TRUE);
XIChangeDeviceProperty(dev, prop_scroll_dist, XA_INTEGER, 32,
PropModeReplace, 3, smooth_scroll_values, FALSE);
XISetDevicePropertyDeletable(dev, prop_scroll_dist, FALSE);
}
#endif
}
}
@@ -2956,6 +2997,18 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
if (!checkonly)
pEvdev->swap_axes = *((BOOL*)val->data);
} else if (atom == prop_scroll_dist)
{
if (val->format != 32 || val->type != XA_INTEGER || val->size != 3)
return BadMatch;
if (!checkonly) {
int *data = (int *)val->data;
pEvdev->smoothScroll.vert_delta = data[0];
pEvdev->smoothScroll.horiz_delta = data[1];
pEvdev->smoothScroll.dial_delta = data[2];
EvdevSetScrollValuators(dev);
}
} else if (atom == prop_axis_label || atom == prop_btn_label ||
atom == prop_product_id || atom == prop_device ||
atom == prop_virtual)