Compare commits

..

184 Commits

Author SHA1 Message Date
Peter Hutterer
7c1971d9e7 evdev 2.10.3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-01 11:41:03 +10:00
Peter Hutterer
9a6952dafe Restore non-xy axes updates
This broke in d24431a186 Restore wheel emulation for absolute devices,
last hunk when the valuator update was moved to before any early exit
condition. But that new update only applies to valuator maps < 2, i.e. x/y
only. Other valuators are now ignored and remain on 0 forever.

Restore the valuator update.

https://bugs.freedesktop.org/show_bug.cgi?id=95315

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-12 15:29:55 +10:00
Peter Hutterer
f12eca9f83 evdev 2.10.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-04-29 09:13:35 +10:00
Peter Hutterer
33dc3d7128 Prevent buffer overrun accessing btn_labels
We go up to BTN_JOYSTICK, hence group can have a value of up to including 15.
The actual btn_labels only has 6 elements though.

Found by coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-04-27 09:11:03 +10:00
Peter Hutterer
7b0a65d989 Don't reset the other axis on wheel emulation scroll buildup
The idea was that of a direction lock: as we move vertically we should not
build up any horizontal scroll motion even if we move slightly diagonally.

The effect was though that the axis would be reset completely as soon as an
event from the other axis occured. With the default threshold of 10, if one in
ten events was a REL_X, we'd never get a wheel event.

Drop this code, it's not needed. By default wheel emulation doesn't do
horizontal scrolling, if a config snippet sets XAxisMapping the user wants
horizontal scrolling. And since we just add the value anyway, as long as the
user does a roughly vertical motion we won't get over the threshold anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=93617

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-20 10:48:36 +10:00
Peter Hutterer
d24431a186 Restore wheel emulation for absolute devices
Wheel emulation relies on oldVals, which stopped updating in 3dcf6f123c.

Since wheel emulation may filter the abs event, store the event before we do
anything with it. If we really want the abs_event, abs_queued will be set to
1, otherwise the value will be ignored.

And now that we know abs_value is always valied, we can copy its value into
old_vals, so that wheel emulation can calculate the delta correctly.

https://bugs.freedesktop.org/show_bug.cgi?id=93617

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-20 10:48:35 +10:00
Peter Hutterer
ce7d8fdebc man: add a warning that wheel emu inertia must be set and it isn't inertia
First, it's not actually inertia, it's simply the scroll distance, yay for the
misnomer.

And it needs to be set for any device that is more fine-grained than a
mouse, especially absolute devices. For example the VirtualBox device has an
abs max of 32767, so a simple motion may have a delta of to 2000 units and
that results in 200 scroll events. That's a bit excessive.

Related to: https://bugs.freedesktop.org/show_bug.cgi?id=93617

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-14 11:53:56 +10:00
Peter Hutterer
6a3beab613 evdev 2.10.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-08 15:11:59 +10:00
Peter Hutterer
d7e61a7074 Only map x and y to axes 0 and 1
The Logitech G600 has one device with all axes north of ABS_MISC. The current
code assigns ABS_MISC as first axis to map to axis 0, i.e. x. On button press,
one node sends the BTN_LEFT but the other node sends an ABS_MISC with a 1 0
value. ABS_MISC is mapped to axis 0, this moves the pointer to (0, y) on
every button click.

Avoid this by simply mapping any axis other than x/y to at least axis 3, and
make sure we only override the MT 0/1 axes when we actually have MT axes.

https://bugs.freedesktop.org/show_bug.cgi?id=92856

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-11-13 06:50:28 +10:00
Peter Hutterer
01e7ac4854 evdev 2.10.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-28 14:28:20 +10:00
Thomas Hindoe Paaboel Andersen
034be31159 Add "Resolution" option for mice to the evdev driver
It can be used to scale the resolution of a mouse to that of a 1000 DPI
mouse. This can be useful to make high resolution mice less sensitive
without turning off acceleration. The target of 1000 DPI is used as the
same default is used in libinput. If the option is not set no scaling
will be done.

https://bugs.freedesktop.org/show_bug.cgi?id=88134
Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 14:59:27 +10:00
Peter Hutterer
66c9978864 Add the default evdev config
This used to be part of the server but now that we have two drivers doing the
same thing (libinput, evdev) shift the configuration defaults to the driver.
This way you get what you install.

https://bugs.freedesktop.org/show_bug.cgi?id=89023

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-18 13:39:37 +10:00
Peter Hutterer
0d3494eadf Bump to 2.9.99
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-27 11:41:50 +10:00
Peter Hutterer
56a5e67162 Unconditionally require mtdev
Missing from 2c9f4f0380

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-16 07:57:38 +10:00
Peter Hutterer
74433f788a Always check for a return value on creating a property
Mostly to make static analyzers happy

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-16 07:57:26 +10:00
Peter Hutterer
fdc33809de Invert a condition to reduce nesting
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-13 10:58:01 +10:00
Peter Hutterer
38e107a39f Disable axis faking and MT event processing on fake MT devices
This effectively disables all axes >= ABS_MT_SLOT on those devices. But at
least the device comes up without an error and it didn't work correctly
beforehand anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=89473

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-11 15:21:09 +10:00
Peter Hutterer
b6176cff5a Invert two conditions to reduce nesting
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-11 15:02:12 +10:00
Peter Hutterer
37afebfb67 Factor out MT axis counting into a separate function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-11 15:02:11 +10:00
Peter Hutterer
5b5ae1786c Split android axis simulation into a helper function
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-11 15:02:11 +10:00
Peter Hutterer
2c9f4f0380 Require multitouch/smooth scrolling dependencies
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-11 15:02:11 +10:00
Peter Hutterer
39ef4444a2 Drop evdev-specific XKB defaults
Just use the server defaults instead. This has very little effect, on most
systems there was some sort of default configuration applied anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-13 09:06:44 +10:00
Tobias Himmer
abc4a8b603 Check for incoming MT slot indices exceeding the allocated number of slots.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=88715

Signed-off-by: Tobias Himmer <provisorisch@online.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-23 12:05:28 +10:00
Colin B. Macdonald
b370ccdff8 Workaround lack of ABS_X on MT devices (#80470)
Often on Android, we have ABS_MT_POSITION_X without ABS_X (which is contrary
to spec). We add fake ABS_X axis in that case.

X.Org Bug 80470 <http://bugs.freedesktop.org/show_bug.cgi?id=80470>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-23 10:40:25 +10:00
Éric Brunet
511498478b Move EVDEV_RELATIVE_MODE logic earlier
When in EVDEV_RELATIVE_MODE, after converting the absolute valuators, the
code unsets pEvdev->abs_queued. This is wrong if there are some absolute
valuators which are not positions, such as a pressure valuators, because
events on these valuators would be lost.

This patch fixes the problem by doing the absolute->relative translation
early. This way, abs_queued is not set and then unset when receiving
absolute valuators representing positions. Other absolute events now set abs_queued
and will be processed.

Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-17 14:42:11 +10:00
Éric Brunet
3dcf6f123c Don't update old_vals when not in EVDEV_RELATIVE_MODE
When not in EVDEV_RELATIVE_MODE, absolute position is stored in old_vals. This serves
no purpose except that old_vals is ready when the device is switched to
EVDEV_RELATIVE_MODE. It is however better to make the copy between old_vals
and abs_vals at the time of the switch rather than all the time.

Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-17 14:37:38 +10:00
Éric Brunet
f59585b367 Change the logic concerning EVDEV_RELATIVE_MODE and in_proximity
When not in_proximity, we don't really trust data, even though a valuator
sent just before a in_proximity event might actually be important. The
present code for EVDEV_RELATIVE_MODE throws away all data if not
in_proximity, which is a little bit too much. This patch allows for
relative values to be calculated and old_vals to be updated even if not
in_proximity, but will prevent evdev to sending (presumably) wrong
information to the X server. But at least, old_vals will be correctly
filled when the device comes into proximity again.

Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-17 14:33:17 +10:00
Éric Brunet
593bbc6390 drop the pEvdev->delta array
Now that relative events have their own valuator mask, use it instead of
delta

Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-17 14:32:41 +10:00
Éric Brunet
e0e2587a95 Split pEvdev->vals into pEvdev->abs_vals and pEvdev->rel_vals
This should hopefully fix bug 84445.

Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-17 14:26:25 +10:00
Peter Hutterer
cb3b023783 evdev 2.9.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-26 09:23:39 +10:00
Peter Hutterer
124eff9ba2 Remove three unused #defines
Obsolete since 768c25a99b

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-07 13:41:06 +10:00
Éric Brunet
605047613c Don't pass superfluous arguments to EvdevPost*Events
The functions EvdevPostProximityEvents, EvdevPostRelativeMotionEvents,
EvdevPostAbsoluteMotionEvents and EvdevPostQueuedEvents are only called
by EvdevProcessSyncEvent. These functions take as arguments an array of
valuators which is set by EvdevProcessSyncEvent to contain ... nothing.
This patch changes the prototype of the four functions, their definitions
and the way they are called  to remove the useless array of valuators.

Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-29 11:18:16 +10:00
Peter Hutterer
3ee98d0b7f Drop some unused #defines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-29 13:14:56 +10:00
Peter Hutterer
977588d24a If only IgnoreRelativeAxes is set, init like a normal relative device
In the current code, if only IgnoreRelativeAxes is set, the code would go on
and force absolute axes to initialize even if the relative axes were
successfully initialized.

Evdev gives precedence to relative axes anyway, initializing absolute axes if
the relative axes failed. Thus, if we explicitely want relative axes but leave
the abs axes as-is, proceed as normal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 10:02:00 +10:00
Peter Hutterer
291b60172d Fix axis initialization for devices with abs x/y and rel scrollwheels
The Xen Virtual Pointer device has ABS_X, ABS_Y and REL_WHEEL. If smooth
scrolling is detected, the current code would first initialize relative axes
for scrolling and immediately overwrite those axes when the abs valuators are
written out.

This patch fixes the default case only, in the case of a device setting the
two Ignore*Axis options both to "off", the axes are still overwritten. The
wheels will work, other axes only if the same number of abs axes exists. And
it keeps the current memory leak too, but it's marked with a FIXME now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 10:02:00 +10:00
Peter Hutterer
8ce06c96e4 Make the slot-state per slot
The previous approach only had the slot state for the current slot. If we
changed slots, that means we lost the information if the slot was ever
initialized. If the ABS_MT_TRACKING_ID was never received, the slot would
still update and try to send events (which the server refused with a warning).

Avoid this by having a per-slot state and a dirty bit that tells us if the
current slot updated at all. If we don't get the tracking ID, leave the slot
empty and refuse any further events from that touch.

This quashes the various "unable to find touch point 0" warnings caused if a
touchpoint starts before the device is enabled.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Walter Harms <wharms@bfs.de>
2014-08-18 10:01:47 +10:00
Peter Hutterer
5d239ceb26 evdev 2.9.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-20 15:41:08 +10:00
Peter Hutterer
13dea90bc8 Use the server's device list for duplicate detection (#78309)
EvdevAddDevice/EvdevRemoveDevice keep a reference to the device to detect
duplicate devices based on the dev_t.

EvdevAddDevices was called during PreInit, EvdevRemoveDevice was called during
DEVICE_CLOSE. That makes it imbalanced if the device succeeds PreInit but the
server skips everything else because MAX_DEVICES is exceeded. So for all
devices after MAX_DEVICES, we'd add a reference but never remove it,
eventually reading/writing past evdev_devices.

The server keeps the list of devices for us anyway, so remove the copy of all
the pointers and instead run through the device list the server gives us.

X.Org Bug 78309 <http://bugs.freedesktop.org/show_bug.cgi?id=78309>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-07 07:27:29 +10:00
Peter Hutterer
b25d716165 evdev 2.8.99.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-29 10:20:50 +10:00
Peter Hutterer
41cf9212d0 Map REL_DIAL to horizontal scrolling (#73105)
This was the original behavior introduced in
f77410e1f9 and stayed that way until smooth
scrolling erroneously added it as vertical axis in
b450efdf95. Revert to horizontal scrolling to
restore the previous behaviour - which unbreaks scrolling on Microsoft mice.

This effectively reverts 54a3120e33 too.

X.Org Bug 73105 <http://bugs.freedesktop.org/show_bug.cgi?id=73105>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-29 09:52:31 +10:00
Peter Hutterer
75368052b5 Revert "Map REL_DIAL to horizontal scrolling (#73105)"
Whoops, the vertical axis is swapped, so when changing the axis we also need
to change the direction.

This reverts commit 16c85cbeac.
2014-04-29 09:52:31 +10:00
Peter Hutterer
16c85cbeac Map REL_DIAL to horizontal scrolling (#73105)
This was the original behavior introduced in
f77410e1f9 and stayed that way until smooth
scrolling erroneously added it as vertical axis in
b450efdf95. Revert to horizontal scrolling to
restore the previous behaviour - which unbreaks scrolling on Microsoft mice.

This effectively reverts 54a3120e33 too.

X.Org Bug 73105 <http://bugs.freedesktop.org/show_bug.cgi?id=73105>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-29 09:39:12 +10:00
Hans de Goede
ae67f64f02 evdev: Add support for server managed fds
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-10 11:58:43 +10:00
Peter Hutterer
f6fcad8b10 Fix wheel emulation for absolute device (#68415)
wheel emulation, for some reasons beyond time, got the value from
pEvdev->vals, then set the value back into pEvdev->vals. Alas, that value is
always 0, hence oldValue is zero and the delta is nil.

If we're not in relative (touchpad) mode, store the current value in
old_vals, so they're retrievable for the next event.

X.Org Bug 68415 <http://bugs.freedesktop.org/show_bug.cgi?id=68415>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-22 13:59:46 +10:00
Peter De Wachter
d171b3d919 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>
2013-10-21 16:39:59 +10:00
Peter De Wachter
c3251deb4b Add configuration options for smooth scrolling.
This patch creates three new xorg.conf options, VertScrollDelta,
HorizScrollDelta and DialDelta, which adjust the sensitivity of
smooth scrolling. These options take a positive integer, default
value is 1.

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>
2013-10-21 15:47:54 +10:00
Peter Hutterer
cabed4bbb6 Use num_slots where appropriate
This was supposed to be added in 43e270fb7a, but
got lost somehow.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14 11:49:29 +10:00
Peter Hutterer
a75c43830e Merge branch 'libevdev' 2013-10-07 09:22:09 +11:00
Peter Hutterer
d9aadfd5f0 bump to 2.8.99
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-07 09:21:57 +11:00
Peter De Wachter
54a3120e33 Map REL_DIAL to vertical scrolling
This makes the absolute axis codepath behave the same as the relative axis
path.

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>
2013-10-07 09:21:07 +11:00
Peter Hutterer
164c62a975 Use libevdev as backend
Removes the need to ioctl manually and check bits, with all the dangers that
come with that. libevdev is much better prepared for invalid values, OOB
checks, etc.

Plus, we get almost free SYN_DROPPED handling as well which we didn't have
before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-04 16:19:19 +10:00
Peter Hutterer
43e270fb7a Use helper function for counting slots
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-09-10 15:06:38 +10:00
Peter Hutterer
4ca57716ca Drop ABS_MT_SLOT minimum - the kernel guarantees a minimum of 0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-09-10 15:04:40 +10:00
Peter Hutterer
0f16065b00 Remove a comment
This comment is now in the wrong place. It was moved when abs support for
wheel emulation was added but is now only confusing. Remove it altogether,
the code is quite obvious what it does.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-28 14:37:26 +10:00
Peter Hutterer
cae1478781 Don't use mtdev for protocol B devices
If a device has ABS_MT_SLOT, mtdev merely reads the events and returns them
to the caller as-is. For this we don't need mtdev, we can just handle those
events ourselves.

This patch switches to the mtdev plumbing layer that takes events and
converts them instead of reading them off the fd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-28 10:38:40 +10:00
Peter Hutterer
27926b3763 Write a SYN_REPORT after the last LED
When writing LED values to the device, append a SYN_REPORT to the list to
ensure other clients are updated immediately. Otherwise, the LED events
will be queued and not sent to other clients until the next input event
arrives.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2013-08-13 19:34:16 +10:00
Peter Hutterer
8a9b1ec6b5 evdev 2.8.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-11 11:09:24 +10:00
Peter Hutterer
356565111a Don't allow a wheel emulation inertia of 0 (#66125)
Inertia of 0 results in an infinite loop of events being sent to the server.

X.Org Bug 66125 <http://bugs.freedesktop.org/show_bug.cgi?id=66125>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-27 06:58:27 +10:00
Peter Hutterer
fff3a60fbf Use EvdevBitIsSet, not the server's BitIsOn
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-31 06:57:22 +10:00
Peter Hutterer
8f209ac60d Drop cached name and led_bitmask - nothing reads this
Both fields are write-only as of xf86-input-evdev-2.5.99.902-1-g1ced7ec

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-31 06:57:22 +10:00
Peter Hutterer
a0d41af896 Switch default model to pc104.
As of xkeyboard-config 1.9, the evdev model is hidden (c887d2876)
The server switched to pc105 with version 1.8 (1df4bd601).

The evdev model resolves to pc104 anyway, so this commit has no real effect
other than to switch from a catch-all rule to explicit.
Use pc104 so this is easy to find for those investigating the code and
wondering why. pc104 is the 'correct' geometry for the us layout, which is
the default after all. Switching to pc105 would show keys missing if no
model is set (e.g. on uk/de layouts) but it would be the wrong layout for
the default.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2013-05-31 06:57:16 +10:00
Peter Hutterer
dea1d1a390 Fail to set up axes for devices that only have MT axes but no ABS_X/Y equivalents (#64029)
The kernel should give us ABS_X/Y for backwards compat but some devices
don't. For now, ignore these devices as evdev is not suited to handle this
yet and will crash if a device is set up without axes (i.e.
pEvdev->vals == NULL) and later receives an event from an MT axis.

X.Org Bug 64029 <http://bugs.freedesktop.org/show_bug.cgi?id=64029>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-05-01 15:05:43 +10:00
Peter Hutterer
b59a1a25da Add option TypeName (#62831)
evdev tries to assign the right XI 1.x type-name based on various device
capabilities. In some cases, that fails. e.g. the Mionix Naos 5000 mouse
looks like a keyboard. And we assign a keyboard type in that case since
there are plenty of keyboards that also advertise some axes or others.

Add a new option TypeName to allow for system-wide configuration of such
devices in a quirks file.

This can also be used to address #55867

X.Org Bug 62831 <http://bugs.freedesktop.org/show_bug.cgi?id=62831>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-16 10:25:02 +10:00
Peter Hutterer
5138cd2ff4 evdev 2.8.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-03-26 16:01:39 +10:00
Peter Hutterer
c085c8b6c1 Return BadValue if EvdevOpenMTDev fails
FALSE == Success, so if we fail during EvdevOpenMTDev, the caller thinks
that everything worked fine, proceeds to set up the fd, etc.

This may later cause a crash, when a device comes back later as different
device and posts axis events where we didn't configure axes in the first
place.

Note: Unclear why there was no udev event received for the device being
removed and coming back as different device though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-12 13:19:49 +10:00
Peter Hutterer
2b675f85ae Make errors on EVIOCGBIT more obvious
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-12 13:19:47 +10:00
Peter Hutterer
2b8b0df62e Always init axis mapping for the first two rel axes (#59784)
Fixes regression introduced in 2f67509b53.

If evdev is used for touchpads, the abs axis movement is converted to a rel
movement. Without the two relative axes initialized, the events are
discarded.

Axes 0 and 1 are always x/y anyway unless specifically configured otherwise.

X.Org Bug 59784 <http://bugs.freedesktop.org/show_bug.cgi?id=59784>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-25 11:13:41 +10:00
Peter Hutterer
bb9b4146cb Merge branch 'touch-axis-swap' 2013-01-25 11:12:05 +10:00
Peter Hutterer
f5fe533f1b Allow relative scroll valuators on absolute devices (#54387)
Special-case RHEL_WHEEL, RHEL_HWHEEL and REL_DIAL to add scroll valuators
for those axes in addition to the absolute axes.

X.Org Bug 54387 <http://bugs.freedesktop.org/show_bug.cgi?id=54387>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-23 17:33:10 +10:00
Peter Hutterer
2f67509b53 Split rel and abs axis mapping into two separate arrays
This will enable a device to have relative scrolling axes in addition to
absolute axes (required by the QEMU tablet).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-23 17:33:10 +10:00
Peter Hutterer
ffc0a34642 Move some stuff into the new alloc function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-23 17:33:10 +10:00
Peter Hutterer
93de7b0b73 Move allocation of EvdevRec into a helper function
Makes it easier to initialise everything to the right values.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-23 17:33:10 +10:00
Colin Walters
9ec9d214d0 autogen.sh: Implement GNOME Build API
http://people.gnome.org/~walters/docs/build-api.txt

Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-01-16 13:16:22 -05:00
Adam Jackson
94e6df8f5f configure: Drop AM_MAINTAINER_MODE
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-01-16 13:11:11 -05:00
Peter Hutterer
67e5376aaa Handle axis swap, calibration, and inversion for touch events (#59340)
X.Org Bug 59340 <http://bugs.freedesktop.org/show_bug.cgi?id=59340>

Reported-by: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-14 15:30:46 +10:00
Peter Hutterer
2432626b70 Move calibration adjustments to helper function
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-14 15:28:34 +10:00
Peter Hutterer
069c035ab0 Move valuator swapping into a helper function
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-14 15:28:34 +10:00
Peter Hutterer
3b7ba39fca Localise tmp variable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-14 15:28:34 +10:00
Mauro Carvalho Chehab
454194f4b5 Force a button if MT axes are present and it is not a gamepad
We expect at least BTN_TOUCH for anything with MT axes, but devices that
don't have that need a button class regardless. Some gamepads define
MT axes but no buttons, causing a bug in the server when they post a
TouchBegin.

[ 97436.293] (EE) BUG: triggered 'if (!b || !v)'
[ 97436.293] (EE) BUG: exevents.c:929 in UpdateDeviceState()

So, ignore it, if it is a joystick (e. g. if it have BTN_JOYSTICK defined).
Otherwise, fake a button.

This patch basically merges two patches written by Peter Hutterer
<peter.hutterer@who-t.net>.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-08 15:07:04 +10:00
Peter Hutterer
00341e632c Drop special XKB option handling
This isn't actually needed at all.

xf86nameCompare() will skip over underscores and is case-independent. So
xf86SetStrOption("foo_bar") will return an Option "FooBar" and vice versa.

The server won't return a zero-length string either, it'll return
NULL and spit a warning to the log.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-08 15:07:03 +10:00
Peter Hutterer
f2d2b65343 Localise XKB initialization
No need to store this in the evdev struct.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-08 15:07:03 +10:00
Peter Hutterer
0d6c6b59c1 If stat fails, pretend it's not a virtual device
If stat fails while checking if the device is virtual, just say "no, it's
not virtual" and continue. If the device really went away, it'll be removed
through other means.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05 17:12:34 +10:00
Benjamin Tissoires
c263d6e46d Add missing mt axis labels
update evdev according to latest changes in input.h

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-30 08:47:19 +10:00
Peter Hutterer
5af11b6752 Use LogMessageVerbSigSafe if available
Messages logged during the signal handler should use LogMessageVerbSigSafe
as of ABI 18.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-10 17:38:35 +10:00
Peter Hutterer
33e7831b5f Fix broken ButtonMapping option (#53168)
Regression introduced in 8af0e6f1eb.
s is now initialized to NULL, so we never entered the loop.

X.Org Bug 53168 <http://bugs.freedesktop.org/show_bug.cgi?id=53168>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-08-08 12:34:25 +10:00
Peter Hutterer
bc8997e812 Link against libudev
Fixes /usr/bin/Xorg: symbol lookup error:
/usr/lib64/xorg/modules/input/evdev_drv.so: undefined symbol: udev_new

This doesn't appear in the default configuration as Xorg links against
libudev and the symbol is defined when evdev is loaded. It can be reproduced
with a HAL-enabled server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-07 07:38:28 +10:00
Peter Hutterer
1cb8f074df Don't delete the device on ENODEV
This is signal handler code and we cannot clean up properly while in the
signal handler. So reduce the code to removing the signal handler and let
the device be cleaned up later.

If hotplugging is on, the server will remove it when the config backend says
so and if it is off, the server will remove it on shutdown.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-07 07:38:26 +10:00
Peter Hutterer
4eacb581fb Only use mtdev for multitouch devices
mtdev uses a chunk of memory per device (~41kB), mainly for for its
internal event buffers. The average box these days can easily have 10
devices, but only few of those are multitouch. So check if we have
ABS_MT_POSITION axes and only create an mtdev instance if we do.

If a device has multitouch axes but not x/y, we will ignore events from this
device now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-07-27 10:14:04 +10:00
Peter Hutterer
98af2003d4 Don't re-open mtdev after PreInit
==16557== 388,240 (3,520 direct, 384,720 indirect) bytes in 10 blocks are definitely lost in loss record 1,669 of 1,671
==16557==    at 0x4A06F18: calloc (vg_replace_malloc.c:566)
==16557==    by 0xC3EAD4D: mtdev_new (core.c:345)
==16557==    by 0xC3EAE6B: mtdev_new_open (core.c:383)
==16557==    by 0xC1E0452: EvdevOpenDevice (evdev.c:2365)
==16557==    by 0xC1E068C: EvdevPreInit (evdev.c:2431)
==16557==    by 0x4B8304: xf86NewInputDevice (xf86Xinput.c:846)
==16557==    by 0x4B8857: NewInputDeviceRequest (xf86Xinput.c:989)
==16557==    by 0x4CCB4C: device_added (udev.c:211)
==16557==    by 0x4CCFA6: config_udev_init (udev.c:342)
==16557==    by 0x4CBE81: config_init (config.c:48)
==16557==    by 0x4A8A9A: InitInput (xf86Init.c:918)
==16557==    by 0x4921EE: main (main.c:258)

After PreInit, the fd and mtdev pointer are still valid. We check for the
fd, but unconditionally allocated another mtdev struct for each device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-07-25 09:23:53 +10:00
Daniel Stone
f5ede98085 Fix compilation warnings for non-multitouch builds
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-13 16:23:58 +10:00
Peter Hutterer
ff926d15b8 Move axis labels into a separate header file
Just to unclutter the code

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-15 16:05:19 +10:00
Peter Hutterer
b0e3c8f978 Split initializing one axis label out into a helper function
We need this for mixed axis devices. No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-15 16:05:16 +10:00
Peter Hutterer
9624f4e2ba Constify InputDriverRec->default_options
Removes a warning, and with the input ABI 18 this is forced to const in the
server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-08 09:12:14 +10:00
Peter Hutterer
047955f51e Move duplicate check up before mtdev allocation
No need to alloc mtdev if we then find out the fd is a duplicate one anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-08 09:12:14 +10:00
Peter Hutterer
8251d7a8ec Close the fd when mtdev open fails
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-08 09:12:14 +10:00
Peter Hutterer
ac5173163d Release mtdev data whenever we close the fd
Add a new EvdevCloseDevice() function to unify this.
We used to leak data
- PreInit allocates mtdev, but nothing except one error path released it.
- each DEVICE_ON re-allocates mtdev but it is never released

Reported-by: Zdenek Kabelac <zdenek.kabelac@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-08 09:12:14 +10:00
Peter Hutterer
61faf2e6e7 strtol doesn't need a empty string, NULL is good enough.
Fixes:
evdev.c: In function 'EvdevInitButtonMapping':
evdev.c:1659:25: warning: initialization discards 'const' qualifier from
pointer target type [enabled by default]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-08 09:12:14 +10:00
Peter Hutterer
7f3f98be7f Use xf86IDrvMsg in emuMB.c instead of ErrorF
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-08 09:12:14 +10:00
Chase Douglas
4145fe1c08 Fix buffer overrun when populating axis label property array
The axis label property array currently only has enough elements for the
non-multitouch axes. This change allocates enough space for all axes,
which prevents an array overrun write. This may manifest as stack
corruption on some platforms.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-07 11:31:57 +10:00
Chase Douglas
9ce068e760 Report the correct number of touches for MT protocol B devices
Protocol B devices report the number of touches by giving a maximum and
minimum slot value. The current code ignores the minimum value, which is
usually 0, and underreports the number of touches by 1.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-25 09:33:52 +10:00
Marcin Slusarz
2c8da280b3 Fix some obvious constness-related compile warnings.
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-21 16:53:36 +10:00
Peter Hutterer
f28507e8ce Devices configured as mice need REL_X/Y
Some keyboards export scroll axes and any absolute axis possible in 11
dimensions. All these axes are mute, except possibly for the scroll wheels.

So if a device has a scroll axis, and we're configuring it as mouse, force
the x/y axes into existence. This stops the logspam complaining about not
enough axes on pointer movement after a xrandr change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-01 11:25:00 +10:00
Peter Hutterer
99340147b9 Fix inverted horizontal scroll (#46205)
REL_HWHEEL has a positive increment, not a negative one like REL_WHEEL.

X.Org Bug 46205 <http://bugs.freedesktop.org/show_bug.cgi?id=46205>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-03-16 07:11:30 +10:00
Peter Hutterer
76b1d58a97 evdev 2.7.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-03-07 20:39:09 +10:00
Peter Hutterer
224a28de25 Only force REL_X/Y if no ABS_X/Y exists
5c5b2c8db8 added forced x/y axes if a device
has any axes of the same mode. This was too broad a brush, some devices have
a relative wheel but absolute x/y axes and would now get misdetected as
purely relative device.

Only force relative axes if a device no rel x/y _and_ no abs x/y.

Reproducible: virtual machine with QEMU USB Tablet will stop working

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-01-26 16:07:10 +10:00
Chase Douglas
bc2f01ab83 Copy last valuator values into new touch valuator masks
Evdev is a 100% stateful protocol. The following represents three
touches. Two touches begin and end at the same time at (500, 500) and
(1000, 1000). The third touch begins after the first two end, and is at
(500, 500).

ABS_MT_SLOT		0	/* Set touch slot */
ABS_MT_TRACKING_ID	0	/* New touch with ID 0 in slot 0 */
ABS_MT_POSITION_X	500	/* Initial X position */
ABS_MT_POSITION_Y	500	/* Initial Y position */
ABS_MT_SLOT		1	/* Set touch slot */
ABS_MT_TRACKING_ID	1	/* New touch with ID 1 in slot 1 */
ABS_MT_POSITION_X	1000	/* Initial X position */
ABS_MT_POSITION_Y	1000	/* Initial Y position */
SYNC				/* End of frame */
ABS_MT_SLOT		0	/* Go back to slot 0 */
ABS_MT_TRACKING_ID	-1	/* Touch in slot 0 ended */
ABS_MT_SLOT		1	/* Go to slot 1 */
ABS_MT_TRACKING_ID	-1	/* Touch in slot 1 ended */
SYNC				/* End of frame */
ABS_MT_SLOT		0	/* Go back to slot 0 */
ABS_MT_TRACKING_ID	2	/* New touch in slot 0 with ID 2 */
SYNC				/* End of frame */
ABS_MT_TRACKING_ID	-1	/* Touch in last slot (0) ended */
SYNC				/* End of frame */

Note that touch 2 has the same X and Y position as touch 0. This is
implied because no new value was emitted for slot 0. In fact, Linux will
not emit an event in the same slot with the same event type and code
unless the value has changed. Thus, we can only assume that all the MT
valuators have the same values as they were when they were last sent for
the given slot.

This change adds an array of valuator mask to hold all the last valuator
values that came from evdev for each slot. When a new touch begins, all
the last values are copied into it.

This patch assumes initial axis values of 0 in each slot. Linux and
mtdev do not provide a facility to query the current values of axes in
each slot yet. This may cause spurious incorrect touch valuator values
at the beginning of an X session, but there's nothing we can do about it
right now.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-24 12:12:47 +10:00
Peter Hutterer
9d9c9870c8 Prefere relative axis labelling over absolute axis labelling
If a device has both relative and absolute axes, we'd initialise the
relative axes but label them with the absolute labels.

The current code is broken for mixed mode devices. Most of these devices
operate primarily in relative mode, but have some absolute axes available
for secondary functionality. For now, label the relative axes properly. We
can fix the absolute axes later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-01-18 16:47:16 +10:00
Peter Hutterer
5c5b2c8db8 Force x/y axes to exist on devices with any other axes (#44655)
Too much in the server relies on x/y to exist and to be axes 0 and 1. So if
any relative axes exist, initialize REL_X/Y or ABS_X/Y as well.

For servers up to 1.11: a scrollwheel-only device now has relative axes
where it only had buttons before.

For servers 1.12 or later: the device now has x/y in addition to the scroll
axes.

X.Org Bug 44655 <http://bugs.freedesktop.org/show_bug.cgi?id=44655>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2012-01-17 14:33:54 +10:00
Pete Beardmore
854df75f49 missing multitouch related define tests
addition of two missing define tests required when no multitouch related
symbols are available in user-space

Fixes X.Org Bug 44578 <https://bugs.freedesktop.org/show_bug.cgi?id=44578>

Signed-off-by: Pete Beardmore <pete.beardmore@msn.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-10 10:56:45 +10:00
Chase Douglas
8c55e94a6a Set the default resolution to 0
If we don't know the resolution, set it to 0. This is invalid, and tells
the X client that we don't know the resolution, rather than reporting an
incorrect value.

This value was originally from commit
6271494faa, which is the initial commit
from Adam Jackson adding absolute axis support.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-06 12:17:00 +10:00
Peter Hutterer
965338e9d0 Remove unused udev.c
Added in 683a55e504 due to a botched up
rebase -i. The contents of udev.c and EvdevIsVirtual are identical, there is
no need for an extra file for this one function.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-03 08:44:27 +10:00
Cyril Brulebois
0075da20d6 configure.ac: Fix udev/libudev dependency.
In 683a55e504, a dependency on libudev was
added, but documented in configure.ac as a dependency on udev (which
also happens to ship a pkg-config file).

Signed-off-by: Cyril Brulebois <kibi@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-03 08:40:02 +10:00
Jeremy Huddleston
009ac94a8e Remove redundant redeclaration of Evdev3BEmuPreInit
Found-by: Tinderbox
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-12-31 21:28:53 -05:00
Cyril Brulebois
4b76d80e93 evdev 2.6.99.901
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2011-12-31 18:38:30 +01:00
Peter Hutterer
6dd6f2d3c6 Require xserver 1.12 RC1
Remove the ABI check hack, just check for the server version directly now
that we have one that definitely has the multitouch APIs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-29 10:37:38 +10:00
Peter Hutterer
0c7c087f77 Test for mtdev before assuming multitouch
If the XI2.2 headers are present but mtdev isn't, build without MULTITOUCH
defined.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-29 10:19:48 +10:00
Peter Hutterer
ba9377c6d9 Remove need for --enable-multitouch
If we spot inputproto 2.1.99.3, we assume we have a capable X server. This
should really be a server version check, but the server version hasn't been
bumped yet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-24 12:49:18 +10:00
Peter Hutterer
7f7606fc46 Include config.h from evdev.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-24 12:49:18 +10:00
Peter Hutterer
0ba58f483e Always include mt_mask in the evdev struct
Even if MT support isn't available, include it in the build. The checks in
the code check whether mt_mask is non-NULL but they would all need ifdef
escaping otherwise.

Leave the mtdev part inside the ifdef however, so that we don't need the
mtdev header if we don't build with multitouch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-24 12:18:16 +10:00
Peter Hutterer
5fb4875747 Merge branch 'multitouch' 2011-12-23 08:16:54 +10:00
Peter Hutterer
e99ab2314f Don't count legacy and MT axes twice
The kernel exports both ABS_X and ABS_MT_POSITION_X (and a couple others)
for a multi-touch capable device. For such devices, only count the axis once
since we submit ABS_MT_POSITION_X through ABS_X.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-20 15:11:56 +10:00
Peter Hutterer
191660189a Add is_blacklisted_axis() helper
The kernel exports a bunch of information as axis that shouldn't be an axis
and we don't treat it as axis in the server. Add this helper instead of
checking for the axis codes manually.

No function change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-20 14:18:30 +10:00
Peter Hutterer
a1c3f8efbb Drop now-unnecessary XI 2.1 and XI 2.2 error suppression defines
Gone since inputproto 2.1.99.3

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-20 13:32:06 +10:00
Peter Hutterer
f3c628acc4 Map ABS_MT_POSITION_X/Y into ABS_X/Y
MT axes are the same as traditional axes, so one into the other so we get
x/y coordinates regardless wich axes it comes from.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-20 11:09:37 +10:00
Paulo Zanoni
7909975b0b Fix relative events with swapped axes
After we swap the axes, we only call valuator_mask_set for axes that are
not zero, so we need to unset the axes that became zero when swapped.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-16 16:09:16 +10:00
Paulo Zanoni
8d6dfd13b0 Fix absolute events with swapped axes
We were correctly swapping the valuator values, but we were not
calling valuator_mask_unset() when needed, so the cursor kept jumping
to the edges.

This patch does the swapping before the main "for", so we don't need to
store unswapped_{x,y} and unswapped_isset_{x,y} even when we don't need
to swap.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-15 14:58:59 +10:00
Peter Hutterer
fed454192d Use xf86InitValuatorAxisStruct, the touch-specific version was dropped
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-15 08:55:32 +10:00
Chase Douglas
cf93a21df1 Don't send pointer events for multitouch touchscreen devices
Pointer events will be emulated by the server.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
2011-11-29 18:02:58 -08:00
Peter Hutterer
fac1a41c75 Add the required defines to compile against the inputproto
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:57:26 +10:00
Peter Hutterer
3175a2a96d Print to the log if we find multitouch axes.
No real effect on the code, but it helps to have that line in the log when
searching for driver issues.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
5e9b027807 Replace 0/1 button values with enums
BUTTON_PRESS is much harder to confuse with a button number than a simple 1.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
2ce305129c Skip event posting for empty slots.
ABS_MT_SLOT comes before any other events. The following order of events
is common for protocol B devices (and mtdev):

...
EV_SYN
ABS_MT_SLOT        → posting here means we miss on the position information
ABS_MT_POSITION_X
ABS_MT_POSITION_Y
ABS_MT_SLOT
ABS_MT_POSITION_X
ABS_MT_POSITION_Y
EV_SYN

Store the stot state as SLOT_EMPTY after posting an event (i.e. EV_SYN and
ABS_MT_SLOT) and then don't post until the next slot/syn event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
9411749f76 Replace open_slot/close_slot with a SlotState enum
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
239e972be1 Simplify a condition, only the event type differs here
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
6127923fe0 When resetting the queue, don't reset the touchMask
Otherwise we segfault after the first SYN event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
fc4f98153c MT axes are counted separately, make sure they're initialized too.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
fabee66bcc 0 is the value for "unknown/unlimited" number of touches
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
91d90a7959 Use mtdev API to allocate/free mtdev structs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Peter Hutterer
c1b89bda12 Remove duplicate line
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:36 +10:00
Chase Douglas
907b7cad3f Ensure touchpad events are always processed with MT
Without this change, an MT touchpad in relative mode could end a touch
while not resetting the oldMask used to calculate relative values. This
fix allows a Magic Trackpad to behave as a relative mode device again.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
2011-11-11 15:50:36 +10:00
Chase Douglas
c9a2b4e9ce Use MTDev for multitouch devices
MTDev translates all multitouch devices to the slotted evdev protocol.
This provides a clean and uniform interface and reduces message handling
inside the input module and X.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
2011-11-11 15:50:36 +10:00
Chase Douglas
e18abd0049 Add experimental XI 2.1 multitouch support
This multitouch addition only supports slotted MT evdev protocol
devices. Support must be enabled at configure time using
--enable-multitouch.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

Amendments: XI_TouchMotion -> XI_TouchUpdate, rename mtMask to mt_mask

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:50:06 +10:00
Peter Hutterer
683a55e504 Use a new "Virtual Device" boolean property to mark virtual devices
Use udev to check for the device's sysfs path, if it contains LNXSYSTM it's
a kernel-emulated device. This property can then be used to determine if
there are any real devices connected, allowing the desktop environment to
e.g. turn off the touchpad whenever there's a mouse attached.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 15:42:31 +10:00
Peter Hutterer
a9cdb6590c Move misplaced #endif caused by smooth-scrolling merge
Bad conflict resolution in xf86-input-evdev-2.6.0-30-g745fca0

Reported-by: Sebastian Glita <glseba@yahoo.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-11 07:31:40 +10:00
Peter Hutterer
dd000dd4fa Bump to 2.6.99
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-09 16:04:06 +10:00
Peter Hutterer
745fca03a2 Merge branch 'smooth-scrolling'
Conflicts:
	src/evdev.c

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-09 16:01:48 +10:00
Peter Hutterer
b450efdf95 Support smooth scrolling on REL_WHEEL, REL_HWHEEL and REL_DIAL
Automatic smooth scrolling setup for these axes, with REL_WHEEL and REL_DIAL
both mapping into vscrolling. REL_WHEEL is the preferred axis.

Mouse wheel emulation is not yet updated for smooth scrolling.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-11-09 15:56:55 +10:00
Peter Hutterer
eede8ccffc Don't crop long value from EvdevBitIsSet.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-04 07:47:47 +10:00
Jools Wills
2aba790ed3 emuThird: Use xf86SetIntOption, not xf86SetBoolOption for integer values
Signed-off-by: Jools Wills <jools@oxfordinspire.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-31 09:58:49 +10:00
Max Schwarz
49693892ce type-safe inline functions for bitmask manipulation
We can't use BitIsSet/SetBit from the server (inputstr.h) since they
operate on byte arrays. EvdevSetBit is added in preparation for the
"smooth-scrolling on wheel emulation" patch.

Signed-off-by: Max Schwarz <Max@x-quadraht.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-24 16:24:35 +10:00
Peter Hutterer
070f30e089 Exit axis labelling if axes are neither rel nor abs
No actual effect since labels_len is always 0 anyway but let's make the
return more explicit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-15 11:34:12 +10:00
Terry Lambert
ffe35b6c25 xf86-input-evdev: Return proper default for unknown values in pInfo->device_control.
Signed-off-by: Terry Lambert <tlambert@chromium.org>
Reviewed-by: Stephane Marchesin <marcheu@chromium.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-07-18 11:44:24 +10:00
Peter Hutterer
5069e05335 Remove unused misc_label and val
evdev.c: In function 'EvdevInitAxesLabels':
evdev.c:2192:11: warning: variable 'misc_label' set but not used
[-Wunused-but-set-variable]
obsolete with 880ad1e19a

emuWheel.c: In function 'EvdevWheelEmuPreInit':
emuWheel.c:252:10: warning: variable 'val' set but not used
[-Wunused-but-set-variable]
obsolete with b0737bdbd1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-06-15 10:36:36 +10:00
Peter Hutterer
0b9fad23a3 Print abs axes ranges on verbosity 6.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-06-15 10:36:36 +10:00
Peter Hutterer
b79776cf8c Require server 1.10
We require ABI 12.2 in the driver, enforce it through pkg-config.
Technically ABI 12.2 is first available in 1.9.99.902 but 1.10 looks so much
nicer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-06-15 10:36:36 +10:00
Daniel Kurtz
a52cd1cab2 Set prop_product_id undeletable
prop_invert was accidentally being set undeletable twice.

Signed-off-by: Daniel Kurtz <djkurtz@google.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-06-15 10:36:13 +10:00
Peter Hutterer
eaf202531f Export device node as property.
There is currently no mapping between XI devices and physical devices other
than what can be extracted by parsing the Xorg logfile. Add new property
"Device Node" to the driver to export the open device file.

Server 1.11 and later standardises on this property name.

The client is responsible for detecting if the device is on the same host
and converting the data into a more useful format (e.g. sysfs path).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-27 15:32:23 +10:00
Peter Korsgaard
74151b3c52 Handle touchscreens without BTN_TOUCH
Some touchscreens (like the Lumio crystaltouch in single touch mode) send
BTN_LEFT rather than BTN_TOUCH:

Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x202e product 0x5 version 0x111
Input device name: "LUMIO Inc LUMIO CrystalTouch ver 1.1C"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 272 (LeftBtn)
    Event code 273 (RightBtn)
    Event code 274 (MiddleBtn)
  Event type 2 (Relative)
    Event code 9 (Misc)
  Event type 3 (Absolute)
    Event code 0 (X)
      Value    650
      Min        0
      Max     4095
    Event code 1 (Y)
      Value   3221
      Min        0
      Max     4095
  Event type 4 (Misc)
    Event code 4 (ScanCode)
Testing ... (interrupt to exit)
Event: time 1305882024.934011, type 4 (Misc), code 4 (ScanCode), value 90001
Event: time 1305882024.934017, type 1 (Key), code 272 (LeftBtn), value 1
Event: time 1305882024.934029, type 3 (Absolute), code 0 (X), value 270
Event: time 1305882024.934034, type 3 (Absolute), code 1 (Y), value 1513
Event: time 1305882024.934039, type 2 (Relative), code 9 (Misc), value 1

This causes evdev to handle these device as a mouse rather than a
touchscreen, which naturally doesn't work very well. We already internally
translate BTN_TOUCH as BTN_LEFT, so accept this kind of devices as
touchscreens by checking for devices with BTN_LEFT, absolute X/Y and NO
relative X/Y axes.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-27 15:26:57 +10:00
Peter Hutterer
e9d96e87ac Add a property to toggle function key mode
On some keyboards, the multimedia function keys are overlaid with the F
keys. This property enables clients to switch the primary mode of these F
keys between function keys and multimedia keys.
Some keyboards provide an Fn key to toggle between the modes. This is
hardware-specific and may or may not work on any given keyboard device.

The current imlementation is only hooked up to apple keyboards.
The kernel provides a tweak to enable/disable.

/sys/module/hid_apple/parameters/fnmode
    0 .. keyboard sends Fx keys, Fn disabled
    1 .. keyboard sends multimedia keys, Fn toggles to function keys
    2 .. keyboard sends function keys, Fn toggles to multimedia keys

If fnmode is on 0, we force it to 2.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Michel Dänzer <michel@daenzer.net>
2011-05-27 15:26:57 +10:00
Peter Hutterer
bb15bac149 Export product/vendor ID through a property.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-05-27 15:26:53 +10:00
Peter Hutterer
7611d2fc73 Move invert variable to the block it is used in.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-05-20 13:38:26 +10:00
Chase Douglas
ebe41bfba7 Copy out of proximity values into current values selectively
Otherwise, an event that causes us to go into proximity with some new
valuator values will retain some old valuator values from when last in
proximity. This change ensures that all values posted while out of
proximity are accounted for.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-18 13:56:32 +10:00
Chase Douglas
68a6a18fc2 Ensure all known valuator values are stored when out of proximity
The current code overwrites *all* the stored axis values with whatever
came in from evdev. Evdev is a stateful protocol, so it only sends us
updates to the axis values that have changed. We need to only update
the values that have changed.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-05 13:49:28 +10:00
Chase Douglas
eeacd3e5a8 Ensure events are posted when entering into proximity
Fixes LP: #736829 (https://bugs.launchpad.net/bugs/573006)

Re-fixes old X.Org Bug 29645
<http://bugs.freedesktop.org/show_bug.cgi?id=29645>

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-05 13:48:58 +10:00
Simon Thum
5708e38494 rename valuator init functions
Since the mode of valuators (no longer?) bears a relation to the device class
actually initialized, this naming was quite misleading.

Signed-off-by: Simon Thum <simon.thum@gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-23 13:11:09 +10:00
Rami Ylimäki
41111ce1ef Remove constness of device filename to avoid warning when freed.
A warning from free() can be avoided by casting the constness away
from its argument pointer or by not declaring the pointer as const in
the first place.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 15:28:10 +10:00
Rami Ylimäki
b4c47d5f94 Release leaked device identifier on input device disconnect.
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 15:23:50 +10:00
Rami Ylimäki
50193a0dd3 Release leaked XKB options on input device disconnect.
Currently the XKB options duplicated in EvdevAddKeyClass are never
released. For example, connecting and disconnecting a bluetooth
keyboard repeatedly causes a steadily growing memory leak.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 15:23:39 +10:00
Peter Hutterer
0049cce4d0 Use Absolute/Relative as argument to xf86Post*
xf86Post* takes an int for the is_absolute parameter. Since the XI protocol
spec requires Relative to be 0 and Absolute to be 1, use those instead to
make the code easier to read.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-02-11 13:31:52 +10:00
Peter Hutterer
d9001a6be9 Add third button emulation.
New properties:
"Evdev Third Button Emulation" → switch on/off
"Evdev Third Button Emulation Timeout" → timeout until event is delivered
"Evdev Third Button Emulation Button" → phys button to be emulated
"Evdev Third Button Emulation Threshold" → move threshold before emulation
is cancelled

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-08 11:34:51 +10:00
Peter Hutterer
22db196815 Static atoms don't need to be initialized to 0.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-31 13:39:46 +10:00
Peter Hutterer
54ac2306b8 Replace xf86Msg() with xf86IDrvMsg().
The latter provides a standardised message format in the form of
    driver name: device name: message

making it easier to grep for driver messages in the log.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-31 12:07:48 +10:00
Chase Douglas
768c25a99b Add support for masked valuators
With the X server now supporting masked valuators for XI2, enable
support in X evdev.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-25 11:34:24 +10:00
Chase Douglas
b5c9f41b2b Switch to "goto" logic for error handling when adding classes
This will be necessary for the addition of multitouch functionality.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-24 14:12:46 +10:00
Chase Douglas
8bc4be3048 Remove support for X input ABI < 12.2
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-24 14:12:39 +10:00
Peter Hutterer
30c3645e20 evdev 2.6.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-11 12:46:40 +10:00
Chase Douglas
3b52fe2ea4 Print out error messages when failing to init devices
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-06 08:35:27 +10:00
Peter Hutterer
540a4cce90 evdev 2.5.99.903
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-05 09:04:56 +10:00
Peter Hutterer
bed25600f6 Don't update first_val and num_val if we don't have data (#32480)
For touchpads, rel_queued may be on (due to abs to rel conversion) but the
delta for x/y is 0/0 on the first touch. Hence, we don't have any valuators
to post. The current results in a num_vals of -15 and a subsequent segfault
when the data is posted to the server.

Start with a last valuator of -1, so that we know if we have at least one to
post.

X.Org Bug 32480 <http://bugs.freedesktop.org/show_bug.cgi?id=32480>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-01-04 08:12:21 +10:00
Peter Hutterer
9aea1c5fa0 Add use_proximity bit for BTN_TOOL handling.
Touchpads send garbage data between BTN_TOOL_FINGER and BTN_TOUCH. This
leads to cursor movement towards invalid positions (bottom left corner,
usually).

Add a new flag "use_proximity" as a delimiter for BTN_TOUCH handling. If
unset, the actual proximity bits are ignored, no proximity events are sent
and BTN_TOUCH is used for the tool handling.

Example event stream for synaptics:

Event: time 1292893041.002731, -------------- Report Sync ------------
Event: time 1292893041.015807, type 1 (Key), code 330 (Touch), value 0
Event: time 1292893041.015812, type 3 (Absolute), code 0 (X), value 4283
Event: time 1292893041.015813, type 3 (Absolute), code 1 (Y), value 4860
Event: time 1292893041.015815, type 3 (Absolute), code 24 (Pressure), value 23
Event: time 1292893041.015817, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1292893041.027537, -------------- Report Sync ------------
Event: time 1292893041.038854, type 3 (Absolute), code 0 (X), value 1
Event: time 1292893041.038857, type 3 (Absolute), code 1 (Y), value 5855
Event: time 1292893041.038859, type 3 (Absolute), code 24 (Pressure), value 1
Event: time 1292893041.038861, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1292893041.038864, -------------- Report Sync ------------
Event: time 1292893041.062432, type 3 (Absolute), code 24 (Pressure), value 0
Event: time 1292893041.062435, type 3 (Absolute), code 28 (Tool Width), value 0
Event: time 1292893041.062437, type 1 (Key), code 325 (ToolFinger), value 0
Event: time 1292893041.062438, -------------- Report Sync ------------

Reported-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
2010-12-22 09:18:52 +10:00
Peter Hutterer
0c987a929d Revert "Don't count BTN_TOUCH as tool. (#29428)"
Synaptics devices send garbage between BTN_TOUCH and BTN_TOOL_FINGER. By
switching to use this as proximity data now, the pointer is reset to the
garbage data position (usually around 1/5855).

This reverts commit 899218e181.

Reported-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
2010-12-22 09:18:52 +10:00
Peter Hutterer
242a01eb0f Rename proximity to in_proximity.
No functional change, just making it a bit more obvious to read.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
2010-12-22 09:07:28 +10:00
Peter Hutterer
7415953b9a Fix grammar typo in comment.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-21 11:13:15 +10:00
Peter Korsgaard
1ced7ec7e2 evdev: rename EvdevCacheCompare() to EvdevCache()
Since 59056e656c (Remove the reopen timer logic) from last year,
EvdevCacheCompare() is only used for caching ioctl values and not for
comparing, so remove the unused compare logic and rename the function
to EvdevCache().

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-13 10:46:43 +10:00
15 changed files with 2797 additions and 1405 deletions

40
10-evdev.conf Normal file
View File

@@ -0,0 +1,40 @@
#
# Catch-all evdev loader for udev-based systems
# We don't simply match on any device since that also adds accelerometers
# and other devices that we don't really want to use. The list below
# matches everything but joysticks.
Section "InputClass"
Identifier "evdev pointer catchall"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev keyboard catchall"
MatchIsKeyboard "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev tablet catchall"
MatchIsTablet "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection

View File

@@ -28,6 +28,7 @@ MAINTAINERCLEANFILES = ChangeLog INSTALL
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-evdev.pc
dist_xorgconf_DATA = 10-evdev.conf
.PHONY: ChangeLog INSTALL

View File

@@ -9,4 +9,6 @@ cd $srcdir
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
$srcdir/configure --enable-maintainer-mode "$@"
if test -z "$NOCONFIGURE"; then
$srcdir/configure "$@"
fi

View File

@@ -23,7 +23,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-evdev],
[2.5.99.902],
[2.10.3],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xf86-input-evdev])
AC_CONFIG_SRCDIR([Makefile.am])
@@ -32,7 +32,6 @@ AC_CONFIG_AUX_DIR(.)
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
# Initialize libtool
AC_DISABLE_STATIC
@@ -45,7 +44,11 @@ XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
# Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, xorg-server xproto inputproto)
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.12] xproto [inputproto >= 2.1.99.3])
PKG_CHECK_MODULES(UDEV, libudev)
PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
PKG_CHECK_MODULES(MTDEV, mtdev)
# Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir,
@@ -56,6 +59,13 @@ AC_ARG_WITH(xorg-module-dir,
inputdir=${moduledir}/input
AC_SUBST(inputdir)
AC_ARG_WITH(xorg-conf-dir,
AC_HELP_STRING([--with-xorg-conf-dir=DIR],
[Default xorg.conf.d directory [[default=$prefix/share/X11/xorg.conf.d/]]]),
[xorgconfdir="$withval"],
[xorgconfdir="$prefix/share/X11/xorg.conf.d"])
AC_SUBST(xorgconfdir)
# X Server SDK location is required to install evdev header files
# This location is also relayed in the xorg-evdev.pc file
sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`

View File

@@ -66,4 +66,29 @@
/* BOOL */
#define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap"
/* BOOL */
#define EVDEV_PROP_THIRDBUTTON "Evdev Third Button Emulation"
/* CARD32 */
#define EVDEV_PROP_THIRDBUTTON_TIMEOUT "Evdev Third Button Emulation Timeout"
/* CARD8 */
#define EVDEV_PROP_THIRDBUTTON_BUTTON "Evdev Third Button Emulation Button"
/* CARD32 */
#define EVDEV_PROP_THIRDBUTTON_THRESHOLD "Evdev Third Button Emulation Threshold"
/* CARD8, 1 value,
This property is initialized on devices that have multimedia keys on the
function keys. The value of the property selects the default behaviour
for the function keys. The behaviour of the fn key (if any exists) is
hardware specific. On some hardware, fn may toggle the other set of
functions available on the keys.
0 send functions keys by default, fn may toggle to multimedia keys
1 send multimedia keys by default, fn may toggle to function keys
*/
#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

@@ -66,7 +66,8 @@ is used. Buttons not specified in the user's mapping use the default mapping.
.BI "Option \*qDevice\*q \*q" string \*q
Specifies the device through which the device can be accessed. This will
generally be of the form \*q/dev/input/eventX\*q, where X is some integer.
The mapping from device node to hardware is system-dependent.
The mapping from device node to hardware is system-dependent. Property:
"Device Node" (read-only).
.TP 7
.BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q
Sets \*qdrag lock buttons\*q that simulate holding a button down, so
@@ -124,6 +125,19 @@ Property: "Evdev Wheel Emulation Button".
Specifies how far (in pixels) the pointer must move to generate button
press/release events in wheel emulation mode. Default: 10. Property: "Evdev
Wheel Emulation Inertia".
.IP
This value must be set for any device does not resemble a standard mouse.
Specifically, on absolute devices such as tablets the value should be set to
a reasonable fraction of the expected movement to avoid excess scroll events.
.IP
.B WARNING:
the name \*qinertia\*q is a misnomer. This option defines the distance
required to generate one scroll event similar to the
.B VertScrollDelta
and
.B HorizScrollDelta
options. It does not enable inertia in the
physical sense, scrolling stops immediately once the movement has stopped.
.TP 7
.BI "Option \*qEmulateWheelTimeout\*q \*q" integer \*q
Specifies the time in milliseconds the
@@ -133,6 +147,31 @@ must be pressed before wheel emulation is started. If the
is released before this timeout, the original button press/release event
is sent. Default: 200. Property: "Evdev Wheel Emulation Timeout".
.TP 7
.BI "Option \*qEmulateThirdButton\*q \*q" boolean \*q
Enable third button emulation. Third button emulation emits a right button
event (by default) by pressing and holding the first button. The first
button must be held down for the configured timeout and must not move more
than the configured threshold for the emulation to activate. Otherwise, the
first button event is posted as normal. Default: off. Property: "Evdev
Third Button Emulation".
.TP 7
.BI "Option \*qEmulateThirdButtonTimeout\*q \*q" integer \*q
Specifies the timeout in milliseconds between the initial button press and
the generation of the emulated button event.
Default: 1000. Property: "Evdev Third Button Emulation Timeout".
.TP 7
.BI "Option \*qEmulateThirdButtonButton\*q \*q" integer \*q
Specifies the physical button number to be emitted if third button emulation
is triggered.
Default: 3. Property: "Evdev Third Button Button".
.TP 7
.BI "Option \*qEmulateThirdButtonMoveThreshold\*q \*q" integer \*q
Specifies the maximum move fuzz in device coordinates for third button
emulation. If the device moves by more than this threshold before the third
button emulation is triggered, the emulation is cancelled and a first button
event is generated as normal.
Default: 20. Property: "Evdev Third Button Emulation Threshold".
.TP 7
.BI "Option \*qGrabDevice\*q \*q" boolean \*q
Force a grab on the event device. Doing so will ensure that no other driver
can initialise the same device and it will also stop the device from sending
@@ -194,6 +233,30 @@ is mapped to the negative Y axis motion and button number
.I N2
is mapped to the positive Y axis motion. Default: "4 5". Property:
"Evdev Wheel Emulation Axes".
.TP 7
.BI "Option \*qTypeName\*q \*q"type"\*q
Specify the X Input 1.x type (see XListInputDevices(__libmansuffix__)).
There is rarely a need to use this option, evdev will guess the device type
based on the device's capabilities. This option is provided for devices that
need quirks.
.TP 7
.BI "Option \*qVertScrollDelta\*q \*q" integer \*q
The amount of motion considered one unit of scrolling vertically.
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". 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".
.TP 7
.BI "Option \*qResolution\*q \*q" integer \*q
Sets the resolution of the device in dots per inch. The resolution is used
to scale relative motion events from mouse devices to 1000 DPI resolution. This
can be used to make high resolution mice less sensitive without turning off
acceleration. If set to 0 no scaling will be performed. Default: "0".
.SH SUPPORTED PROPERTIES
The following properties are provided by the
@@ -234,6 +297,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

@@ -26,15 +26,19 @@
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
AM_CPPFLAGS =-I$(top_srcdir)/include
AM_CPPFLAGS =-I$(top_srcdir)/include $(LIBEVDEV_CFLAGS)
@DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
@DRIVER_NAME@_drv_la_LIBADD = $(MTDEV_LIBS) $(UDEV_LIBS) $(LIBEVDEV_LIBS)
@DRIVER_NAME@_drv_ladir = @inputdir@
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \
@DRIVER_NAME@.h \
emuMB.c \
emuThird.c \
emuWheel.c \
draglock.c
draglock.c \
apple.c \
axis_labels.h

313
src/apple.c Normal file
View File

@@ -0,0 +1,313 @@
/*
* Copyright © 2011 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <evdev.h>
#include <evdev-properties.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <exevents.h>
#include <xf86.h>
#include <xf86Xinput.h>
#include <X11/Xatom.h>
/* Apple-specific controls.
*
* On Apple keyboards, the multimedia function keys are overlaid with the F
* keys. F1 is also BrightnessDown, F10 is Mute, etc. The kernel provides a
* tweak to enable/disable this.
*
* /sys/module/hid_apple/parameters/fnmode
* 0 .. keyboard sends Fx keys, fn is disabled
* 1 .. keyboard sends multimedia keys, fn sends Fx keys
* 2 .. keyboard sends Fx keys, fn sends multimedia keys
*
* We only handle 1 and 2, don't care about 0. If fnmode is found to be on
* 0, we force it to 2 instead.
*/
/* In this file: fkeymode refers to the evdev-specific enums and parameters,
* fnmode refers to the fnmode parameter exposed by the kernel. fnmode is
* apple-specific */
#define FNMODE_PATH "/sys/module/hid_apple/parameters/fnmode"
/* Taken from the kernel */
#define USB_VENDOR_ID_APPLE 0x05ac
#define USB_DEVICE_ID_APPLE_ALU_MINI_ANSI 0x021d
#define USB_DEVICE_ID_APPLE_ALU_MINI_ISO 0x021e
#define USB_DEVICE_ID_APPLE_ALU_MINI_JIS 0x021f
#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
static int EvdevAppleGetProperty (DeviceIntPtr dev, Atom property);
static int EvdevAppleSetProperty(DeviceIntPtr dev, Atom atom,
XIPropertyValuePtr val, BOOL checkonly);
static Atom prop_fkeymode;
static Bool fnmode_readonly; /* set if we can only read fnmode */
struct product_table
{
unsigned int vendor;
unsigned int product;
} apple_keyboard_table[] = {
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO},
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS},
{ 0, 0}
};
/**
* @return TRUE if the device matches a product in the given product table,
* FALSE otherwise
*/
static Bool product_check(const struct product_table *t, int vendor, int product)
{
while (t->vendor)
{
if (vendor == t->vendor && product == t->product)
return TRUE;
t++;
}
return FALSE;
}
/**
* @return 0 on success, -1 otherwise (check errno)
*/
static int
set_fnmode(enum fkeymode fkeymode)
{
int fd;
char mode;
int bytes_written;
if (fkeymode == FKEYMODE_UNKNOWN)
{
errno = EINVAL; /* silly you */
return -1;
}
fd = open(FNMODE_PATH, O_WRONLY);
if (fd < 0)
return -1;
mode = (fkeymode == FKEYMODE_FKEYS) ? '2' : '1';
bytes_written = write(fd, &mode, 1);
close(fd);
return (bytes_written == 1) ? 0 : -1;
}
/**
* Get the current value of fnmode. If fnmode is found to be on 0, we set it
* to 2 in the process. Yes, quite daring, I know. I live on the edge.
*
* @return The current setting of fnmode or FKEYMODE_UNKNOWN on error (check
* errno)
*/
static enum fkeymode
get_fnmode(void)
{
int fd;
char retvalue;
fd = open(FNMODE_PATH, O_RDWR);
if (fd < 0 && errno == EACCES)
{
fnmode_readonly = TRUE;
fd = open(FNMODE_PATH, O_RDONLY);
}
if (fd < 0)
goto err;
if (read(fd, &retvalue, 1) != 1)
goto err;
if (retvalue != '0' && retvalue != '1' && retvalue != '2')
{
xf86Msg(X_ERROR, "Invalid fnmode value: %c\n", retvalue);
errno = EINVAL;
goto err;
}
close(fd);
/* we don't want 0, switch to 2 */
if (retvalue == '0')
{
if (fnmode_readonly)
xf86Msg(X_WARNING, "fnmode is disabled and read-only. Fn key will"
"not toggle to multimedia keys.\n");
else
set_fnmode(FKEYMODE_FKEYS);
}
return retvalue == '1' ? FKEYMODE_MMKEYS : FKEYMODE_FKEYS;
err:
if (fd >= 0)
close(fd);
return FKEYMODE_UNKNOWN;
}
/**
* Set the property value to fkeymode. If the property doesn't exist,
* initialize it.
*/
static void set_fkeymode_property(InputInfoPtr pInfo, enum fkeymode fkeymode)
{
DeviceIntPtr dev = pInfo->dev;
BOOL init = FALSE;
char data;
switch(fkeymode)
{
case FKEYMODE_FKEYS: data = 0; break;
case FKEYMODE_MMKEYS: data = 1; break;
case FKEYMODE_UNKNOWN:
xf86IDrvMsg(pInfo, X_ERROR, "Failed to get fnmode (%s)\n", strerror(errno));
return;
}
if (!prop_fkeymode) {
init = TRUE;
prop_fkeymode = MakeAtom(EVDEV_PROP_FUNCTION_KEYS, strlen(EVDEV_PROP_FUNCTION_KEYS), TRUE);
}
/* Don't send an event if we're initializing the property */
XIChangeDeviceProperty(dev, prop_fkeymode, XA_INTEGER, 8,
PropModeReplace, 1, &data, !init);
if (init)
{
XISetDevicePropertyDeletable(dev, prop_fkeymode, FALSE);
XIRegisterPropertyHandler(dev, EvdevAppleSetProperty, EvdevAppleGetProperty, NULL);
}
}
/**
* Called when a client reads the property state.
* Update with current kernel state, it may have changed behind our back.
*/
static int
EvdevAppleGetProperty (DeviceIntPtr dev, Atom property)
{
if (property == prop_fkeymode)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
enum fkeymode fkeymode;
fkeymode = get_fnmode();
if (fkeymode != pEvdev->fkeymode) {
/* set internal copy first, so we don't write to the file in
* SetProperty handler */
pEvdev->fkeymode = fkeymode;
set_fkeymode_property(pInfo, fkeymode);
}
}
return Success;
}
static int
EvdevAppleSetProperty(DeviceIntPtr dev, Atom atom,
XIPropertyValuePtr val, BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
if (atom == prop_fkeymode)
{
CARD8 v = *(CARD8*)val->data;
if (val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
if (fnmode_readonly)
return BadAccess;
if (v > 1)
return BadValue;
if (!checkonly)
{
if ((!v && pEvdev->fkeymode != FKEYMODE_FKEYS) ||
(v && pEvdev->fkeymode != FKEYMODE_MMKEYS))
{
pEvdev->fkeymode = v ? FKEYMODE_MMKEYS : FKEYMODE_FKEYS;
set_fnmode(pEvdev->fkeymode);
}
}
}
return Success;
}
void
EvdevAppleInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
enum fkeymode fkeymode;
if (!product_check(apple_keyboard_table,
libevdev_get_id_vendor(pEvdev->dev),
libevdev_get_id_product(pEvdev->dev)))
return;
fkeymode = get_fnmode();
pEvdev->fkeymode = fkeymode;
set_fkeymode_property(pInfo, fkeymode);
}

198
src/axis_labels.h Normal file
View File

@@ -0,0 +1,198 @@
/*
* Copyright © 2004-2008 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <xserver-properties.h>
#ifndef AXIS_LABELS
#define AXIS_LABELS
/* Aligned with linux/input.h.
Note that there are holes in the ABS_ range, these are simply replaced with
MISC here */
static const char* abs_labels[] = {
AXIS_LABEL_PROP_ABS_X, /* 0x00 */
AXIS_LABEL_PROP_ABS_Y, /* 0x01 */
AXIS_LABEL_PROP_ABS_Z, /* 0x02 */
AXIS_LABEL_PROP_ABS_RX, /* 0x03 */
AXIS_LABEL_PROP_ABS_RY, /* 0x04 */
AXIS_LABEL_PROP_ABS_RZ, /* 0x05 */
AXIS_LABEL_PROP_ABS_THROTTLE, /* 0x06 */
AXIS_LABEL_PROP_ABS_RUDDER, /* 0x07 */
AXIS_LABEL_PROP_ABS_WHEEL, /* 0x08 */
AXIS_LABEL_PROP_ABS_GAS, /* 0x09 */
AXIS_LABEL_PROP_ABS_BRAKE, /* 0x0a */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_HAT0X, /* 0x10 */
AXIS_LABEL_PROP_ABS_HAT0Y, /* 0x11 */
AXIS_LABEL_PROP_ABS_HAT1X, /* 0x12 */
AXIS_LABEL_PROP_ABS_HAT1Y, /* 0x13 */
AXIS_LABEL_PROP_ABS_HAT2X, /* 0x14 */
AXIS_LABEL_PROP_ABS_HAT2Y, /* 0x15 */
AXIS_LABEL_PROP_ABS_HAT3X, /* 0x16 */
AXIS_LABEL_PROP_ABS_HAT3Y, /* 0x17 */
AXIS_LABEL_PROP_ABS_PRESSURE, /* 0x18 */
AXIS_LABEL_PROP_ABS_DISTANCE, /* 0x19 */
AXIS_LABEL_PROP_ABS_TILT_X, /* 0x1a */
AXIS_LABEL_PROP_ABS_TILT_Y, /* 0x1b */
AXIS_LABEL_PROP_ABS_TOOL_WIDTH, /* 0x1c */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_VOLUME /* 0x20 */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MISC, /* undefined */
AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR, /* 0x30 */
AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR, /* 0x31 */
AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR, /* 0x32 */
AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR, /* 0x33 */
AXIS_LABEL_PROP_ABS_MT_ORIENTATION, /* 0x34 */
AXIS_LABEL_PROP_ABS_MT_POSITION_X, /* 0x35 */
AXIS_LABEL_PROP_ABS_MT_POSITION_Y, /* 0x36 */
AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE, /* 0x37 */
AXIS_LABEL_PROP_ABS_MT_BLOB_ID, /* 0x38 */
AXIS_LABEL_PROP_ABS_MT_TRACKING_ID, /* 0x39 */
AXIS_LABEL_PROP_ABS_MT_PRESSURE, /* 0x3a */
#ifdef AXIS_LABEL_PROP_ABS_MT_DISTANCE
AXIS_LABEL_PROP_ABS_MT_DISTANCE, /* 0x3b */
AXIS_LABEL_PROP_ABS_MT_TOOL_X, /* 0x3c */
AXIS_LABEL_PROP_ABS_MT_TOOL_Y, /* 0x3d */
#endif /* AXIS_LABEL_PROP_ABS_MT_DISTANCE */
};
static const char* rel_labels[] = {
AXIS_LABEL_PROP_REL_X,
AXIS_LABEL_PROP_REL_Y,
AXIS_LABEL_PROP_REL_Z,
AXIS_LABEL_PROP_REL_RX,
AXIS_LABEL_PROP_REL_RY,
AXIS_LABEL_PROP_REL_RZ,
AXIS_LABEL_PROP_REL_HWHEEL,
AXIS_LABEL_PROP_REL_DIAL,
AXIS_LABEL_PROP_REL_WHEEL,
AXIS_LABEL_PROP_REL_MISC
};
static const char* btn_labels[][16] = {
{ /* BTN_MISC group offset 0x100*/
BTN_LABEL_PROP_BTN_0, /* 0x00 */
BTN_LABEL_PROP_BTN_1, /* 0x01 */
BTN_LABEL_PROP_BTN_2, /* 0x02 */
BTN_LABEL_PROP_BTN_3, /* 0x03 */
BTN_LABEL_PROP_BTN_4, /* 0x04 */
BTN_LABEL_PROP_BTN_5, /* 0x05 */
BTN_LABEL_PROP_BTN_6, /* 0x06 */
BTN_LABEL_PROP_BTN_7, /* 0x07 */
BTN_LABEL_PROP_BTN_8, /* 0x08 */
BTN_LABEL_PROP_BTN_9 /* 0x09 */
},
{ /* BTN_MOUSE group offset 0x110 */
BTN_LABEL_PROP_BTN_LEFT, /* 0x00 */
BTN_LABEL_PROP_BTN_RIGHT, /* 0x01 */
BTN_LABEL_PROP_BTN_MIDDLE, /* 0x02 */
BTN_LABEL_PROP_BTN_SIDE, /* 0x03 */
BTN_LABEL_PROP_BTN_EXTRA, /* 0x04 */
BTN_LABEL_PROP_BTN_FORWARD, /* 0x05 */
BTN_LABEL_PROP_BTN_BACK, /* 0x06 */
BTN_LABEL_PROP_BTN_TASK /* 0x07 */
},
{ /* BTN_JOYSTICK group offset 0x120 */
BTN_LABEL_PROP_BTN_TRIGGER, /* 0x00 */
BTN_LABEL_PROP_BTN_THUMB, /* 0x01 */
BTN_LABEL_PROP_BTN_THUMB2, /* 0x02 */
BTN_LABEL_PROP_BTN_TOP, /* 0x03 */
BTN_LABEL_PROP_BTN_TOP2, /* 0x04 */
BTN_LABEL_PROP_BTN_PINKIE, /* 0x05 */
BTN_LABEL_PROP_BTN_BASE, /* 0x06 */
BTN_LABEL_PROP_BTN_BASE2, /* 0x07 */
BTN_LABEL_PROP_BTN_BASE3, /* 0x08 */
BTN_LABEL_PROP_BTN_BASE4, /* 0x09 */
BTN_LABEL_PROP_BTN_BASE5, /* 0x0a */
BTN_LABEL_PROP_BTN_BASE6, /* 0x0b */
NULL,
NULL,
NULL,
BTN_LABEL_PROP_BTN_DEAD /* 0x0f */
},
{ /* BTN_GAMEPAD group offset 0x130 */
BTN_LABEL_PROP_BTN_A, /* 0x00 */
BTN_LABEL_PROP_BTN_B, /* 0x01 */
BTN_LABEL_PROP_BTN_C, /* 0x02 */
BTN_LABEL_PROP_BTN_X, /* 0x03 */
BTN_LABEL_PROP_BTN_Y, /* 0x04 */
BTN_LABEL_PROP_BTN_Z, /* 0x05 */
BTN_LABEL_PROP_BTN_TL, /* 0x06 */
BTN_LABEL_PROP_BTN_TR, /* 0x07 */
BTN_LABEL_PROP_BTN_TL2, /* 0x08 */
BTN_LABEL_PROP_BTN_TR2, /* 0x09 */
BTN_LABEL_PROP_BTN_SELECT, /* 0x0a */
BTN_LABEL_PROP_BTN_START, /* 0x0b */
BTN_LABEL_PROP_BTN_MODE, /* 0x0c */
BTN_LABEL_PROP_BTN_THUMBL, /* 0x0d */
BTN_LABEL_PROP_BTN_THUMBR /* 0x0e */
},
{ /* BTN_DIGI group offset 0x140 */
BTN_LABEL_PROP_BTN_TOOL_PEN, /* 0x00 */
BTN_LABEL_PROP_BTN_TOOL_RUBBER, /* 0x01 */
BTN_LABEL_PROP_BTN_TOOL_BRUSH, /* 0x02 */
BTN_LABEL_PROP_BTN_TOOL_PENCIL, /* 0x03 */
BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH, /* 0x04 */
BTN_LABEL_PROP_BTN_TOOL_FINGER, /* 0x05 */
BTN_LABEL_PROP_BTN_TOOL_MOUSE, /* 0x06 */
BTN_LABEL_PROP_BTN_TOOL_LENS, /* 0x07 */
NULL,
NULL,
BTN_LABEL_PROP_BTN_TOUCH, /* 0x0a */
BTN_LABEL_PROP_BTN_STYLUS, /* 0x0b */
BTN_LABEL_PROP_BTN_STYLUS2, /* 0x0c */
BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP, /* 0x0d */
BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP /* 0x0e */
},
{ /* BTN_WHEEL group offset 0x150 */
BTN_LABEL_PROP_BTN_GEAR_DOWN, /* 0x00 */
BTN_LABEL_PROP_BTN_GEAR_UP /* 0x01 */
}
};
#endif

View File

@@ -44,9 +44,7 @@
#include <evdev-properties.h>
#ifdef HAVE_PROPERTIES
static Atom prop_dlock = 0; /* Drag lock buttons. */
#endif
void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button);
@@ -105,13 +103,12 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
/* We only have a meta button */
pEvdev->dragLock.meta = meta_button;
xf86Msg(X_CONFIG, "%s: DragLockButtons : "
"%i as meta\n",
pInfo->name, meta_button);
xf86IDrvMsg(pInfo, X_CONFIG, "DragLockButtons : "
"%i as meta\n", meta_button);
} else {
xf86Msg(X_ERROR, "%s: DragLockButtons : "
"Incomplete pair specifying button pairs %s\n",
pInfo->name, option_string);
xf86IDrvMsg(pInfo, X_ERROR, "DragLockButtons : "
"Incomplete pair specifying button pairs %s\n",
option_string);
}
} else {
@@ -119,23 +116,24 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
if ((meta_button <= EVDEV_MAXBUTTONS) && (meta_button >= 0 ) &&
(lock_button <= EVDEV_MAXBUTTONS) && (lock_button >= 0)) {
xf86Msg(X_CONFIG, "%s: DragLockButtons : %i -> %i\n",
pInfo->name, meta_button, lock_button);
xf86IDrvMsg(pInfo, X_CONFIG,
"DragLockButtons : %i -> %i\n",
meta_button, lock_button);
pEvdev->dragLock.lock_pair[meta_button - 1] = lock_button;
pairs=TRUE;
} else {
/* Let the user know something was wrong
with this pair of buttons */
xf86Msg(X_CONFIG, "%s: DragLockButtons : "
"Invalid button pair %i -> %i\n",
pInfo->name, meta_button, lock_button);
xf86IDrvMsg(pInfo, X_CONFIG,"DragLockButtons : "
"Invalid button pair %i -> %i\n",
meta_button, lock_button);
}
}
} else {
xf86Msg(X_ERROR, "%s: Found DragLockButtons "
"with invalid lock button string : '%s'\n",
pInfo->name, option_string);
xf86IDrvMsg(pInfo, X_ERROR, "Found DragLockButtons "
"with invalid lock button string : '%s'\n",
option_string);
/* This should be the case anyhow, just make sure */
next_num = NULL;
@@ -211,7 +209,6 @@ EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value)
return FALSE;
}
#ifdef HAVE_PROPERTIES
/**
* Set the drag lock property.
* If only one value is supplied, then this is used as the meta button.
@@ -319,5 +316,3 @@ EvdevDragLockInitProperty(DeviceIntPtr dev)
XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
}
#endif

View File

@@ -43,10 +43,8 @@
#include <evdev-properties.h>
#ifdef HAVE_PROPERTIES
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
static Atom prop_mbtimeout = 0; /* Middle button timeout property */
#endif
/*
* Lets create a simple finite-state machine for 3 button emulation:
*
@@ -193,12 +191,13 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
pEvdev->emulateMB.pending = FALSE;
if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
EvdevPostButtonEvent(pInfo, abs(id),
(id >= 0) ? BUTTON_PRESS : BUTTON_RELEASE);
pEvdev->emulateMB.state =
stateTab[pEvdev->emulateMB.state][4][2];
} else {
ErrorF("Got unexpected buttonTimer in state %d\n",
pEvdev->emulateMB.state);
xf86IDrvMsg(pInfo, X_ERROR, "Got unexpected buttonTimer in state %d\n",
pEvdev->emulateMB.state);
}
xf86UnblockSIGIO (sigstate);
@@ -330,7 +329,6 @@ EvdevMBEmuFinalize(InputInfoPtr pInfo)
}
#ifdef HAVE_PROPERTIES
static int
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
@@ -391,4 +389,3 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
}
#endif

416
src/emuThird.c Normal file
View File

@@ -0,0 +1,416 @@
/*
* Copyright © 2011 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of the authors
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. The authors make no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* Right mouse button emulation code.
* Emulates a right button event if the first button is held down for a
* timeout. If the device moves more than a certain amount before the
* timeout is over, the emulation is cancelled and a normal button event is
* generated.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
#include <xf86Xinput.h>
#include <exevents.h>
#include <evdev-properties.h>
/* Threshold (in device coordinates) for devices to cancel emulation */
#define DEFAULT_MOVE_THRESHOLD 20
static Atom prop_3bemu; /* Right button emulation on/off property */
static Atom prop_3btimeout; /* Right button timeout property */
static Atom prop_3bbutton; /* Right button target physical button */
static Atom prop_3bthreshold; /* Right button move cancellation threshold */
/* State machine for 3rd button emulation */
enum EmulationState {
EM3B_OFF, /* no event */
EM3B_PENDING, /* timer pending */
EM3B_EMULATING /* in emulation */
};
static void
Evdev3BEmuPostButtonEvent(InputInfoPtr pInfo, int button, enum ButtonAction act)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
int absolute = Relative;
/* if we cancel, emit the button down event at our start position,
* not at the current position. Only for absolute devices though. For
* relative events, this may be a bit iffy since pointer accel may shoot
* us back more than we moved and confuse the user.
*/
if (emu3B->flags & EVDEV_ABSOLUTE_EVENTS)
absolute = Absolute;
xf86PostButtonEventP(pInfo->dev, absolute, button,
(act == BUTTON_PRESS) ? 1 : 0, 0,
(absolute ? 2 : 0), emu3B->startpos);
}
/**
* Timer function. Post a button down event to the server.
*
* @param arg The InputInfoPtr for this device.
*/
CARD32
Evdev3BEmuTimer(OsTimerPtr timer, CARD32 time, pointer arg)
{
InputInfoPtr pInfo = (InputInfoPtr)arg;
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
int sigstate = 0;
sigstate = xf86BlockSIGIO ();
emu3B->state = EM3B_EMULATING;
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_PRESS);
xf86UnblockSIGIO (sigstate);
return 0;
}
/**
* Cancel all emulation, reset the timer and reset deltas.
*/
static void
Evdev3BCancel(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
if (emu3B->state != EM3B_OFF)
{
TimerCancel(emu3B->timer);
emu3B->state = EM3B_OFF;
memset(emu3B->delta, 0, sizeof(emu3B->delta));
}
emu3B->flags = 0;
}
/**
* Emulate a third button on button press. Note that emulation only triggers
* on button 1.
*
* Return TRUE if event was swallowed by middle mouse button emulation,
* FALSE otherwise.
*/
BOOL
Evdev3BEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
int ret = FALSE;
if (!emu3B->enabled)
goto out;
if (press)
emu3B->buttonstate |= button;
else
emu3B->buttonstate &= ~button;
/* Any other button pressed? Cancel timer */
if (button != 1)
{
switch (emu3B->state)
{
case EM3B_PENDING:
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
Evdev3BCancel(pInfo);
break;
case EM3B_EMULATING:
/* We're emulating and now the user pressed a different
* button. Just release the emulating one, tell the user to
* not do that and get on with life */
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_RELEASE);
Evdev3BCancel(pInfo);
break;
default:
break;
}
goto out;
}
/* Don't emulate if any other button is down */
if ((emu3B->buttonstate & ~0x1) != 0)
goto out;
/* Release event → cancel, send press and release now. */
if (!press)
{
switch(emu3B->state)
{
case EM3B_PENDING:
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
Evdev3BCancel(pInfo);
break;
case EM3B_EMULATING:
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_RELEASE);
Evdev3BCancel(pInfo);
ret = TRUE;
break;
default:
break;
}
goto out;
}
if (press && emu3B->state == EM3B_OFF)
{
emu3B->state = EM3B_PENDING;
emu3B->timer = TimerSet(emu3B->timer, 0, emu3B->timeout,
Evdev3BEmuTimer, pInfo);
ret = TRUE;
goto out;
}
out:
return ret;
}
/**
* Handle absolute x/y motion. If the motion is above the threshold, cancel
* emulation.
*/
void
Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
int cancel = FALSE;
int axis = 0;
if (emu3B->state != EM3B_PENDING)
{
if (valuator_mask_isset(vals, 0))
emu3B->startpos[0] = valuator_mask_get(vals, 0);
if (valuator_mask_isset(vals, 1))
emu3B->startpos[1] = valuator_mask_get(vals, 1);
return;
}
if ((emu3B->flags & EVDEV_ABSOLUTE_EVENTS) == 0)
emu3B->flags |= EVDEV_ABSOLUTE_EVENTS;
while (axis <= 1 && !cancel)
{
if (valuator_mask_isset(vals, axis))
{
double delta = valuator_mask_get_double(vals, axis) - emu3B->startpos[axis];
if (fabs(delta) > emu3B->threshold)
cancel = TRUE;
}
axis++;
}
if (cancel)
{
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
Evdev3BCancel(pInfo);
}
}
/**
* Handle relative x/y motion. If the motion is above the threshold, cancel
* emulation.
*/
void
Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, double dx, double dy)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
if (emu3B->state != EM3B_PENDING)
return;
emu3B->delta[0] += dx;
emu3B->delta[1] += dy;
emu3B->flags |= EVDEV_RELATIVE_EVENTS;
if (fabs(emu3B->delta[0]) > emu3B->threshold ||
fabs(emu3B->delta[1]) > emu3B->threshold)
{
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
Evdev3BCancel(pInfo);
}
}
void
Evdev3BEmuPreInit(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
emu3B->enabled = xf86SetBoolOption(pInfo->options,
"EmulateThirdButton",
FALSE);
emu3B->timeout = xf86SetIntOption(pInfo->options,
"EmulateThirdButtonTimeout",
1000);
emu3B->button = xf86SetIntOption(pInfo->options,
"EmulateThirdButtonButton",
3);
/* FIXME: this should be auto-configured based on axis ranges */
emu3B->threshold = xf86SetIntOption(pInfo->options,
"EmulateThirdButtonMoveThreshold",
DEFAULT_MOVE_THRESHOLD);
/* allocate now so we don't allocate in the signal handler */
emu3B->timer = TimerSet(NULL, 0, 0, NULL, NULL);
}
void
Evdev3BEmuOn(InputInfoPtr pInfo)
{
/* This function just exists for symmetry in evdev.c */
}
void
Evdev3BEmuFinalize(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
TimerFree(emu3B->timer);
emu3B->timer = NULL;
}
static int
Evdev3BEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
if (atom == prop_3bemu)
{
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
emu3B->enabled = *((BOOL*)val->data);
} else if (atom == prop_3btimeout)
{
if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
emu3B->timeout = *((CARD32*)val->data);
} else if (atom == prop_3bbutton)
{
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
emu3B->button = *((CARD8*)val->data);
} else if (atom == prop_3bthreshold)
{
if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
emu3B->threshold = *((CARD32*)val->data);
}
return Success;
}
/**
* Initialise properties for third button emulation
*/
void
Evdev3BEmuInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
int rc;
if (!dev->button) /* don't init prop for keyboards */
return;
/* third button emulation on/off */
prop_3bemu = MakeAtom(EVDEV_PROP_THIRDBUTTON, strlen(EVDEV_PROP_THIRDBUTTON), TRUE);
rc = XIChangeDeviceProperty(dev, prop_3bemu, XA_INTEGER, 8,
PropModeReplace, 1,
&emu3B->enabled,
FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_3bemu, FALSE);
/* third button emulation timeout */
prop_3btimeout = MakeAtom(EVDEV_PROP_THIRDBUTTON_TIMEOUT,
strlen(EVDEV_PROP_THIRDBUTTON_TIMEOUT),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_3btimeout, XA_INTEGER, 32, PropModeReplace, 1,
&emu3B->timeout, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_3btimeout, FALSE);
/* third button emulation button to be triggered */
prop_3bbutton = MakeAtom(EVDEV_PROP_THIRDBUTTON_BUTTON,
strlen(EVDEV_PROP_THIRDBUTTON_BUTTON),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_3bbutton, XA_INTEGER, 8, PropModeReplace, 1,
&emu3B->button, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_3bbutton, FALSE);
/* third button emulation movement threshold */
prop_3bthreshold = MakeAtom(EVDEV_PROP_THIRDBUTTON_THRESHOLD,
strlen(EVDEV_PROP_THIRDBUTTON_THRESHOLD),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_3bthreshold, XA_INTEGER, 32, PropModeReplace, 1,
&emu3B->threshold, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_3bthreshold, FALSE);
XIRegisterPropertyHandler(dev, Evdev3BEmuSetProperty, NULL, NULL);
}

View File

@@ -44,16 +44,13 @@
#define WHEEL_NOT_CONFIGURED 0
#ifdef HAVE_PROPERTIES
static Atom prop_wheel_emu = 0;
static Atom prop_wheel_axismap = 0;
static Atom prop_wheel_inertia = 0;
static Atom prop_wheel_timeout = 0;
static Atom prop_wheel_button = 0;
#endif
/* Local Funciton Prototypes */
static BOOL EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char *axis_name);
static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
/* Filter mouse button events */
@@ -98,9 +95,8 @@ BOOL
EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
WheelAxisPtr pAxis = NULL, pOtherAxis = NULL;
WheelAxisPtr pAxis = NULL;
int value = pEv->value;
int oldValue;
/* Has wheel emulation been configured to be enabled? */
if (!pEvdev->emulateWheel.enabled)
@@ -118,11 +114,15 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
return TRUE;
}
/* We don't want to intercept real mouse wheel events */
if(pEv->type == EV_ABS) {
oldValue = pEvdev->vals[pEvdev->axis_map[pEv->code]];
pEvdev->vals[pEvdev->axis_map[pEv->code]] = value;
value -= oldValue; /* make value into a differential measurement */
int axis = pEvdev->abs_axis_map[pEv->code];
int oldValue;
if (axis > -1 && valuator_mask_fetch(pEvdev->old_vals, axis, &oldValue)) {
valuator_mask_set(pEvdev->abs_vals, axis, value);
value -= oldValue; /* make value into a differential measurement */
} else
value = 0; /* avoid a jump on the first touch */
}
switch(pEv->code) {
@@ -130,13 +130,11 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
/* ABS_X has the same value as REL_X, so this case catches both */
case REL_X:
pAxis = &(pEvdev->emulateWheel.X);
pOtherAxis = &(pEvdev->emulateWheel.Y);
break;
/* ABS_Y has the same value as REL_Y, so this case catches both */
case REL_Y:
pAxis = &(pEvdev->emulateWheel.Y);
pOtherAxis = &(pEvdev->emulateWheel.X);
break;
default:
@@ -144,15 +142,10 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
}
/* If we found REL_X, REL_Y, ABS_X or ABS_Y then emulate a mouse
wheel. Reset the inertia of the other axis when a scroll event
was sent to avoid the buildup of erroneous scroll events if the
user doesn't move in a perfectly straight line.
wheel.
*/
if (pAxis)
{
if (EvdevWheelEmuInertia(pInfo, pAxis, value))
pOtherAxis->traveled_distance = 0;
}
EvdevWheelEmuInertia(pInfo, pAxis, value);
/* Eat motion events while emulateWheel button pressed. */
return TRUE;
@@ -198,7 +191,8 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
/* Handle button mapping here to avoid code duplication,
returns true if a button mapping was found. */
static BOOL
EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_name)
EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis,
const char *axis_name)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
char *option_string;
@@ -230,14 +224,14 @@ EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_
if (down_button > pEvdev->num_buttons) pEvdev->num_buttons = down_button;
} else {
xf86Msg(X_WARNING, "%s: Invalid %s value:\"%s\"\n",
pInfo->name, axis_name, option_string);
xf86IDrvMsg(pInfo, X_WARNING, "Invalid %s value:\"%s\"\n",
axis_name, option_string);
}
free(option_string);
/* Clean up and log what happened */
if (msg) {
xf86Msg(X_CONFIG, "%s: %s: %s\n",pInfo->name, axis_name, msg);
xf86IDrvMsg(pInfo, X_CONFIG, "%s: %s\n", axis_name, msg);
free(msg);
return TRUE;
}
@@ -250,14 +244,10 @@ void
EvdevWheelEmuPreInit(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
char val[4];
int wheelButton;
int inertia;
int timeout;
val[0] = 0;
val[1] = 0;
if (xf86SetBoolOption(pInfo->options, "EmulateWheel", FALSE)) {
pEvdev->emulateWheel.enabled = TRUE;
} else
@@ -266,9 +256,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
wheelButton = xf86SetIntOption(pInfo->options, "EmulateWheelButton", 4);
if ((wheelButton < 0) || (wheelButton > EVDEV_MAXBUTTONS)) {
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelButton value: %d\n",
pInfo->name, wheelButton);
xf86Msg(X_WARNING, "%s: Wheel emulation disabled.\n", pInfo->name);
xf86IDrvMsg(pInfo, X_WARNING, "Invalid EmulateWheelButton value: %d\n",
wheelButton);
xf86IDrvMsg(pInfo, X_WARNING, "Wheel emulation disabled.\n");
pEvdev->emulateWheel.enabled = FALSE;
}
@@ -278,10 +268,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
inertia = xf86SetIntOption(pInfo->options, "EmulateWheelInertia", 10);
if (inertia <= 0) {
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelInertia value: %d\n",
pInfo->name, inertia);
xf86Msg(X_WARNING, "%s: Using built-in inertia value.\n",
pInfo->name);
xf86IDrvMsg(pInfo, X_WARNING, "Invalid EmulateWheelInertia value: %d\n",
inertia);
xf86IDrvMsg(pInfo, X_WARNING, "Using built-in inertia value.\n");
inertia = 10;
}
@@ -291,10 +280,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
timeout = xf86SetIntOption(pInfo->options, "EmulateWheelTimeout", 200);
if (timeout < 0) {
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelTimeout value: %d\n",
pInfo->name, timeout);
xf86Msg(X_WARNING, "%s: Using built-in timeout value.\n",
pInfo->name);
xf86IDrvMsg(pInfo, X_WARNING, "Invalid EmulateWheelTimeout value: %d\n",
timeout);
xf86IDrvMsg(pInfo, X_WARNING, "Using built-in timeout value.\n");
timeout = 200;
}
@@ -314,9 +302,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
pEvdev->num_buttons = 5;
/* Display default Configuration */
xf86Msg(X_CONFIG, "%s: YAxisMapping: buttons %d and %d\n",
pInfo->name, pEvdev->emulateWheel.Y.up_button,
pEvdev->emulateWheel.Y.down_button);
xf86IDrvMsg(pInfo, X_CONFIG, "YAxisMapping: buttons %d and %d\n",
pEvdev->emulateWheel.Y.up_button,
pEvdev->emulateWheel.Y.down_button);
}
@@ -329,13 +317,13 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
pEvdev->emulateWheel.X.traveled_distance = 0;
pEvdev->emulateWheel.Y.traveled_distance = 0;
xf86Msg(X_CONFIG, "%s: EmulateWheelButton: %d, "
"EmulateWheelInertia: %d, "
"EmulateWheelTimeout: %d\n",
pInfo->name, pEvdev->emulateWheel.button, inertia, timeout);
xf86IDrvMsg(pInfo, X_CONFIG,
"EmulateWheelButton: %d, "
"EmulateWheelInertia: %d, "
"EmulateWheelTimeout: %d\n",
pEvdev->emulateWheel.button, inertia, timeout);
}
#ifdef HAVE_PROPERTIES
static int
EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
@@ -399,7 +387,7 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
inertia = *((CARD16*)val->data);
if (inertia < 0)
if (inertia <= 0)
return BadValue;
if (!checkonly)
@@ -485,4 +473,3 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev)
XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,10 @@
* Oliver McFadden (oliver.mcfadden@nokia.com)
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef EVDEV_H
#define EVDEV_H
@@ -39,6 +43,10 @@
#include <xf86_OSproc.h>
#include <xkbstr.h>
#include <mtdev.h>
#include <libevdev/libevdev.h>
#ifndef EV_CNT /* linux 2.6.23 kernels and earlier lack _CNT defines */
#define EV_CNT (EV_MAX+1)
#endif
@@ -55,6 +63,10 @@
#define LED_CNT (LED_MAX+1)
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18
#define LogMessageVerbSigSafe xf86MsgVerb
#endif
#define EVDEV_MAXBUTTONS 32
#define EVDEV_MAXQUEUE 32
@@ -72,31 +84,40 @@
#define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */
#define EVDEV_RELATIVE_MODE (1 << 11) /* Force relative events for devices with absolute axes */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
#define HAVE_PROPERTIES 1
#endif
#ifndef MAX_VALUATORS
#define MAX_VALUATORS 36
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
typedef struct {
char *rules;
char *model;
char *layout;
char *variant;
char *options;
} XkbRMLVOSet;
#ifndef XI_PROP_DEVICE_NODE
#define XI_PROP_DEVICE_NODE "Device Node"
#endif
#define LONG_BITS (sizeof(long) * 8)
/* Number of longs needed to hold the given number of bits */
#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
#define DEFAULT_MOUSE_DPI 1000.0
/* Function key mode */
enum fkeymode {
FKEYMODE_UNKNOWN = 0,
FKEYMODE_FKEYS, /* function keys send function keys */
FKEYMODE_MMKEYS, /* function keys send multimedia keys */
};
enum SlotState {
SLOTSTATE_OPEN = 8,
SLOTSTATE_CLOSE,
SLOTSTATE_UPDATE,
SLOTSTATE_EMPTY,
};
enum ButtonAction {
BUTTON_RELEASE = 0,
BUTTON_PRESS = 1
};
/* axis specific data for wheel emulation */
typedef struct {
int up_button;
@@ -110,36 +131,50 @@ typedef struct {
EV_QUEUE_KEY, /* xf86PostKeyboardEvent() */
EV_QUEUE_BTN, /* xf86PostButtonEvent() */
EV_QUEUE_PROXIMITY, /* xf86PostProximityEvent() */
EV_QUEUE_TOUCH, /*xf86PostTouchEvent() */
} type;
int key; /* May be either a key code or button number. */
int val; /* State of the key/button; pressed or released. */
union {
int key; /* May be either a key code or button number. */
unsigned int touch; /* Touch ID */
} detail;
int val; /* State of the key/button/touch; pressed or released. */
ValuatorMask *touchMask;
} EventQueueRec, *EventQueuePtr;
typedef struct {
const char *device;
struct libevdev *dev;
char *device;
int grabDevice; /* grab the event device? */
int num_vals; /* number of valuators */
int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
int vals[MAX_VALUATORS];
int old_vals[MAX_VALUATORS]; /* Translate absolute inputs to relative */
int num_mt_vals; /* number of multitouch valuators */
int abs_axis_map[ABS_CNT]; /* Map evdev ABS_* to index */
int rel_axis_map[REL_CNT]; /* Map evdev REL_* to index */
ValuatorMask *abs_vals; /* values for absolute axis */
ValuatorMask *rel_vals; /* values for relative axis */
ValuatorMask *old_vals; /* old absolute values for calculating relative motion */
ValuatorMask *prox; /* last absolute values set while not in proximity */
ValuatorMask *mt_mask;
ValuatorMask **last_mt_vals;
int cur_slot;
struct slot {
int dirty;
enum SlotState state;
} *slots;
struct mtdev *mtdev;
BOOL fake_mt;
int flags;
int proximity;
int in_proximity; /* device in proximity */
int use_proximity; /* using the proximity bit? */
int num_buttons; /* number of buttons */
BOOL swap_axes;
BOOL invert_x;
BOOL invert_y;
int resolution;
int delta[REL_CNT];
unsigned int abs_queued, rel_queued, prox_queued;
unsigned int abs_prox; /* valuators posted while out of prox? */
/* XKB stuff has to be per-device rather than per-driver */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
XkbComponentNamesRec xkbnames;
#endif
XkbRMLVOSet rmlvo;
/* Middle mouse button emulation */
struct {
@@ -150,6 +185,19 @@ typedef struct {
Time expires; /* time of expiry */
Time timeout;
} emulateMB;
/* Third mouse button emulation */
struct emulate3B {
BOOL enabled;
BOOL state; /* current state */
Time timeout; /* timeout until third button press */
int buttonstate; /* phys. button state */
int button; /* phys button to emit */
int threshold; /* move threshold in dev coords */
OsTimerPtr timer;
double delta[2]; /* delta x/y, accumulating */
int startpos[2]; /* starting pos for abs devices */
int flags; /* remember if we had rel or abs movement */
} emulate3B;
struct {
int meta; /* meta key to lock any button */
BOOL meta_state; /* meta_button state */
@@ -166,6 +214,11 @@ typedef struct {
Time expires; /* time of expiry */
Time timeout;
} emulateWheel;
struct {
int vert_delta;
int horiz_delta;
int dial_delta;
} smoothScroll;
/* run-time calibration */
struct {
int min_x;
@@ -180,33 +233,28 @@ typedef struct {
int reopen_left; /* number of attempts left to re-open the device */
OsTimerPtr reopen_timer;
/* Cached info from device. */
char name[1024];
unsigned long bitmask[NLONGS(EV_CNT)];
unsigned long key_bitmask[NLONGS(KEY_CNT)];
unsigned long rel_bitmask[NLONGS(REL_CNT)];
unsigned long abs_bitmask[NLONGS(ABS_CNT)];
unsigned long led_bitmask[NLONGS(LED_CNT)];
struct input_absinfo absinfo[ABS_CNT];
/* minor/major number */
dev_t min_maj;
/* Event queue used to defer keyboard/button events until EV_SYN time. */
int num_queue;
EventQueueRec queue[EVDEV_MAXQUEUE];
enum fkeymode fkeymode;
char *type_name;
} EvdevRec, *EvdevPtr;
/* Event posting functions */
void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
void EvdevQueueProximityEvent(InputInfoPtr pInfo, int value);
void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value);
void EvdevQueueTouchEvent(InputInfoPtr pInfo, unsigned int touch,
ValuatorMask *mask, uint16_t type);
void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, enum ButtonAction act);
void EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count);
void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
int v[MAX_VALUATORS]);
void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
int v[MAX_VALUATORS]);
void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo);
void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo);
unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);
/* Middle Button emulation */
@@ -218,6 +266,15 @@ void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuOn(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr);
/* Third button emulation */
CARD32 Evdev3BEmuTimer(OsTimerPtr timer, CARD32 time, pointer arg);
BOOL Evdev3BEmuFilterEvent(InputInfoPtr, int, BOOL);
void Evdev3BEmuPreInit(InputInfoPtr pInfo);
void Evdev3BEmuOn(InputInfoPtr);
void Evdev3BEmuFinalize(InputInfoPtr);
void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, double dx, double dy);
void Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals);
/* Mouse Wheel emulation */
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
@@ -227,9 +284,9 @@ BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
void EvdevDragLockPreInit(InputInfoPtr pInfo);
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
#ifdef HAVE_PROPERTIES
void EvdevMBEmuInitProperty(DeviceIntPtr);
void Evdev3BEmuInitProperty(DeviceIntPtr);
void EvdevWheelEmuInitProperty(DeviceIntPtr);
void EvdevDragLockInitProperty(DeviceIntPtr);
#endif
void EvdevAppleInitProperty(DeviceIntPtr);
#endif