xref: /aosp_15_r20/external/libchrome-gestures/docs/gesture_properties.md (revision aed3e5085e770be5b69ce25295ecf6ddf906af95)
1*aed3e508SAndroid Build Coastguard Worker# Gesture Properties
2*aed3e508SAndroid Build Coastguard Worker
3*aed3e508SAndroid Build Coastguard WorkerThe Gestures library has many parameters which affect its operation. Examples
4*aed3e508SAndroid Build Coastguard Workerinclude acceleration curves, whether to reverse the scroll direction, and
5*aed3e508SAndroid Build Coastguard Workerthresholds for determining whether a touch is from a palm or a finger.
6*aed3e508SAndroid Build Coastguard Worker
7*aed3e508SAndroid Build Coastguard WorkerThese parameters are represented by gesture properties, values which can be
8*aed3e508SAndroid Build Coastguard Workerchanged by Chromium (though not always through the settings UI). This document
9*aed3e508SAndroid Build Coastguard Workerdescribes the gesture properties system and how it can be used by developers.
10*aed3e508SAndroid Build Coastguard Worker
11*aed3e508SAndroid Build Coastguard Worker[TOC]
12*aed3e508SAndroid Build Coastguard Worker
13*aed3e508SAndroid Build Coastguard Worker## Property representation
14*aed3e508SAndroid Build Coastguard Worker
15*aed3e508SAndroid Build Coastguard WorkerEach pointing device (touchpad, mouse, etc.) connected to a system has its own
16*aed3e508SAndroid Build Coastguard Workerset of gesture properties. Properties are identified by human-readable names,
17*aed3e508SAndroid Build Coastguard Workersuch as "Scroll Accel Curve", "Mouse Reverse Scrolling", or "Palm Pressure".
18*aed3e508SAndroid Build Coastguard Worker
19*aed3e508SAndroid Build Coastguard WorkerEach property has a type (integer, double, boolean, or string), and a size,
20*aed3e508SAndroid Build Coastguard Workerwhich is the number of values of that type that it stores. (For strings, the
21*aed3e508SAndroid Build Coastguard Workersize is always 1.)
22*aed3e508SAndroid Build Coastguard Worker
23*aed3e508SAndroid Build Coastguard WorkerChromium creates some read-only properties, which normally means that modifying
24*aed3e508SAndroid Build Coastguard Workerthem wouldn't make sense (for example, the "Device Vendor ID" property, which
25*aed3e508SAndroid Build Coastguard Workerreflects a hardware ID). However, the Gestures library itself does not do this,
26*aed3e508SAndroid Build Coastguard Workerso other clients don't need to support them.
27*aed3e508SAndroid Build Coastguard Worker
28*aed3e508SAndroid Build Coastguard Worker## Changing properties without recompiling
29*aed3e508SAndroid Build Coastguard Worker
30*aed3e508SAndroid Build Coastguard WorkerAll properties have default values which are set in source code. These are
31*aed3e508SAndroid Build Coastguard Workersometimes overridden by one of the configuration files in the [xorg-conf
32*aed3e508SAndroid Build Coastguard Workerrepository][xorg-conf] (normally to tune a touchpad or set the resolution for a
33*aed3e508SAndroid Build Coastguard Workermouse). However, since most of the time these are things you want to tweak many
34*aed3e508SAndroid Build Coastguard Workertimes or toggle quickly, it's easiest to change them using the Gesture
35*aed3e508SAndroid Build Coastguard WorkerProperties Service.
36*aed3e508SAndroid Build Coastguard Worker
37*aed3e508SAndroid Build Coastguard Worker[xorg-conf]: https://chromium.googlesource.com/chromiumos/platform/xorg-conf/
38*aed3e508SAndroid Build Coastguard Worker
39*aed3e508SAndroid Build Coastguard Worker### Enabling the Gesture Properties Service
40*aed3e508SAndroid Build Coastguard Worker
41*aed3e508SAndroid Build Coastguard WorkerFirst, enable the service by going to
42*aed3e508SAndroid Build Coastguard Worker`chrome://flags/#gesture-properties-dbus-service` (which has to be typed or
43*aed3e508SAndroid Build Coastguard Workerpasted into the address bar for security reasons), set the "Enable gesture
44*aed3e508SAndroid Build Coastguard Workerproperties service" flag to "Enabled", and restart Chromium. You should only
45*aed3e508SAndroid Build Coastguard Workerhave to do this once per Chromium profile.
46*aed3e508SAndroid Build Coastguard Worker
47*aed3e508SAndroid Build Coastguard Worker### From crosh
48*aed3e508SAndroid Build Coastguard Worker
49*aed3e508SAndroid Build Coastguard WorkerNow that the service is enabled, you can change property values from `crosh`. To
50*aed3e508SAndroid Build Coastguard Workeropen it, press Ctrl+Alt+T.
51*aed3e508SAndroid Build Coastguard Worker
52*aed3e508SAndroid Build Coastguard WorkerTo determine the ID number of the input device you want to change properties
53*aed3e508SAndroid Build Coastguard Workerfor, run `gesture_prop devices` (or `gesture_prop devs` for short). Here's some
54*aed3e508SAndroid Build Coastguard Workerexample output:
55*aed3e508SAndroid Build Coastguard Worker
56*aed3e508SAndroid Build Coastguard Worker```
57*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop devices
58*aed3e508SAndroid Build Coastguard Workermethod return time=1576605764.119024 sender=:1.65 -> destination=:1.77 serial=330 reply_serial=2
59*aed3e508SAndroid Build Coastguard Worker   uint32 1
60*aed3e508SAndroid Build Coastguard Worker   array [
61*aed3e508SAndroid Build Coastguard Worker      dict entry(
62*aed3e508SAndroid Build Coastguard Worker         int32 9
63*aed3e508SAndroid Build Coastguard Worker         string "Atmel maXTouch Touchpad"
64*aed3e508SAndroid Build Coastguard Worker      )
65*aed3e508SAndroid Build Coastguard Worker   ]
66*aed3e508SAndroid Build Coastguard Worker```
67*aed3e508SAndroid Build Coastguard Worker
68*aed3e508SAndroid Build Coastguard WorkerIn this case, there is one input device with gesture properties, the maXTouch
69*aed3e508SAndroid Build Coastguard WorkerTouchpad with ID 9. We can see all of the properties it supports with
70*aed3e508SAndroid Build Coastguard Worker`gesture_prop list 9`:
71*aed3e508SAndroid Build Coastguard Worker
72*aed3e508SAndroid Build Coastguard Worker```
73*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop list 9
74*aed3e508SAndroid Build Coastguard Workermethod return time=1576606086.727507 sender=:1.65 -> destination=:1.81 serial=503 reply_serial=2
75*aed3e508SAndroid Build Coastguard Worker   uint32 205
76*aed3e508SAndroid Build Coastguard Worker   array [
77*aed3e508SAndroid Build Coastguard Worker      string "Two Finger Vertical Close Distance Thresh"
78*aed3e508SAndroid Build Coastguard Worker      string "Two Finger Horizontal Close Distance Thresh"
79*aed3e508SAndroid Build Coastguard Worker      string "Logging Notify"
80*aed3e508SAndroid Build Coastguard Worker      string "Damp Scroll Min Move Factor"
81*aed3e508SAndroid Build Coastguard Worker      string "No-Pinch Certain Ratio"
82*aed3e508SAndroid Build Coastguard Worker      string "Merged Finger Suspicious Angle Min Displacement"
83*aed3e508SAndroid Build Coastguard Worker      string "Merged Finger X Jump Min Disp"
84*aed3e508SAndroid Build Coastguard Worker      string "Finger Merge Maximum Pressure"
85*aed3e508SAndroid Build Coastguard Worker      string "Device Touchpad"
86*aed3e508SAndroid Build Coastguard Worker      string "Merged Finger Max Age"
87*aed3e508SAndroid Build Coastguard Worker      string "Mouse CPI"
88*aed3e508SAndroid Build Coastguard Worker      ...
89*aed3e508SAndroid Build Coastguard Worker      string "Australian Scrolling"
90*aed3e508SAndroid Build Coastguard Worker      ...
91*aed3e508SAndroid Build Coastguard Worker   ]
92*aed3e508SAndroid Build Coastguard Worker```
93*aed3e508SAndroid Build Coastguard Worker
94*aed3e508SAndroid Build Coastguard WorkerLet's find the value of the "Australian Scrolling" property, which determines
95*aed3e508SAndroid Build Coastguard Workerwhether the scrolling direction is inverted:
96*aed3e508SAndroid Build Coastguard Worker
97*aed3e508SAndroid Build Coastguard Worker```
98*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop get 9 "Australian Scrolling"
99*aed3e508SAndroid Build Coastguard Workermethod return time=1576606330.909750 sender=:1.65 -> destination=:1.86 serial=574 reply_serial=2
100*aed3e508SAndroid Build Coastguard Worker   boolean false
101*aed3e508SAndroid Build Coastguard Worker   uint32 1
102*aed3e508SAndroid Build Coastguard Worker   variant       array [
103*aed3e508SAndroid Build Coastguard Worker         boolean true
104*aed3e508SAndroid Build Coastguard Worker      ]
105*aed3e508SAndroid Build Coastguard Worker```
106*aed3e508SAndroid Build Coastguard Worker
107*aed3e508SAndroid Build Coastguard WorkerThe output tells us multiple things:
108*aed3e508SAndroid Build Coastguard Worker
109*aed3e508SAndroid Build Coastguard Worker*   `boolean false` tells us that the property is not read-only;
110*aed3e508SAndroid Build Coastguard Worker*   `uint32 1` is the number of values this property has, in this case 1; and
111*aed3e508SAndroid Build Coastguard Worker*   the lines inside `variant array [` are the values of the property.
112*aed3e508SAndroid Build Coastguard Worker
113*aed3e508SAndroid Build Coastguard WorkerAt the moment, "Australian Scrolling" is true, meaning that scroll direction is
114*aed3e508SAndroid Build Coastguard Workerinverted. If we move two fingers up on the pad, the content will scroll down.
115*aed3e508SAndroid Build Coastguard WorkerLet's change the value:
116*aed3e508SAndroid Build Coastguard Worker
117*aed3e508SAndroid Build Coastguard Worker```
118*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop set 9 "Australian Scrolling" array:boolean:false
119*aed3e508SAndroid Build Coastguard Workermethod return time=1576606314.847606 sender=:1.65 -> destination=:1.84 serial=566 reply_serial=2
120*aed3e508SAndroid Build Coastguard Worker```
121*aed3e508SAndroid Build Coastguard Worker
122*aed3e508SAndroid Build Coastguard WorkerThis should immediately take effect, meaning that moving two fingers up on the
123*aed3e508SAndroid Build Coastguard Workerpad scrolls the content up. Unless you change it again, the value will remain
124*aed3e508SAndroid Build Coastguard Workerthe same until Chromium next restarts.
125*aed3e508SAndroid Build Coastguard Worker
126*aed3e508SAndroid Build Coastguard Worker#### Value syntax
127*aed3e508SAndroid Build Coastguard Worker
128*aed3e508SAndroid Build Coastguard WorkerIn the example above, we specified the value as `array:boolean:false`, which may
129*aed3e508SAndroid Build Coastguard Workerseem rather obtuse for setting a simple flag. This is because all properties
130*aed3e508SAndroid Build Coastguard Worker(except strings) are counted as arrays, hence the `array:` prefix, and we have
131*aed3e508SAndroid Build Coastguard Workerto specify the type of value we're setting, in this case `boolean`. (The
132*aed3e508SAndroid Build Coastguard Workeravailable types are `int32`, `double`, `boolean`, and `string`.) To specify
133*aed3e508SAndroid Build Coastguard Workermultiple values, separate them by commas:
134*aed3e508SAndroid Build Coastguard Worker
135*aed3e508SAndroid Build Coastguard Worker```
136*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop set 9 "Some array property" array:int32:1,2,3,4
137*aed3e508SAndroid Build Coastguard Worker```
138*aed3e508SAndroid Build Coastguard Worker
139*aed3e508SAndroid Build Coastguard WorkerThis syntax is actually borrowed from the Linux `dbus-send` command, so see [its
140*aed3e508SAndroid Build Coastguard Worker`man` page](https://dbus.freedesktop.org/doc/dbus-send.1.html#description) for a
141*aed3e508SAndroid Build Coastguard Workerfull description.
142*aed3e508SAndroid Build Coastguard Worker
143*aed3e508SAndroid Build Coastguard Worker### Over D-Bus
144*aed3e508SAndroid Build Coastguard Worker
145*aed3e508SAndroid Build Coastguard WorkerOn Chromebooks with developer mode enabled, it's also possible to use the
146*aed3e508SAndroid Build Coastguard Workerservice over D-Bus from your own program. This could be useful if you need to
147*aed3e508SAndroid Build Coastguard Workerwrite more advanced tooling to change certain properties, such as the
148*aed3e508SAndroid Build Coastguard Workeracceleration curves, which would be tedious to modify manually. See the
149*aed3e508SAndroid Build Coastguard Worker`cmd_gesture_prop` function in the [`crosh` script][crosh] and the handlers in
150*aed3e508SAndroid Build Coastguard Worker[`gesture_properties_service_provider.cc`][service-provider] as references for
151*aed3e508SAndroid Build Coastguard Workerthe D-Bus API.
152*aed3e508SAndroid Build Coastguard Worker
153*aed3e508SAndroid Build Coastguard Worker[crosh]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform2/crosh/crosh?q=cmd_gesture_prop
154*aed3e508SAndroid Build Coastguard Worker[service-provider]: https://source.chromium.org/chromium/chromium/src/+/HEAD:ash/dbus/gesture_properties_service_provider.cc
155*aed3e508SAndroid Build Coastguard Worker
156*aed3e508SAndroid Build Coastguard Worker## Pointer acceleration curves
157*aed3e508SAndroid Build Coastguard Worker
158*aed3e508SAndroid Build Coastguard WorkerPerhaps the most important gesture properties are those that represent
159*aed3e508SAndroid Build Coastguard Workeracceleration curves. These define how fast the mouse pointer moves in relation
160*aed3e508SAndroid Build Coastguard Workerto the speed at which the user moves the mouse or their finger. While a default
161*aed3e508SAndroid Build Coastguard Workerfor each curve is compiled in to Chromium, a custom curve can be activated by
162*aed3e508SAndroid Build Coastguard Workersetting a corresponding boolean property (e.g. "Use Custom Mouse Pointer Accel
163*aed3e508SAndroid Build Coastguard WorkerCurve").
164*aed3e508SAndroid Build Coastguard Worker
165*aed3e508SAndroid Build Coastguard Worker(Note that mouse wheel scrolling curves are defined more simply, as a single
166*aed3e508SAndroid Build Coastguard Workerpolynomial with five terms, so they aren't covered here.)
167*aed3e508SAndroid Build Coastguard Worker
168*aed3e508SAndroid Build Coastguard WorkerAcceleration curves are defined by up to 20 quadratic curve segments. Each curve
169*aed3e508SAndroid Build Coastguard Workersegment has four parameters defining a quadratic, where *x* is the magnitude of
170*aed3e508SAndroid Build Coastguard Workerthe motion:
171*aed3e508SAndroid Build Coastguard Worker
172*aed3e508SAndroid Build Coastguard Worker*   the maximum value of *x* for which this segment will be applied (default
173*aed3e508SAndroid Build Coastguard Worker    infinity, called `x_` in code)
174*aed3e508SAndroid Build Coastguard Worker*   *a*, the *x²* multiplier (default 0, called `sqr_`)
175*aed3e508SAndroid Build Coastguard Worker*   *b*, the *x* multiplier (default 1, called `mul_`)
176*aed3e508SAndroid Build Coastguard Worker*   *c*, the constant (default 0, called `int_`)
177*aed3e508SAndroid Build Coastguard Worker
178*aed3e508SAndroid Build Coastguard WorkerSo, each quadratic (of the form *ax² + bx + c*) applies to values of
179*aed3e508SAndroid Build Coastguard Worker*x* between the maximum value of the previous segment and its own maximum value.
180*aed3e508SAndroid Build Coastguard Worker
181*aed3e508SAndroid Build Coastguard WorkerIn the gesture properties, the four parameters from each curve segment are
182*aed3e508SAndroid Build Coastguard Workerconcatenated together into an array of 80 doubles. (These are then cast to
183*aed3e508SAndroid Build Coastguard Worker[`struct CurveSegment`][struct-curvesegment]s by `AccelFilterInterpreter`.)
184*aed3e508SAndroid Build Coastguard Worker
185*aed3e508SAndroid Build Coastguard WorkerPutting all of this together, we might change the mouse pointer acceleration
186*aed3e508SAndroid Build Coastguard Worker"curve" into a straight line where *y = -x* (therefore inverting pointer
187*aed3e508SAndroid Build Coastguard Workermovement) with the following commands:
188*aed3e508SAndroid Build Coastguard Worker
189*aed3e508SAndroid Build Coastguard Worker```
190*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop set 12 "Mouse Pointer Accel Curve" array:double:inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0,inf,0,-1,0
191*aed3e508SAndroid Build Coastguard Workercrosh> gesture_prop set 12 "Use Custom Mouse Pointer Accel Curve" array:boolean:true
192*aed3e508SAndroid Build Coastguard Worker```
193*aed3e508SAndroid Build Coastguard Worker
194*aed3e508SAndroid Build Coastguard Worker(Of course, really only the first four values of the curve matter here, as the
195*aed3e508SAndroid Build Coastguard Workermaximum *x* of the first segment is infinite.)
196*aed3e508SAndroid Build Coastguard Worker
197*aed3e508SAndroid Build Coastguard Worker[struct-curvesegment]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/gestures/include/accel_filter_interpreter.h?q=%22struct%20CurveSegment%22
198