Compare commits

..

393 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
298e61e566 release 25.0.0
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-18 18:24:09 +01:00
Enrico Weigelt, metux IT consult
1a80d31ed7 configure.ac: tiny formatting cleanups
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-18 18:23:38 +01:00
Enrico Weigelt, metux IT consult
e8a08514f6 drop obsolete #ifdef HAVE_CONFIG_H
config.h is always present

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-17 18:55:18 +01:00
Enrico Weigelt, metux IT consult
a413634da8 replace DRIVER_NAME autotools symbol by fixed string
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-17 18:49:52 +01:00
Enrico Weigelt, metux IT consult
0eb641f218 drop xorg-evdec.pc
Nothing's ever trying to compile against the driver, so no
pkgconfig descriptor needed here.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-17 18:43:47 +01:00
Enrico Weigelt, metux IT consult
c59ba05346 drop .gitlab-ci.yml
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-17 18:39:12 +01:00
Enrico Weigelt, metux IT consult
0981f96cdc man: replace Xorg by XLibre
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-16 13:40:10 +01:00
Enrico Weigelt, metux IT consult
b1320d6f02 README.md: fix URLs
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-16 12:22:27 +01:00
Enrico Weigelt, metux IT consult
26dde8fc21 release 2.11.1
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-15 13:28:10 +01:00
Enrico Weigelt, metux IT consult
51d93c47f7 configure.ac: fix package name and issue tracker URL
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-15 13:22:48 +01:00
Enrico Weigelt, metux IT consult
3801a36ec9 emuWheel: use strdup() instead of xstrdup()
Never passing NULL here, so no need to call xstrdup() / Xstrdup()

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-10 19:06:32 +01:00
SuperPuiu
e361cfad9f Transform an if-else statement into a conditional operator
Signed-off-by: SuperPuiu <SuperPuiu@proton.me>
2025-07-29 19:00:18 +02:00
b-aaz
4570407894 configure: Automatically detect the default xorg-module-dir.
The module directory has changed to a per ABI folder in the xlibre-xserver.
Now the default value of `xorg-module-dir` will be detected from the `moduledir` variable in xorg-server.pc.

Signed-off-by: b-aaz <b-aazbsd.proton.me>
2025-07-29 18:54:05 +02:00
Enrico Weigelt, metux IT consult
9ee18e3450 .github: add CI pipeline
This pipeline builds the driver against the latest Xserver stable
release as well as current master.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-28 20:04:48 +02:00
callmetango
e518cb19bd .github: Add issue forms
Add the following forms for issue creation:

* Bug report
* Feature request
* Code change
* Documentation update
* Organizational task

* add issue type selection page on "New Issue" call
* mention Github Discussions and the mailing list where appropriate

Part-of: X11Libre/misc#156
Signed-off-by: callmetango <callmetango@users.noreply.github.com>
2025-07-07 17:00:04 +02:00
Alan Coopersmith
0b5b97bc6b man page: Replace __xservername__ & __xconfigfile__ with Xorg & xorg.conf
These were originally to allow distros to build using XFree86 & XF86config
names, but we haven't supported that in nearly two decades now.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/13>
2025-06-01 15:33:56 -07:00
Alan Coopersmith
96a4dc7565 Improve man page formatting
More closely follow common style as described on
https://man7.org/linux/man-pages/man7/man-pages.7.html
and fix warnings raised by  `mandoc -T lint` and `groff -rCHECKSTYLE=10`

Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/13>
2025-05-31 15:53:11 -07:00
Peter Hutterer
abcafeede7 xf86-input-evdev 2.11.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2024-10-15 14:32:50 +10:00
Peter Hutterer
d893fc74d2 Map some specific high keycodes into the FK20-23 range
These mappings have been part of xkeyboard-config for over a decade and
the likely reason they were introduced is that the corresponding evdev
keycode is > 255.

Let's forcibly remap those in the driver here so the rest of the system
can switch to the real keycodes instead of having to map them to the
whatever X expects.

See https://github.com/systemd/systemd/pull/34325/

Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/10>
2024-10-09 14:33:05 +10:00
Martin Rys
b9327e6b28 Swap Compose and Kana values to conform to USB HID spec
Should fix https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/issues/204

Current state conflicts with XKB which defines them correctly.

NUM and CAPS are still incorrectly swapped, but it's equally wrong on
XKB's side and everywhere else, so it's just cosmetic and a breaking
change just to satisfy USB HID ordering is not worth it, since the keys
work fine this way anyway.

Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/8>
2024-09-05 11:32:21 +10:00
Peter Hutterer
917c2ea204 gitlab CI: set the standard workflow rules for an fdo project 2024-09-03 13:49:04 +10:00
Enrico Weigelt, metux IT consult
b48c2b7028 dont spam xserver with false-positives
It's not necessary to spam the xserver log with error messages of
just temporary read failures that aren't actually errors.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/6>
2024-06-10 19:05:58 +02:00
Enrico Weigelt, metux IT consult
aac329fd2a fix FTBS on non-udev target platforms (eg. FreeBSD)
On platforms that don't have libudev at all (eg. FreeBSD), the build
breaks. The only consumer, EvdevDeviceIsVirtual(), can live well with
just bailing out directly if libudev isn't present.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/6>
2024-06-10 19:05:54 +02:00
Enrico Weigelt, metux IT consult
fbfb16edfe tolerate including linux/input.h
On some platforms (eg. FreeBSD) we're running into a name clash between
xf86str.h and linux/input.h. Since we don't actually need those symbols
here, an easy workaround is #undef'ing them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/6>
2024-06-10 18:42:22 +02:00
Enrico Weigelt, metux IT consult
409e8205e8 fix unportable linux-only include
including <linux/types.h> obviously isn't portable - instead using
<sys/types.h> is the right choice for us.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/6>
2024-06-10 18:38:12 +02:00
Enrico Weigelt, metux IT consult
7fc0d51f70 drop quirk for ancient linux kernel version (<2.6.30)
This kernel had been released 1.5 decades ago - probably no need to have
special quirks for such an ancient kernel version anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-10 18:05:40 +02:00
Enrico Weigelt, metux IT consult
7c48b6225b bump minimal xorg version to 1.18
1.18 was released a decade ago, so it seems reasonable stop supporting
older ones.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev/-/merge_requests/5>
2024-05-14 10:59:46 +02:00
Alan Coopersmith
8edcb2b9e8 gitlab CI: ensure libtool is installed in build container
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-10-01 11:22:19 -07:00
Alan Coopersmith
84b2740814 gitlab CI: stop requiring Signed-off-by in commits
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-02-09 12:06:53 -08:00
Alan Coopersmith
469a30f158 Convert src/draglock.c from ISO-8859-1 to UTF-8
Fixes flawfinder error in CI:
Error: encoding error in ./src/draglock.c
'utf-8' codec can't decode byte 0xa9 in position 343: invalid start byte

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-16 11:11:01 -08:00
Alan Coopersmith
23909c35a4 gitlab CI: add a basic build test
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-16 10:55:36 -08:00
Alan Coopersmith
abf0fa611e Fix spelling/wording issues
Found by using:
    codespell --builtin clear,rare,usage,informal,code,names

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-16 10:51:03 -08:00
Alan Coopersmith
6609d352f3 Build xz tarballs instead of bzip2
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-16 10:49:21 -08:00
Alan Coopersmith
71036116be Update configure.ac bug URL for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-25 12:45:55 -08:00
Alan Coopersmith
b6b36166bd Update README for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-18 11:30:58 -08:00
Peter Hutterer
67a97afbc0 evdev 2.10.6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-29 10:05:22 +10:00
Andrey Zabolotnyi
2fb95783e0 Fix generation of proximity-in/out events.
Invoking xf86PostProximityEvent with no valuators does nothing, so we
have to provide a valid valuator set to the call.

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

[whot: slight change from 104562
abs_vals is reset on every frame but old_vals is kept around to remember the
last value of the valuator (and is updated to the current values before
processing the frame). We expect the prox in to have x/y, so let's just
unconditionally use old_vals for proximity events.]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-29 10:00:26 +10:00
Peter Hutterer
456f23cbbd Ignore x/y axis changes on proximity out
Wacom tablets send a farewell reset to 0 on all axes when the tool goes out of
proximity. Ignore those so we can rely on our various valuator masks always
having the correct coordinates.

Possible false positive if you manage to go out of proximity right above the
zero datum but meh.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-29 10:00:05 +10:00
Christian Gmeiner
ab1d9adfd3 Print cause of a failed open(..) call
This is quite helpful for debugging.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-01-30 13:37:57 +10:00
Andrey Zabolotnyi
192fdb0690 Fix handling of devices with only buttons (e.g. tablet pads).
When transforming 'only buttons' device into a pseudo-mouse by adding
relative X and Y axes, EVDEV_RELATIVE_EVENTS flag  must be set on device,
otherwise it gets classified as a keyboard by X11.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-01-16 16:30:59 +10:00
Mihail Konev
8c1058f2eb autogen: add default patch prefix
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
2017-01-26 14:00:21 +10:00
Emil Velikov
4921912374 autogen.sh: use quoted string variables
Place quotes around the $srcdir, $ORIGDIR and $0 variables to prevent
fall-outs, when they contain space.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 11:13:25 +10:00
Peter Hutterer
67681097b8 autogen.sh: use exec instead of waiting for configure to finish
Syncs the invocation of configure with the one from the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-01-26 11:13:25 +10:00
Peter Hutterer
1dd61111ad evdev 2.10.5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-18 13:14:29 +10:00
Alexander Volkov
231061d004 Don't send pointer events in addition to touch events
Updating abs_vals for touch events since d24431a186
leads to posting Motion events with updated coordinates to the X server,
which in turn resends them to clients.

Don't queue Motion events for touch events, the X server should
synthesize them itself.

Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-03 11:28:17 +10:00
David Strobach
425ed6017a Middle emulation - make the emulated button number configurable
Sometimes it may be desirable to remap physical middle button
to something else and use emulation instead. The emulation is
however hardcoded to emulate physical button 2, so the emulated
button gets remapped together with the physical one. This patch
adds the Emulate3Button configuration option to allow for user
selection of the emulated button number and a configuration
like this:

Section "InputClass"
    Identifier "Middle button emulation config"
    MatchProduct ".... some device ..."
    MatchDriver "evdev"
    Option "Emulate3Buttons" "on"
    Option "Emulate3Button" "9"
EndSection

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-21 15:26:58 +10:00
Peter Hutterer
7251e42dfb Fix off-by-one error counting axes
We stopped counting one too early, but still initialized that axis later,
leading to a bug macro to trigger.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-24 08:27:24 +10:00
Peter Hutterer
551db5b86e evdev 2.10.4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-10-01 17:49:10 +10:00
Keith Packard
bb8bde7456 Support XINPUT ABI 24 (remove select mask from block/wakeup handlers)
The evdev driver wasn't using the select mask arguments, so this
change just involves adjusting the argument lists.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-09-06 13:51:21 +10:00
Keith Packard
7b1267f7f1 Support XINPUT ABI version 23 (threaded input)
Use input_lock/input_unlock calls instead of SIGIO functions

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-02 09:42:05 +10:00
Keith Packard
e08b033276 Report errors when attempting to write keyboard controls
This is mostly to eliminate a compiler warning.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-02 09:41:25 +10:00
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
Peter Hutterer
1c5ad6f8a0 evdev 2.5.99.902
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-08 12:40:49 +10:00
Peter Hutterer
6fd1d0860e Return error codes from EvdevOpenDevice()
The server's behaviour is to stop adding new devices when a BadAlloc occurs
on any device (on the assumption that new devices won't magically have more
memory). Change EvdevOpenDevice() to return an error code of BadValue when
it fails (and thus to the server) to prevent other devices being ignored
because of one misconfigured one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-12-07 08:05:42 +10:00
Peter Hutterer
31ba99e9ed evdev 2.5.99.901
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-19 15:03:33 +10:00
Peter Hutterer
a4aefca2ed Reshuffle to avoid the need for XI86_CONFIGURED.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-28 13:11:56 +10:00
Peter Hutterer
20d7a0a4aa Input API 12 requires a valuator mode for each axis.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-27 08:32:21 +10:00
Nikolai Kondrashov
5e26ba8641 Extend button mapping to full ranges
Extend button code to number mapping to cover full BTN_MOUSE and BTN_MISC
ranges, including undefined codes.

This extends mapping introduced with 0367e387 to the following:

        1       BTN_LEFT        BTN_0       BTN_TOUCH
        2       BTN_MIDDLE      BTN_1       BTN_STYLUS
        3       BTN_RIGHT       BTN_2       BTN_STYLUS2

        8       BTN_SIDE        BTN_3
        9       BTN_EXTRA       BTN_4
        10      BTN_FORWARD     BTN_5
        11      BTN_BACK        BTN_6
        12      BTN_TASK        BTN_7
        13      0x118           BTN_8
        14      0x119           BTN_9
        15      0x11A           0x10A
        16      0x11B           0x10B
        17      0x11C           0x10C
        18      0x11D           0x10D
        19      0x11E           0x10E
        20      0x11F           0x10F

This should fix https://bugs.freedesktop.org/show_bug.cgi?id=30336

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-10-22 07:52:48 +10:00
Peter Hutterer
71dd18f728 Rename CountBits to EvdevCountBits.
Avoid name collision with the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-21 08:13:25 +10:00
Peter Hutterer
c3e49f2b95 Use an array for the proximity bits.
Instead of two lists that need to be kept in sync, just store the bits in an
array and run through them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-10-21 08:12:44 +10:00
Peter Hutterer
b06d3ffdcd Rename abs/rel/prox to abs_queued/rel_queued/prox_queued.
Mainly to avoid confusing between pEvdev->prox and pEvdev->proximity and to
better express what these fields are actually holding.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-10-21 08:12:38 +10:00
Benjamin Tissoires
3646371eef Add the names of the valuators for the multitouch properties
Thoses definitions have been included in the kernel and in the X server.
However, the evdev driver has not been updated accordingly.

Without these definitions, the multitouch axes are not correctly labelled.

Signed-off-by: Benjamin Tissoires <tissoire@cena.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-10-18 10:00:54 +10:00
Peter Hutterer
b48f4c41c0 Add proximity support.
When one of the tools comes into proximity, queue up a proximity event and
send it accordingly.

Includes special handling for tablets that do not send axes with tools
(#29645)

Some tablets send axis values, then EV_SYN, and in the next event the
BTN_TOOL_PEN/BTN_TOUCH, etc. For these tablets, the cursor doesn't move as
coordinates while not in proximity are ignored.

Buffer coordinates received while out-of-proximity and if we get a proximity
event without other coordinates, re-use the last ones received.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-18 09:54:42 +10:00
Peter Hutterer
185ad42078 Rename evdev->tool to evdev->proximity.
evdev doesn't care about the actual tool used, only that it is used as an
indicator for proximity. Rename the field accordingly to make the code more
obvious to read.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
2010-10-13 11:01:12 +10:00
Peter Hutterer
7282e3ac6c When posting buttons, post absolute valuators if we have them.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-11 08:47:47 +10:00
Peter Hutterer
c504852aa2 Fix valuator offset when posting absolute motion events.
If first_v was not zero, the values passed to xf86PostMotionEventP were
wrong.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-11 08:46:51 +10:00
Peter Hutterer
4bbf9c9125 Don't pass pointers around to first_v and num_v.
We only use them as values, no need for the addresses.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-11 08:46:09 +10:00
Peter Hutterer
684426a9d2 De-duplicate event queue access.
Factor out access to the next queue element in a static function to be
reused for button and key presses.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2010-10-11 08:44:26 +10:00
Peter Hutterer
9664e5a487 Remove refcnt initialization from InputDriverRec.
Removed from the server with
commit 6130170e7e9b64c611ee942ec3455dd1a185193d
Author: Adam Jackson <ajax@redhat.com>
Date:   Sat Sep 18 06:41:35 2010 -0400

    xfree86: Remove unused refcounting from input drivers

And given that it was unused, we don't need to ifdef it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-10-11 07:52:14 +10:00
Nikolai Kondrashov
0367e3871f Clean up button code to number mapping
Now BTN_MOUSE, BTN_MISC and BTN_DIGI button ranges are all mapped to the
same lower numbers including first three, corresponding to the LMR mouse
buttons. Like this:

    1       BTN_LEFT        BTN_0       BTN_TOUCH
    2       BTN_MIDDLE      BTN_1       BTN_STYLUS
    3       BTN_RIGHT       BTN_2       BTN_STYLUS2

    8       BTN_SIDE        BTN_3
    9       BTN_EXTRA       BTN_4
    10      BTN_FORWARD     BTN_5
    11      BTN_BACK        BTN_6
    12      BTN_TASK        BTN_7
    13                      BTN_8
    14                      BTN_9

This streamlines the button mapping under the assumption that these ranges
don't generally appear in a single device simultaneously. If they do appear,
they will simply report overlapping button numbers.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-07 10:40:36 +10:00
Nikolai Kondrashov
617a09e298 Add BTN_TOUCH/STYLUS/STYLUS2 support.
These three buttons are mapped into buttons 1/2/3, respectively.
Overlapping range with BTN_LEFT/MIDDLE/RIGHT, assuming that these
ranges don't generally appear in a single device simultaneously.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-07 10:38:20 +10:00
Tim Yamin
b83515485b SwapAxes should rescale raw values when enabled
Current implementation assumes that X & Y axes have the same min and max
values. If they don't, you'll end up with funny behaviour if SwapAxes is
turned on.

Signed-off-by: Tim Yamin <plasm@roo.me.uk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-07 10:31:02 +10:00
Peter Hutterer
009d442aa3 Merge branch 'input-api' of git://people.freedesktop.org/~whot/xf86-input-evdev 2010-09-01 13:04:29 +10:00
Nikolai Kondrashov
10493de96e Improve dumb tablet detection
Improve dumb tablet detection by checking if BTN_STYLUS or BTN_STYLUS2
(first or second pen barrel button) is present when BTN_TOOL_PEN is not
found.

This enables detection of tablets without explicit tool proximity reporting.
These include at least four UC-Logic tablet models: WP4030U, WP5540U,
WP8060U and PF1209, on which many Genius and Trust models are based.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 12:48:04 +10:00
Peter Hutterer
829facd516 Bump to 2.5.99.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-31 14:21:53 +10:00
Nikolai Kondrashov
fbafe59420 Fix comments about BTN_TOOL_PEN.
Fix incorrect usage of BTN_DIGI instead of BTN_TOOL_PEN in comments.
Fix forgotten pEvdev->digi reference.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-31 14:21:39 +10:00
Peter Hutterer
990540fa19 evdev 2.5.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-23 10:34:36 +10:00
Peter Hutterer
b8945e61eb man: don't reference README.mouse
No real reason to refer to the mouse driver's readme.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-23 10:27:45 +10:00
Peter Hutterer
97dc45b769 evdev 2.4.99.901
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-19 12:50:25 +10:00
Bartosz Brachaczek
ec6cb31cc4 evdev: Initialize valuators array. (#24737)
The array needs to be filled with zeros, otherwise we may end up sending
it with random values if non-zero values aren't in one row (which is the
case for A4Tech X-750F which sends REL_MISC events without a reason).

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

Signed-off-by: Bartosz Brachaczek <b.brachaczek@gmail.com>
Tested-by: Bartek Iwaniec <hash87@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-16 10:45:26 +10:00
Bartosz Brachaczek
ed47c7f33e evdev: Revert "Set all valuators for relative motion events (#24737)"
It isn't necessary to post zero-deltas to X Server. In order not to post
uninitialized "v" array we should rather simply initialize it.

This reverts commit c1f16a4f59.

Signed-off-by: Bartosz Brachaczek <b.brachaczek@gmail.com>
Tested-by: Bartek Iwaniec <hash87@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-16 10:45:07 +10:00
Peter Hutterer
899218e181 Don't count BTN_TOUCH as tool. (#29428)
Devices that don't have a tool but BTN_TOUCH simply have the tool always on.
Devices that have a tool other than BTN_TOUCH set this tool before BTN_TOUCH
is emitted anyway.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-16 10:04:08 +10:00
Peter Hutterer
4964c61f4b Return BadMatch for already configured devices.
PreInit can now return different error codes. Return BadAlloc for alloc
failures and BadMatch if the device was already configured or the cache
comparison/probe failed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-22 13:26:40 +10:00
Peter Hutterer
92e8dc4961 Use the new input API (changed PreInit function prototype).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-22 13:26:38 +10:00
Peter Hutterer
e0e4b7d89b Move private init down.
No real change, preparation for new input API.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-22 10:57:34 +10:00
Peter Hutterer
d2c11d36a0 Use pInfo->options instead of dev->commonOptions.
No real change, preparation for new input API.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-22 10:57:34 +10:00
Peter Hutterer
2f636402d8 Add ifdefs for pre ABI 12 support.
The server doesn't provide these defines anymore, define them here for
future use. To be purged whenever we drop support for the current server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-22 10:57:34 +10:00
Peter Hutterer
3d3565c069 Remove usage of XI86_POINTER_CAPABLE and XI86_KEYBOARD_CAPABLE.
XI86_KEYBOARD_CAPABLE was write-only, both in the driver and the server.
XI86_POINTER_CAPABLE was write-only in the server and can be emulated with
has_abs_axes and has_rel_axes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-22 10:57:34 +10:00
Alex Warg
421585fda6 Fix out-of-bounds access if more than MAX_VALUATORS are present. (#28809)
The functions EvdevAddRelClass and EvdevAddAbsClass do out of bounds
accesses to vals and old_vals arrays in the EvdevRec structure if there are
more than MAX_VALUATORS axes reported by the kernel.

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

Signed-off-by: Alex Warg <alexander.warg@os.inf.tu-dresden.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-01 08:16:07 +10:00
Peter Hutterer
8697811f56 man: some minor fixes to man page.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-28 10:49:56 +10:00
Peter Hutterer
b06bffdc97 Add myself to Authors in man page.
git blames me for about half the driver now, I guess that's enough
justification ;)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-28 10:49:56 +10:00
Gaetan Nadon
9410e452d2 config: use AC_PROG_INSTALL now supplied by XORG_DEFAULT_OPTIONS
It depends on util-macros 1.8
The existing statement can now be removed from the configuration file.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-06-16 15:19:39 -04:00
Gaetan Nadon
516e538da4 config: upgrade to util-macros 1.8 for additional man page support
Use MAN_SUBST now supplied in XORG_MANPAGE_SECTIONS
The value of MAN_SUBST is the same for all X.Org packages.

Use AC_PROG_SED now supplied by XORG_DEFAULT_OPTIONS
The existing statement can now be removed from the configuration file.

Use Automake $() for variables in Makefile.am

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-06-16 15:19:38 -04:00
Gaetan Nadon
1f38e1bc11 COPYING: update and refactor the Copyright notices
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-06-16 15:17:06 -04:00
Peter Hutterer
456579ba30 Bump to 2.4.99
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-01 10:20:25 +10:00
Peter Hutterer
21a2ac818e Disable middle mouse button emulation by default.
The AUTO feature was the default, MB emulation was on until a middle mouse
button was pressed. MB emulation however results in a delay of the first
press, causing minor annoyances to the users and being generally confusing
when the behaviour before a button press is different to after a button
pres.

Disable the feature by default instead. There's not a lot of two-button mice
around anymore though and the inability to detect two-button mice makes for
non-deterministic detection of when the emulation should be on.

Middle button emulation can be enabled with a configuration snippet:

Section "InputClass"
        Identifier "middle button emulation"
        MatchIsPointer "on"
        Option "Emulate3Buttons" "on"
EndSection

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2010-05-31 11:01:26 +10:00
Peter Hutterer
4c21624240 Remove libc wrappers for malloc, calloc and free.
Evdev is Linux-only, and we've had the above calls for quite a while now.
Plus, now that the server has removed them they generate _a lot_ of warnings
otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
6e244b1098 Move mode declaration, it's not const either.
What we're getting back from xf86SetStrOption is a strdup'd string, not
const, especially given that we free it a few lines down.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
e7c301563a Move opening the device into a separate function.
Re-use from EvdevOn and PreInit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
ffc2c9961f Move checks for calibration, inversion and axis swap to EvdevProbe.
Keyboard devices don't need these checks.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
7c01cff1fa Move EVIOCGRAB into a static func.
This is in preparation of some major rework, there are no functional
changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
e6e20c1b3e Move error handling in PreInit down to the end.
Just have one exit path instead of different ones. Guards are in place to
avoid freeing/deleting something that shouldn't be.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
b27d03b248 Comment odd EVIOCGRAB behaviour and reshuffle conditions a bit.
The reason for this rather weird approach is to ungrab immediately after
getting a successful grab. Evdev shouldn't be hogging the device if nothing
is done with it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
ba78428ed5 Remove support for kernel 2.4.
It's been 6 years since 2.6, I doubt evdev would even work on 2.4 right now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-05-28 09:24:28 +10:00
Gaetan Nadon
041a1f246a config: AC_PROG_SED is required explicitly.
It sets the SED env variable with an appropriate sed program path
It still works on some platform when not explicity called.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-05-10 21:44:43 -04:00
Peter Hutterer
44b80d177f Update a stale comment about the use of pEvdev->tool.
Including some typo fixes in the same comment.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-06 11:11:30 +10:00
Peter Hutterer
7bbbce9a83 Read the device resolution from the kernel.
For earlier kernels, use the previous hardcoded resolution in place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-04-29 22:05:23 +10:00
Peter Hutterer
35b6085bf8 config: remove AH_TOP autoheader statement.
Include it in evdev.h instead.
xorg-server.h is required to define the right datatype sizes on 64 bit,
hence ensure that evdev.h is the first included in each file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-29 09:07:03 +10:00
Gaetan Nadon
539d67505c Revert "config: remove AH_TOP autoheader statement"
The changed location of xorg-server.h had some side-effects.
See Bug 27768 <https://bugs.freedesktop.org/show_bug.cgi?id=27768>

This reverts commit 9dbace89be.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-22 11:42:49 +10:00
Peter Hutterer
a77dea1caa Merge branch 'master' of git://gitorious.org/omcfadde/xf86-input-evdev 2010-04-20 16:31:09 +10:00
Oliver McFadden
5fb1e841eb evdev: EvdevProbe: check ioctl() return value and warn on failure.
Called function "ioctl" whose return value should be checked (checked 10
out of 11 times)

Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-20 09:12:43 +03:00
Oliver McFadden
a4f2d12cd8 evdev: ioctl() may return a negative value therefor use a signed integer.
Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-20 09:12:38 +03:00
Oliver McFadden
6b5c0401e2 evdev: leaked_storage: free memory allocated from the xf86Option code.
Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-20 09:12:30 +03:00
Gaetan Nadon
993e011b91 man: Use Autoconf provided $(AM_V_GEN)$(SED)
Enables silent rule and use platform appropriate version of sed.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
2d5e922a6d include: EXTRA_DIST is not required for header files.
The sdk_HEADERS is sufficient as the "sdk" prefix
matches the "dir" suffix in the "sdkdir" variable.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
41a38ec886 config: require macros 1.4, fix warnings, m4 quotings and layout
Fix some m4 quoting
Fix some autoconf warnings
remove AC_PROG_CC as it overrides AC_PROG_C_C99 from XORG_DEFAULT_OPTIONS
Regroup statements per section
Add comments
Upgrade X.Org macros to 1.4 for INSTALL file copying

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
b31c00efea config: optional extension check for inputproto not required
The check should be in PKG_CHECK_MODULES permanently.

The XORG_DRIVER_CHECK_EXT will add inputproto to PKG_CHECK_MODULES
only if the extension is available. By definition, this extension
is always available and the evdev driver cannot function without it.

This is evidenced by the absence of XINPUT conditional code.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
b48dcfa3f2 config: replace deprecated INCLUDES with AM_CPPFLAGS
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
44baa36b99 config: refactor and comment the sdkdir distcheck workaround
Seperate legitimate sdkdir usage from distcheck workaround.
Comment this non obvious workaround.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
7fa5982d47 config: remove unrequired AC_HEADER_STDC
Autoconf says:
"This macro is obsolescent, as current systems have conforming
header files. New programs need not use this macro".

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
fe8d0fa11a replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS
Regroup AC statements at the top.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
09b918db86 config: update AC_PREREQ statement to 2.60
Unrelated to the previous patches, the new value simply reflects
the reality that the minimum level for autoconf to configure
all x.org modules is 2.60 dated June 2006.

ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
9dbace89be config: remove AH_TOP autoheader statement
The generated config.h does not need to include xorg-server.h
for the content it provides.
Add #include <xorg-server.h> in .[hc] files as needed.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Paulo Ricardo Zanoni
aaf65e7bfa Don't set pEvdev->rel for mouse wheel events
This way we won't get empty MotionNotify events when the mouse wheel is
used.

Signed-off-by: Paulo Ricardo Zanoni <pzanoni@mandriva.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-17 15:17:27 +10:00
Peter Hutterer
8eede7ea8d Use X_PROBED instead of X_INFO for probed values.
No functional changes, only the log output differs now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
2010-04-09 14:32:18 +10:00
Peter Hutterer
1936632cb0 evdev 2.4.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-06 10:31:16 +10:00
Simon Thum
0dc931e1ac move feedback initialization up
This allows the backend to propery initialize the feedback from options,
as it works with most other drivers. This is the hacky equivalent of
fixing the initialization of pointer acceleration, which would require
changes to most drivers however.

Signed-off-by: Simon Thum <simon.thum@gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-03-24 07:50:55 +10:00
Peter Hutterer
d525b48a2f When labeling a device as touchpad, only check for LMR buttons.
Touchpads that have physical buttons have either LMR or BTN_TOOL_FINGER.
Other buttons in the range evdev recognises shouldn't be taken into account
here - they skew the detection towards touchpads and away from touchscreens.

Fedora Bug 571639

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
2010-03-18 08:04:01 +10:00
Oliver McFadden
801778c310 emuMB: default to disabled mouse button emulation for touchscreens.
Because touchscreens only use one button (see EvdevProcessKeyEvent())
EvdevMBEmuFilterEvent() never calls EvdevMBEmuEnable(..., FALSE) to
disable emulation. This results in touchscreen devices incurring a delay
of Emulate3Timeout (typically 50 ms.)

Default to MBEMU_DISABLED for touchscreen devices (unless overwritten by
Xorg.conf.)

Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-25 16:07:39 +10:00
Peter Hutterer
99505011d1 man: fix man page formatting for option EmulateWheel.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-18 19:02:40 +10:00
Gaetan Nadon
fd036680c2 config: move CWARNFLAGS from configure.ac to Makefile.am
Compiler warning flags should be explicitly set in the makefile
rather than being merged with other packages compiler flags.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-02-11 10:08:07 -05:00
Andrej Gelenberg
e81cd935cf Implement XSetDeviceMode request handler
Implement XSetDeviceMode request handler for evdev.
Devices with absolute axes can be switched in relative
mode or absolute mode. Devices with relative axes
can be switched only in relative mode. Other devices
return BadMatch, cause they have no valuators and
don't report motion events.

New option "Mode" force devices with absolute axes
to work in relative or absolute mode.

Need xinputproto.

Signed-off-by: Andrej Gelenberg <andrej.gelenberg@udo.edu>
2010-01-19 21:40:06 +13:00
Alan Coopersmith
0b5844ce67 Update Sun license notices to current X.Org standard form
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
2010-01-15 15:10:55 -08:00
Dima Kogan
d6beb16be2 allow wheel emulation to work with absolute-position devices
Signed-off-by: Dima Kogan <dkogan@cds.caltech.edu>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-08 11:02:05 +10:00
Dima Kogan
2f5a0fb698 removed unnecessary static declarations
Signed-off-by: Dima Kogan <dkogan@cds.caltech.edu>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-07 11:53:53 +10:00
Peter Hutterer
1b0df04abe Fix up BTN_TOUCH handling for non-button tablets.
BTN_TOOL_* is treated as tool, just like before. BTN_TOUCH on the other hand
may need to be treated as a button left press. This again requires a button
class.

Tested on an HP Touchsmart and a Wacom tablet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-02 09:34:22 +10:00
Peter Hutterer
2ca24a16f0 Only init the calibration property for absolute devices.
Relative devices can't be calibrated anyway so why bother.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-01 15:44:18 +10:00
David Woodhouse
7b285a802b Report initial calibration parameters.
Where an initial calibration is provided through the Calibration option
to the driver, it wasn't being exposed in the 'Evdev Axis Calibration'
property. Remedy that...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-01 14:14:17 +10:00
David Woodhouse
f187badb71 Swap axes before applying touch screen calibration.
When the SwapAxes option is set, the X and Y axes in calibration should
be labelled as the user perceives them -- not as the kernel sends them.

Currently, we apply the X-axis calibration to the X-axis of the input,
and then do the axis swapping so we've actually applied the X-axis
calibration to what the user sees as the Y-axis.

This patch changes the order of the operations, so that the axes are
swapped before the calibration is applied.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-01 14:12:49 +10:00
Peter Hutterer
0e9d75ba68 Fix a comment, EV_CNT is available since 2.6.24
Introduced in the kernel as 2.6.23-6147-g7b19ada.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-01 14:11:55 +10:00
Gaetan Nadon
3a6d27b83d Makefile.am: add ChangeLog and INSTALL on MAINTAINERCLEANFILES
Now that the INSTALL file is generated.
Allows running make maintainer-clean.
2009-11-23 09:25:05 -05:00
Gaetan Nadon
886e303af1 INSTALL, NEWS, README or AUTHORS files are missing/incorrect #24206
Automake 'foreign' option is specified in configure.ac.
Remove from Makefile.am
2009-11-19 09:40:56 -05:00
Gaetan Nadon
3d23ef4888 INSTALL, NEWS, README or AUTHORS files are missing/incorrect #24206
Add missing INSTALL file. Use standard GNU file on building tarball
README may have been updated
Remove AUTHORS file as it is empty and no content available yet.
Remove NEWS file as it is empty and no content available yet.
2009-11-19 09:40:56 -05:00
Gaetan Nadon
c0473e4921 Several driver modules do not have a ChangeLog target in Makefile.am #23814
The git generated ChangeLog replaces the hand written one.
Update configure.ac to xorg-macros level 1.3.
Use XORG_DEFAULT_OPTIONS which replaces four XORG_* macros
Update Makefile.am to add ChangeLog target if missing
Remove ChangeLog from EXTRA_DIST or *CLEAN variables
This is a pre-req for the INSTALL_CMD
2009-11-19 09:40:56 -05:00
Gaetan Nadon
afc9e91765 .gitignore: use common defaults with custom section # 24239
Using common defaults will reduce errors and maintenance.
Only the very small or inexistent custom section need periodic maintenance
when the structure of the component changes. Do not edit defaults.
2009-11-19 09:40:56 -05:00
Bartosz Brachaczek
c1f16a4f59 Set all valuators for relative motion events (#24737)
We should process all the deltas reported by a relative motion device,
otherwise some devices such as A4Tech X-750F or similar may trigger a
situation when the `v` array contains random values (it isn't
initialized anywhere) and later we process them and in effect the mouse
cursor "jumps" on the screen.
I'm not sure why, but we also must be sure that the `first` and `last`
variables reflect the axis map, otherwise the mouse cursor "jumps" on
the screen when clicking mouse buttons in some rare cases reported by
Bartek Iwaniec on Bugzilla. That's why a simple initialization of the
`v` array with zeros isn't sufficient.

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

Signed-off-by: Bartosz Brachaczek <b.brachaczek@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-11-19 09:24:46 +10:00
Dmitry Torokhov
a0f7f34dc5 Relax checks when reopening devices
When checking whether we are dealing with the same device as before
when we try to reopen it evdev should not require exact match of
entire keymap. Users should be allowed to adjust keymaps to better
match their hardware even after X starts. However we don't expect
changes in [BTN_MISC, KEY_OK) range since these codes are reserved for
mice, joysticks, tablets and so forth, so we will limit the check to
this range.

The same goes for absinfo - limits can change and it should not result
in device being disabled.

Also check the length of the data returned by ioctl and don't try to
compare more than we were given.

[peter: moved the key comparison below the led+abs comparison]

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-11-05 08:41:59 +10:00
Peter Hutterer
11669d8279 Fix drag-lock property handler for multiple draglock buttons.
Parsing of the values was wrong. Given an input of 1 2 3 4, button 1 sets
the lock for button 2 and button 3 sets the lock for button 4.

This also means we need to return BadMatch if the property isn't a multiple
of 2.

Red Hat Bug 524428 <https://bugzilla.redhat.com/show_bug.cgi?id=524428>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-11-02 14:01:25 +10:00
Peter Hutterer
9cbffda910 Forward keycodes > 255
The server doesn't handle them yet but eventually it should learn.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-26 15:42:54 +10:00
Peter Hutterer
59056e656c Remove the reopen timer logic.
This logic was needed in older kernels that sometimes gave error messages
after coming back from resume (2.6.27 release kernels). I haven't seen any
log files that needed this reopen timer in a long time, suggesting that need
for it is gone.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-20 16:16:02 +10:00
Peter Hutterer
aa6399fdb9 evdev 2.3.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-19 11:40:24 +10:00
Peter Hutterer
1d86f5dec1 Convert IgnoreAbsolute/RelativeAxes options into trinary state.
The Xen Virtual Pointer device exports both absolute and relative axes from
the kernel device. Which coordinates are used is a run-time decision and
depends on the host-specific configuration.
0a3657d2ee broke these devices, and they are
now unusable out-of-the-box as there is no configuration to cover them.

This patch converts the IgnoreAbsoluteAxes and the IgnoreRelativeAxes
configuration options into a trinary state.
1. If unset, configure the device as normal by trying to guess the right
   axis setup.
2. If set to true, ignore the specific axis type completely (except for
   wheel events).
3. If set to false, explicitly 'unignore' the axis type, alwas configuring
   it if it is present on the device. This setting introduces seemingly
   buggy behaviour (see Bug 21832)

1. and 2. replicate the current driver behaviour.
The result of 3. is that is that if a device has absolute axes and the
options set to false, both axes will be initialized (absolute last to get
clipping right). This requires axis labelling priorty to switch from
relative first to absolute first.

Relative events are forwarded into the server through the absolute axes,
the server scales this into the device absolute range and everyone is happy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-15 11:36:49 +10:00
Peter Hutterer
fbd86e2530 Fix copy/paste typo in comment. 2009-10-15 10:52:27 +10:00
Peter Hutterer
9ea1f9a695 Fix typo, use uppercase like the other messages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-13 18:30:44 +10:00
Oliver McFadden
57b54ee399 evdev: Support the "Calibration" string option.
Originally based on a patch from Daniel Stone, this commit allows for
the calibration factors to be set either from Xorg.conf or via HAL.

Previously the only way was via the properties interface.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-13 18:30:43 +10:00
Peter Hutterer
f2dc0681fe Finalize the middle button emulation when a read error occurs (#23048)
If a read error occurs, remove the block and wakeup handlers for middle
mouse button emulation. Otherwise, they'll still be around after the device
has been reopened and overwritten with the new ones created by EvdevOn. Once
this happened, future removal of the device can lead to a server crash.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-10 11:12:42 +10:00
Peter Hutterer
3fa49dfcab evdev 2.2.99.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-08 14:26:41 +10:00
Peter Hutterer
941391ca34 Add explicit options to ignore relative or absolute axes.
The X server cannot deal with devices that have both relative and absolute
axes. Evdev tries to guess wich axes to ignore given the device type and
disables absolute axes for mice and relative axes for tablets, touchscreens
and touchpad. This guess is sometimes wrong and causes exitus felis
domesticae parvulae.

Two new configuration options are provided to explicitly allow ignoring an
axis. Mouse wheel axes are exempt and will work even if relative axes are
ignored.  No property, this option must be set in the configuration.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2009-10-07 12:55:22 +10:00
Peter Hutterer
2144f7d834 Remove unused has_xy.
has_xy is only ever set, but not used for anything else.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-30 12:30:59 +10:00
Peter Hutterer
61b4e88e01 emuWheel: fix signed/unsigned screwup
This patch fixes wheel emulation on buttons other than 0.

Reported-by: Andy Neitzke
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-23 19:29:41 +10:00
Peter Hutterer
9ee70943ec Require xorg-macros 1.3 and XORG_DEFAULT_OPTIONS
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-11 09:57:22 +10:00
Peter Hutterer
415b6ffa95 Only take the driver-internal button mapping to count buttons (#23405)
Regression:
    If a user has multiple buttons mapped to the same button number, the
    number of buttons counted is set to a wrong value.  e.g. a button
    mapping of 1 1 1 for a mouse with three buttons would only initialize 1
    button to the X server.

    In the future, the user cannot change this button mapping as the server
    only knows about one button.

The user-supplied button map (option ButtonMapping) shouldn't matter when
counting the buttons. Only the driver-internal mapping (BTN_0 -> button 1,
etc.) matters.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-20 11:09:12 +10:00
Dima Kogan
f4ba2bd785 Allow 0 as wheel emulation button for unconditional scrolling (#20529)
If wheel emulation is on and the emulation button is 0, then any x/y motion
of the device is converted into wheel events. The devices becomes a
scrolling-only device.

Signed-off-by: Dima Kogan <dkogan@cds.caltech.edu>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-18 13:09:33 +10:00
Peter Hutterer
2e5f68754f Restrict wheel emulation to a single axis at a time.
Wheel emulation works for both horizontal and vertical axes. Thus, if a
device doesn't move in perfect straight line, scroll events build up on the
respective other axis.

In some clients, scroll wheel events have specific meanings other than
scrolling (e.g. mplayer). In these clients, erroneous scrolling events come
at a high cost.

Thus, if a scroll wheel event is generated for one axis, reset the inertia
of the other axis to 0, avoiding the buildup of these erroneous scrolling
events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-18 13:07:13 +10:00
Peter Hutterer
8fdb2abb6f man: fix documentation for EVDEV_PROP_WHEEL_BUTTON
0 doesn't disable it, it's still treated like a button number. copy/paste
error.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-14 13:00:09 +10:00
Peter Hutterer
ca0fb396f1 evdev 2.2.99.1 2009-08-14 11:00:12 +10:00
Peter Hutterer
7967677789 Treat tablets (BTN_TOOL_PEN devices) differently from touchpads.
The previous checks for BTN_TOOL_FINGER and BTN_TOUCH reported false
positives for touchpads for most popular tablets.
As a result, their events were converted to relative events.

Add a new flag EVDEV_TABLET pending presence of BTN_TOOL_PEN and ignore the
touchpad special casing to report the events as-is.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-14 10:15:00 +10:00
Peter Hutterer
36064dca90 Add EvdevPostButtonEvent API to immediately post a button event (#23269)
The wheel emulation code needs this API. When the timer expires, the event
must be posted immediately, not enqueued onto the internal event queue.
Otherwise, the emulated middle button press is enqueued only and no event is
sent until the next physical event (and its EV_SYN) arrives.

Since the timer is triggered outside of the SIGIO and SIGIO is blocked
during this period anyway, we could also just enqueue the event and flush by
simulating an EV_SYN. It's easier this way though.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Oliver McFadden <oliver.mcfadden@nokia.com>
2009-08-14 10:00:31 +10:00
Peter Hutterer
8bf93709cb Rename parts of the Post API to a Queue API.
Button and key events aren't posted from EvdevPost*Event, they are simply
enqueued onto the evdev-internal event queue until the next EV_SYN arrives.
Rename those interfaces from EvdevPost* to EvdevQueue* and leave only those
that actually post to the server with a matching "*Post*" name.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Oliver McFadden <oliver.mcfadden@nokia.com>
2009-08-13 14:36:46 +10:00
Peter Hutterer
37373a223b comment typo fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-13 14:36:44 +10:00
Peter Hutterer
d764dded18 Skip check for EVDEV_RELATIVE_EVENTS for wheel events.
This patch fixes a regression introduced with 1f641d75e.
Wheel axis events are posted as button clicks, a device may have no relative
axes but it does need to post these button clicks.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-11 14:38:26 +10:00
Michael Witten
f352598e45 evdev.c: Fix/improve discrimination of rel/abs axes
The relevant comment from evdev.c:

We don't allow relative and absolute axes on the same device. The
reason is that some devices (MS Optical Desktop 2000) register both
rel and abs axes for x/y.

The abs axes register min/max; this min/max then also applies to the
relative device (the mouse) and caps it at 0..255 for both axes.
So, unless you have a small screen, you won't be enjoying it much;
consequently, absolute axes are generally ignored.

However, currenly only a device with absolute axes can be registered
as a touch{pad,screen}. Thus, given such a device, absolute axes are
used and relative axes are ignored.

The code for initializing abs/rel axes has been abstracted out into
3 functions, so that initialization in EvdevInit(device) is as easy
as:

    if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN))
        EvdevInitTouchDevice(device, pEvdev);
    else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
        EvdevInitRelClass(device, pEvdev);
    else if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
        EvdevInitAbsClass(device, pEvdev);

Signed-off-by: Michael Witten <mfwitten@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-06 14:06:24 +10:00
Oliver McFadden
69d6ff3e01 evdev: Use the EvdevPost...Event() functions in the emulation code.
This is similar to commit 1f641d75ed.

It provides the same functionality of queuing the (in this case
emulated) events and waiting until an EV_SYN synchronization event is
received before posting them to the server.

This preserves the order of events (both real and emulated) and ensures
that MotionNotify events will always be posted first. It also unifies
the event posting into a few small functions which improves
maintainability.

From this point on, you should never use the xf86Post...Event()
functions in new code, but rather the EvdevPost...Event() versions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-04 16:07:17 +10:00
Peter Hutterer
6f4634111a Evdev doesn't require inputproto.
None of the inputproto headers seem to be included anywhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 09:29:36 +10:00
Oliver McFadden
1f641d75ed evdev: Only send the events at synchronization time.
Instead of just posting the button/key press/release events to the
server as soon as they arrive, add them to an internal queue and post
them once we receive an EV_SYN synchronization event.

The motion events are always sent first, followed by the queued events.
There will be one motion event and possibly many queued button/key
events posted every EV_SYN event.

Note that the size of the event queue (EVDEV_MAXQUEUE) is arbitrary and
you may change it. If we receive more events than the queue can handle,
those events are dropped and a warning message printed.

Tested on my Lenovo T400 using evdev for all input devices; keyboard,
touchpad, and trackpoint.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-29 15:26:53 +10:00
Peter Hutterer
2994825665 Don't register middle mouse button emulation handlers for keyboards.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-20 14:52:46 +10:00
Oliver McFadden
9bfd9e8a36 Coverity Prevent: NO_EFFECT in EvdevWheelEmuSetProperty:
Event unsigned_compare: Comparing unsigned less than zero is never true. "pEvdev->emulateWheel.timeout < 0UL"
342  	            if (pEvdev->emulateWheel.timeout < 0)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-17 11:08:51 +10:00
Peter Hutterer
dcca28a59c Count REL_DIAL as a scrollwheel during EvdevProbe (#21457)
The Griffin Powermate only has a single axis (REL_DIAL). This axis is
posted as horizontal scroll wheel, so we need to ensure the scroll wheel
setup (including ensuring that enough buttons are available) is triggered
accordingly.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-03 10:37:35 +10:00
Asbjrn Sannes
db8b1ca5cf evdev: Fix spelling of property in man page to match source code. #22571
Signed-off-by: Asbj�rn Sannes <ace@sannes.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-02 07:55:30 +10:00
Peter Hutterer
8cc0d0f285 Fix absolute axis labelling - mapping must be initialized before the labels.
88eedea281 added axis labelling to the
valuator initialization. This requires the axis mapping to be established
before the absolute axis labels are initialized.

88eedea did this for relative axes, but missed out on the absolute ones. As
a result, all abs. labels were initialized to "None".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-29 14:40:21 +10:00
Peter Hutterer
aa1609285d Message "found absolute touchpad" also applies to tablets - fix.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-29 14:40:21 +10:00
Peter Hutterer
b07ab6ea97 If a device fails to initialize relative axes, init the abs. axes instead.
Some devices have relative axes that don't count (scroll wheels). In this
case, don't claim we've initialized relative axes, continue with the
absolute axes instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-29 14:40:18 +10:00
Peter Hutterer
7bc48c666d Fix wrong axis label index causing OOB reads/writes.
The atoms array is filled with each axis atom in mapping order (i.e. after
the driver mapping has been applied). 'axis' OTOH is from 0 to ABS_MAX.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-23 15:47:41 +10:00
Peter Hutterer
880ad1e19a Initialize the axis labels to 0, not "misc".
If we don't know what an axis label is, then don't initialize it. None is a
valid label.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-23 14:53:11 +10:00
Peter Hutterer
6ab23e4519 Add missing checks for ABI_XINPUT_VERSION 7.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 16:19:08 +10:00
Peter Hutterer
88eedea281 Cope with ABI_XINPUT_VERSION 7 - requires button + axes labels.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 15:33:48 +10:00
Peter Hutterer
9a5a4fed3a Split axes and button labels into separate function.
We'll re-use this bit very soon.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 15:18:14 +10:00
Derek Upham
0a3657d2ee evdev: Prevent driver from processing motion events that it has not configured. #21832
The current implementation initializes itself to support relative
motion events, or absolute motion events, or neither.  But the
event-handling code attempts to process all events, no matter what the
initialization was.  This patch reproduces the flag tests found during
init, to skip events that the driver doesn't support.

Signed-off-by: Derek Upham <sand@blarg.net>
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-28 08:53:56 +10:00
Peter Hutterer
dc2191285e Deal with BTN_3 to BTN_9 buttons.
These buttons were previously mapped to 0, i.e. inactive. This patch
slightly improves things in that the buttons are now mapped to 8+.

Devices that have both BTN_3 and BTN_SIDE (or a similar pair in that
sequence) have both mapped to the same button number though.
Devices that have BTN_LEFT, BTN_0, BTN_3 and BTN_SIDE have the last three
mapped to 8 (and their followers have double-mappings too). We'll fix that
once we actually see devices affected by this.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 15:51:08 +10:00
Peter Hutterer
255b9f6bbf Only initialize the number of buttons we actually have.
This takes into account driver-configured button mappings, i.e. if device
with one button has this button mapped to 25 through the ButtonMapping
option, the X server will think the device has result 25 buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 15:51:08 +10:00
Peter Hutterer
aa117d49a5 Rename pEvdev->buttons to pEvdev->num_buttons for clarity.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 15:51:08 +10:00
Peter Hutterer
b358f1eb3a Ensure enough buttons are advertised to pass the button mapping.
Some buttons are mapped to higher button numbers. For example, BTN_0 is
posted as button 8 if BTN_LEFT is present. On top of that, the
driver-specific button mapping may map the button to something else again.
We need to take these mappings into account when counting the number of
buttons on the device.

Example: A device with BTN_LEFT and BTN_0 and a mapping from 1 -> 7 and 8 ->
2.

BTN_LEFT is mapped to 1. 1 is mapped to 7. num_buttons is 7.
BTN_0 is mapped to 8. 8 is mapped to 2. num_buttons remains 7.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 15:51:08 +10:00
Peter Hutterer
33cc112ca1 Up the number of button labels atoms to EVDEV_MAXBUTTONS.
Button labels would smash memory if the device had less than 4 buttons and
did not advertise a wheel event. In this case the hard-coded wheel button
labels would write past the atoms[] boundary.

Potential memory smash if a device had a BTN_LEFT and BTN_0, since the
latter would map to 8, regardless of the the number of actual buttons
(same with BTN_MIDDLE and BTN_1 or BTN_RIGHT and BTN_2).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 15:51:08 +10:00
Peter Hutterer
3c43d880f1 Only label axes and buttons if the device has axes or buttons.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 15:51:08 +10:00
Peter Hutterer
5462898935 Use xf86DisableDevice instead of the DIX' DisableDevice.
DisableDevice has changed API in xi2, xf86DisableDevice hasn't. So let's use
this one so we can have one version for master and xi2.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 14:27:08 +10:00
Dan Nicholson
9243d338d1 Fix copy-paste error when probing type name
A minor copy and paste error was introduced in 71e9a69e leaving an "if"
where an "else if" should be. Without this, any device configured as
XI_TOUCHPAD or XI_TABLET will end up having the type_name reset to
either XI_TOUCHSCREEN or XI_MOUSE.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-11 08:19:04 +10:00
Peter Hutterer
71e9a69ed6 Revamp the whole "has_axes" definition.
Since we can now deal with multiple axes, etc. we might as well print it
properly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-29 18:27:13 +10:00
Peter Hutterer
220e2dfb8f Print read errors as X_NONE to avoid mallocs in the server.
Messages of type X_NONE are just passed down to the log files, everything else
gets the (EE) or (II) prefixed. Since this mallocs, we can't use it in the
signal handler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-16 13:44:07 +10:00
Peter Hutterer
ddc1266374 Pre-allocate the reopen timer so we don't allocate during sigio handling.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-16 13:44:05 +10:00
Peter Hutterer
98ecb5233b Trigger read error handling if len is <= 0.
Red Hat Bug 494245 <https://bugzilla.redhat.com/show_bug.cgi?id=494245>

Reported-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-06 10:25:03 +10:00
Peter Hutterer
92ca3dc2e7 Fix wrong reference to axis and button label atom list.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-26 13:40:40 +10:00
Peter Hutterer
3fa28c8acd Remove test/ directory.
This shouldn't really be part of the driver source, it's better to just have
it as a separate repository. Code has moved to
git://people.freedesktop.org/~whot/testdevices.git

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-26 10:20:56 +10:00
Peter Hutterer
d9809d7edd Fix jumpy touchpads by updating old_vals only when reported by the device.
Remember whether ABS_X or ABS_Y were reported before the SYN event and only
update the old_vals[0, 1] if we got data for them.
Touchpads that reported pressure data before x/y would otherwise update
old_x/y with bogus values, leading to jumps when the first x/y coordinates
were actually reported.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-17 14:15:00 +10:00
Peter Hutterer
b11439a176 If we have a touchpad, print so, don't claim we're configuring a tablet.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-17 13:27:03 +10:00
Jeremy Jay
740dc202f7 make sure to clear all axis_map entries
don't use uninitialized axis_map entries, ie axis_map[ABS_PRESSURE]

Signed-off-by: Jeremy Jay <dinkumator@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-17 13:27:03 +10:00
Peter Hutterer
7ac0c4456d Assume touchscreen/touchpad if we have _either_ ABS_PRESSURE or BTN_TOUCH
Touchpads have pressure or touch and also BTN_TOOL_FINGER.
Touchscreens have either pressure or touch, but no finger.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-17 10:08:33 +10:00
Peter Hutterer
b4f6ab126d Move keymap/modifier initialization behind the ABI < 5 ifdefs.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-16 10:36:13 +10:00
Jeremy Jay
a3ea979c2b Set "rel" when converting absolute touchpad coordinates to relative (#20661)
We unset "abs" and convert to relative, but never set "rel" so the events
don't get posted. This bit got broken in 43dd2a9592.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-16 08:43:16 +10:00
Peter Hutterer
a7fb654a68 Restore repeat-filtering for server 1.5 and earlier.
Letting the server deal with key repeats is fine if we have server 1.6. For
earlier servers, we need to pass on the repeat events (except for modifier
keys).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Marty Jack <martyj19@comcast.net>
2009-03-10 16:04:49 +10:00
Peter Hutterer
3f06825a44 Bump to 2.2.99.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-09 10:01:35 +10:00
42 changed files with 4707 additions and 2660 deletions

View File

@@ -0,0 +1,65 @@
name: 🐞 Bug report
description: Create a report to help us improve
labels: [bug, needs-triage]
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to help everyone identify and fix the bug. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: dropdown
id: affected-version
attributes:
label: Select the version
options:
- 2.11.0.1
- Git master branch
- other or don't know
default: 1
validations:
required: true
- type: textarea
id: description
attributes:
label: Describe your issue
placeholder: When I did X then Y happened.
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
placeholder: |
1. Start ...
2. Do this
3. Do that
validations:
required: true
- type: textarea
id: expected
attributes:
label: What did you expect?
placeholder: I expected this to happen.
- type: textarea
id: environment
attributes:
label: Additional Information
description: |
Additional information you want to provide such as logs, system info, environment, screenshots, etc.
placeholder: |
Add any other context about the bug here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-evdev/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for reporting this issue! We will get back to you as soon as possible.

View File

@@ -0,0 +1,49 @@
name: ✨ Feature request
description: Suggest a feature for this software
labels: [enhancement, needs-triage]
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to properly describe the new software feature you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: "Describe the feature"
placeholder: A thing in X that allows to do Y.
validations:
required: true
- type: textarea
id: rationale
attributes:
label: "It should be done because"
placeholder: Doing Y is needed for Z.
validations:
required: true
- type: textarea
id: alternative
attributes:
label: "What are the alternatives?"
placeholder: We could do A or B instead.
- type: textarea
id: context
attributes:
label: Additional context
description: Additional information you want to provide such as references to related issues or protocols, the implications on existing use cases, etc.
placeholder: |
Add any other context about the feature request here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-evdev/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for your suggestion! Let's see together if it can be done.

View File

@@ -0,0 +1,49 @@
name: 🔧 Code cleanup
description: Level up the source code
labels: [code-cleanup, needs-triage]
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to properly describe the code cleanup you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: "Describe the cleanup"
placeholder: C in X needs to be changed into D.
validations:
required: true
- type: textarea
id: rationale
attributes:
label: "It should be done because"
placeholder: Having D is needed for E.
validations:
required: true
- type: textarea
id: alternative
attributes:
label: "What are the alternatives?"
placeholder: We could do A or B instead.
- type: textarea
id: context
attributes:
label: Additional context
description: Additional information you want to provide such as implications on existing code, how to ensure API/ABI stability, which tests are needed or to be run, related issues, etc.
placeholder: |
Add any other context about the cleanup here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-evdev/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for looking at the source code! Let's see together how it can be improved.

View File

@@ -0,0 +1,38 @@
name: 🔖 Documentation update
description: Make your mark for better documentation
labels: [documentation, needs-triage]
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to help others understand our software. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: Describe the update
placeholder: These things need to be better documented.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Additional Information
description: Additional information you want to provide such as tickets related to changes in the software, affected files, screenshots, etc.
placeholder: |
Add any other context about the update here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-evdev/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for requesting this update! We will get back to you as soon as possible.

43
.github/ISSUE_TEMPLATE/05-org-task.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: ✅ Organizational task
description: Create a task for project organization
labels: [needs-triage, organization]
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to get organizational things done. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: Describe the task
placeholder: These things need to be done.
validations:
required: true
- type: textarea
id: rationale
attributes:
label: "It should be done because"
placeholder: Doing Y is needed for Z.
- type: textarea
id: environment
attributes:
label: Additional Information
description: Additional information you want to provide such as the context for bigger tasks, the implicatons on existing workflows, related issues, etc.
placeholder: |
Add any other context about the task here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-evdev/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for adding this task! We will get back to you as soon as possible.

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: XLibre Community Support
url: https://github.com/orgs/X11Libre/discussions
about: Please ask and answer questions here.
- name: Mailing List
url: https://www.freelists.org/list/xlibre
about: You can join the discussions on our mailing list.

View File

@@ -0,0 +1,69 @@
name: 'build driver'
description: 'build driver against specific Xserver'
inputs:
xserver-version:
required: true
runs:
using: "composite"
steps:
- name: check out driver repo
uses: actions/checkout@v4
- name: prepare build environment
shell: bash
run: |
MACHINE=`gcc -dumpmachine`
echo "MACHINE=$MACHINE" >> "$GITHUB_ENV"
echo "PKG_CONFIG_PATH=$X11_PREFIX/share/pkgconfig:$X11_PREFIX/lib/$MACHINE/pkgconfig:$X11_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" >> "$GITHUB_ENV"
sudo chown root /bin/tar && sudo chmod u+s /bin/tar
- name: apt cache
uses: actions/cache@v4
with:
path: /var/cache/apt
key: apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }}
restore-keys: apt-cache-
- name: pkg install
shell: bash
run: sudo .github/scripts/ubuntu/install-pkg.sh
- name: X11 prereq cache
uses: actions/cache@v4
with:
path: |
${{ env.X11_PREFIX }}
key: ${{ runner.name }}-x11-deps-${{ hashFiles('.github/scripts/install-prereq.sh') }}
restore-keys: ${{ runner.name }}-x11-deps-
- name: generic prereq
shell: bash
run: .github/scripts/install-prereq.sh
- name: check out xserver repo
uses: actions/checkout@v4
with:
repository: X11Libre/xserver
path: xserver-sdk
ref: ${{ inputs.xserver-version }}
- name: build xserver sdk
shell: bash
env:
MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dnamespace=false -Dxselinux=false -Dxephyr=false -Dwerror=false -Dxcsecurity=false -Dxorg=true -Dxvfb=false -Dxnest=false -Ddocs=false
run: |
cd xserver-sdk
echo -n > .meson_environment
echo "export MESON_BUILDDIR=$MESON_BUILDDIR" >> .meson_environment
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> .meson_environment
.gitlab-ci/meson-build.sh --skip-test
sudo meson install --no-rebuild -C "$MESON_BUILDDIR"
sudo mkdir -p /usr/local/lib/$MACHINE/xorg/modules # /home/runner/x11/lib/xorg/modules
sudo chown -R runner /usr/local/lib/$MACHINE/xorg/modules # /home/runner/x11/lib/xorg/modules
- name: compile driver
shell: bash
run: |
CFLAGS="-Wall" ./autogen.sh # --prefix=$X11_PREFIX
CFLAGS="-Wall" make -j # install

13
.github/scripts/conf.sh vendored Normal file
View File

@@ -0,0 +1,13 @@
export X11_OS=`uname -s`
export X11_PREFIX="${X11_PREFIX:-$HOME/x11}"
export X11_BUILD_DIR="${X11_BUILD_DIR:-$HOME/build-deps}"
export DRV_BUILD_DIR="${DRV_BUILD_DIR:-$HOME/build-drivers}"
case "$X11_OS" in
Darwin) export FDO_CI_CONCURRENT=`sysctl -n hw.logicalcpu` ;;
Linux) export FDO_CI_CONCURRENT=`nproc` ;;
esac
export PATH="$X11_PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$X11_PREFIX/lib/x86_64-linux-gnu/pkgconfig:$X11_PREFIX/lib/pkgconfig:$X11_PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

17
.github/scripts/github/make-release vendored Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
err() {
echo "$0: $*"
}
[ "$GITHUB_REPOSITORY" ] || err "missing variable GITHUB_REPOSITORY"
TITLE=$(git tag -l --format='%(contents)' $tag)
echo "tag=$tag"
echo "title=$TITLE"
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="$tag" \
--generate-notes

15
.github/scripts/install-prereq.sh vendored Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -e
. .github/scripts/util.sh
mkdir -p $X11_BUILD_DIR
cd $X11_BUILD_DIR
if [ "$X11_OS" = "Linux" ]; then
build_meson drm https://gitlab.freedesktop.org/mesa/drm libdrm-2.4.121 "" \
-Domap=enabled
fi
build_meson libxcvt https://gitlab.freedesktop.org/xorg/lib/libxcvt libxcvt-0.1.0
build_ac xorgproto https://gitlab.freedesktop.org/xorg/proto/xorgproto xorgproto-2024.1

94
.github/scripts/ubuntu/install-pkg.sh vendored Executable file
View File

@@ -0,0 +1,94 @@
#!/bin/bash
set -e
# Packages which are needed by this script, but not for the xserver build
EPHEMERAL="
libexpat-dev
libgles2-mesa-dev
libxkbcommon-dev
x11-utils
x11-xserver-utils
xauth
xvfb
"
apt-get update
apt-get install -y \
$EPHEMERAL \
autoconf \
automake \
build-essential \
ca-certificates \
libaudit-dev \
libbsd-dev \
libcairo2-dev \
libdbus-1-dev \
libdrm-dev \
libegl1-mesa-dev \
libepoxy-dev \
libevdev2 \
libexpat1 \
libffi-dev \
libgbm-dev \
libgcrypt-dev \
libgl1-mesa-dev \
libgles2 \
libglx-mesa0 \
libinput10 \
libinput-dev \
libnvidia-egl-wayland-dev \
libpciaccess-dev \
libpixman-1-dev \
libspice-protocol-dev \
libsystemd-dev \
libudev-dev \
libunwind-dev \
libx11-dev \
libx11-xcb-dev \
libxau-dev \
libxaw7-dev \
libxcb-glx0-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-shm0-dev \
libxcb-util0-dev \
libxcb-xf86dri0-dev \
libxcb-xkb-dev \
libxcb-xv0-dev \
libxcb1-dev \
libxdmcp-dev \
libxext-dev \
libxfixes-dev \
libxfont-dev \
libxi-dev \
libxinerama-dev \
libxkbcommon0 \
libxkbfile-dev \
libxmu-dev \
libxmuu-dev \
libxpm-dev \
libxrender-dev \
libxres-dev \
libxshmfence-dev \
libxt-dev \
libxtst-dev \
libxv-dev \
mesa-common-dev \
meson \
nettle-dev \
libpango1.0-dev \
pkg-config \
x11-xkb-utils \
xfonts-utils \
xkb-data \
xtrans-dev \
xutils-dev \
libxaw7-dev \
python3-mako

85
.github/scripts/util.sh vendored Normal file
View File

@@ -0,0 +1,85 @@
. .github/scripts/conf.sh
clone_source() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
if [ ! -f $pkgname/.git/config ]; then
echo "need to clone $pkgname"
if [ "$commit" ]; then
git clone $url $pkgname --branch=$ref
else
git clone $url $pkgname --branch=$ref --depth 1
fi
else
echo "already cloned $pkgname"
fi
if [ "$commit" ]; then
( cd $pkgname && git checkout -f "$commit" )
fi
}
build_meson() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
shift || true
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
meson "$@" build -Dprefix=$X11_PREFIX
ninja -j${FDO_CI_CONCURRENT:-4} -C build install
)
touch $X11_PREFIX/$pkgname.DONE
fi
}
build_ac() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
shift || true
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
./autogen.sh --prefix=$X11_PREFIX
make -j${FDO_CI_CONCURRENT:-4} install
)
touch $X11_PREFIX/$pkgname.DONE
fi
}
build_drv_ac() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
shift || true
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
./autogen.sh # --prefix=$X11_PREFIX
make -j${FDO_CI_CONCURRENT:-4} # install
)
}

43
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Build driver
permissions:
contents: write
env:
MESON_BUILDDIR: "build"
X11_PREFIX: /home/runner/x11
X11_BUILD_DIR: /home/runner/build-deps
on:
push:
pull_request:
jobs:
for-xserver-stable-25_0:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-driver
with:
xserver-version: xlibre-xserver-25.0.0.5
for-xserver-master:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-driver
with:
xserver-version: master
release:
name: Release pushed tag
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/xlibre-') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: .github/scripts/github/make-release

76
.gitignore vendored
View File

@@ -1,28 +1,78 @@
*.patch
ChangeLog
Makefile
Makefile.in
#
# X.Org module default exclusion patterns
# The next section if for module specific patterns
#
# Do not edit the following section
# GNU Build System (Autotools)
aclocal.m4
autom4te.cache
autom4te.cache/
autoscan.log
ChangeLog
compile
config.guess
config.h
config.h.in
config.log
config-ml.in
config.py
config.status
config.status.lineno
config.sub
configure
configure.scan
depcomp
.deps/
INSTALL
install-sh
.libs/
libtool
libtool.m4
ltmain.sh
man/evdev.4
lt~obsolete.m4
ltoptions.m4
ltsugar.m4
ltversion.m4
Makefile
Makefile.in
mdate-sh
missing
.deps
.libs
*.lo
*.la
stamp-h1
xf86-input-evdev-*.tar.*
mkinstalldirs
*.pc
py-compile
stamp-h?
symlink-tree
texinfo.tex
ylwrap
# Do not edit the following section
# Edit Compile Debug Document Distribute
*~
tags
*.[0-9]
*.[0-9]x
*.bak
*.bin
core
*.dll
*.exe
*-ISO*.bdf
*-JIS*.bdf
*-KOI8*.bdf
*.kld
*.ko
*.ko.cmd
*.lai
*.l[oa]
*.[oa]
*.obj
*.patch
*.so
*.pcf.gz
*.pdb
*.tar.bz2
*.tar.gz
#
# Add & Override patterns for xf86-input-evdev
#
# Edit the following section as needed
# For example, !report.pc overrides *.pc. See 'man gitignore'
#

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

72
COPYING
View File

@@ -1,57 +1,11 @@
Various copyright notices found in this driver:
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.
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
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.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the copyright holders shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the copyright holders.
Copyright © 2008 University of South Australia
copyrights taken from xf86-input-mouse, partly valid for this driver.
Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
Copyright 1993 by David Dawes <dawes@xfree86.org>
Copyright 2002 by SuSE Linux AG, Author: Egbert Eich
Copyright 1994-2002 by The XFree86 Project, Inc.
Copyright 2002 by Paul Elliott
Copyright © 2008 University of South Australia
Copyright 2008 by Chris Salch
Copyright © 2008 Red Hat, Inc.
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without
@@ -72,6 +26,26 @@ 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.
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Copyright 2005 Adam Jackson.

View File

@@ -18,27 +18,25 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
# Ensure headers are installed below $(prefix) for distcheck
DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg'
# During distcheck, system locations (as provided by pkg-config) may
# not be writable; provide instead relative locations.
DISTCHECK_CONFIGURE_FLAGS = --with-xorg-module-dir='$${libdir}/xorg/modules' \
--with-sdkdir='$${includedir}/xorg'
if BUILD_TEST
test_dir=test
endif
SUBDIRS = src man include
MAINTAINERCLEANFILES = ChangeLog INSTALL
SUBDIRS = src man include $(test_dir)
dist_xorgconf_DATA = 10-evdev.conf
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-evdev.pc
.PHONY: ChangeLog INSTALL
EXTRA_DIST = ChangeLog
MAINTAINERCLEANFILES=ChangeLog
.PHONY: ChangeLog
INSTALL:
$(INSTALL_CMD)
ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog
dist-hook: ChangeLog INSTALL
EXTRA_DIST = README.md

20
README
View File

@@ -1,20 +0,0 @@
xf86-input-evdev - Generic Linux input driver for the Xorg X server
Please submit bugs & patches to the Xorg bugzilla:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
All questions regarding this software should be directed at the
Xorg mailing list:
http://lists.freedesktop.org/mailman/listinfo/xorg
The master development code repository can be found at:
git://anongit.freedesktop.org/git/xorg/driver/xf86-input-evdev
http://cgit.freedesktop.org/xorg/driver/xf86-input-evdev
For more information on the git code manager, see:
http://wiki.x.org/wiki/GitPage

8
README.md Normal file
View File

@@ -0,0 +1,8 @@
xf86-input-evdev - Generic Linux input driver for the XLibre X server
---------------------------------------------------------------------
The primary development code repository can be found at:
https://github.com/X11Libre/xf86-input-evdev
Please submit bug reports and requests to merge patches there.

View File

@@ -1,12 +1,17 @@
#! /bin/sh
srcdir=`dirname $0`
srcdir=`dirname "$0"`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
cd "$srcdir"
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
cd "$ORIGDIR" || exit $?
$srcdir/configure --enable-maintainer-mode "$@"
git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
git config --local format.subjectPrefix "PATCH xf86-input-evdev"
if test -z "$NOCONFIGURE"; then
exec "$srcdir"/configure "$@"
fi

View File

@@ -20,78 +20,61 @@
#
# Process this file with autoconf to produce a configure script
AC_PREREQ(2.57)
AC_INIT([xf86-input-evdev],
2.2.4,
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
xf86-input-evdev)
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xlibre-xf86-input-evdev],
[25.0.0],
[https://github.com/X11Libre/xf86-input-evdev/issues],
[xlibre-xf86-input-evdev])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz])
# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.2)
AM_CONFIG_HEADER([config.h])
# Checks for programs.
# Initialize libtool
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_CC
XORG_CWARNFLAGS
AH_TOP([#include "xorg-server.h"])
# Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
# Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.18] xproto [inputproto >= 2.1.99.3])
PKG_CHECK_MODULES(UDEV, libudev, [AC_DEFINE(HAVE_LIBUDEV, 1,[libudev support])])
PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
PKG_CHECK_MODULES(MTDEV, mtdev)
# Define a configure option for an alternate input module directory
PKG_PROG_PKG_CONFIG([0.25])
AC_ARG_WITH(xorg-module-dir,
AC_HELP_STRING([--with-xorg-module-dir=DIR],
[Default xorg module directory [[default=$libdir/xorg/modules]]]),
AS_HELP_STRING([--with-xorg-module-dir=DIR],
[Default xorg module directory]),
[moduledir="$withval"],
[moduledir="$libdir/xorg/modules"])
[moduledir=`$PKG_CONFIG --variable=moduledir xorg-server`])
inputdir=${moduledir}/input
AC_SUBST(inputdir)
# Enable building everything in the test/ directory. These are uinput-based
# devices that resemble random hardware that may or may not look like a mouse,
# keyboard, etc.
AC_ARG_ENABLE(testdevices,
AC_HELP_STRING([--enable-testdevices], [Build uinput-based test devices]),
[BUILD_TEST="yes"],
[BUILD_TEST="no"])
AM_CONDITIONAL([BUILD_TEST], [test "x$BUILD_TEST" = "xyes"])
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)
if test "x$BUILD_TEST" = "xyes"; then
AC_CHECK_FUNC([dlopen], [],
AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
AC_SUBST([DLOPEN_LIBS])
fi
# 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`
# Checks for pkg-config packages. We need to be able to override sdkdir
# to satisfy silly distcheck requirements.
PKG_CHECK_MODULES(XORG, xorg-server xproto $REQUIRED_MODULES)
XORG_CFLAGS="$CWARNFLAGS $XORG_CFLAGS"
AC_ARG_WITH([sdkdir], [],
[sdkdir="$withval"],
[sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`])
# Workaround overriding sdkdir to be able to create a tarball when user has no
# write permission in sdkdir. See DISTCHECK_CONFIGURE_FLAGS in Makefile.am
AC_ARG_WITH([sdkdir], [], [sdkdir="$withval"])
AC_SUBST([sdkdir])
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
DRIVER_NAME=evdev
AC_SUBST([DRIVER_NAME])
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION
XORG_CHANGELOG
AC_OUTPUT([Makefile
src/Makefile
man/Makefile
include/Makefile
test/Makefile
xorg-evdev.pc])
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile include/Makefile])
AC_OUTPUT

View File

@@ -1,2 +1 @@
EXTRA_DIST = evdev-properties.h
sdk_HEADERS = evdev-properties.h

View File

@@ -33,6 +33,8 @@
#define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation"
/* CARD32 */
#define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout"
/* CARD8 */
#define EVDEV_PROP_MIDBUTTON_BUTTON "Evdev Middle Button Button"
/* Wheel emulation */
/* BOOL */
@@ -43,7 +45,7 @@
#define EVDEV_PROP_WHEEL_INERTIA "Evdev Wheel Emulation Inertia"
/* CARD16 */
#define EVDEV_PROP_WHEEL_TIMEOUT "Evdev Wheel Emulation Timeout"
/* CARD8, value range 0-32, 0 to disable a value */
/* CARD8, value range 0-32, 0 to always scroll */
#define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button"
/* Drag lock */
@@ -56,7 +58,7 @@
/* Reopen attempts. */
/* CARD8 */
#define EVDEV_PROP_REOPEN "Evdev Reopen Attempts"
#define EVDEV_PROP_REOPEN "Evdev Reopen Attempts" /* OBSOLETE */
/* Run-time calibration */
/* CARD32, 4 values [minx, maxx, miny, maxy], or no values for unset */
@@ -66,4 +68,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

@@ -1,57 +1,37 @@
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
#
# 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.
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the copyright holders shall
# not be used in advertising or otherwise to promote the sale, use or
# other dealings in this Software without prior written authorization
# from the copyright holders.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
drivermandir = $(DRIVER_MAN_DIR)
driverman_PRE = @DRIVER_NAME@.man
driverman_PRE = evdev.man
driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
driverman_DATA = $(driverman_PRE:man=$(DRIVER_MAN_SUFFIX))
EXTRA_DIST = @DRIVER_NAME@.man
EXTRA_DIST = evdev.man
CLEANFILES = $(driverman_DATA)
SED = sed
# Strings to replace in man pages
XORGRELSTRING = @PACKAGE_STRING@
XORGMANNAME = X Version 11
MAN_SUBSTS = \
-e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
-e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
-e 's|__xservername__|Xorg|g' \
-e 's|__xconfigfile__|xorg.conf|g' \
-e 's|__projectroot__|$(prefix)|g' \
-e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \
-e 's|__drivermansuffix__|$(DRIVER_MAN_SUFFIX)|g' \
-e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \
-e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \
-e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g'
SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
.man.$(DRIVER_MAN_SUFFIX):
sed $(MAN_SUBSTS) < $< > $@
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@

View File

@@ -1,8 +1,8 @@
.\" shorthand for double quote that works everywhere.
.ds q \N'34'
.TH EVDEV __drivermansuffix__ __vendorversion__
.TH EVDEV __drivermansuffix__ 2016-11-17 __vendorversion__
.SH NAME
evdev \- Generic Linux input driver
evdev \- Generic Linux input driver for XLibre
.SH SYNOPSIS
.nf
.B "Section \*qInputDevice\*q"
@@ -16,87 +16,118 @@ evdev \- Generic Linux input driver
.B EndSection
.fi
.SH DESCRIPTION
.B evdev
is an __xservername__ input driver for Linux\'s generic event devices. It
therefore supports all input devices that the kernel knows about, including
most mice and keyboards.
.PP
The
.B evdev
driver can serve as both a pointer and a keyboard input device, and may be
used as both the core keyboard and the core pointer. Multiple input devices
are supported by multiple instances of this driver, with one Load
directive for evdev in the Module section of your __xconfigfile__ for each
input device that will use this driver.
is an XLibre input driver for Linux\'s generic event devices.
It therefore supports all input devices that the kernel knows about,
including most mice, keyboards, tablets, and touchscreens.
.B evdev
is the default driver on the major Linux distributions.
.PP
The
.B evdev
driver can serve as both a pointer and a keyboard input device.
Multiple input devices are supported by multiple instances of this driver,
with one InputDevice section of your xorg.conf for each input device
that will use this driver.
.PP
It is recommended that
.B evdev
devices are configured through the
.B InputClass
directive (refer to
.BR xorg.conf (__filemansuffix__))
instead of manual per-device configuration.
Devices configured in the
.BR xorg.conf (__filemansuffix__)
are not hot-plug capable.
.SH SUPPORTED HARDWARE
In general, any input device that the kernel has a driver for can be accessed
through the
through the
.B evdev
driver. See the Linux kernel documentation for a complete list.
.PP
driver.
See the Linux kernel documentation for a complete list.
.SH CONFIGURATION DETAILS
Please refer to __xconfigfile__(__filemansuffix__) for general configuration
details and for options that can be used with all input drivers. This
section only covers configuration details specific to this driver.
Please refer to
.BR xorg.conf (__filemansuffix__)
for general configuration details and
for options that can be used with all input drivers.
This section only covers configuration details specific to this driver.
.PP
The following driver
The following driver
.B Options
are supported:
.TP 7
.BI "Option \*qButtonMapping\*q \*q" string \*q
Sets the button mapping for this device. The mapping is a space-separated list
of button mappings that correspond in order to the physical buttons on the
device (i.e. the first number is the mapping for button 1, etc.). The default
mapping is "1 2 3 ... 32". A mapping of 0 deactivates the button. Multiple
buttons can have the same mapping.
Sets the button mapping for this device.
The mapping is a space-separated list of button mappings
that correspond in order to the physical buttons on the device
(i.e. the first number is the mapping for button 1, etc.).
The default mapping is "1 2 3 ... 32".
A mapping of 0 deactivates the button.
Multiple buttons can have the same mapping.
For example, a left-handed mouse with deactivated scroll-wheel would use a
mapping of "3 2 1 0 0". Invalid mappings are ignored and the default mapping
is used. Buttons not specified in the user's mapping use the default mapping.
mapping of "3 2 1 0 0".
Invalid mappings are ignored and the default mapping is used.
Buttons not specified in the user's mapping use the default mapping.
.TP 7
.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.
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.
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
that low dexterity people do not have to hold a button down at the
same time they move a mouse cursor. Button numbers occur in pairs,
with the lock button number occurring first, followed by the button
number that is the target of the lock button. Property: "Evdev
same time they move a mouse cursor.
Button numbers occur in pairs,
with the lock button number occurring first,
followed by the button number that is the target of the lock button.
Property: "Evdev
Drag Lock Buttons".
.TP 7
.BI "Option \*qDragLockButtons\*q \*q" "M1" \*q
Sets a \*qmaster drag lock button\*q that acts as a \*qMeta Key\*q
indicating that the next button pressed is to be
\*qdrag locked\*q. Property: "Evdev Drag Lock Buttons".
.TP 7
indicating that the next button pressed is to be \*qdrag locked\*q.
Property: "Evdev Drag Lock Buttons".
.TP 7
.BI "Option \*qEmulate3Buttons\*q \*q" boolean \*q
Enable/disable the emulation of the third (middle) mouse button for mice
which only have two physical buttons. The third button is emulated by
pressing both buttons simultaneously. Default: on, until a middle mouse
button event is registered. Property: "Evdev Middle Button Emulation".
which only have two physical buttons.
The third button is emulated by pressing both buttons simultaneously.
Default: off.
Property: "Evdev Middle Button Emulation".
.TP 7
.BI "Option \*qEmulate3Timeout\*q \*q" integer \*q
Sets the timeout (in milliseconds) that the driver waits before deciding
if two buttons where pressed "simultaneously" when 3 button emulation is
enabled. Default: 50. Property: "Evdev Middle Button Timeout".
if two buttons were pressed "simultaneously" when 3 button emulation is enabled.
Default: 50.
Property: "Evdev Middle Button Timeout".
.TP 7
.BI "Option \*qEmulate3Button\*q \*q" integer \*q
Specifies the physical button number to be emitted if middle button emulation
is triggered.
Default: 2.
Property: "Evdev Middle Button Button".
.TP 7
.BI "Option \*qEmulateWheel\*q \*q" boolean \*q
Enable/disable "wheel" emulation. Wheel emulation means emulating button
press/release events when the mouse is moved while a specific real button
is pressed. Wheel button events (typically buttons 4 and 5) are
usually used for scrolling. Wheel emulation is useful for getting wheel-like
behaviour with trackballs. It can also be useful for mice with 4 or
more buttons but no wheel. See the description of the
Enable/disable "wheel" emulation.
Wheel emulation means emulating button press/release events
when the mouse is moved while a specific real button is pressed.
Wheel button events (typically buttons 4 and 5) are usually used for scrolling.
Wheel emulation is useful for getting wheel-like behaviour with trackballs.
It can also be useful for mice with 4 or more buttons but no wheel.
See the description of the
.BR EmulateWheelButton ,
.BR EmulateWheelInertia ,
.BR EmulateWheelTimeout ,
.BR XAxisMapping ,
and
.B YAxisMapping
options. Default: off. Property "Evdev Wheel Emulation".
options.
Default: off.
Property: "Evdev Wheel Emulation".
.TP 7
.BI "Option \*qEmulateWheelButton\*q \*q" integer \*q
Specifies which button must be held down to enable wheel emulation mode.
@@ -105,102 +136,234 @@ press/release events as specified for the
.B XAxisMapping
and
.B YAxisMapping
settings. Default: 4. Property: "Evdev Wheel Emulation Button".
settings.
If the button is 0 and
.B EmulateWheel
is on, any motion of the device is converted into wheel events.
Default: 4.
Property: "Evdev Wheel Emulation Button".
.TP 7
.BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q
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".
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
.BR EmulateWheelButton
must be pressed before wheel emulation is started. If the
.BR EmulateWheelButton
is released before this timeout, the original button press/release event
is sent. Default: 200. Property: "Evdev Wheel Emulation Timeout".
.B EmulateWheelButton
must be pressed before wheel emulation is started.
If the
.B EmulateWheelButton
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
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
events to /dev/kbd or /dev/input/mice. Events from this device will not be
sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation).
events to /dev/kbd or /dev/input/mice.
Events from this device will not be sent to virtual devices
(e.g. rfkill or the Macintosh mouse button emulation).
Default: disabled.
.TP 7
.BI "Option \*qInvertX\*q \*q" Bool \*q
.TP 7
.BI "Option \*qInvertY\*q \*q" Bool \*q
Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
Invert the given axis.
Default: off.
Property: "Evdev Axis Inversion".
.TP 7
.BI "Option \*qReopenAttempts\*q \*q" integer \*q
Number of reopen attempts after a read error occurs on the device (e.g. after
waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
.BI "Option \*qIgnoreRelativeAxes\*q \*q" Bool \*q
.TP 7
.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q
Ignore the specified type of axis.
Default: unset.
The X server cannot deal with devices that have both relative and absolute axes.
Evdev tries to guess which axes to ignore given the device type and
disables absolute axes for mice and relative axes for tablets, touchscreens,
and touchpad.
These options allow to forcibly disable an axis type.
Mouse wheel axes are exempt and will work even if relative axes are ignored.
No property, this configuration must be set in the configuration.
.br
If either option is set to False, the driver will not ignore the specified
axes regardless of the presence of other axes.
This may trigger buggy behavior and events from this axis are always forwarded.
Users are discouraged from setting this option.
.TP 7
.BI "Option \*qCalibration\*q \*q" "min-x max-x min-y max-y" \*q
Calibrates the X and Y axes for devices that need to scale to a different
coordinate system than reported to the X server.
This feature is required for devices that need to scale to
a different coordinate system than originally reported by the kernel
(e.g. touchscreens).
The scaling to the custom coordinate system is done in-driver and
the X server is unaware of the transformation.
Property: "Evdev Axis Calibration".
.TP 7
.B Option \*qMode\*q \*qRelative\*q\fP|\fP\*qAbsolute\*q
Sets the mode of the device if device has absolute axes.
The default value for touchpads is relative, for other absolute.
This option has no effect on devices without absolute axes.
.TP 7
.BI "Option \*qSwapAxes\*q \*q" Bool \*q
Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
Swap x/y axes.
Default: off.
Property: "Evdev Axes Swap".
.TP 7
.BI "Option \*qXAxisMapping\*q \*q" "N1 N2" \*q
Specifies which buttons are mapped to motion in the X direction in wheel
emulation mode. Button number
emulation mode.
Button number
.I N1
is mapped to the negative X axis motion and button number
.I N2
is mapped to the positive X axis motion. Default: no mapping. Property:
"Evdev Wheel Emulation Axes".
is mapped to the positive X axis motion.
Default: no mapping.
Property: "Evdev Wheel Emulation Axes".
.TP 7
.BI "Option \*qYAxisMapping\*q \*q" "N1 N2" \*q
Specifies which buttons are mapped to motion in the Y direction in wheel
emulation mode. Button number
emulation mode.
Button number
.I N1
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".
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
.BR 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
.B evdev
driver.
.TP 7
.BI "Evdev Axis Calibration"
.B "Evdev Axis Calibration"
4 32-bit values, order min-x, max-x, min-y, max-y or 0 values to disable
run-time axis calibration. This feature is required for devices that need to
scale to a different coordinate system than originally reported to the X
server, such as touchscreens that require run-time calibration.
in-driver axis calibration.
.TP 7
.BI "Evdev Axis Inversion"
2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
.B "Evdev Axis Inversion"
2 boolean values (8 bit, 0 or 1), order X, Y.
1 inverts the axis.
.TP 7
.BI "Evdev Axes Swap"
1 boolean value (8 bit, 0 or 1). 1 swaps x/y axes.
.B "Evdev Axes Swap"
1 boolean value (8 bit, 0 or 1).
1 swaps x/y axes.
.TP 7
.BI "Evdev Drag Lock Buttons"
8-bit. Either 1 value or pairs of values. Value range 0-32, 0 disables a
value.
.B "Evdev Drag Lock Buttons"
8-bit. Either 1 value or pairs of values.
Value range 0-32, 0 disables a value.
.TP 7
.BI "Evdev Middle Button Emulation"
.B "Evdev Middle Button Emulation"
1 boolean value (8 bit, 0 or 1).
.TP 7
.BI "Evdev Middle Button Timeout"
.B "Evdev Middle Button Timeout"
1 16-bit positive value.
.TP 7
.BI "Evdev Wheel Emulation"
1 boolean value (8 bit, 0 or 1).
.TP 7
.BI "Evdev Wheel Emulation Axes"
4 8-bit values, order X up, X down, Y up, Y down. 0 disables a value.
.TP 7
.BI "Evdev Wheel Emulation Button"
.B "Evdev Middle Button Button"
1 8-bit value, allowed range 0-32, 0 disables the button.
.TP 7
.BI "Evdev Wheel Emulation Inertia"
.B "Evdev Wheel Emulation"
1 boolean value (8 bit, 0 or 1).
.TP 7
.B "Evdev Wheel Emulation Axes"
4 8-bit values, order X up, X down, Y up, Y down.
0 disables a value.
.TP 7
.B "Evdev Wheel Emulation Button"
1 8-bit value, allowed range 0-32, 0 disables the button.
.TP 7
.B "Evdev Wheel Emulation Inertia"
1 16-bit positive value.
.TP 7
.BI "Evdev Wheel Emulation Timeout"
.B "Evdev Wheel Emulation Timeout"
1 16-bit positive value.
.TP 7
.B "Evdev Scrolling Distance"
3 32-bit values: vertical, horizontal and dial.
.SH AUTHORS
Kristian Høgsberg.
Kristian Høgsberg, Peter Hutterer
.SH "SEE ALSO"
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__),
README.mouse.
.BR XLibre (__appmansuffix__),
.BR xorg.conf (__filemansuffix__),
.BR Xserver (__appmansuffix__),
.BR X (__miscmansuffix__)

View File

@@ -24,17 +24,20 @@
# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
# _ladir passes a dummy rpath to libtool so the thing will actually link
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = $(XORG_CFLAGS)
@DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
@DRIVER_NAME@_drv_ladir = @inputdir@
AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
AM_CPPFLAGS =-I$(top_srcdir)/include $(LIBEVDEV_CFLAGS)
INCLUDES=-I$(top_srcdir)/include/
evdev_drv_la_LTLIBRARIES = evdev_drv.la
evdev_drv_la_LDFLAGS = -module -avoid-version
evdev_drv_la_LIBADD = $(MTDEV_LIBS) $(UDEV_LIBS) $(LIBEVDEV_LIBS)
evdev_drv_ladir = @inputdir@
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \
@DRIVER_NAME@.h \
evdev_drv_la_SOURCES = evdev.c \
evdev.h \
emuMB.c \
emuThird.c \
emuWheel.c \
draglock.c
draglock.c \
apple.c \
axis_labels.h

311
src/apple.c Normal file
View File

@@ -0,0 +1,311 @@
/*
* 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)
*/
#include "config.h"
#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);
}

196
src/axis_labels.h Normal file
View File

@@ -0,0 +1,196 @@
/*
* 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.
*/
#include "config.h"
#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

@@ -5,7 +5,7 @@
* Copyright 1994-2002 by The XFree86 Project, Inc.
* Copyright 2002 by Paul Elliott
* (Ported from xf86-input-mouse, above copyrights taken from there)
* Copyright © 2008 University of South Australia
* Copyright © 2008 University of South Australia
* Copyright 2008 by Chris Salch
* Copyright 2008 Red Hat, Inc.
*
@@ -32,9 +32,8 @@
/* Draglock code */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "evdev.h"
#include <xf86.h>
#include <xf86Xinput.h>
@@ -42,11 +41,8 @@
#include <exevents.h>
#include <evdev-properties.h>
#include "evdev.h"
#ifdef HAVE_PROPERTIES
static Atom prop_dlock = 0; /* Drag lock buttons. */
#endif
void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button);
@@ -105,13 +101,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 +114,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;
@@ -145,20 +141,22 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
if (next_num != NULL && *next_num == '\0')
next_num = NULL;
}
free(option_string);
}
/* Updates DragLock button state and firest button event messges */
/* Updates DragLock button state and fires button event messges */
void
EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
BOOL state=0;
BOOL state = 0;
/* update button state */
state = pEvdev->dragLock.lock_state[button - 1] ? FALSE : TRUE;
pEvdev->dragLock.lock_state[button - 1] = state;
xf86PostButtonEvent(pInfo->dev, 0, button, state, 0, 0);
EvdevQueueButtonEvent(pInfo, button, state);
}
/* Filter button presses looking for either a meta button or the
@@ -209,7 +207,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.
@@ -256,7 +253,7 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
pEvdev->dragLock.meta = meta;
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
}
} else
} else if ((val->size % 2) == 0)
{
CARD8* vals = (CARD8*)val->data;
@@ -269,10 +266,11 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
pEvdev->dragLock.meta = 0;
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++)
pEvdev->dragLock.lock_pair[i] = vals[i];
for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i += 2)
pEvdev->dragLock.lock_pair[vals[i] - 1] = vals[i + 1];
}
}
} else
return BadMatch;
}
return Success;
@@ -316,5 +314,3 @@ EvdevDragLockInitProperty(DeviceIntPtr dev)
XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
}
#endif

View File

@@ -30,9 +30,8 @@
/* Middle mouse button emulation code. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
@@ -40,18 +39,10 @@
#include <exevents.h>
#include <evdev-properties.h>
#include "evdev.h"
enum {
MBEMU_DISABLED = 0,
MBEMU_ENABLED,
MBEMU_AUTO
};
#ifdef HAVE_PROPERTIES
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
static Atom prop_mbtimeout = 0; /* Middle button timeout property */
#endif
static Atom prop_mbbuton = 0; /* Middle button target button property */
/*
* Lets create a simple finite-state machine for 3 button emulation:
*
@@ -191,22 +182,34 @@ int
EvdevMBEmuTimer(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
int sigstate;
int id;
int mapped_id;
sigstate = xf86BlockSIGIO ();
#if HAVE_THREADED_INPUT
input_lock();
#else
int sigstate = xf86BlockSIGIO();
#endif
pEvdev->emulateMB.pending = FALSE;
if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
mapped_id = abs(id);
if (mapped_id == 2)
mapped_id = pEvdev->emulateMB.button;
EvdevPostButtonEvent(pInfo, mapped_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);
#if HAVE_THREADED_INPUT
input_unlock();
#else
xf86UnblockSIGIO(sigstate);
#endif
return 0;
}
@@ -225,17 +228,13 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
{
EvdevPtr pEvdev = pInfo->private;
int id;
int mapped_id;
int *btstate;
int ret = FALSE;
if (!pEvdev->emulateMB.enabled)
return ret;
if (button == 2) {
EvdevMBEmuEnable(pInfo, FALSE);
return ret;
}
/* don't care about other buttons */
if (button != 1 && button != 3)
return ret;
@@ -248,12 +247,15 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][0]) != 0)
{
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
mapped_id = abs(id);
if (mapped_id == 2)
mapped_id = pEvdev->emulateMB.button;
EvdevQueueButtonEvent(pInfo, mapped_id, (id >= 0));
ret = TRUE;
}
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0)
{
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
ret = TRUE;
}
@@ -272,9 +274,7 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
}
void EvdevMBEmuWakeupHandler(pointer data,
int i,
pointer LastSelectMask)
void EvdevMBEmuWakeupHandler(WAKEUP_HANDLER_ARGS)
{
InputInfoPtr pInfo = (InputInfoPtr)data;
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
@@ -288,9 +288,7 @@ void EvdevMBEmuWakeupHandler(pointer data,
}
}
void EvdevMBEmuBlockHandler(pointer data,
struct timeval **waitTime,
pointer LastSelectMask)
void EvdevMBEmuBlockHandler(BLOCK_HANDLER_ARGS)
{
InputInfoPtr pInfo = (InputInfoPtr) data;
EvdevPtr pEvdev= (EvdevPtr) pInfo->private;
@@ -309,19 +307,23 @@ void
EvdevMBEmuPreInit(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
pEvdev->emulateMB.enabled = MBEMU_AUTO;
if (xf86FindOption(pInfo->options, "Emulate3Buttons"))
{
pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
"Emulate3Buttons",
MBEMU_ENABLED);
xf86Msg(X_INFO, "%s: Forcing middle mouse button emulation %s.\n",
pInfo->name, (pEvdev->emulateMB.enabled) ? "on" : "off");
}
int bt;
pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
"Emulate3Buttons",
FALSE);
pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
"Emulate3Timeout", 50);
bt = xf86SetIntOption(pInfo->options, "Emulate3Button", 2);
if (bt < 0 || bt > EVDEV_MAXBUTTONS) {
xf86IDrvMsg(pInfo, X_WARNING, "Invalid Emulate3Button value: %d\n",
bt);
xf86IDrvMsg(pInfo, X_WARNING, "Middle button emulation disabled.\n");
pEvdev->emulateMB.enabled = FALSE;
}
pEvdev->emulateMB.button = bt;
}
void
@@ -347,23 +349,13 @@ EvdevMBEmuFinalize(InputInfoPtr pInfo)
}
/* Enable/disable middle mouse button emulation. */
void
EvdevMBEmuEnable(InputInfoPtr pInfo, BOOL enable)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
if (pEvdev->emulateMB.enabled == MBEMU_AUTO)
pEvdev->emulateMB.enabled = enable;
}
#ifdef HAVE_PROPERTIES
static int
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
int bt;
if (atom == prop_mbemu)
{
@@ -379,6 +371,18 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
if (!checkonly)
pEvdev->emulateMB.timeout = *((CARD32*)val->data);
} else if (atom == prop_mbbuton)
{
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
bt = *((CARD8*)val->data);
if (bt < 0 || bt > EVDEV_MAXBUTTONS)
return BadValue;
if (!checkonly)
pEvdev->emulateMB.button = bt;
}
return Success;
@@ -416,6 +420,15 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
return;
XISetDevicePropertyDeletable(dev, prop_mbtimeout, FALSE);
prop_mbbuton = MakeAtom(EVDEV_PROP_MIDBUTTON_BUTTON,
strlen(EVDEV_PROP_MIDBUTTON_BUTTON),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_mbbuton, XA_INTEGER, 8, PropModeReplace, 1,
&pEvdev->emulateMB.button, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_mbbuton, FALSE);
XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
}
#endif

420
src/emuThird.c Normal file
View File

@@ -0,0 +1,420 @@
/*
* 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.
*/
#include "config.h"
#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;
#if HAVE_THREADED_INPUT
input_lock();
#else
int sigstate = xf86BlockSIGIO();
#endif
emu3B->state = EM3B_EMULATING;
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_PRESS);
#if HAVE_THREADED_INPUT
input_unlock();
#else
xf86UnblockSIGIO(sigstate);
#endif
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

@@ -30,9 +30,8 @@
*/
/* Mouse wheel emulation code. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
@@ -40,21 +39,17 @@
#include <exevents.h>
#include <evdev-properties.h>
#include "evdev.h"
#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 void EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
/* Local Function Prototypes */
static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
/* Filter mouse button events */
BOOL
@@ -82,8 +77,7 @@ EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value)
* If the button is released early enough emit the button
* press/release events
*/
xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0);
xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0);
EvdevQueueButtonClicks(pInfo, button, 1);
}
}
@@ -101,25 +95,42 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
WheelAxisPtr pAxis = NULL;
int value = pEv->value;
int ms;
/* Has wheel emulation been configured to be enabled? */
if (!pEvdev->emulateWheel.enabled)
return FALSE;
/* Handle our motion events if the emuWheel button is pressed*/
if (pEvdev->emulateWheel.button_state) {
/* Handle our motion events if the emuWheel button is pressed
* wheel button of 0 means always emulate wheel.
*/
if (pEvdev->emulateWheel.button_state || !pEvdev->emulateWheel.button) {
/* Just return if the timeout hasn't expired yet */
ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
if (ms > 0)
return TRUE;
if (pEvdev->emulateWheel.button)
{
int ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
if (ms > 0)
return TRUE;
}
if(pEv->type == EV_ABS) {
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 */
}
/* We don't want to intercept real mouse wheel events */
switch(pEv->code) {
/* ABS_X has the same value as REL_X, so this case catches both */
case REL_X:
pAxis = &(pEvdev->emulateWheel.X);
break;
/* ABS_Y has the same value as REL_Y, so this case catches both */
case REL_Y:
pAxis = &(pEvdev->emulateWheel.Y);
break;
@@ -128,7 +139,9 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
break;
}
/* If we found REL_X or REL_Y, emulate a mouse wheel */
/* If we found REL_X, REL_Y, ABS_X or ABS_Y then emulate a mouse
wheel.
*/
if (pAxis)
EvdevWheelEmuInertia(pInfo, pAxis, value);
@@ -139,17 +152,20 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
return FALSE;
}
/* Simulate inertia for our emulated mouse wheel */
static void
/* Simulate inertia for our emulated mouse wheel.
Returns the number of wheel events generated.
*/
static int
EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
int button;
int inertia;
int rc = 0;
/* if this axis has not been configured, just eat the motion */
if (!axis->up_button)
return;
return rc;
axis->traveled_distance += value;
@@ -163,17 +179,18 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
/* Produce button press events for wheel motion */
while(abs(axis->traveled_distance) > pEvdev->emulateWheel.inertia) {
axis->traveled_distance -= inertia;
xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0);
xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0);
EvdevQueueButtonClicks(pInfo, button, 1);
rc++;
}
return rc;
}
/* 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;
@@ -191,9 +208,7 @@ EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_
((up_button > 0) && (up_button <= EVDEV_MAXBUTTONS)) &&
((down_button > 0) && (down_button <= EVDEV_MAXBUTTONS))) {
/* Use xstrdup to allocate a string for us */
msg = xstrdup("buttons XX and YY");
msg = strdup("buttons XX and YY");
if (msg)
sprintf(msg, "buttons %d and %d", up_button, down_button);
@@ -201,19 +216,19 @@ EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_
pAxis->down_button = down_button;
/* Update the number of buttons if needed */
if (up_button > pEvdev->buttons) pEvdev->buttons = up_button;
if (down_button > pEvdev->buttons) pEvdev->buttons = down_button;
if (up_button > pEvdev->num_buttons) pEvdev->num_buttons = up_button;
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);
xfree(msg);
xf86IDrvMsg(pInfo, X_CONFIG, "%s: %s\n", axis_name, msg);
free(msg);
return TRUE;
}
}
@@ -225,14 +240,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
@@ -241,9 +252,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;
}
@@ -253,10 +264,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;
}
@@ -266,10 +276,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;
}
@@ -285,13 +294,13 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
/* Simpler to check just the largest value in this case */
/* XXX: we should post this to the server */
if (5 > pEvdev->buttons)
pEvdev->buttons = 5;
if (5 > pEvdev->num_buttons)
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);
}
@@ -304,13 +313,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)
@@ -374,7 +383,7 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
inertia = *((CARD16*)val->data);
if (inertia < 0)
if (inertia <= 0)
return BadValue;
if (!checkonly)
@@ -460,4 +469,3 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev)
XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -25,19 +25,34 @@
* Kristian Høgsberg (krh@redhat.com)
* Adam Jackson (ajax@redhat.com)
* Peter Hutterer (peter@cs.unisa.edu.au)
* Oliver McFadden (oliver.mcfadden@nokia.com)
*/
#include "config.h"
#ifndef EVDEV_H
#define EVDEV_H
#include <linux/input.h>
#include <linux/types.h>
#include <sys/types.h>
/* Tolerate prior #include <linux/input.h> */
#undef BUS_NONE
#undef BUS_PCI
#undef BUS_SBUS
#undef BUS_PLATFORM
#undef BUS_USB
#include <xorg-server.h>
#include <xf86Xinput.h>
#include <xf86_OSproc.h>
#include <xkbstr.h>
#ifndef EV_CNT /* linux 2.4 kernels and earlier lack _CNT defines */
#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
#ifndef KEY_CNT
@@ -53,33 +68,73 @@
#define LED_CNT (LED_MAX+1)
#endif
#define EVDEV_MAXBUTTONS 32
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
#define HAVE_PROPERTIES 1
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18
#define LogMessageVerbSigSafe xf86MsgVerb
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 23
#define HAVE_THREADED_INPUT 1
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 24
#define BLOCK_HANDLER_ARGS void *data, void *waitTime
#define WAKEUP_HANDLER_ARGS void *data, int i
#else
#define BLOCK_HANDLER_ARGS pointer data, struct timeval **waitTime, pointer LastSelectMask
#define WAKEUP_HANDLER_ARGS void *data, int i, pointer LastSelectMask
#endif
#define EVDEV_MAXBUTTONS 32
#define EVDEV_MAXQUEUE 32
/* evdev flags */
#define EVDEV_KEYBOARD_EVENTS (1 << 0)
#define EVDEV_BUTTON_EVENTS (1 << 1)
#define EVDEV_RELATIVE_EVENTS (1 << 2)
#define EVDEV_ABSOLUTE_EVENTS (1 << 3)
#define EVDEV_TOUCHPAD (1 << 4)
#define EVDEV_INITIALIZED (1 << 5) /* WheelInit etc. called already? */
#define EVDEV_TOUCHSCREEN (1 << 6)
#define EVDEV_CALIBRATED (1 << 7) /* run-time calibrated? */
#define EVDEV_TABLET (1 << 8) /* device looks like a tablet? */
#define EVDEV_UNIGNORE_ABSOLUTE (1 << 9) /* explicitly unignore abs axes */
#define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */
#define EVDEV_RELATIVE_MODE (1 << 11) /* Force relative events for devices with absolute axes */
#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;
@@ -87,27 +142,56 @@ typedef struct {
int traveled_distance;
} WheelAxis, *WheelAxisPtr;
/* Event queue used to defer keyboard/button events until EV_SYN time. */
typedef struct {
const char *device;
enum {
EV_QUEUE_KEY, /* xf86PostKeyboardEvent() */
EV_QUEUE_BTN, /* xf86PostButtonEvent() */
EV_QUEUE_PROXIMITY, /* xf86PostProximityEvent() */
EV_QUEUE_TOUCH, /*xf86PostTouchEvent() */
} type;
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 {
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 tool;
int buttons; /* number of buttons */
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;
/* XKB stuff has to be per-device rather than per-driver */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
XkbComponentNamesRec xkbnames;
#endif
XkbRMLVOSet rmlvo;
unsigned int abs_queued, rel_queued, prox_queued;
/* Middle mouse button emulation */
struct {
@@ -117,7 +201,21 @@ typedef struct {
int state; /* state machine (see bt3emu.c) */
Time expires; /* time of expiry */
Time timeout;
uint8_t button; /* phys button to emit */
} 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 */
@@ -134,6 +232,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;
@@ -148,30 +251,47 @@ 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 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);
void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo);
unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);
/* Middle Button emulation */
int EvdevMBEmuTimer(InputInfoPtr);
BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL);
void EvdevMBEmuWakeupHandler(pointer, int, pointer);
void EvdevMBEmuBlockHandler(pointer, struct timeval**, pointer);
void EvdevMBEmuWakeupHandler(WAKEUP_HANDLER_ARGS);
void EvdevMBEmuBlockHandler(BLOCK_HANDLER_ARGS);
void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuOn(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr);
void EvdevMBEmuEnable(InputInfoPtr, BOOL);
/* 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);
@@ -182,9 +302,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

View File

@@ -1,39 +0,0 @@
# Copyright 2008 Red Hat, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# on the rights to use, copy, modify, merge, publish, distribute, sub
# license, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AM_CFLAGS = $(XORG_CFLAGS)
noinst_PROGRAMS=fakedev btn0 absrel abs dummy
fakedev_SOURCES=fakedev.c fakedev.h
fakedev_LDFLAGS=$(DLOPEN_LIBS) -rdynamic
LFLAGS=-shared -fPIC
btn0_SOURCES=btn0.c
btn0_LDFLAGS=$(LFLAGS)
absrel_SOURCES=absrel.c
absrel_LDFLAGS=$(LFLAGS)
abs_SOURCES=abs.c
abs_LDFLAGS=$(LFLAGS)
dummy_SOURCES=dummy.c
dummy_LDFLAGS=$(LFLAGS)

View File

@@ -1,84 +0,0 @@
/*
* Copyright © 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.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
/* creates a device with ABS_X, ABS_Y, BTN_LEFT, BTN_MIDDLE, BTN_RIGHT. */
#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include "fakedev.h"
int abs_setup(struct uinput_user_dev* dev, int fd)
{
if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
/* buttons */
if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT) == -1) goto error;
/* axes */
if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error;
if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
dev->absmin[ABS_X] = 0;
dev->absmax[ABS_X] = 120;
dev->absmin[ABS_Y] = 0;
dev->absmax[ABS_Y] = 120;
return 0;
error:
perror("ioctl failed.");
return -1;
}
int abs_run(int fd)
{
absmove(fd, 100, 100);
sleep(1);
absmove(fd, 120, 120);
sleep(1);
return 0;
}
struct test_device abs_dev = {
.name = "Abs test device",
.setup = abs_setup,
.run = abs_run,
};
struct test_device* get_device()
{
return &abs_dev;
}

View File

@@ -1,91 +0,0 @@
/*
* Copyright © 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.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
/* creates a device with ABS_X, ABS_Y, REL_X, REL_Y, BTN_LEFT, BTN_MIDDLE,
BTN_RIGHT. */
#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include "fakedev.h"
int absrel_setup(struct uinput_user_dev* dev, int fd)
{
if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
/* buttons */
if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT) == -1) goto error;
/* axes */
if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error;
if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
dev->absmin[ABS_X] = 0;
dev->absmax[ABS_X] = 1000;
dev->absmin[ABS_Y] = 0;
dev->absmax[ABS_Y] = 1000;
return 0;
error:
perror("ioctl failed.");
return -1;
}
int absrel_run(int fd)
{
absmove(fd, 100, 100);
sleep(1);
absmove(fd, 120, 120);
sleep(1);
move(fd, 10, 10);
return 0;
}
struct test_device absrel_dev = {
.name = "Abs/Rel test device",
.setup = absrel_setup,
.run = absrel_run,
};
struct test_device* get_device()
{
return &absrel_dev;
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright © 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.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
/* Creates a device that has REL_X REL_Y BTN_0 BTN_1 BTN_2
*
* Moves the device around in a 10px square and clicks after each completed
* circle.
*/
#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include "fakedev.h"
int btn0_setup(struct uinput_user_dev *dev, int fd)
{
if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
/* buttons */
if (ioctl(fd, UI_SET_KEYBIT, BTN_0) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_1) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_2) == -1) goto error;
/* axes */
if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
return 0;
error:
perror("ioctl failed.");
return -1;
}
int btn0_run(int fd)
{
move(fd, -10, 0);
usleep(1000);
move(fd, 0, -10);
usleep(1000);
move(fd, 10, 0);
usleep(1000);
move(fd, 0, 10);
usleep(1000);
click(fd, BTN_0, 1);
usleep(1000);
click(fd, BTN_0, 0);
return 0;
}
struct test_device btn0_dev = {
.name = "BTN_0 test device",
.setup = btn0_setup,
.run = btn0_run,
};
struct test_device* get_device()
{
return &btn0_dev;
}

View File

@@ -1,77 +0,0 @@
/*
* Copyright © 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.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
/* dummy device, looks like a mouse but doesn't do anything.
* Good for filling up the device list.
*
*/
#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include "fakedev.h"
int dummy_setup(struct uinput_user_dev *dev, int fd)
{
if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
/* buttons */
if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT) == -1) goto error;
/* axes */
if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
return 0;
error:
perror("ioctl failed.");
return -1;
}
int dummy_run(int fd)
{
usleep(1000);
return 0;
}
struct test_device dummy_dev = {
.name = "dummy_ test device",
.setup = dummy_setup,
.run = dummy_run,
};
struct test_device* get_device()
{
return &dummy_dev;
}

View File

@@ -1,199 +0,0 @@
/*
* Copyright © 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.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include <dlfcn.h>
#include "fakedev.h"
/* "public interfaces" */
void send_event(int fd, int type, int code, int value)
{
struct input_event event;
event.type = type;
event.code = code;
event.value = value;
gettimeofday(&event.time, NULL);
if (write(fd, &event, sizeof(event)) < sizeof(event))
perror("Send event failed.");
}
void move(int fd, int x, int y)
{
if (!x && !y)
return;
send_event(fd, EV_REL, REL_X, x);
send_event(fd, EV_REL, REL_Y, y);
send_event(fd, EV_SYN, SYN_REPORT, 0);
}
void absmove(int fd, int x, int y)
{
send_event(fd, EV_ABS, ABS_X, x);
send_event(fd, EV_ABS, ABS_Y, y);
send_event(fd, EV_SYN, SYN_REPORT, 0);
}
void click(int fd, int btn, int down)
{
send_event(fd, EV_KEY, btn, down);
send_event(fd, EV_SYN, SYN_REPORT, 0);
}
/* end public interfaces */
static int fd = -1;
static int stop = 0;
static void sighandler(int signum)
{
printf("Stopping.\n");
stop = 1;
}
static void init_signal(void)
{
struct sigaction action;
sigset_t mask;
sigfillset(&mask);
action.sa_handler = sighandler;
action.sa_mask = mask;
action.sa_flags = 0;
sigaction(SIGTERM, &action, NULL);
sigaction(SIGINT, &action, NULL);
sigprocmask(SIG_UNBLOCK, &mask, 0);
}
static int init_uinput(struct test_device* test_dev)
{
struct uinput_user_dev dev;
fd = open("/dev/input/uinput", O_RDWR);
if (fd < 0)
goto error;
memset(&dev, 0, sizeof(dev));
strcpy(dev.name, test_dev->name);
dev.id.bustype = 0;
dev.id.vendor = 0x1F;
dev.id.product = 0x1F;
dev.id.version = 0;
test_dev->setup(&dev, fd);
if (write(fd, &dev, sizeof(dev)) < sizeof(dev))
goto error;
if (ioctl(fd, UI_DEV_CREATE, NULL) == -1) goto error;
return 0;
error:
fprintf(stderr, "Error: %s\n", strerror(errno));
if (fd != -1)
close(fd);
return -1;
}
static void cleanup_uinput(void)
{
if (fd == -1)
return;
ioctl(fd, UI_DEV_DESTROY, NULL);
close(fd);
fd = -1;
}
int main (int argc, char **argv)
{
struct test_device *dev;
void *dlhandle = NULL;
struct test_device* (*get_device)(void);
if (argc <= 1)
{
fprintf(stderr, "Usage: %s test_dev\n", argv[0]);
return -1;
}
printf("Loading %s.\n", argv[1]);
dlhandle = dlopen(argv[1], RTLD_NOW | RTLD_GLOBAL);
if (!dlhandle)
{
fprintf(stderr, "Error: %s\n", dlerror());
return -1;
}
*(void**)(&get_device) = dlsym(dlhandle, "get_device");
if (!get_device)
{
fprintf(stderr, "Error getting the symbol: %s.\n", dlerror());
return -1;
}
dev = (*get_device)();
if (init_uinput(dev) < 0) {
fprintf(stderr, "Failed to initialize /dev/uinput. Exiting.\n");
return -1;
}
init_signal();
printf("Device created. Press CTRL+C to terminate.\n");
while (!stop) {
if (dev->run(fd))
break;
}
cleanup_uinput();
return 0;
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright © 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.
*
* Authors:
* Peter Hutterer (peter.hutterer@redhat.com)
*/
#ifndef _EVDEV_TEST_H
#define _EVDEV_TEST_H
#include <linux/uinput.h>
struct test_device {
char *name; /* device name */
/**
* Called to setup the device. Call ioctls to set your EVBITs, KEYBITs,
* etc. here. Return 0 on success or non-zero to exit.
*/
int (*setup)(struct uinput_user_dev* dev, int fd);
/**
* Called during each run of the main loop. Generate events by calling
* move(), click(), etc.
* Return 0 on success, or non-zero to stop the main loop.
*/
int (*run)(int fd);
};
extern void move (int fd, int x, int y);
extern void absmove (int fd, int x, int y);
extern void click (int fd, int btn, int down);
#endif

View File

@@ -1,6 +0,0 @@
sdkdir=@sdkdir@
Name: xorg-evdev
Description: X.Org evdev input driver.
Version: @PACKAGE_VERSION@
Cflags: -I${sdkdir}