mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
231 Commits
xf86-video
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f48abf89e4 | ||
|
|
87819fe86b | ||
|
|
ffa1fbc770 | ||
|
|
40bb3c69ce | ||
|
|
675218cbf5 | ||
|
|
ad834abd57 | ||
|
|
3549c3e5f0 | ||
|
|
5def56d2f4 | ||
|
|
b907c23d00 | ||
|
|
6c975917f8 | ||
|
|
ac421e536c | ||
|
|
bd55c2f021 | ||
|
|
11d506dce6 | ||
|
|
a34a2cd347 | ||
|
|
78c00bd77f | ||
|
|
760f1c6bb1 | ||
|
|
2db04ba3c3 | ||
|
|
363d0bdb9f | ||
|
|
16a26a1eca | ||
|
|
b879ae7351 | ||
|
|
53566b7d4d | ||
|
|
29c2765fc3 | ||
|
|
7ef4e2c5e1 | ||
|
|
dd0eeacc24 | ||
|
|
67c0ea6c94 | ||
|
|
6bcbbc0411 | ||
|
|
534a3734d0 | ||
|
|
215c230d5c | ||
|
|
8f96530449 | ||
|
|
4fb97edcd4 | ||
|
|
4e86393bc0 | ||
|
|
a64a78791f | ||
|
|
09b2a5e87b | ||
|
|
fa18a4a38d | ||
|
|
172523d745 | ||
|
|
8fb820ffaf | ||
|
|
c7893b212d | ||
|
|
e9dd721e2d | ||
|
|
cab104fd9e | ||
|
|
708eb34599 | ||
|
|
36a687796f | ||
|
|
26229df106 | ||
|
|
f4616d87fc | ||
|
|
2aa5ca8cdd | ||
|
|
39263dc65d | ||
|
|
57521e4e60 | ||
|
|
7da1522309 | ||
|
|
b4fcb825fc | ||
|
|
7c955ad050 | ||
|
|
4f80c0f2cb | ||
|
|
5070d64aa8 | ||
|
|
caacacf057 | ||
|
|
9065d0ccb2 | ||
|
|
a9fcce1833 | ||
|
|
ab934d840d | ||
|
|
6f6ac98295 | ||
|
|
a2633c8078 | ||
|
|
e6c699dedc | ||
|
|
847eac8262 | ||
|
|
a196672a6b | ||
|
|
3985d42320 | ||
|
|
e138e4b79a | ||
|
|
125e2b8ce2 | ||
|
|
91bc0a0ba3 | ||
|
|
4c55186aed | ||
|
|
62069b97d2 | ||
|
|
2718a5c56b | ||
|
|
90d1d494f8 | ||
|
|
a77c2622cc | ||
|
|
84a0e39c0d | ||
|
|
7386937221 | ||
|
|
fcf8375f2b | ||
|
|
9930477cbe | ||
|
|
4509ec1daf | ||
|
|
a205dfc091 | ||
|
|
184206e717 | ||
|
|
79ff677c52 | ||
|
|
37e3addf89 | ||
|
|
e237de0dea | ||
|
|
92c6611b6f | ||
|
|
bd405ddc83 | ||
|
|
36d702006d | ||
|
|
6dc4199155 | ||
|
|
e8534d47c8 | ||
|
|
555f5a7cbf | ||
|
|
134829d911 | ||
|
|
4e121b297e | ||
|
|
9793de8137 | ||
|
|
a9d72b40fb | ||
|
|
c1f7f8c3d2 | ||
|
|
40e1474d84 | ||
|
|
d9097df01b | ||
|
|
5c074af5a9 | ||
|
|
72551662a0 | ||
|
|
53e7525744 | ||
|
|
5d13259a5d | ||
|
|
2b7edaa4ab | ||
|
|
bf0d81011e | ||
|
|
ef4bb69c1a | ||
|
|
d1818ef206 | ||
|
|
a9223edcd8 | ||
|
|
ec23c6b2f5 | ||
|
|
18d70d796f | ||
|
|
37b854cb64 | ||
|
|
8c06093191 | ||
|
|
0830676a0c | ||
|
|
1cf7b8f7ee | ||
|
|
826e6e7dd4 | ||
|
|
5a0ea39b79 | ||
|
|
373e13ae35 | ||
|
|
76800bfa75 | ||
|
|
04003a98a9 | ||
|
|
0443fb430f | ||
|
|
998f52010f | ||
|
|
de07c04f5c | ||
|
|
01355b9d4b | ||
|
|
9591dc1f6c | ||
|
|
08ba40b253 | ||
|
|
39dc453691 | ||
|
|
e8887435ac | ||
|
|
b0f6987ee6 | ||
|
|
fec73e1418 | ||
|
|
da112737eb | ||
|
|
d40125ea8c | ||
|
|
42422d8f69 | ||
|
|
15e0091f0b | ||
|
|
d45f315845 | ||
|
|
a4a7003f7c | ||
|
|
3e0dc9945d | ||
|
|
ff6251a2bd | ||
|
|
e9222a8285 | ||
|
|
8b7738457f | ||
|
|
1b9deb8e7e | ||
|
|
0ec391f51c | ||
|
|
f77410e1f9 | ||
|
|
d28c2e1efb | ||
|
|
697e850a63 | ||
|
|
87037b9953 | ||
|
|
71f4eaec77 | ||
|
|
7208397612 | ||
|
|
c250f84383 | ||
|
|
2b334d6b69 | ||
|
|
9773dac623 | ||
|
|
1a0bc8e64a | ||
|
|
6271494faa | ||
|
|
f5bfc7ec3c | ||
|
|
bf0848ec8e | ||
|
|
f1445feac7 | ||
|
|
ad5bdcb50f | ||
|
|
bb36ca65c6 | ||
|
|
40a1e1439c | ||
|
|
946beb16f8 | ||
|
|
305f90d37a | ||
|
|
11cf9c92c0 | ||
|
|
7f1e8146d4 | ||
|
|
8ae4d17ca3 | ||
|
|
134ce2e493 | ||
|
|
10e7c3fbdf | ||
|
|
f766404fd9 | ||
|
|
d032d3c8b4 | ||
|
|
5adbc6b98c | ||
|
|
eeb3727004 | ||
|
|
fa15e90993 | ||
|
|
12a27693b9 | ||
|
|
1c40c7db18 | ||
|
|
e2be2ffa47 | ||
|
|
e86aab93c5 | ||
|
|
c69f4bd570 | ||
|
|
64677ecc76 | ||
|
|
08a09682f5 | ||
|
|
9c9a47210a | ||
|
|
2d2c4804f9 | ||
|
|
6b97bf7a4e | ||
|
|
5c6b3dd86f | ||
|
|
f15636ac52 | ||
|
|
276685fa1d | ||
|
|
27a86f8168 | ||
|
|
26dbf38041 | ||
|
|
294355842b | ||
|
|
9eb546e0e0 | ||
|
|
daf926081d | ||
|
|
c22c955c48 | ||
|
|
f87c44b90c | ||
|
|
23309b334c | ||
|
|
1716ec88bb | ||
|
|
246812bfbc | ||
|
|
a0ea7363f5 | ||
|
|
3c4a96fbd8 | ||
|
|
ba65c34068 | ||
|
|
9644a4afbf | ||
|
|
d37ba205bb | ||
|
|
9875e2f7f9 | ||
|
|
6db4a9fb84 | ||
|
|
a9e87f29cc | ||
|
|
b4a5a20476 | ||
|
|
24f9e67a8f | ||
|
|
d8d8f114ca | ||
|
|
ebb30a554f | ||
|
|
3d8bb262e4 | ||
|
|
987c6b1597 | ||
|
|
8155e49e76 | ||
|
|
e1fe72e7fe | ||
|
|
9f3be57929 | ||
|
|
5a5457e69c | ||
|
|
3fc70342aa | ||
|
|
1a8cea3dc4 | ||
|
|
ef01c2ef65 | ||
|
|
036b457c1b | ||
|
|
79eb7dcac8 | ||
|
|
d7f686bfa3 | ||
|
|
ec09e0d55d | ||
|
|
4c72fb7b76 | ||
|
|
77cbbc20b6 | ||
|
|
5c5ef3fbd6 | ||
|
|
a96b048e56 | ||
|
|
d8ea40dc4a | ||
|
|
ab65184d47 | ||
|
|
63f7edf786 | ||
|
|
771eee9682 | ||
|
|
e468150448 | ||
|
|
fa03de438e | ||
|
|
7b91f9277a | ||
|
|
7defeb0aef | ||
|
|
1cb568c0a6 | ||
|
|
dc88668839 | ||
|
|
090d43acf3 | ||
|
|
1b9a9599a4 | ||
|
|
f7a9c74fbc | ||
|
|
9cb7c3dbad | ||
|
|
eba5ea8d5a | ||
|
|
51d21a3694 |
27
.gitignore
vendored
Normal file
27
.gitignore
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
*.patch
|
||||
ChangeLog
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
man/evdev.4
|
||||
missing
|
||||
.deps
|
||||
.libs
|
||||
*.lo
|
||||
*.la
|
||||
stamp-h1
|
||||
*.bz2
|
||||
*.gz
|
||||
*.pc
|
||||
99
COPYING
99
COPYING
@@ -1,12 +1,95 @@
|
||||
This is a stub file. This package has not yet had its complete licensing
|
||||
information compiled. Please see the individual source files for details on
|
||||
your rights to use and modify this software.
|
||||
Various copyright notices found in this driver:
|
||||
|
||||
Please submit updated COPYING files to the Xorg bugzilla:
|
||||
Copyright © 2004-2008 Red Hat, Inc.
|
||||
|
||||
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
|
||||
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.
|
||||
|
||||
All licensing questions regarding this software should be directed at the
|
||||
Xorg mailing list:
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Copyright 2005 Adam Jackson.
|
||||
|
||||
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
|
||||
ADAM JACKSON 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.
|
||||
|
||||
http://lists.freedesktop.org/mailman/listinfo/xorg
|
||||
|
||||
368
ChangeLog
368
ChangeLog
@@ -1,368 +0,0 @@
|
||||
2006-06-22 Adam Jackson <ajax@freedesktop.org>
|
||||
|
||||
* src/inotify-syscalls.h:
|
||||
MIPS support. (Joshua Kinard)
|
||||
|
||||
2006-06-02 Adam Jackson <ajax@freedesktop.org>
|
||||
|
||||
* src/evdev_axes.c:
|
||||
Fix an obvious bogon to avoid crashing on absolute axis setup.
|
||||
|
||||
2006-05-15 Zephaniah E. Hull,,, <warp@aehallh.com>
|
||||
|
||||
* src/evdev.h:
|
||||
Hopefully fix the bitops stuff to actually _work_.
|
||||
|
||||
2006-05-14 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* man/evdev.man:
|
||||
Tweak credits and references.
|
||||
* src/evdev.c: (EvdevParseBits), (EvdevParseBitOption),
|
||||
(EvdevCorePreInit):
|
||||
Change the longs to unsigned longs in the bitfields.
|
||||
|
||||
Cleanup our includes.
|
||||
* src/evdev.h:
|
||||
Stop pulling in asm/types.h and asm/bitops.h.
|
||||
|
||||
Conditionally define the stuff that used to come from
|
||||
the above, including our own test_bit, set_bit and clear_bit.
|
||||
|
||||
Change the longs to unsigned longs in the bitfields.
|
||||
* src/evdev_axes.c: (EvdevAxisAbsNew), (EvdevAxisRelNew):
|
||||
Change the longs to unsigned longs in the bitfields.
|
||||
|
||||
Use the bitop defines in evdev.h properly.
|
||||
* src/evdev_brain.c: (MatchAll), (MatchNot), (MatchAny):
|
||||
Change the longs to unsigned longs in the bitfields.
|
||||
* src/evdev_btn.c: (EvdevBtnNew):
|
||||
Change the longs to unsigned longs in the bitfields.
|
||||
|
||||
Use the bitop defines in evdev.h properly.
|
||||
* src/evdev_key.c: (EvdevKeyNew):
|
||||
Change the longs to unsigned longs in the bitfields.
|
||||
|
||||
Use the bitop defines in evdev.h properly.
|
||||
* src/inotify-syscalls.h:
|
||||
Add HPPA/HPPA64 entries. (Thanks to Fabio M. Di Nitto
|
||||
<fabbione@ubuntu.com>)
|
||||
|
||||
2006-04-30 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* configure.ac:
|
||||
xf86-input-evdev v1.1.2
|
||||
* src/evdev_brain.c: (evdevControl):
|
||||
Bugzilla #6734 <https://bugs.freedesktop.org/show_bug.cgi=6734>
|
||||
Apply patch from Philip Langdale which causes us to make sure that
|
||||
O_NONBLOCK is set on the inotify device.
|
||||
|
||||
2006-04-15 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* configure.ac:
|
||||
* src/Makefile.am:
|
||||
xf86-input-evdev v1.1.1
|
||||
|
||||
2006-04-14 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev.h:
|
||||
evdevAbsRec: Remove the scale bool, rename scale_x and scale_y
|
||||
to scale[2].
|
||||
evdevAxesRec: Make btnMap an int array instead of a Card8 array.
|
||||
* src/evdev_axes.c: (EvdevAxesAbsSyn), (EvdevAxesAbsProcess),
|
||||
(EvdevAxisAbsNew), (EvdevAxesInit):
|
||||
Make abs support and non-core stuff actually work.
|
||||
|
||||
Relative emulation for abs mode is still a bit broken, but that's far
|
||||
less critical.
|
||||
|
||||
* src/evdev_btn.c: (EvdevBtnInit):
|
||||
How many buttons we've registered is configuration information, not an
|
||||
error message.
|
||||
|
||||
2006-04-08 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev.c: (EvdevCorePreInit):
|
||||
Remove a debugging message.
|
||||
* src/evdev_axes.c: (EvdevAxesNew), (EvdevAxesInit):
|
||||
Actually, well, _work_.
|
||||
Note, abs support still segfaults, I'll debug it after I've slept.
|
||||
But I should get it tomorrow.
|
||||
|
||||
2006-04-08 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* configure.ac:
|
||||
Dropped the xorg-xserver 1.0.99.901 requirement.
|
||||
(Things were tweaked to mostly work for older servers again.)
|
||||
* src/evdev.c: (EvdevReadInput):
|
||||
Close the device properly on read errer.
|
||||
* src/evdev_brain.c: (evdevReadInput), (evdevControl):
|
||||
Minimal inotify support, not ideal yet, but...
|
||||
* src/inotify-syscalls.h:
|
||||
Minimal inotify support, not ideal yet, but...
|
||||
* src/inotify.h:
|
||||
Minimal inotify support, not ideal yet, but...
|
||||
|
||||
2006-04-08 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/Makefile.am:
|
||||
Remove evdev_abs.c and evdev_rel.c.
|
||||
Added evdev_axes.c.
|
||||
* src/evdev.c: (EvdevReadInput), (EvdevProc), (EvdevNew),
|
||||
(EvdevPtrCtrlProc):
|
||||
Change the calls to refer to EvdevAxes instead of Abs and Rel.
|
||||
Include mipointer.h. (Fixes a compile error.)
|
||||
Remove an unused variable from EvdevReadInput.
|
||||
* src/evdev.h:
|
||||
Removed evdev_abs.c and evdev_rel.c, added evdev_axes.c.
|
||||
Added count to rel and abs.
|
||||
Moved btnMap from rel to the new axes.
|
||||
Shuffle some includes, and include stdarg.h.
|
||||
* src/evdev_abs.c:
|
||||
Removed.
|
||||
* src/evdev_axes.c: (EvdevConvert), (EvdevAxesRealSyn),
|
||||
(EvdevAxesAbsSyn), (EvdevAxesRelSyn), (EvdevAxesSyn),
|
||||
(EvdevAxesAbsProcess), (EvdevAxesRelProcess), (EvdevAxesOn),
|
||||
(EvdevAxesOff), (EvdevAxisAbsNew), (EvdevAxisRelNew),
|
||||
(EvdevAxesNew), (EvdevPtrCtrlProc), (EvdevAxesInit):
|
||||
New, a mix of rel and abs that should actually work in the
|
||||
rel case.
|
||||
* src/evdev_btn.c: (EvdevBtnCalcRemap):
|
||||
Rearrange include order.
|
||||
btnMap was moved from being part of rel to being part of axes.
|
||||
* src/evdev_rel.c:
|
||||
Removed.
|
||||
* src/evdev_brain.c:
|
||||
Rearrange include order.
|
||||
* src/evdev_key.c:
|
||||
Rearrange include order.
|
||||
|
||||
NOTE: This commit has been compile tested, not run tested.
|
||||
|
||||
I have some other changes to make before I can do more heavy testing.
|
||||
|
||||
2006-04-06 Adam Jackson <ajax@freedesktop.org>
|
||||
|
||||
* configure.ac:
|
||||
* src/evdev.c:
|
||||
* src/evdev.h:
|
||||
* src/evdev_abs.c:
|
||||
* src/evdev_btn.c:
|
||||
* src/evdev_key.c:
|
||||
* src/evdev_rel.c:
|
||||
Unlibcwrap. Bump server version requirement. Bump to 1.1.0.
|
||||
|
||||
2006-03-31 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev_brain.c: (FillDevInfo), (evdevRescanDevices):
|
||||
Fix the fd pointer leak reported by primer. (Not the same patch.)
|
||||
* src/evdev_key.c: (EvdevKeyNew):
|
||||
Disable the undocumented xkb guts options in the key driver.
|
||||
(Requested by Daniel Stone.)
|
||||
|
||||
2006-03-16 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev_brain.c: (MatchDriver):
|
||||
Switch from my own globbing function to fnmatch.
|
||||
|
||||
* src/evdev_key.c: (EvdevKeyNew):
|
||||
Detect keys numbered higher then buttons.
|
||||
Remove the (depreciated since long before xkb support was added to
|
||||
evdev) XkbKeymap option.
|
||||
|
||||
2006-03-16 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* man/evdev.man:
|
||||
Update to include all the new device matching options.
|
||||
|
||||
2006-02-27 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev_key.c: (EvdevKeyOff):
|
||||
Don't leave keys in the down state when we get turned off.
|
||||
(VT switching, getting unplugged, that sort of stuff.)
|
||||
|
||||
2006-02-27 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev.c: (EvdevReadInput):
|
||||
Better error reporting if the read fails.
|
||||
|
||||
* src/evdev_brain.c: (evdevNewDriver):
|
||||
Work properly if we're defining entirely by capability maps.
|
||||
|
||||
2006-02-24 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/Makefile.am:
|
||||
Compile with -Wall now.
|
||||
Add evdev.h to the sources so that make distcheck gets it.
|
||||
|
||||
* src/evdev.h:
|
||||
Bugzilla #5943 <https://bugs.freedesktop.org/show_bug.cgi=5943>
|
||||
Make sure we include errno.h.
|
||||
|
||||
Reduce EVDEV_MAXBUTTONS to 96.
|
||||
|
||||
Split up evdevStateRec into a struct with pointers to new structs
|
||||
for btn, abs, rel, and key.
|
||||
|
||||
New structure type for handling the device capability bitmaps.
|
||||
|
||||
Add device bits and struct input_id to evdevDeviceRec.
|
||||
|
||||
Add matching device bits, struct input_id, and pass number to
|
||||
evdevDriverRec.
|
||||
|
||||
Prototype for evdevGetBits from evdev_brain.c.
|
||||
|
||||
* src/evdev.c: (EvdevProc), (EvdevSwitchMode), (EvdevNew),
|
||||
(EvdevParseBits), (EvdevParseBitOption), (EvdevCorePreInit):
|
||||
Conversion for the evdevStateRec split.
|
||||
|
||||
Remove the errno.h include, it's in evdev.h for now.
|
||||
|
||||
Move the bit getting from the drivers to here, into evdevDeviceRec.
|
||||
|
||||
Fix a rare case of fd leakage.
|
||||
|
||||
Add several new (and somewhat ugly) device matching options:
|
||||
<map>Bits: Where map is one of ev, key, rel, abs, msc, led, snd, or
|
||||
ff.
|
||||
In the format of '+0 +3 -1-2 ~5-10', requires bits 0 and 3 be set,
|
||||
bits 1 and 2 to not be set, and at least one bit in the range of 5 to
|
||||
10 be set.
|
||||
bustype, vendor, product, and version: Simple integer options for
|
||||
matching the struct device_id fields, must be 0 (the default) or the
|
||||
exact value you wish to match against.
|
||||
pass: Bounded to 0-3, devices are matched to the first matching entry
|
||||
found, order for multiple matching entries in the same pass is
|
||||
undefined, but it starts with pass 0 and goes to pass 3.
|
||||
|
||||
* src/evdev_abs.c: (EvdevAbsSyn), (EvdevAbsProcess),
|
||||
(EvdevAbsInit), (EvdevAbsNew):
|
||||
Adaptation for the evdevStateRec split and the change in capability
|
||||
bitmap handling.
|
||||
|
||||
* src/evdev_brain.c: (MatchAll), (MatchNot), (MatchAny),
|
||||
(MatchDriver), (MatchDevice), (evdevScanDevice), (FillDevInfo),
|
||||
(evdevRescanDevices), (evdevGetBits):
|
||||
Add evdevGetBits to fill the new evdevBitsRec struct type.
|
||||
|
||||
Lots of somewhat ugly code for matching by capability bits.
|
||||
|
||||
Split out of evdevRescanDevices to smaller handling functions.
|
||||
The new design should be better if I decide to handle arbitrary Device
|
||||
fields again.
|
||||
|
||||
* src/evdev_btn.c: (EvdevBtnInit), (EvdevBtnOn),
|
||||
(EvdevBtnCalcRemap), (EvdevBtnNew), (EvdevBtnProcess):
|
||||
Adaptation for the evdevStateRec split and the change in capability
|
||||
bitmap handling.
|
||||
|
||||
Handle all buttons, no button compression at this time, however we
|
||||
reorder things so that BTN_MOUSE comes before BTN_MISC, somewhat
|
||||
evily.
|
||||
|
||||
Support for the new btn->state[] array of int pointers.
|
||||
|
||||
* src/evdev_key.c: (EvdevKeyInit), (SetXkbOption), (EvdevKeyNew):
|
||||
Adaptation for the evdevStateRec split and the change in capability
|
||||
bitmap handling.
|
||||
|
||||
* src/evdev_rel.c: (EvdevRelSyn), (EvdevRelProcess),
|
||||
(EvdevRelInit), (EvdevRelNew):
|
||||
Adaptation for the evdevStateRec split and the change in capability
|
||||
bitmap handling.
|
||||
|
||||
2006-02-20 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev_btn.c: (EvdevBtnInit):
|
||||
Bugzilla #5950 <https://bugs.freedesktop.org/show_bug.cgi=5950>
|
||||
Possible (maybe) fix for bug #5950.
|
||||
Though, I'm not convinced and still don't see how this bug could
|
||||
be happening, especially if this doesn't do it.
|
||||
|
||||
2006-02-19 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev_key.c: (EvdevKbdBell):
|
||||
Add bell support.
|
||||
|
||||
2006-02-16 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* src/evdev_btn.c: (EvdevBtnCalcRemap):
|
||||
Bugzilla #5914 <https://bugs.freedesktop.org/show_bug.cgi?id=5914>
|
||||
Stupid little bug, properly handle wheels on 3 button mice.
|
||||
|
||||
2006-02-14 Zephaniah E. Hull <warp@aehallh.com>
|
||||
|
||||
* configure.ac:
|
||||
* man/evdev.man:
|
||||
* src/Makefile.am:
|
||||
* src/evdev.c: (EvdevReadInput), (EvdevSigioReadInput),
|
||||
(EvdevProc), (EvdevSwitchMode), (EvdevNew), (EvdevCorePreInit):
|
||||
* src/evdev.h:
|
||||
* src/evdev_abs.c: (EvdevPtrCtrlProc), (EvdevConvert),
|
||||
(EvdevAbsSyn), (EvdevAbsProcess), (EvdevAbsInit), (EvdevAbsOn),
|
||||
(EvdevAbsOff), (EvdevAbsNew):
|
||||
* src/evdev_brain.c: (glob_match), (evdevGetFDForDevice),
|
||||
(evdevRescanDevices), (evdevReadInput), (evdevControl),
|
||||
(evdevStart), (evdevNewDriver):
|
||||
* src/evdev_btn.c: (EvdevBtnPostFakeClicks), (EvdevBtnInit),
|
||||
(EvdevBtnOn), (EvdevBtnOff), (EvdevBtnCalcRemap), (EvdevBtnNew),
|
||||
(EvdevBtnProcess):
|
||||
* src/evdev_key.c: (EvdevKbdBell), (EvdevKbdCtrl), (EvdevKeyInit),
|
||||
(SetXkbOption), (EvdevKeyNew), (EvdevKeyOn), (EvdevKeyOff),
|
||||
(EvdevKeyProcess):
|
||||
* src/evdev_rel.c: (EvdevPtrCtrlProc), (EvdevConvert),
|
||||
(EvdevRelSyn), (EvdevRelProcess), (EvdevRelInit), (EvdevRelOn),
|
||||
(EvdevRelOff), (EvdevRelNew):
|
||||
Bugzilla #5696 <https://bugs.freedesktop.org/show_bug.cgi?id=5696>
|
||||
Slightly updated version of the patch listed.
|
||||
Basicly a rewrite of the driver, with a few pieces of the old.
|
||||
XKB support, proper device matching, basic absolute pointer support.
|
||||
Lots more, will require some user config changes.
|
||||
|
||||
2006-01-09 David Nusinow,,, <set EMAIL_ADDRESS environment variable>
|
||||
|
||||
* man/Makefile.am:
|
||||
* man/evdev.man:
|
||||
Bugzilla #968 <https://bugs.freedesktop.org/show_bug.cgi?id=968>
|
||||
Patch #4301 <https://bugs.freedesktop.org/attachment.cgi?id=4301>
|
||||
Add evdev manpage
|
||||
|
||||
2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* configure.ac:
|
||||
Update package version for X11R7 release.
|
||||
|
||||
2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* configure.ac:
|
||||
Update package version number for final X11R7 release candidate.
|
||||
|
||||
2005-12-06 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* man/Makefile.am:
|
||||
Change *man_SOURCES ==> *man_PRE to fix autotools warnings.
|
||||
|
||||
2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* configure.ac:
|
||||
Update package version number for X11R7 RC3 release.
|
||||
|
||||
2005-12-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* configure.ac:
|
||||
Remove extraneous AC_MSG_RESULT.
|
||||
|
||||
2005-11-29 Adam Jackson <ajax@freedesktop.org>
|
||||
|
||||
* configure.ac:
|
||||
Only build dlloader modules by default.
|
||||
|
||||
2005-11-09 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* configure.ac:
|
||||
Update package version number for X11R7 RC2 release.
|
||||
|
||||
2005-11-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
|
||||
|
||||
* configure.ac:
|
||||
Update pkgcheck dependencies to work with separate build roots.
|
||||
17
Makefile.am
17
Makefile.am
@@ -19,4 +19,19 @@
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
SUBDIRS = src man
|
||||
SUBDIRS = src man include
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = xorg-evdev.pc
|
||||
|
||||
EXTRA_DIST = ChangeLog autogen.sh
|
||||
|
||||
MAINTAINERCLEANFILES=ChangeLog
|
||||
|
||||
.PHONY: ChangeLog
|
||||
|
||||
ChangeLog:
|
||||
(GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || \
|
||||
(touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
|
||||
|
||||
dist-hook: ChangeLog
|
||||
|
||||
20
README
Normal file
20
README
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
29
configure.ac
29
configure.ac
@@ -22,7 +22,7 @@
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([xf86-input-evdev],
|
||||
1.1.2,
|
||||
2.1.3,
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||
xf86-input-evdev)
|
||||
|
||||
@@ -44,24 +44,6 @@ AC_PROG_CC
|
||||
|
||||
AH_TOP([#include "xorg-server.h"])
|
||||
|
||||
#AC_DEFINE(XFree86LOADER,1,[Stub define for loadable drivers])
|
||||
#
|
||||
#AC_ARG_ENABLE(XINPUT, AS_HELP_STRING([--enable-xinput],
|
||||
# [Build XInput support (default: yes)]),
|
||||
# [XINPUT=$enableval],[XINPUT=yes])
|
||||
#AM_CONDITIONAL(XINPUT, test "x$XINPUT" = "xyes")
|
||||
#if test "x$XINPUT" = "xyes" ; then
|
||||
# AC_DEFINE(XINPUT,1,[Enable XInput support])
|
||||
#fi
|
||||
#
|
||||
#AC_ARG_ENABLE(XKB, AS_HELP_STRING([--enable-xkb],
|
||||
# [Build XKB support (default: yes)]),
|
||||
# [XKB=$enableval],[XKB=yes])
|
||||
#AM_CONDITIONAL(XKB, test "x$XKB" = "xyes")
|
||||
#if test "x$XKB" = "xyes" ; then
|
||||
# AC_DEFINE(XKB,1,[Enable XKB support])
|
||||
#fi
|
||||
|
||||
AC_ARG_WITH(xorg-module-dir,
|
||||
AC_HELP_STRING([--with-xorg-module-dir=DIR],
|
||||
[Default xorg module directory [[default=$libdir/xorg/modules]]]),
|
||||
@@ -71,13 +53,12 @@ inputdir=${moduledir}/input
|
||||
AC_SUBST(inputdir)
|
||||
|
||||
# Checks for extensions
|
||||
#XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
|
||||
XORG_DRIVER_CHECK_EXT(XKB, kbproto)
|
||||
XORG_DRIVER_CHECK_EXT(XINPUT, inputproto)
|
||||
|
||||
# Checks for pkg-config packages
|
||||
PKG_CHECK_MODULES(XORG, xorg-server xproto $REQUIRED_MODULES)
|
||||
sdkdir=$(pkg-config --variable=sdkdir xorg-server)
|
||||
AC_SUBST(sdkdir)
|
||||
|
||||
CFLAGS="$CFLAGS $XORG_CFLAGS "' -I$(top_srcdir)/src'
|
||||
AC_SUBST([CFLAGS])
|
||||
@@ -90,4 +71,8 @@ AC_HEADER_STDC
|
||||
XORG_MANPAGE_SECTIONS
|
||||
XORG_RELEASE_VERSION
|
||||
|
||||
AC_OUTPUT([Makefile src/Makefile man/Makefile])
|
||||
AC_OUTPUT([Makefile
|
||||
src/Makefile
|
||||
man/Makefile
|
||||
include/Makefile
|
||||
xorg-evdev.pc])
|
||||
|
||||
2
include/Makefile.am
Normal file
2
include/Makefile.am
Normal file
@@ -0,0 +1,2 @@
|
||||
EXTRA_DIST = evdev-properties.h
|
||||
sdk_HEADERS = evdev-properties.h
|
||||
69
include/evdev-properties.h
Normal file
69
include/evdev-properties.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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_PROPERTIES_H_
|
||||
#define _EVDEV_PROPERTIES_H_
|
||||
|
||||
/* Middle mouse button emulation */
|
||||
/* BOOL */
|
||||
#define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation"
|
||||
/* CARD32 */
|
||||
#define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout"
|
||||
|
||||
/* Wheel emulation */
|
||||
/* BOOL */
|
||||
#define EVDEV_PROP_WHEEL "Evdev Wheel Emulation"
|
||||
/* CARD8, 4 values [x up, x down, y up, y down], 0 to disable a value*/
|
||||
#define EVDEV_PROP_WHEEL_AXES "Evdev Wheel Emulation Axes"
|
||||
/* CARD16 */
|
||||
#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 */
|
||||
#define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button"
|
||||
|
||||
/* Drag lock */
|
||||
/* CARD8, either 1 value or pairs, value range 0-32, 0 to disable a value*/
|
||||
#define EVDEV_PROP_DRAGLOCK "Evdev Drag Lock Buttons"
|
||||
|
||||
/* Axis inversion */
|
||||
/* BOOL, 2 values [x, y], 1 inverts axis */
|
||||
#define EVDEV_PROP_INVERT_AXES "Evdev Axis Inversion"
|
||||
|
||||
/* Reopen attempts. */
|
||||
/* CARD8 */
|
||||
#define EVDEV_PROP_REOPEN "Evdev Reopen Attempts"
|
||||
|
||||
/* Run-time calibration */
|
||||
/* CARD32, 4 values [minx, maxx, miny, maxy], or no values for unset */
|
||||
#define EVDEV_PROP_CALIBRATION "Evdev Axis Calibration"
|
||||
|
||||
/* Swap x and y axis. */
|
||||
/* BOOL */
|
||||
#define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap"
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,3 @@
|
||||
# $Id$
|
||||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
|
||||
412
man/evdev.man
412
man/evdev.man
@@ -9,6 +9,9 @@ evdev \- Generic Linux input driver
|
||||
.BI " Identifier \*q" devname \*q
|
||||
.B " Driver \*qevdev\*q"
|
||||
.BI " Option \*qDevice\*q \*q" devpath \*q
|
||||
.BI " Option \*qEmulate3Buttons\*q \*q" True \*q
|
||||
.BI " Option \*qEmulate3Timeout\*q \*q" 50 \*q
|
||||
.BI " Option \*qGrabDevice\*q \*q" False \*q
|
||||
\ \ ...
|
||||
.B EndSection
|
||||
.fi
|
||||
@@ -37,286 +40,167 @@ 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.
|
||||
.PP
|
||||
.SH BASIC CONFIGURATIONS
|
||||
Most users of this driver will probably be quite happy with the following for
|
||||
all QWERTY keyboards:
|
||||
.PP
|
||||
.nf
|
||||
.B "Section \*qInputDevice\*q"
|
||||
.BI " Identifier \*q" keyboard \*q
|
||||
.B " Driver \*qevdev\*q"
|
||||
.BI " Option \*qevBits\*q \*q" "+1" \*q
|
||||
.BI " Option \*qkeyBits\*q \*q" "~1-255 ~352-511" \*q
|
||||
.BI " Option \*qPass\*q \*q" "3" \*q
|
||||
\ \ ...
|
||||
.B EndSection
|
||||
.fi
|
||||
.PP
|
||||
And the following for all mice:
|
||||
.PP
|
||||
.nf
|
||||
.B "Section \*qInputDevice\*q"
|
||||
.BI " Identifier \*q" mouse \*q
|
||||
.B " Driver \*qevdev\*q"
|
||||
.BI " Option \*qevBits\*q \*q" "+1-2" \*q
|
||||
.BI " Option \*qkeyBits\*q \*q" "~272-287" \*q
|
||||
.BI " Option \*qrelBits\*q \*q" "~0-2 ~6 ~8" \*q
|
||||
.BI " Option \*qPass\*q \*q" "3" \*q
|
||||
\ \ ...
|
||||
.B EndSection
|
||||
.fi
|
||||
.PP
|
||||
To understand what those Bits options do, or for more complex
|
||||
configurations, please see
|
||||
.BR "ADVANCED OPTIONS"
|
||||
below.
|
||||
.PP
|
||||
.SH ADVANCED OPTIONS
|
||||
.SS DEVICE SPECIFICATION
|
||||
For this section you'll want to have knowledge of
|
||||
.B glob (7)
|
||||
and our evil
|
||||
.B "BIT MATCHING SPECIFICATION"
|
||||
stuff.
|
||||
.PP
|
||||
The following driver
|
||||
.B Options
|
||||
control what devices are accepted:
|
||||
|
||||
are supported:
|
||||
.TP 7
|
||||
.BI "Option \*qDevice\*q \*q" string \*q
|
||||
Specifies the device note through which the device can be accessed.
|
||||
At this time ONLY /dev/input/event<N>, where <N> is an integer, are
|
||||
matched against this this field.
|
||||
.fi
|
||||
This option uses globbing.
|
||||
.fi
|
||||
Please note that use of this option is strongly discouraged.
|
||||
|
||||
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.
|
||||
.TP 7
|
||||
.BI "Option \*qName\*q \*q" string \*q
|
||||
Specifies the device name for the device you wish to use.
|
||||
.fi
|
||||
The device name is generally the only consistent identifier for devices
|
||||
that are commonly unplugged and plugged back into different ports.
|
||||
.fi
|
||||
A list of currently plugged in devices and associated device names can be
|
||||
obtained by typing \*qcat /proc/bus/input/devices\*q, the \*qName\*q field
|
||||
is the value you want for this option.
|
||||
.fi
|
||||
This option uses globbing.
|
||||
|
||||
.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".
|
||||
.TP 7
|
||||
.BI "Option \*qPhys\*q \*q" string \*q
|
||||
Specifies the device phys string for the device you wish to use.
|
||||
.fi
|
||||
The phys string is generally consistant to the USB port a device is plugged
|
||||
into.
|
||||
.fi
|
||||
A list of currently plugged in devices and associated device names can be
|
||||
obtained by typing \*qcat /proc/bus/input/devices\*q, the \*qPhys\*q field
|
||||
is the value you want for this option.
|
||||
.fi
|
||||
This option uses globbing.
|
||||
|
||||
.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".
|
||||
.TP 7
|
||||
.BI "Option \*q<map>Bits\*q \*q" "bit specifier" \*q
|
||||
Specifies device capability bits which must be set, possibly set, or unset.
|
||||
.fi
|
||||
<map>Bits: Where map is one of ev, key, rel, abs, msc, led, snd, or
|
||||
ff.
|
||||
.fi
|
||||
The bit specifier format is a string consisting of +<n>, -<n>, and ~<n>
|
||||
space sepirated specifiers, where <n> is a positive integer or integer range.
|
||||
(The latter given in the format of 2-6.)
|
||||
.fi
|
||||
+ specifies bits which must be set.
|
||||
.fi
|
||||
- specifies bits which must not be set.
|
||||
.fi
|
||||
~ is a little more complex, it specifies that at least one of the bits given
|
||||
with ~ for the field in question must be set, but it doesn't matter how many
|
||||
or which of the bits. (It is actually the most useful of the 3 specifiers.)
|
||||
.fi
|
||||
As an example '+0 +3 -1-2 ~5-10', requires bits 0 and 3 be set,
|
||||
bits 1 and 2 to not be set, and at least one bit in the range of 5 to
|
||||
10 be set.
|
||||
.fi
|
||||
An annoyingly formatted set of bitmasks for your devices can be obtained
|
||||
by typing \*qcat /proc/bus/input/devices\*q, and
|
||||
.B /usr/include/linux/input.h
|
||||
should contain the defines which declare what bits are what for each field.
|
||||
|
||||
.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.
|
||||
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.
|
||||
.TP 7
|
||||
.BI "Option \*qbustype\*q \*q" integer \*q
|
||||
Specifies the bus ID for the device you wish to use.
|
||||
.fi
|
||||
This is either 0 (the default, matches anything), or the Bus=<n> field in
|
||||
.B /proc/bus/input/devices
|
||||
for your device.
|
||||
.fi
|
||||
This value depends on what type of bus your device is connected to.
|
||||
|
||||
.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
|
||||
Drag Lock Buttons".
|
||||
.TP 7
|
||||
.BI "Option \*qvendor\*q \*q" integer \*q
|
||||
Specifies the vendor ID for the device you wish to use.
|
||||
.fi
|
||||
This is either 0 (the default, matches anything), or the Vendor=<n> field in
|
||||
.B /proc/bus/input/devices
|
||||
for your device.
|
||||
.fi
|
||||
This value should remain constant barring perhaps firmware updates to the
|
||||
device itself.
|
||||
|
||||
.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
|
||||
.BI "Option \*qversion\*q \*q" integer \*q
|
||||
Specifies the version for the device you wish to use.
|
||||
.fi
|
||||
This is either 0 (the default, matches anything), or the Version=<n> field in
|
||||
.B /proc/bus/input/devices
|
||||
for your device.
|
||||
.fi
|
||||
This value should remain constant barring perhaps firmware updates to the
|
||||
device itself.
|
||||
|
||||
.TP 7
|
||||
.BI "Option \*qproduct\*q \*q" integer \*q
|
||||
Specifies the product ID for the device you wish to use.
|
||||
.fi
|
||||
This is either 0 (the default, matches anything), or the Product=<n> field in
|
||||
.B /proc/bus/input/devices
|
||||
for your device.
|
||||
.fi
|
||||
This value should remain constant barring perhaps firmware updates to the
|
||||
device itself.
|
||||
|
||||
.TP 7
|
||||
.BI "Option \*qPass\*q \*q" integer \*q
|
||||
Specifies the order in which evdev will scan for devices.
|
||||
.fi
|
||||
This is in the range of 0 to 3, and is used for the case
|
||||
where more then one evdev inputsection matches the same device.
|
||||
.fi
|
||||
An inputsection with a lower pass number will always beat out
|
||||
one with a higher pass number. Order when both sections are
|
||||
the same number is undefined.
|
||||
.fi
|
||||
The default is 0.
|
||||
|
||||
|
||||
.PP
|
||||
.SS RELATIVE AXIS CONFIGURATION
|
||||
The relative axis portion of this driver handle all reported relative axies.
|
||||
.fi
|
||||
The axies are named X, Y, Z, RX, RY, RZ, HWHEEL, DIAL, WHEEL, MISC, 10, 11,
|
||||
12, 13, 14, and 15.
|
||||
.fi
|
||||
The axies are reported to X as valuators, with the default mapping of axies
|
||||
to valuators being the first axies found to the first valuator, the second
|
||||
found to the second valuator, and so on, so that if you have axies X, Y,
|
||||
HWHEEL, and WHEEL, you would have X=0, Y=1, HWHEEL=2, WHEEL=3.
|
||||
.fi
|
||||
If the driver is reporting core events, valuators 0 and 1 are always mapped
|
||||
to x and y coordinates, respectively.
|
||||
.fi
|
||||
The following driver
|
||||
.B Options
|
||||
control the relative axis portion of the driver:
|
||||
.TP 7
|
||||
.BI "Option \*q<axis>RelativeAxisMap\*q \*q" number \*q
|
||||
This remaps the axis specified to the specified valuator.
|
||||
.TP 7
|
||||
.BI "Option \*q<axis>RelativeAxisButtons\*q \*q" number " number\*q
|
||||
This remaps the axis specified to the specified buttons.
|
||||
.fi
|
||||
Note that the physical buttons are always remapped around 'fake' buttons
|
||||
created by this option, so that if you have physical buttons 1 2 3 4 5,
|
||||
and map the Wheel axis to buttons 4 5, you get buttons 1 2 3
|
||||
.B 4 5
|
||||
6 7, with buttons 6 and 7 being physical buttons 4 and 5.
|
||||
.PP
|
||||
.SS ABSOLUTE AXIS CONFIGURATION
|
||||
The relative axis portion of this driver handle all reported relative axies.
|
||||
.fi
|
||||
The axies are named X, Y, Z, RX, RY, RZ, THROTTLE, RUDDER, WHEEL, GAS, BREAK,
|
||||
<11-15>, HAT0X, HAT0Y, HAT1X, HAT1Y, HAT2X, HAT2Y, HAT3X, HAT3Y, PRESSURE,
|
||||
TILT_X, TILT_Y, TOOL_WIDTH, VOLUME, <29-39>, MISC, <41-62>.
|
||||
.fi
|
||||
The axies are reported to X as valuators, with the default mapping of axies
|
||||
to valuators being the first axies found to the first valuator, the second
|
||||
found to the second valuator, and so on, so that if you have axies X, Y,
|
||||
TILT_X, and TILT_Y, you would have X=0, Y=1, TILT_X=2, TILT_Y=3.
|
||||
.fi
|
||||
If the driver is reporting core events, valuators 0 and 1 are always mapped
|
||||
to x and y coordinates, respectively.
|
||||
.fi
|
||||
The following driver
|
||||
.B Options
|
||||
control the relative axis portion of the driver:
|
||||
.TP 7
|
||||
.BI "Option \*q<axis>AbsoluteAxisMap\*q \*q" number \*q
|
||||
This remaps the axis specified to the specified valuator.
|
||||
.TP 7
|
||||
.BI "Option \*qAbsoluteScreen\*q \*q" number \*q
|
||||
This binds the device to a specific screen, scaling it to
|
||||
the coordinate space of that screen.
|
||||
.fi
|
||||
The number can either be -1, or a valid screen number.
|
||||
.fi
|
||||
If -1 or if in relative mode no scaling or screen fixing is done.
|
||||
.fi
|
||||
This is of most use for digitizers, where the screen and the input
|
||||
device are the same surface.
|
||||
.TP 7
|
||||
.BI "Option \*qMode\*q \*q" <mode>\*q
|
||||
This selects the default mode for the device.
|
||||
.fi
|
||||
Valid values are \*qabsolute\*q and \*qrelative\*q.
|
||||
.fi
|
||||
This can be set at run time per actual device with the xinput utility.
|
||||
.PP
|
||||
.SS BUTTON CONFIGURATION
|
||||
At the moment, the button portion of this driver only handles buttons
|
||||
reported as mouse buttons, that is from BTN_MOUSE to BTN_JOYSTICK - 1.
|
||||
.fi
|
||||
At this time there are no configuration options for buttens.
|
||||
.SS KEYBOARD CONFIGURATION
|
||||
The keyboard portion of this driver handles all keys reported and requires
|
||||
XKB support.
|
||||
.fi
|
||||
The following driver
|
||||
.B Options
|
||||
control the relative axis portion of the driver:
|
||||
.TP 7
|
||||
.BI "Option \*qXkbRules\*q \*q" rules \*q
|
||||
specifies which XKB rules file to use for interpreting the
|
||||
.BR XkbModel ,
|
||||
.BR XkbLayout ,
|
||||
.BR XkbVariant ,
|
||||
.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
|
||||
.BR EmulateWheelButton ,
|
||||
.BR EmulateWheelInertia ,
|
||||
.BR EmulateWheelTimeout ,
|
||||
.BR XAxisMapping ,
|
||||
and
|
||||
.B XkbOptions
|
||||
settings. Default: "xorg" for most platforms, but "xfree98" for the
|
||||
Japanese PC-98 platforms.
|
||||
.B YAxisMapping
|
||||
options below. Default: off. Property "Evdev Wheel Emulation".
|
||||
.TP 7
|
||||
.BI "Option \*qXkbModel\*q \*q" modelname \*q
|
||||
specifies the XKB keyboard model name. Default: "evdev".
|
||||
.BI "Option \*qEmulateWheelButton\*q \*q" integer \*q
|
||||
Specifies which button must be held down to enable wheel emulation mode.
|
||||
While this button is down, X and/or Y pointer movement will generate button
|
||||
press/release events as specified for the
|
||||
.B XAxisMapping
|
||||
and
|
||||
.B YAxisMapping
|
||||
settings. Default: 4. Property: "Evdev Wheel Emulation Button".
|
||||
.TP 7
|
||||
.BI "Option \*qXkbLayout\*q \*q" layoutname \*q
|
||||
specifies the XKB keyboard layout name. This is usually the country or
|
||||
language type of the keyboard. Default: "us".
|
||||
.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".
|
||||
.TP 7
|
||||
.BI "Option \*qXkbVariant\*q \*q" variants \*q
|
||||
specifies the XKB keyboard variant components. These can be used to
|
||||
enhance the keyboard layout details. Default: not set.
|
||||
.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".
|
||||
.TP 7
|
||||
.BI "Option \*qXkbOptions\*q \*q" options \*q
|
||||
specifies the XKB keyboard option components. These can be used to
|
||||
enhance the keyboard behaviour. Default: not set.
|
||||
.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
|
||||
.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".
|
||||
.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
|
||||
.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".
|
||||
.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.
|
||||
.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".
|
||||
.TP 7
|
||||
.BI "Option \*qSwapAxes\*q \*q" Bool \*q
|
||||
Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
|
||||
.TP 7
|
||||
.BI "Option \*qGrabDevice\*q \*q" boolean \*q
|
||||
Force a grab on the event device. Doing so will ensure that no other driver
|
||||
can initialise the same device and it will also stop the device from sending
|
||||
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.
|
||||
|
||||
.SH SUPPORTED PROPERTIES
|
||||
The following properties are provided by the
|
||||
.B evdev
|
||||
driver.
|
||||
.TP 7
|
||||
.BI "Evdev Middle Button Emulation"
|
||||
1 boolean value (8 bit, 0 or 1).
|
||||
.TP 7
|
||||
.BI "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 Inertia"
|
||||
1 16-bit positive value.
|
||||
.TP 7
|
||||
.BI "Evdev Wheel Emulation Timeout"
|
||||
1 16-bit positive value.
|
||||
.TP 7
|
||||
.BI "Evdev Wheel Emulation Button"
|
||||
1 8-bit value, allowed range 0-32, 0 disables the button.
|
||||
.TP 7
|
||||
.BI "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 Axis Inversion"
|
||||
2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
|
||||
.TP 7
|
||||
.BI "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.
|
||||
.TP 7
|
||||
.BI "Evdev Axis Swap"
|
||||
1 boolean value (8 bit, 0 or 1). 1 swaps x/y axes.
|
||||
|
||||
.PP
|
||||
.SH AUTHORS
|
||||
Zephaniah E. Hull.
|
||||
.fi
|
||||
Kristian Høgsberg.
|
||||
.SH "SEE ALSO"
|
||||
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__).
|
||||
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__),
|
||||
README.mouse.
|
||||
|
||||
@@ -26,7 +26,13 @@
|
||||
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
|
||||
@DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la
|
||||
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
|
||||
@DRIVER_NAME@_drv_la_CFLAGS = -Wall
|
||||
@DRIVER_NAME@_drv_ladir = @inputdir@
|
||||
|
||||
@DRIVER_NAME@_drv_la_SOURCES = evdev.c evdev.h evdev_brain.c evdev_axes.c evdev_btn.c evdev_key.c inotify.h inotify-syscalls.h
|
||||
INCLUDES=-I$(top_srcdir)/include/
|
||||
|
||||
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \
|
||||
@DRIVER_NAME@.h \
|
||||
emuMB.c \
|
||||
emuWheel.c \
|
||||
draglock.c
|
||||
|
||||
|
||||
320
src/draglock.c
Normal file
320
src/draglock.c
Normal file
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* 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
|
||||
* (Ported from xf86-input-mouse, above copyrights taken from there)
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Draglock code */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <xf86.h>
|
||||
#include <xf86Xinput.h>
|
||||
#include <X11/Xatom.h>
|
||||
#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);
|
||||
|
||||
|
||||
/* Setup and configuration code */
|
||||
void
|
||||
EvdevDragLockPreInit(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
char *option_string = NULL;
|
||||
int meta_button = 0;
|
||||
int lock_button = 0;
|
||||
char *next_num = NULL;
|
||||
char *end_str = NULL;
|
||||
BOOL pairs = FALSE;
|
||||
|
||||
option_string = xf86CheckStrOption(pInfo->options, "DragLockButtons",NULL);
|
||||
|
||||
if (!option_string)
|
||||
return;
|
||||
|
||||
next_num = option_string;
|
||||
|
||||
/* Loop until we hit the end of our option string */
|
||||
while (next_num != NULL) {
|
||||
lock_button = 0;
|
||||
meta_button = strtol(next_num, &end_str, 10);
|
||||
|
||||
/* check to see if we found anything */
|
||||
if (next_num != end_str) {
|
||||
/* setup for the next number */
|
||||
next_num = end_str;
|
||||
} else {
|
||||
/* we have nothing more to parse, drop out of the loop */
|
||||
next_num = NULL;
|
||||
}
|
||||
|
||||
/* Check for a button to lock if we have a meta button */
|
||||
if (meta_button != 0 && next_num != NULL ) {
|
||||
lock_button = strtol(next_num, &end_str, 10);
|
||||
|
||||
/* check to see if we found anything */
|
||||
if (next_num != end_str) {
|
||||
/* setup for the next number */
|
||||
next_num = end_str;
|
||||
} else {
|
||||
/* we have nothing more to parse, drop out of the loop */
|
||||
next_num = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ok, let the user know what we found on this look */
|
||||
if (meta_button != 0) {
|
||||
if (lock_button == 0) {
|
||||
if (!pairs) {
|
||||
/* We only have a meta button */
|
||||
pEvdev->dragLock.meta = meta_button;
|
||||
|
||||
xf86Msg(X_CONFIG, "%s: DragLockButtons : "
|
||||
"%i as meta\n",
|
||||
pInfo->name, meta_button);
|
||||
} else {
|
||||
xf86Msg(X_ERROR, "%s: DragLockButtons : "
|
||||
"Incomplete pair specifying button pairs %s\n",
|
||||
pInfo->name, option_string);
|
||||
}
|
||||
} else {
|
||||
|
||||
/* Do bounds checking to make sure we don't crash */
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xf86Msg(X_ERROR, "%s: Found DragLockButtons "
|
||||
"with invalid lock button string : '%s'\n",
|
||||
pInfo->name, option_string);
|
||||
|
||||
/* This should be the case anyhow, just make sure */
|
||||
next_num = NULL;
|
||||
}
|
||||
|
||||
/* Check for end of string, to avoid annoying error */
|
||||
if (next_num != NULL && *next_num == '\0')
|
||||
next_num = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Updates DragLock button state and firest button event messges */
|
||||
void
|
||||
EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
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);
|
||||
}
|
||||
|
||||
/* Filter button presses looking for either a meta button or the
|
||||
* control of a button pair.
|
||||
*
|
||||
* @param button button number (1 for left, 3 for right)
|
||||
* @param value TRUE if button press, FALSE if release
|
||||
*
|
||||
* @return TRUE if the event was swallowed here, FALSE otherwise.
|
||||
*/
|
||||
BOOL
|
||||
EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
|
||||
if (button == 0)
|
||||
return FALSE;
|
||||
|
||||
/* Do we have a single meta key or
|
||||
several button pairings? */
|
||||
if (pEvdev->dragLock.meta != 0) {
|
||||
|
||||
if (pEvdev->dragLock.meta == button) {
|
||||
|
||||
/* setup up for button lock */
|
||||
if (value)
|
||||
pEvdev->dragLock.meta_state = TRUE;
|
||||
|
||||
return TRUE;
|
||||
} else if (pEvdev->dragLock.meta_state) { /* waiting to lock */
|
||||
|
||||
pEvdev->dragLock.meta_state = FALSE;
|
||||
|
||||
EvdevDragLockLockButton(pInfo, button);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
} else if (pEvdev->dragLock.lock_pair[button - 1] && value) {
|
||||
/* A meta button in a meta/lock pair was pressed */
|
||||
EvdevDragLockLockButton(pInfo, pEvdev->dragLock.lock_pair[button - 1]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Eat events for buttons that are locked */
|
||||
if (pEvdev->dragLock.lock_state[button - 1])
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
/**
|
||||
* Set the drag lock property.
|
||||
* If only one value is supplied, then this is used as the meta button.
|
||||
* If more than one value is supplied, then each value is the drag lock button
|
||||
* for the pair. 0 disables a pair.
|
||||
* i.e. to set bt 3 to draglock button 1, supply 0,0,1
|
||||
*/
|
||||
int
|
||||
EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
BOOL checkonly)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (atom == prop_dlock)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (val->format != 8 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
/* Don't allow changes while a lock is active */
|
||||
if (pEvdev->dragLock.meta)
|
||||
{
|
||||
if (pEvdev->dragLock.meta_state)
|
||||
return BadAccess;
|
||||
} else
|
||||
{
|
||||
for (i = 0; i < EVDEV_MAXBUTTONS; i++)
|
||||
if (pEvdev->dragLock.lock_state[i])
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if (val->size == 0)
|
||||
return BadMatch;
|
||||
else if (val->size == 1)
|
||||
{
|
||||
int meta = *((CARD8*)val->data);
|
||||
if (meta > EVDEV_MAXBUTTONS)
|
||||
return BadValue;
|
||||
|
||||
if (!checkonly)
|
||||
{
|
||||
pEvdev->dragLock.meta = meta;
|
||||
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
||||
}
|
||||
} else
|
||||
{
|
||||
CARD8* vals = (CARD8*)val->data;
|
||||
|
||||
for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++)
|
||||
if (vals[i] > EVDEV_MAXBUTTONS)
|
||||
return BadValue;
|
||||
|
||||
if (!checkonly)
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise property for drag lock buttons setting.
|
||||
*/
|
||||
void
|
||||
EvdevDragLockInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (!dev->button) /* don't init prop for keyboards */
|
||||
return;
|
||||
|
||||
prop_dlock = MakeAtom(EVDEV_PROP_DRAGLOCK, strlen(EVDEV_PROP_DRAGLOCK), TRUE);
|
||||
if (pEvdev->dragLock.meta)
|
||||
{
|
||||
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
|
||||
PropModeReplace, 1, &pEvdev->dragLock.meta,
|
||||
FALSE);
|
||||
} else {
|
||||
int highest = 0;
|
||||
int i;
|
||||
CARD8 pair[EVDEV_MAXBUTTONS] = {0};
|
||||
|
||||
for (i = 0; i < EVDEV_MAXBUTTONS; i++)
|
||||
{
|
||||
if (pEvdev->dragLock.lock_pair[i])
|
||||
highest = i;
|
||||
pair[i] = pEvdev->dragLock.lock_pair[i];
|
||||
}
|
||||
|
||||
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
|
||||
highest + 1, pair, FALSE);
|
||||
}
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_dlock, FALSE);
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
415
src/emuMB.c
Normal file
415
src/emuMB.c
Normal file
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
* 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
|
||||
* (Ported from xf86-input-mouse, above copyrights taken from there)
|
||||
* Copyright © 2008 University of South Australia
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Middle mouse button emulation code. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86Xinput.h>
|
||||
#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
|
||||
/*
|
||||
* Lets create a simple finite-state machine for 3 button emulation:
|
||||
*
|
||||
* We track buttons 1 and 3 (left and right). There are 11 states:
|
||||
* 0 ground - initial state
|
||||
* 1 delayed left - left pressed, waiting for right
|
||||
* 2 delayed right - right pressed, waiting for left
|
||||
* 3 pressed middle - right and left pressed, emulated middle sent
|
||||
* 4 pressed left - left pressed and sent
|
||||
* 5 pressed right - right pressed and sent
|
||||
* 6 released left - left released after emulated middle
|
||||
* 7 released right - right released after emulated middle
|
||||
* 8 repressed left - left pressed after released left
|
||||
* 9 repressed right - right pressed after released right
|
||||
* 10 pressed both - both pressed, not emulating middle
|
||||
*
|
||||
* At each state, we need handlers for the following events
|
||||
* 0: no buttons down
|
||||
* 1: left button down
|
||||
* 2: right button down
|
||||
* 3: both buttons down
|
||||
* 4: emulate3Timeout passed without a button change
|
||||
* Note that button events are not deltas, they are the set of buttons being
|
||||
* pressed now. It's possible (ie, mouse hardware does it) to go from (eg)
|
||||
* left down to right down without anything in between, so all cases must be
|
||||
* handled.
|
||||
*
|
||||
* a handler consists of three values:
|
||||
* 0: action1
|
||||
* 1: action2
|
||||
* 2: new emulation state
|
||||
*
|
||||
* action > 0: ButtonPress
|
||||
* action = 0: nothing
|
||||
* action < 0: ButtonRelease
|
||||
*
|
||||
* The comment preceeding each section is the current emulation state.
|
||||
* The comments to the right are of the form
|
||||
* <button state> (<events>) -> <new emulation state>
|
||||
* which should be read as
|
||||
* If the buttons are in <button state>, generate <events> then go to
|
||||
* <new emulation state>.
|
||||
*/
|
||||
static signed char stateTab[11][5][3] = {
|
||||
/* 0 ground */
|
||||
{
|
||||
{ 0, 0, 0 }, /* nothing -> ground (no change) */
|
||||
{ 0, 0, 1 }, /* left -> delayed left */
|
||||
{ 0, 0, 2 }, /* right -> delayed right */
|
||||
{ 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
|
||||
{ 0, 0, -1 } /* timeout N/A */
|
||||
},
|
||||
/* 1 delayed left */
|
||||
{
|
||||
{ 1, -1, 0 }, /* nothing (left event) -> ground */
|
||||
{ 0, 0, 1 }, /* left -> delayed left (no change) */
|
||||
{ 1, -1, 2 }, /* right (left event) -> delayed right */
|
||||
{ 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
|
||||
{ 1, 0, 4 }, /* timeout (left press) -> pressed left */
|
||||
},
|
||||
/* 2 delayed right */
|
||||
{
|
||||
{ 3, -3, 0 }, /* nothing (right event) -> ground */
|
||||
{ 3, -3, 1 }, /* left (right event) -> delayed left (no change) */
|
||||
{ 0, 0, 2 }, /* right -> delayed right (no change) */
|
||||
{ 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
|
||||
{ 3, 0, 5 }, /* timeout (right press) -> pressed right */
|
||||
},
|
||||
/* 3 pressed middle */
|
||||
{
|
||||
{ -2, 0, 0 }, /* nothing (middle release) -> ground */
|
||||
{ 0, 0, 7 }, /* left -> released right */
|
||||
{ 0, 0, 6 }, /* right -> released left */
|
||||
{ 0, 0, 3 }, /* left & right -> pressed middle (no change) */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 4 pressed left */
|
||||
{
|
||||
{ -1, 0, 0 }, /* nothing (left release) -> ground */
|
||||
{ 0, 0, 4 }, /* left -> pressed left (no change) */
|
||||
{ -1, 0, 2 }, /* right (left release) -> delayed right */
|
||||
{ 3, 0, 10 }, /* left & right (right press) -> pressed both */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 5 pressed right */
|
||||
{
|
||||
{ -3, 0, 0 }, /* nothing (right release) -> ground */
|
||||
{ -3, 0, 1 }, /* left (right release) -> delayed left */
|
||||
{ 0, 0, 5 }, /* right -> pressed right (no change) */
|
||||
{ 1, 0, 10 }, /* left & right (left press) -> pressed both */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 6 released left */
|
||||
{
|
||||
{ -2, 0, 0 }, /* nothing (middle release) -> ground */
|
||||
{ -2, 0, 1 }, /* left (middle release) -> delayed left */
|
||||
{ 0, 0, 6 }, /* right -> released left (no change) */
|
||||
{ 1, 0, 8 }, /* left & right (left press) -> repressed left */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 7 released right */
|
||||
{
|
||||
{ -2, 0, 0 }, /* nothing (middle release) -> ground */
|
||||
{ 0, 0, 7 }, /* left -> released right (no change) */
|
||||
{ -2, 0, 2 }, /* right (middle release) -> delayed right */
|
||||
{ 3, 0, 9 }, /* left & right (right press) -> repressed right */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 8 repressed left */
|
||||
{
|
||||
{ -2, -1, 0 }, /* nothing (middle release, left release) -> ground */
|
||||
{ -2, 0, 4 }, /* left (middle release) -> pressed left */
|
||||
{ -1, 0, 6 }, /* right (left release) -> released left */
|
||||
{ 0, 0, 8 }, /* left & right -> repressed left (no change) */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 9 repressed right */
|
||||
{
|
||||
{ -2, -3, 0 }, /* nothing (middle release, right release) -> ground */
|
||||
{ -3, 0, 7 }, /* left (right release) -> released right */
|
||||
{ -2, 0, 5 }, /* right (middle release) -> pressed right */
|
||||
{ 0, 0, 9 }, /* left & right -> repressed right (no change) */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
/* 10 pressed both */
|
||||
{
|
||||
{ -1, -3, 0 }, /* nothing (left release, right release) -> ground */
|
||||
{ -3, 0, 4 }, /* left (right release) -> pressed left */
|
||||
{ -1, 0, 5 }, /* right (left release) -> pressed right */
|
||||
{ 0, 0, 10 }, /* left & right -> pressed both (no change) */
|
||||
{ 0, 0, -1 }, /* timeout N/A */
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
EvdevMBEmuTimer(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int sigstate;
|
||||
int id;
|
||||
|
||||
sigstate = xf86BlockSIGIO ();
|
||||
|
||||
pEvdev->emulateMB.pending = FALSE;
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
|
||||
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
|
||||
pEvdev->emulateMB.state =
|
||||
stateTab[pEvdev->emulateMB.state][4][2];
|
||||
} else {
|
||||
ErrorF("Got unexpected buttonTimer in state %d\n",
|
||||
pEvdev->emulateMB.state);
|
||||
}
|
||||
|
||||
xf86UnblockSIGIO (sigstate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Emulate a middle button on button press.
|
||||
*
|
||||
* @param code button number (1 for left, 3 for right)
|
||||
* @param press TRUE if press, FALSE if release.
|
||||
*
|
||||
* @return TRUE if event was swallowed by middle mouse button emulation, FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
BOOL
|
||||
EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int 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;
|
||||
|
||||
btstate = &pEvdev->emulateMB.buttonstate;
|
||||
if (press)
|
||||
*btstate |= (button == 1) ? 0x1 : 0x2;
|
||||
else
|
||||
*btstate &= (button == 1) ? ~0x1 : ~0x2;
|
||||
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][0]) != 0)
|
||||
{
|
||||
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
|
||||
ret = TRUE;
|
||||
}
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0)
|
||||
{
|
||||
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
pEvdev->emulateMB.state =
|
||||
stateTab[pEvdev->emulateMB.state][*btstate][2];
|
||||
|
||||
if (stateTab[pEvdev->emulateMB.state][4][0] != 0) {
|
||||
pEvdev->emulateMB.expires = GetTimeInMillis () + pEvdev->emulateMB.timeout;
|
||||
pEvdev->emulateMB.pending = TRUE;
|
||||
ret = TRUE;
|
||||
} else {
|
||||
pEvdev->emulateMB.pending = FALSE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void EvdevMBEmuWakeupHandler(pointer data,
|
||||
int i,
|
||||
pointer LastSelectMask)
|
||||
{
|
||||
InputInfoPtr pInfo = (InputInfoPtr)data;
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
int ms;
|
||||
|
||||
if (pEvdev->emulateMB.pending)
|
||||
{
|
||||
ms = pEvdev->emulateMB.expires - GetTimeInMillis();
|
||||
if (ms <= 0)
|
||||
EvdevMBEmuTimer(pInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void EvdevMBEmuBlockHandler(pointer data,
|
||||
struct timeval **waitTime,
|
||||
pointer LastSelectMask)
|
||||
{
|
||||
InputInfoPtr pInfo = (InputInfoPtr) data;
|
||||
EvdevPtr pEvdev= (EvdevPtr) pInfo->private;
|
||||
int ms;
|
||||
|
||||
if (pEvdev->emulateMB.pending)
|
||||
{
|
||||
ms = pEvdev->emulateMB.expires - GetTimeInMillis ();
|
||||
if (ms <= 0)
|
||||
ms = 0;
|
||||
AdjustWaitForDelay (waitTime, ms);
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
|
||||
"Emulate3Timeout", 50);
|
||||
}
|
||||
|
||||
void
|
||||
EvdevMBEmuOn(InputInfoPtr pInfo)
|
||||
{
|
||||
RegisterBlockAndWakeupHandlers (EvdevMBEmuBlockHandler,
|
||||
EvdevMBEmuWakeupHandler,
|
||||
(pointer)pInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EvdevMBEmuFinalize(InputInfoPtr pInfo)
|
||||
{
|
||||
RemoveBlockAndWakeupHandlers (EvdevMBEmuBlockHandler,
|
||||
EvdevMBEmuWakeupHandler,
|
||||
(pointer)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
|
||||
int
|
||||
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
BOOL checkonly)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (atom == prop_mbemu)
|
||||
{
|
||||
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateMB.enabled = *((BOOL*)val->data);
|
||||
} else if (atom == prop_mbtimeout)
|
||||
{
|
||||
if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateMB.timeout = *((CARD32*)val->data);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise property for MB emulation on/off.
|
||||
*/
|
||||
void
|
||||
EvdevMBEmuInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int rc;
|
||||
|
||||
if (!dev->button) /* don't init prop for keyboards */
|
||||
return;
|
||||
|
||||
prop_mbemu = MakeAtom(EVDEV_PROP_MIDBUTTON, strlen(EVDEV_PROP_MIDBUTTON), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbemu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateMB.enabled,
|
||||
FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_mbemu, FALSE);
|
||||
|
||||
prop_mbtimeout = MakeAtom(EVDEV_PROP_MIDBUTTON_TIMEOUT,
|
||||
strlen(EVDEV_PROP_MIDBUTTON_TIMEOUT),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 32, PropModeReplace, 1,
|
||||
&pEvdev->emulateMB.timeout, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_mbtimeout, FALSE);
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
472
src/emuWheel.c
Normal file
472
src/emuWheel.c
Normal file
@@ -0,0 +1,472 @@
|
||||
/*
|
||||
* 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
|
||||
* (Ported from xf86-input-mouse, above copyrights taken from there)
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Mouse wheel emulation code. */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86Xinput.h>
|
||||
#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);
|
||||
|
||||
/* Filter mouse button events */
|
||||
BOOL
|
||||
EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
int ms;
|
||||
|
||||
/* Has wheel emulation been configured to be enabled? */
|
||||
if (!pEvdev->emulateWheel.enabled)
|
||||
return FALSE;
|
||||
|
||||
/* Check for EmulateWheelButton */
|
||||
if (pEvdev->emulateWheel.button == button) {
|
||||
pEvdev->emulateWheel.button_state = value;
|
||||
|
||||
if (value)
|
||||
/* Start the timer when the button is pressed */
|
||||
pEvdev->emulateWheel.expires = pEvdev->emulateWheel.timeout +
|
||||
GetTimeInMillis();
|
||||
else {
|
||||
ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
|
||||
if (ms > 0) {
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Don't care about this event */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Filter mouse wheel events */
|
||||
BOOL
|
||||
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) {
|
||||
/* Just return if the timeout hasn't expired yet */
|
||||
ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
|
||||
if (ms > 0)
|
||||
return TRUE;
|
||||
|
||||
/* We don't want to intercept real mouse wheel events */
|
||||
switch(pEv->code) {
|
||||
case REL_X:
|
||||
pAxis = &(pEvdev->emulateWheel.X);
|
||||
break;
|
||||
|
||||
case REL_Y:
|
||||
pAxis = &(pEvdev->emulateWheel.Y);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we found REL_X or REL_Y, emulate a mouse wheel */
|
||||
if (pAxis)
|
||||
EvdevWheelEmuInertia(pInfo, pAxis, value);
|
||||
|
||||
/* Eat motion events while emulateWheel button pressed. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Simulate inertia for our emulated mouse wheel */
|
||||
static void
|
||||
EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
int button;
|
||||
int inertia;
|
||||
|
||||
/* if this axis has not been configured, just eat the motion */
|
||||
if (!axis->up_button)
|
||||
return;
|
||||
|
||||
axis->traveled_distance += value;
|
||||
|
||||
if (axis->traveled_distance < 0) {
|
||||
button = axis->up_button;
|
||||
inertia = -pEvdev->emulateWheel.inertia;
|
||||
} else {
|
||||
button = axis->down_button;
|
||||
inertia = pEvdev->emulateWheel.inertia;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
char *option_string;
|
||||
|
||||
pAxis->up_button = WHEEL_NOT_CONFIGURED;
|
||||
|
||||
/* Check to see if there is configuration for this axis */
|
||||
option_string = xf86SetStrOption(pInfo->options, axis_name, NULL);
|
||||
if (option_string) {
|
||||
int up_button = 0;
|
||||
int down_button = 0;
|
||||
char *msg = NULL;
|
||||
|
||||
if ((sscanf(option_string, "%d %d", &up_button, &down_button) == 2) &&
|
||||
((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");
|
||||
|
||||
if (msg)
|
||||
sprintf(msg, "buttons %d and %d", up_button, down_button);
|
||||
|
||||
pAxis->up_button = up_button;
|
||||
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;
|
||||
|
||||
} else {
|
||||
xf86Msg(X_WARNING, "%s: Invalid %s value:\"%s\"\n",
|
||||
pInfo->name, axis_name, option_string);
|
||||
|
||||
}
|
||||
|
||||
/* Clean up and log what happened */
|
||||
if (msg) {
|
||||
xf86Msg(X_CONFIG, "%s: %s: %s\n",pInfo->name, axis_name, msg);
|
||||
xfree(msg);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Setup the basic configuration options used by mouse wheel emulation */
|
||||
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
|
||||
pEvdev->emulateWheel.enabled = FALSE;
|
||||
|
||||
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);
|
||||
|
||||
pEvdev->emulateWheel.enabled = FALSE;
|
||||
}
|
||||
|
||||
pEvdev->emulateWheel.button = wheelButton;
|
||||
|
||||
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);
|
||||
|
||||
inertia = 10;
|
||||
}
|
||||
|
||||
pEvdev->emulateWheel.inertia = inertia;
|
||||
|
||||
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);
|
||||
|
||||
timeout = 200;
|
||||
}
|
||||
|
||||
pEvdev->emulateWheel.timeout = timeout;
|
||||
|
||||
/* Configure the Y axis or default it */
|
||||
if (!EvdevWheelEmuHandleButtonMap(pInfo, &(pEvdev->emulateWheel.Y),
|
||||
"YAxisMapping")) {
|
||||
/* Default the Y axis to sane values */
|
||||
pEvdev->emulateWheel.Y.up_button = 4;
|
||||
pEvdev->emulateWheel.Y.down_button = 5;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
||||
/* This axis should default to an unconfigured state as most people
|
||||
are not going to expect a Horizontal wheel. */
|
||||
EvdevWheelEmuHandleButtonMap(pInfo, &(pEvdev->emulateWheel.X),
|
||||
"XAxisMapping");
|
||||
|
||||
/* Used by the inertia code */
|
||||
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);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
int
|
||||
EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
BOOL checkonly)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (atom == prop_wheel_emu)
|
||||
{
|
||||
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
{
|
||||
pEvdev->emulateWheel.enabled = *((BOOL*)val->data);
|
||||
/* Don't enable with zero inertia, otherwise we may get stuck in an
|
||||
* infinite loop */
|
||||
if (pEvdev->emulateWheel.inertia <= 0)
|
||||
{
|
||||
pEvdev->emulateWheel.inertia = 10;
|
||||
/* We may get here before the property is actually enabled */
|
||||
if (prop_wheel_inertia)
|
||||
XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER,
|
||||
16, PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.inertia, TRUE);
|
||||
}
|
||||
|
||||
/* Don't enable with negative timeout */
|
||||
if (pEvdev->emulateWheel.timeout < 0)
|
||||
{
|
||||
pEvdev->emulateWheel.timeout = 200;
|
||||
XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.timeout, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (atom == prop_wheel_button)
|
||||
{
|
||||
int bt;
|
||||
|
||||
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->emulateWheel.button = bt;
|
||||
} else if (atom == prop_wheel_axismap)
|
||||
{
|
||||
if (val->format != 8 || val->size != 4 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
{
|
||||
pEvdev->emulateWheel.X.up_button = *((CARD8*)val->data);
|
||||
pEvdev->emulateWheel.X.down_button = *(((CARD8*)val->data) + 1);
|
||||
pEvdev->emulateWheel.Y.up_button = *(((CARD8*)val->data) + 2);
|
||||
pEvdev->emulateWheel.Y.down_button = *(((CARD8*)val->data) + 3);
|
||||
}
|
||||
} else if (atom == prop_wheel_inertia)
|
||||
{
|
||||
int inertia;
|
||||
|
||||
if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
inertia = *((CARD16*)val->data);
|
||||
|
||||
if (inertia < 0)
|
||||
return BadValue;
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateWheel.inertia = inertia;
|
||||
} else if (atom == prop_wheel_timeout)
|
||||
{
|
||||
int timeout;
|
||||
|
||||
if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
timeout = *((CARD16*)val->data);
|
||||
|
||||
if (timeout < 0)
|
||||
return BadValue;
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateWheel.timeout = timeout;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
EvdevWheelEmuInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int rc = TRUE;
|
||||
char vals[4];
|
||||
|
||||
if (!dev->button) /* don't init prop for keyboards */
|
||||
return;
|
||||
|
||||
prop_wheel_emu = MakeAtom(EVDEV_PROP_WHEEL, strlen(EVDEV_PROP_WHEEL), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.enabled, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_emu, FALSE);
|
||||
|
||||
vals[0] = pEvdev->emulateWheel.X.up_button;
|
||||
vals[1] = pEvdev->emulateWheel.X.down_button;
|
||||
vals[2] = pEvdev->emulateWheel.Y.up_button;
|
||||
vals[3] = pEvdev->emulateWheel.Y.down_button;
|
||||
|
||||
prop_wheel_axismap = MakeAtom(EVDEV_PROP_WHEEL_AXES, strlen(EVDEV_PROP_WHEEL_AXES), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_axismap, XA_INTEGER, 8,
|
||||
PropModeReplace, 4, vals, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_axismap, FALSE);
|
||||
|
||||
prop_wheel_inertia = MakeAtom(EVDEV_PROP_WHEEL_INERTIA, strlen(EVDEV_PROP_WHEEL_INERTIA), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.inertia, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE);
|
||||
|
||||
prop_wheel_timeout = MakeAtom(EVDEV_PROP_WHEEL_TIMEOUT, strlen(EVDEV_PROP_WHEEL_TIMEOUT), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.timeout, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE);
|
||||
|
||||
prop_wheel_button = MakeAtom(EVDEV_PROP_WHEEL_BUTTON, strlen(EVDEV_PROP_WHEEL_BUTTON), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.button, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_button, FALSE);
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
1957
src/evdev.c
1957
src/evdev.c
File diff suppressed because it is too large
Load Diff
350
src/evdev.h
350
src/evdev.h
@@ -1,35 +1,6 @@
|
||||
/*
|
||||
* Copyright © 2006 Zephaniah E. Hull
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL 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 PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Author: Zephaniah E. Hull (warp@aehallh.com)
|
||||
*/
|
||||
/*
|
||||
* Copyright © 2004 Red Hat, Inc.
|
||||
* Copyright © 2004-2008 Red Hat, Inc.
|
||||
* Copyright © 2008 University of South Australia
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
@@ -42,227 +13,166 @@
|
||||
* for any purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* 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.
|
||||
*
|
||||
* Author: Kristian Høgsberg (krh@redhat.com)
|
||||
* Authors:
|
||||
* Kristian Høgsberg (krh@redhat.com)
|
||||
* Adam Jackson (ajax@redhat.com)
|
||||
* Peter Hutterer (peter@cs.unisa.edu.au)
|
||||
*/
|
||||
|
||||
#ifndef EVDEV_BRAIN_H_
|
||||
#define EVDEV_BRAIN_H_
|
||||
|
||||
#define _XF86_ANSIC_H
|
||||
#define XF86_LIBC_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#ifndef EVDEV_H
|
||||
#define EVDEV_H
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <xf86Xinput.h>
|
||||
#include <xf86_OSproc.h>
|
||||
|
||||
#ifndef BITS_PER_LONG
|
||||
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
|
||||
#ifdef XKB
|
||||
#include <xkbstr.h>
|
||||
#endif
|
||||
|
||||
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
|
||||
#define LONG(x) ((x)/BITS_PER_LONG)
|
||||
#define MASK(x) (1UL << ((x) & (BITS_PER_LONG - 1)))
|
||||
|
||||
#ifndef test_bit
|
||||
#define test_bit(bit, array) (!!(array[LONG(bit)] & MASK(bit)))
|
||||
#ifndef EV_CNT /* linux 2.4 kernels and earlier lack _CNT defines */
|
||||
#define EV_CNT (EV_MAX+1)
|
||||
#endif
|
||||
#ifndef set_bit
|
||||
#define set_bit(bit, array) (array[LONG(bit)] |= MASK(bit))
|
||||
#ifndef KEY_CNT
|
||||
#define KEY_CNT (KEY_MAX+1)
|
||||
#endif
|
||||
#ifndef clear_bit
|
||||
#define clear_bit(bit, array) (array[LONG(bit)] &= ~MASK(bit))
|
||||
#ifndef REL_CNT
|
||||
#define REL_CNT (REL_MAX+1)
|
||||
#endif
|
||||
#ifndef ABS_CNT
|
||||
#define ABS_CNT (ABS_MAX+1)
|
||||
#endif
|
||||
#ifndef LED_CNT
|
||||
#define LED_CNT (LED_MAX+1)
|
||||
#endif
|
||||
|
||||
/* 2.4 compatibility */
|
||||
#ifndef EVIOCGSW
|
||||
#define EVDEV_MAXBUTTONS 32
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
|
||||
|
||||
#define EV_SW 0x05
|
||||
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
|
||||
#define HAVE_PROPERTIES 1
|
||||
#endif
|
||||
|
||||
#ifndef EVIOCGRAB
|
||||
#define EVIOCGRAB _IOW('E', 0x90, int)
|
||||
#endif
|
||||
#define LONG_BITS (sizeof(long) * 8)
|
||||
|
||||
#ifndef BTN_TASK
|
||||
#define BTN_TASK 0x117
|
||||
#endif
|
||||
/* Number of longs needed to hold the given number of bits */
|
||||
#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
|
||||
|
||||
#ifndef EV_SYN
|
||||
#define EV_SYN EV_RST
|
||||
#endif
|
||||
/* end compat */
|
||||
|
||||
#include <X11/extensions/XKB.h>
|
||||
#include <X11/extensions/XKBstr.h>
|
||||
|
||||
|
||||
/*
|
||||
* Switch events
|
||||
*/
|
||||
|
||||
#define EV_SW_0 0x00
|
||||
#define EV_SW_1 0x01
|
||||
#define EV_SW_2 0x02
|
||||
#define EV_SW_3 0x03
|
||||
#define EV_SW_4 0x04
|
||||
#define EV_SW_5 0x05
|
||||
#define EV_SW_6 0x06
|
||||
#define EV_SW_7 0x07
|
||||
#define EV_SW_MAX 0x0f
|
||||
|
||||
#define EV_BUS_GSC 0x1A
|
||||
|
||||
#define EVDEV_MAXBUTTONS 96
|
||||
/* axis specific data for wheel emulation */
|
||||
typedef struct {
|
||||
int up_button;
|
||||
int down_button;
|
||||
int traveled_distance;
|
||||
} WheelAxis, *WheelAxisPtr;
|
||||
|
||||
typedef struct {
|
||||
unsigned long ev[NBITS(EV_MAX)];
|
||||
unsigned long key[NBITS(KEY_MAX)];
|
||||
unsigned long rel[NBITS(REL_MAX)];
|
||||
unsigned long abs[NBITS(ABS_MAX)];
|
||||
unsigned long msc[NBITS(MSC_MAX)];
|
||||
unsigned long led[NBITS(LED_MAX)];
|
||||
unsigned long snd[NBITS(SND_MAX)];
|
||||
unsigned long ff[NBITS(FF_MAX)];
|
||||
} evdevBitsRec, *evdevBitsPtr;
|
||||
const char *device;
|
||||
int grabDevice; /* grab the event device? */
|
||||
int screen;
|
||||
int min_x, min_y, max_x, max_y;
|
||||
int abs_x, abs_y, old_x, old_y;
|
||||
int flags;
|
||||
int tool;
|
||||
int buttons; /* number of buttons */
|
||||
BOOL swap_axes;
|
||||
BOOL invert_x;
|
||||
BOOL invert_y;
|
||||
|
||||
typedef struct {
|
||||
int real_buttons;
|
||||
int buttons;
|
||||
CARD8 map[EVDEV_MAXBUTTONS];
|
||||
int *state[EVDEV_MAXBUTTONS];
|
||||
} evdevBtnRec, *evdevBtnPtr;
|
||||
/* XKB stuff has to be per-device rather than per-driver */
|
||||
int noXkb;
|
||||
#ifdef XKB
|
||||
char *xkb_rules;
|
||||
char *xkb_model;
|
||||
char *xkb_layout;
|
||||
char *xkb_variant;
|
||||
char *xkb_options;
|
||||
XkbComponentNamesRec xkbnames;
|
||||
#endif
|
||||
/* Middle mouse button emulation */
|
||||
struct {
|
||||
BOOL enabled;
|
||||
BOOL pending; /* timer waiting? */
|
||||
int buttonstate; /* phys. button state */
|
||||
int state; /* state machine (see bt3emu.c) */
|
||||
Time expires; /* time of expiry */
|
||||
Time timeout;
|
||||
} emulateMB;
|
||||
struct {
|
||||
int meta; /* meta key to lock any button */
|
||||
BOOL meta_state; /* meta_button state */
|
||||
unsigned int lock_pair[EVDEV_MAXBUTTONS]; /* specify a meta/lock pair */
|
||||
BOOL lock_state[EVDEV_MAXBUTTONS]; /* state of any locked buttons */
|
||||
} dragLock;
|
||||
struct {
|
||||
BOOL enabled;
|
||||
int button;
|
||||
int button_state;
|
||||
int inertia;
|
||||
WheelAxis X;
|
||||
WheelAxis Y;
|
||||
Time expires; /* time of expiry */
|
||||
Time timeout;
|
||||
} emulateWheel;
|
||||
/* run-time calibration */
|
||||
struct {
|
||||
int min_x;
|
||||
int max_x;
|
||||
int min_y;
|
||||
int max_y;
|
||||
} calibration;
|
||||
|
||||
typedef struct {
|
||||
int axes;
|
||||
int n; /* Which abs_v is current, and which is previous. */
|
||||
int v[2][ABS_MAX];
|
||||
int count;
|
||||
int min[ABS_MAX];
|
||||
int max[ABS_MAX];
|
||||
int map[ABS_MAX];
|
||||
int scale[2];
|
||||
int screen; /* Screen number for this device. */
|
||||
} evdevAbsRec, *evdevAbsPtr;
|
||||
unsigned char btnmap[32]; /* config-file specified button mapping */
|
||||
|
||||
typedef struct {
|
||||
int axes;
|
||||
int v[REL_MAX];
|
||||
int count;
|
||||
int map[REL_MAX];
|
||||
} evdevRelRec, *evdevRelPtr;
|
||||
int reopen_attempts; /* max attempts to re-open after read failure */
|
||||
int reopen_left; /* number of attempts left to re-open the device */
|
||||
OsTimerPtr reopen_timer;
|
||||
|
||||
typedef struct {
|
||||
int axes;
|
||||
int v[ABS_MAX];
|
||||
int btnMap[ABS_MAX][2];
|
||||
} evdevAxesRec, *evdevAxesPtr;
|
||||
/* Cached info from device. */
|
||||
char name[1024];
|
||||
long bitmask[NLONGS(EV_CNT)];
|
||||
long key_bitmask[NLONGS(KEY_CNT)];
|
||||
long rel_bitmask[NLONGS(REL_CNT)];
|
||||
long abs_bitmask[NLONGS(ABS_CNT)];
|
||||
long led_bitmask[NLONGS(LED_CNT)];
|
||||
struct input_absinfo absinfo[ABS_CNT];
|
||||
|
||||
typedef struct {
|
||||
char *xkb_rules;
|
||||
char *xkb_model;
|
||||
char *xkb_layout;
|
||||
char *xkb_variant;
|
||||
char *xkb_options;
|
||||
XkbComponentNamesRec xkbnames;
|
||||
} evdevKeyRec, *evdevKeyPtr;
|
||||
/* minor/major number */
|
||||
dev_t min_maj;
|
||||
} EvdevRec, *EvdevPtr;
|
||||
|
||||
typedef struct _evdevState {
|
||||
Bool can_grab;
|
||||
Bool sync;
|
||||
int mode; /* Either Absolute or Relative. */
|
||||
unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);
|
||||
|
||||
evdevBtnPtr btn;
|
||||
evdevAbsPtr abs;
|
||||
evdevRelPtr rel;
|
||||
evdevKeyPtr key;
|
||||
evdevAxesPtr axes;
|
||||
} evdevStateRec, *evdevStatePtr;
|
||||
/* Middle Button emulation */
|
||||
int EvdevMBEmuTimer(InputInfoPtr);
|
||||
BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL);
|
||||
void EvdevMBEmuWakeupHandler(pointer, int, pointer);
|
||||
void EvdevMBEmuBlockHandler(pointer, struct timeval**, pointer);
|
||||
void EvdevMBEmuPreInit(InputInfoPtr);
|
||||
void EvdevMBEmuOn(InputInfoPtr);
|
||||
void EvdevMBEmuFinalize(InputInfoPtr);
|
||||
void EvdevMBEmuEnable(InputInfoPtr, BOOL);
|
||||
|
||||
typedef struct _evdevDevice {
|
||||
const char *name;
|
||||
const char *phys;
|
||||
const char *device;
|
||||
int seen;
|
||||
/* Mouse Wheel emulation */
|
||||
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
|
||||
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
|
||||
BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
|
||||
|
||||
InputInfoPtr pInfo;
|
||||
int (*callback)(DeviceIntPtr cb_data, int what);
|
||||
/* Draglock code */
|
||||
void EvdevDragLockPreInit(InputInfoPtr pInfo);
|
||||
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
|
||||
|
||||
evdevBitsRec bits;
|
||||
struct input_id id;
|
||||
|
||||
evdevStateRec state;
|
||||
|
||||
struct _evdevDevice *next;
|
||||
} evdevDeviceRec, *evdevDevicePtr;
|
||||
|
||||
typedef struct _evdevDriver {
|
||||
const char *name;
|
||||
const char *phys;
|
||||
const char *device;
|
||||
|
||||
evdevBitsRec all_bits;
|
||||
evdevBitsRec not_bits;
|
||||
evdevBitsRec any_bits;
|
||||
|
||||
struct input_id id;
|
||||
|
||||
int pass;
|
||||
|
||||
InputDriverPtr drv;
|
||||
IDevPtr dev;
|
||||
Bool (*callback)(struct _evdevDriver *driver, evdevDevicePtr device);
|
||||
evdevDevicePtr devices;
|
||||
Bool configured;
|
||||
|
||||
struct _evdevDriver *next;
|
||||
} evdevDriverRec, *evdevDriverPtr;
|
||||
|
||||
int evdevGetFDForDevice (evdevDevicePtr driver);
|
||||
Bool evdevStart (InputDriverPtr drv);
|
||||
Bool evdevNewDriver (evdevDriverPtr driver);
|
||||
Bool evdevGetBits (int fd, evdevBitsPtr bits);
|
||||
|
||||
int EvdevBtnInit (DeviceIntPtr device);
|
||||
int EvdevBtnOn (DeviceIntPtr device);
|
||||
int EvdevBtnOff (DeviceIntPtr device);
|
||||
int EvdevBtnNew(InputInfoPtr pInfo);
|
||||
void EvdevBtnProcess (InputInfoPtr pInfo, struct input_event *ev);
|
||||
void EvdevBtnPostFakeClicks(InputInfoPtr pInfo, int button, int count);
|
||||
|
||||
int EvdevAxesInit (DeviceIntPtr device);
|
||||
int EvdevAxesOn (DeviceIntPtr device);
|
||||
int EvdevAxesOff (DeviceIntPtr device);
|
||||
int EvdevAxesNew(InputInfoPtr pInfo);
|
||||
void EvdevAxesAbsProcess (InputInfoPtr pInfo, struct input_event *ev);
|
||||
void EvdevAxesRelProcess (InputInfoPtr pInfo, struct input_event *ev);
|
||||
void EvdevAxesSyn (InputInfoPtr pInfo);
|
||||
|
||||
int EvdevKeyInit (DeviceIntPtr device);
|
||||
int EvdevKeyNew (InputInfoPtr pInfo);
|
||||
int EvdevKeyOn (DeviceIntPtr device);
|
||||
int EvdevKeyOff (DeviceIntPtr device);
|
||||
void EvdevKeyProcess (InputInfoPtr pInfo, struct input_event *ev);
|
||||
|
||||
#endif /* LNX_EVDEV_H_ */
|
||||
#ifdef HAVE_PROPERTIES
|
||||
void EvdevMBEmuInitProperty(DeviceIntPtr);
|
||||
void EvdevWheelEmuInitProperty(DeviceIntPtr);
|
||||
void EvdevDragLockInitProperty(DeviceIntPtr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
543
src/evdev_axes.c
543
src/evdev_axes.c
@@ -1,543 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2006 Zephaniah E. Hull
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL 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 PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Author: Zephaniah E. Hull (warp@aehallh.com)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/extensions/XIproto.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "evdev.h"
|
||||
|
||||
#include <xf86.h>
|
||||
|
||||
#include <xf86Module.h>
|
||||
#include <mipointer.h>
|
||||
|
||||
|
||||
#include <xf86_OSproc.h>
|
||||
|
||||
static char *rel_axis_names[] = {
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"RX",
|
||||
"RY",
|
||||
"RZ",
|
||||
"HWHEEL",
|
||||
"DIAL",
|
||||
"WHEEL",
|
||||
"MISC",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *abs_axis_names[] = {
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"RX",
|
||||
"RY",
|
||||
"RZ",
|
||||
"THROTTLE",
|
||||
"RUDDER",
|
||||
"WHEEL",
|
||||
"GAS",
|
||||
"BRAKE",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"HAT0X",
|
||||
"HAT0Y",
|
||||
"HAT1X",
|
||||
"HAT1Y",
|
||||
"HAT2X",
|
||||
"HAT2Y",
|
||||
"HAT3X",
|
||||
"HAT3Y",
|
||||
"PRESSURE",
|
||||
"TILT_X",
|
||||
"TILT_Y",
|
||||
"TOOL_WIDTH",
|
||||
"VOLUME",
|
||||
"29",
|
||||
"30",
|
||||
"31",
|
||||
"32",
|
||||
"33",
|
||||
"34",
|
||||
"35",
|
||||
"36",
|
||||
"37",
|
||||
"38",
|
||||
"39",
|
||||
"MISC",
|
||||
"41",
|
||||
"42",
|
||||
"43",
|
||||
"44",
|
||||
"45",
|
||||
"46",
|
||||
"47",
|
||||
"48",
|
||||
"49",
|
||||
"50",
|
||||
"51",
|
||||
"52",
|
||||
"53",
|
||||
"54",
|
||||
"55",
|
||||
"56",
|
||||
"57",
|
||||
"58",
|
||||
"59",
|
||||
"60",
|
||||
"61",
|
||||
"62",
|
||||
NULL
|
||||
};
|
||||
|
||||
static Bool
|
||||
EvdevConvert(InputInfoPtr pInfo, int first, int num, int v0, int v1, int v2,
|
||||
int v3, int v4, int v5, int *x, int *y)
|
||||
{
|
||||
if (first == 0) {
|
||||
*x = v0;
|
||||
*y = v1;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevAxesRealSyn (InputInfoPtr pInfo, int absolute)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
evdevAxesPtr axes = state->axes;
|
||||
int i, btn;
|
||||
|
||||
for (i = 0; i < state->axes->axes; i++) {
|
||||
if ((state->axes->v[i] > 0) && (btn = state->axes->btnMap[i][0]))
|
||||
EvdevBtnPostFakeClicks (pInfo, btn, state->axes->v[i]);
|
||||
else if ((state->axes->v[i] < 0) && (btn = state->axes->btnMap[i][1]))
|
||||
EvdevBtnPostFakeClicks (pInfo, btn, -state->axes->v[i]);
|
||||
}
|
||||
|
||||
xf86PostMotionEvent(pInfo->dev, absolute, 0,
|
||||
state->axes->axes,
|
||||
axes->v[0x00], axes->v[0x01], axes->v[0x02], axes->v[0x03],
|
||||
axes->v[0x04], axes->v[0x05], axes->v[0x06], axes->v[0x07],
|
||||
axes->v[0x08], axes->v[0x09], axes->v[0x0a], axes->v[0x0b],
|
||||
axes->v[0x0c], axes->v[0x0d], axes->v[0x0e], axes->v[0x0f],
|
||||
axes->v[0x10], axes->v[0x11], axes->v[0x12], axes->v[0x13],
|
||||
axes->v[0x14], axes->v[0x15], axes->v[0x16], axes->v[0x17],
|
||||
axes->v[0x18], axes->v[0x19], axes->v[0x1a], axes->v[0x1b],
|
||||
axes->v[0x1c], axes->v[0x1d], axes->v[0x1e], axes->v[0x1f],
|
||||
axes->v[0x20], axes->v[0x21], axes->v[0x22], axes->v[0x23],
|
||||
axes->v[0x24], axes->v[0x25], axes->v[0x26], axes->v[0x27],
|
||||
axes->v[0x28], axes->v[0x29], axes->v[0x2a], axes->v[0x2b],
|
||||
axes->v[0x2c], axes->v[0x2d], axes->v[0x2e], axes->v[0x2f],
|
||||
axes->v[0x30], axes->v[0x31], axes->v[0x32], axes->v[0x33],
|
||||
axes->v[0x34], axes->v[0x35], axes->v[0x36], axes->v[0x37],
|
||||
axes->v[0x38], axes->v[0x39], axes->v[0x3a], axes->v[0x3b],
|
||||
axes->v[0x3c], axes->v[0x3d], axes->v[0x3e], axes->v[0x3f]);
|
||||
|
||||
for (i = 0; i < ABS_MAX; i++)
|
||||
state->axes->v[i] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevAxesAbsSyn (InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int i, n;
|
||||
|
||||
if (!state->axes || !state->abs || !state->abs->count)
|
||||
return;
|
||||
|
||||
n = state->abs->n & 1;
|
||||
state->abs->n++;
|
||||
i = 0;
|
||||
|
||||
if (state->mode == Relative && state->abs->axes >= 2) {
|
||||
for (i = 0; i < 2; i++)
|
||||
state->axes->v[i] = state->abs->v[n][i] - state->abs->v[!n][i];
|
||||
EvdevAxesRealSyn (pInfo, 0);
|
||||
} else if (state->mode == Absolute && state->abs->screen >= 0 && state->abs->axes >= 2) {
|
||||
int conv_x, conv_y;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
state->axes->v[i] = xf86ScaleAxis (state->abs->v[n][i],
|
||||
0, state->abs->scale[i],
|
||||
state->abs->min[i], state->abs->max[i]);
|
||||
|
||||
|
||||
EvdevConvert (pInfo, 0, 2, state->abs->v[n][0], state->abs->v[n][1],
|
||||
0, 0, 0, 0, &conv_x, &conv_y);
|
||||
xf86XInputSetScreen (pInfo, state->abs->screen, conv_x, conv_y);
|
||||
}
|
||||
|
||||
for (; i < ABS_MAX; i++)
|
||||
state->axes->v[i] = state->abs->v[n][i];
|
||||
|
||||
EvdevAxesRealSyn (pInfo, 1);
|
||||
state->abs->count = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevAxesRelSyn (InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int i;
|
||||
|
||||
if (!state->axes || !state->rel || !state->rel->count)
|
||||
return;
|
||||
|
||||
for (i = 0; i < REL_MAX; i++) {
|
||||
state->axes->v[i] = state->rel->v[i];
|
||||
state->rel->v[i] = 0;
|
||||
}
|
||||
|
||||
EvdevAxesRealSyn (pInfo, 0);
|
||||
state->rel->count = 0;
|
||||
}
|
||||
|
||||
void
|
||||
EvdevAxesSyn (InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevAxesAbsSyn (pInfo);
|
||||
EvdevAxesRelSyn (pInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EvdevAxesAbsProcess (InputInfoPtr pInfo, struct input_event *ev)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int n = state->abs->n & 1;
|
||||
int map;
|
||||
|
||||
if (ev->code >= ABS_MAX)
|
||||
return;
|
||||
|
||||
/* FIXME: Handle inverted axes properly. */
|
||||
map = state->abs->map[ev->code];
|
||||
if (map >= 0)
|
||||
state->abs->v[n][map] = ev->value;
|
||||
else
|
||||
state->abs->v[n][-map] = ev->value;
|
||||
|
||||
state->abs->count++;
|
||||
|
||||
if (!state->sync)
|
||||
EvdevAxesAbsSyn (pInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EvdevAxesRelProcess (InputInfoPtr pInfo, struct input_event *ev)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int map;
|
||||
|
||||
if (ev->code >= REL_MAX)
|
||||
return;
|
||||
|
||||
map = state->rel->map[ev->code];
|
||||
if (map >= 0)
|
||||
state->rel->v[map] += ev->value;
|
||||
else
|
||||
state->rel->v[-map] -= ev->value;
|
||||
|
||||
state->rel->count++;
|
||||
|
||||
if (!state->sync)
|
||||
EvdevAxesRelSyn (pInfo);
|
||||
}
|
||||
|
||||
int
|
||||
EvdevAxesOn (DeviceIntPtr device)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
EvdevAxesOff (DeviceIntPtr device)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
EvdevAxisAbsNew(InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
struct input_absinfo absinfo;
|
||||
char *s, option[64];
|
||||
int i, j, k = 0, real_axes;
|
||||
|
||||
real_axes = 0;
|
||||
for (i = 0; i < ABS_MAX; i++)
|
||||
if (test_bit (i, pEvdev->bits.abs))
|
||||
real_axes++;
|
||||
|
||||
if (!real_axes)
|
||||
return !Success;
|
||||
|
||||
state->abs = Xcalloc (sizeof (evdevAbsRec));
|
||||
|
||||
xf86Msg(X_INFO, "%s: Found %d absolute axes.\n", pInfo->name, real_axes);
|
||||
xf86Msg(X_INFO, "%s: Configuring as pointer.\n", pInfo->name);
|
||||
pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
|
||||
XI86_CONFIGURED;
|
||||
pInfo->type_name = XI_MOUSE;
|
||||
pInfo->conversion_proc = EvdevConvert;
|
||||
|
||||
for (i = 0, j = 0; i < ABS_MAX; i++) {
|
||||
if (!test_bit (i, pEvdev->bits.abs))
|
||||
continue;
|
||||
|
||||
snprintf(option, sizeof(option), "%sAbsoluteAxisMap", abs_axis_names[i]);
|
||||
k = xf86SetIntOption(pInfo->options, option, -1);
|
||||
if (k != -1)
|
||||
state->abs->map[i] = k;
|
||||
else
|
||||
state->abs->map[i] = j;
|
||||
|
||||
if (k != -1)
|
||||
xf86Msg(X_CONFIG, "%s: %s: %d.\n", pInfo->name, option, k);
|
||||
|
||||
if (ioctl (pInfo->fd, EVIOCGABS(i), &absinfo) < 0) {
|
||||
xf86Msg(X_ERROR, "ioctl EVIOCGABS failed: %s\n", strerror(errno));
|
||||
return !Success;
|
||||
}
|
||||
state->abs->min[state->abs->map[i]] = absinfo.minimum;
|
||||
state->abs->max[state->abs->map[i]] = absinfo.maximum;
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
state->abs->axes = real_axes;
|
||||
for (i = 0; i < ABS_MAX; i++) {
|
||||
if (state->abs->map[i] > state->abs->axes)
|
||||
state->abs->axes = state->abs->map[i];
|
||||
}
|
||||
|
||||
if (state->abs->axes != real_axes)
|
||||
xf86Msg(X_CONFIG, "%s: Configuring %d absolute axes.\n", pInfo->name,
|
||||
state->abs->axes);
|
||||
|
||||
s = xf86SetStrOption(pInfo->options, "Mode", "Absolute");
|
||||
if (!strcasecmp(s, "Absolute")) {
|
||||
state->mode = Absolute;
|
||||
xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s);
|
||||
} else if (!strcasecmp(s, "Relative")) {
|
||||
state->mode = Relative;
|
||||
xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s);
|
||||
} else {
|
||||
state->mode = Absolute;
|
||||
xf86Msg(X_CONFIG, "%s: Unknown Mode: %s.\n", pInfo->name, s);
|
||||
}
|
||||
|
||||
if (test_bit (ABS_X, pEvdev->bits.abs) && test_bit (ABS_Y, pEvdev->bits.abs))
|
||||
k = xf86SetIntOption(pInfo->options, "AbsoluteScreen", 0);
|
||||
else
|
||||
k = xf86SetIntOption(pInfo->options, "AbsoluteScreen", -1);
|
||||
if (k < screenInfo.numScreens && k >= 0) {
|
||||
state->abs->screen = k;
|
||||
xf86Msg(X_CONFIG, "%s: AbsoluteScreen: %d.\n", pInfo->name, k);
|
||||
} else {
|
||||
state->abs->screen = 0;
|
||||
xf86Msg(X_CONFIG, "%s: AbsoluteScreen: %d is not a valid screen.\n", pInfo->name, k);
|
||||
}
|
||||
|
||||
state->abs->scale[0] = screenInfo.screens[state->abs->screen]->width;
|
||||
state->abs->scale[1] = screenInfo.screens[state->abs->screen]->height;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
EvdevAxisRelNew(InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
char *s, option[64];
|
||||
int i, j, k = 0, real_axes;
|
||||
|
||||
real_axes = 0;
|
||||
for (i = 0; i < REL_MAX; i++)
|
||||
if (test_bit (i, pEvdev->bits.rel))
|
||||
real_axes++;
|
||||
|
||||
if (!real_axes && (!state->abs || state->abs->axes < 2))
|
||||
return !Success;
|
||||
|
||||
state->rel = Xcalloc (sizeof (evdevRelRec));
|
||||
|
||||
xf86Msg(X_INFO, "%s: Found %d relative axes.\n", pInfo->name,
|
||||
real_axes);
|
||||
xf86Msg(X_INFO, "%s: Configuring as pointer.\n", pInfo->name);
|
||||
pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
|
||||
XI86_CONFIGURED;
|
||||
pInfo->type_name = XI_MOUSE;
|
||||
pInfo->conversion_proc = EvdevConvert;
|
||||
|
||||
for (i = 0, j = 0; i < REL_MAX; i++) {
|
||||
if (!test_bit (i, pEvdev->bits.rel))
|
||||
continue;
|
||||
|
||||
snprintf(option, sizeof(option), "%sRelativeAxisMap", rel_axis_names[i]);
|
||||
s = xf86SetStrOption(pInfo->options, option, "0");
|
||||
if (s && (k = strtol(s, NULL, 0)))
|
||||
state->rel->map[i] = k;
|
||||
else
|
||||
state->rel->map[i] = j;
|
||||
|
||||
if (s && k)
|
||||
xf86Msg(X_CONFIG, "%s: %s: %d.\n", pInfo->name, option, k);
|
||||
|
||||
|
||||
snprintf(option, sizeof(option), "%sRelativeAxisButtons", rel_axis_names[i]);
|
||||
if (i == REL_WHEEL || i == REL_Z)
|
||||
s = xf86SetStrOption(pInfo->options, option, "4 5");
|
||||
else if (i == REL_HWHEEL)
|
||||
s = xf86SetStrOption(pInfo->options, option, "6 7");
|
||||
else
|
||||
s = xf86SetStrOption(pInfo->options, option, "0 0");
|
||||
|
||||
k = state->rel->map[i];
|
||||
|
||||
if (!s || (sscanf(s, "%d %d", &state->axes->btnMap[k][0],
|
||||
&state->axes->btnMap[k][1]) != 2))
|
||||
state->axes->btnMap[k][0] = state->axes->btnMap[k][1] = 0;
|
||||
|
||||
if (state->axes->btnMap[k][0] || state->axes->btnMap[k][1])
|
||||
xf86Msg(X_CONFIG, "%s: %s: %d %d.\n", pInfo->name, option,
|
||||
state->axes->btnMap[k][0], state->axes->btnMap[k][1]);
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
state->rel->axes = real_axes;
|
||||
for (i = 0; i < REL_MAX; i++)
|
||||
if (state->rel->map[i] > state->rel->axes)
|
||||
state->rel->axes = state->rel->map[i];
|
||||
|
||||
if (state->abs && (state->abs->axes >= 2) && (state->rel->axes < 2))
|
||||
state->rel->axes = 2;
|
||||
|
||||
if (state->rel->axes != real_axes)
|
||||
xf86Msg(X_CONFIG, "%s: Configuring %d relative axes.\n", pInfo->name,
|
||||
state->rel->axes);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
EvdevAxesNew (InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int ret = Success;
|
||||
|
||||
state->axes = Xcalloc (sizeof (evdevAxesRec));
|
||||
if (EvdevAxisAbsNew(pInfo) != Success)
|
||||
ret = !Success;
|
||||
if (EvdevAxisRelNew(pInfo) != Success)
|
||||
ret = !Success;
|
||||
if (!state->abs && !state->rel) {
|
||||
Xfree (state->axes);
|
||||
state->axes = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
EvdevPtrCtrlProc(DeviceIntPtr device, PtrCtrl *ctrl)
|
||||
{
|
||||
/* Nothing to do, dix handles all settings */
|
||||
}
|
||||
|
||||
int
|
||||
EvdevAxesInit (DeviceIntPtr device)
|
||||
{
|
||||
InputInfoPtr pInfo = device->public.devicePrivate;
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int i, axes = 0;
|
||||
|
||||
if (state->abs && state->abs->axes > axes)
|
||||
axes = state->abs->axes;
|
||||
if (state->rel && state->rel->axes > axes)
|
||||
axes = state->rel->axes;
|
||||
|
||||
state->axes->axes = axes;
|
||||
|
||||
xf86Msg(X_CONFIG, "%s: %d valuators.\n", pInfo->name,
|
||||
axes);
|
||||
if (!axes)
|
||||
return Success;
|
||||
|
||||
if (!InitValuatorClassDeviceStruct(device, axes,
|
||||
miPointerGetMotionEvents,
|
||||
miPointerGetMotionBufferSize(), 0))
|
||||
return !Success;
|
||||
|
||||
for (i = 0; i < axes; i++) {
|
||||
xf86InitValuatorAxisStruct(device, i, 0, 0, 0, 0, 1);
|
||||
xf86InitValuatorDefaults(device, i);
|
||||
}
|
||||
|
||||
if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc))
|
||||
return !Success;
|
||||
|
||||
xf86MotionHistoryAllocate (pInfo);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
@@ -1,487 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2006 Zephaniah E. Hull
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL 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 PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Author: Zephaniah E. Hull (warp@aehallh.com)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evdev.h"
|
||||
|
||||
#include "xf86_OSlib.h"
|
||||
|
||||
#include <xf86.h>
|
||||
#include <fnmatch.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
#include "inotify.h"
|
||||
#include "inotify-syscalls.h"
|
||||
|
||||
#ifndef SYSCALL
|
||||
#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
|
||||
#endif
|
||||
|
||||
static Bool evdev_alive = FALSE;
|
||||
static InputInfoPtr evdev_pInfo = NULL;
|
||||
static evdevDriverPtr evdev_drivers = NULL;
|
||||
static int evdev_seq;
|
||||
static int evdev_inotify;
|
||||
|
||||
int
|
||||
evdevGetFDForDevice (evdevDevicePtr device)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!device)
|
||||
return -1;
|
||||
|
||||
|
||||
if (device->device) {
|
||||
SYSCALL(fd = open (device->device, O_RDWR | O_NONBLOCK));
|
||||
if (fd == -1)
|
||||
xf86Msg(X_ERROR, "%s (%d): Open failed: %s\n", __FILE__, __LINE__, strerror(errno));
|
||||
return fd;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define device_add(driver,device) do { \
|
||||
device->next = driver->devices; \
|
||||
driver->devices = device; \
|
||||
} while (0)
|
||||
|
||||
typedef struct {
|
||||
evdevBitsRec bits;
|
||||
char name[256];
|
||||
char phys[256];
|
||||
char dev[256];
|
||||
struct input_id id;
|
||||
} evdevDevInfoRec, *evdevDevInfoPtr;
|
||||
|
||||
static Bool
|
||||
MatchAll (unsigned long *dev, unsigned long *match, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if ((dev[i] & match[i]) != match[i])
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
MatchNot (unsigned long *dev, unsigned long *match, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if ((dev[i] & match[i]))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
MatchAny (unsigned long *dev, unsigned long *match, int len)
|
||||
{
|
||||
int i, found = 0;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (match[i]) {
|
||||
found = 1;
|
||||
if ((dev[i] & match[i]))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (found)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
MatchDriver (evdevDriverPtr driver, evdevDevInfoPtr info)
|
||||
{
|
||||
if (driver->name && fnmatch(driver->name, info->name, 0))
|
||||
return FALSE;
|
||||
if (driver->phys && fnmatch(driver->phys, info->phys, 0))
|
||||
return FALSE;
|
||||
if (driver->device && fnmatch(driver->device, info->dev, 0))
|
||||
return FALSE;
|
||||
|
||||
if (driver->id.bustype && driver->id.bustype != info->id.bustype)
|
||||
return FALSE;
|
||||
if (driver->id.vendor && driver->id.vendor != info->id.vendor)
|
||||
return FALSE;
|
||||
if (driver->id.product && driver->id.product != info->id.product)
|
||||
return FALSE;
|
||||
if (driver->id.version && driver->id.version != info->id.version)
|
||||
return FALSE;
|
||||
|
||||
#define match(which) \
|
||||
if (!MatchAll(info->bits.which, driver->all_bits.which, \
|
||||
sizeof(driver->all_bits.which) / \
|
||||
sizeof(driver->all_bits.which[0]))) \
|
||||
return FALSE; \
|
||||
if (!MatchNot(info->bits.which, driver->not_bits.which, \
|
||||
sizeof(driver->not_bits.which) / \
|
||||
sizeof(driver->not_bits.which[0]))) \
|
||||
return FALSE; \
|
||||
if (!MatchAny(info->bits.which, driver->any_bits.which, \
|
||||
sizeof(driver->any_bits.which) / \
|
||||
sizeof(driver->any_bits.which[0]))) \
|
||||
return FALSE;
|
||||
|
||||
match(ev)
|
||||
match(key)
|
||||
match(rel)
|
||||
match(abs)
|
||||
match(msc)
|
||||
match(led)
|
||||
match(snd)
|
||||
match(ff)
|
||||
|
||||
#undef match
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
MatchDevice (evdevDevicePtr device, evdevDevInfoPtr info)
|
||||
{
|
||||
int i, len;
|
||||
|
||||
if (device->id.bustype != info->id.bustype)
|
||||
return FALSE;
|
||||
if (device->id.vendor != info->id.vendor)
|
||||
return FALSE;
|
||||
if (device->id.product != info->id.product)
|
||||
return FALSE;
|
||||
if (device->id.version != info->id.version)
|
||||
return FALSE;
|
||||
|
||||
if (strcmp(device->name, info->name))
|
||||
return FALSE;
|
||||
|
||||
len = sizeof(info->bits.ev) / sizeof(info->bits.ev[0]);
|
||||
for (i = 0; i < len; i++)
|
||||
if (device->bits.ev[i] != info->bits.ev[i])
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
evdevScanDevice (evdevDriverPtr driver, evdevDevInfoPtr info)
|
||||
{
|
||||
evdevDevicePtr device;
|
||||
int found;
|
||||
|
||||
if (!MatchDriver (driver, info))
|
||||
return FALSE;
|
||||
|
||||
found = 0;
|
||||
for (device = driver->devices; device; device = device->next) {
|
||||
if (MatchDevice (device, info)) {
|
||||
if (device->seen != (evdev_seq - 1)) {
|
||||
device->device = xstrdup(info->dev);
|
||||
device->phys = xstrdup(info->phys);
|
||||
device->callback(device->pInfo->dev, DEVICE_ON);
|
||||
}
|
||||
|
||||
device->seen = evdev_seq;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
device = Xcalloc (sizeof (evdevDeviceRec));
|
||||
|
||||
device->device = xstrdup(info->dev);
|
||||
device->name = xstrdup(info->name);
|
||||
device->phys = xstrdup(info->phys);
|
||||
device->id.bustype = info->id.bustype;
|
||||
device->id.vendor = info->id.vendor;
|
||||
device->id.product = info->id.product;
|
||||
device->id.version = info->id.version;
|
||||
device->seen = evdev_seq;
|
||||
device_add(driver, device);
|
||||
driver->callback(driver, device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
FillDevInfo (char *dev, evdevDevInfoPtr info)
|
||||
{
|
||||
int fd;
|
||||
|
||||
SYSCALL(fd = open (dev, O_RDWR | O_NONBLOCK));
|
||||
if (fd == -1)
|
||||
return FALSE;
|
||||
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(info->name)), info->name) == -1)
|
||||
info->name[0] = '\0';
|
||||
if (ioctl(fd, EVIOCGPHYS(sizeof(info->phys)), info->phys) == -1)
|
||||
info->phys[0] = '\0';
|
||||
if (ioctl(fd, EVIOCGID, &info->id) == -1) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
if (!evdevGetBits (fd, &info->bits)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strncpy (info->dev, dev, sizeof(info->dev));
|
||||
close (fd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
evdevRescanDevices (InputInfoPtr pInfo)
|
||||
{
|
||||
char dev[20];
|
||||
int i, j, found;
|
||||
evdevDriverPtr driver;
|
||||
evdevDevicePtr device;
|
||||
evdevDevInfoRec info;
|
||||
|
||||
evdev_seq++;
|
||||
xf86Msg(X_INFO, "%s: Rescanning devices (%d).\n", pInfo->name, evdev_seq);
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
snprintf(dev, sizeof(dev), "/dev/input/event%d", i);
|
||||
|
||||
if (!FillDevInfo (dev, &info))
|
||||
continue;
|
||||
|
||||
found = 0;
|
||||
|
||||
for (j = 0; j <= 3 && !found; j++) {
|
||||
for (driver = evdev_drivers; driver && !found; driver = driver->next) {
|
||||
if ((driver->pass == j) && (found = evdevScanDevice (driver, &info)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (driver = evdev_drivers; driver; driver = driver->next)
|
||||
for (device = driver->devices; device; device = device->next)
|
||||
if (device->seen == (evdev_seq - 1)) {
|
||||
device->callback(device->pInfo->dev, DEVICE_OFF);
|
||||
|
||||
if (device->device)
|
||||
xfree(device->device);
|
||||
device->device = NULL;
|
||||
|
||||
if (device->phys)
|
||||
xfree(device->phys);
|
||||
device->phys = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
evdevReadInput (InputInfoPtr pInfo)
|
||||
{
|
||||
int scan = 0, i, len;
|
||||
char buf[4096];
|
||||
struct inotify_event *event;
|
||||
|
||||
if (evdev_inotify) {
|
||||
while ((len = read (pInfo->fd, buf, sizeof(buf))) >= 0) {
|
||||
for (i = 0; i < len; i += sizeof (struct inotify_event) + event->len) {
|
||||
event = (struct inotify_event *) &buf[i];
|
||||
if (!event->len)
|
||||
continue;
|
||||
if (event->mask & IN_ISDIR)
|
||||
continue;
|
||||
if (strncmp("event", event->name, 5))
|
||||
continue;
|
||||
scan = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (scan)
|
||||
evdevRescanDevices (pInfo);
|
||||
} else {
|
||||
/*
|
||||
* XXX: Freezing the server for a moment is not really friendly.
|
||||
* But we need to wait until udev has actually created the device.
|
||||
*/
|
||||
usleep (500000);
|
||||
evdevRescanDevices (pInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
evdevControl(DeviceIntPtr pPointer, int what)
|
||||
{
|
||||
InputInfoPtr pInfo;
|
||||
int i, flags;
|
||||
|
||||
pInfo = pPointer->public.devicePrivate;
|
||||
|
||||
switch (what) {
|
||||
case DEVICE_INIT:
|
||||
pPointer->public.on = FALSE;
|
||||
break;
|
||||
|
||||
case DEVICE_ON:
|
||||
/*
|
||||
* XXX: We do /proc/bus/usb/devices instead of /proc/bus/input/devices
|
||||
* because the only hotplug input devices at the moment are USB...
|
||||
* And because the latter is useless to poll/select against.
|
||||
* FIXME: Get a patch in the kernel which fixes the latter.
|
||||
*/
|
||||
evdev_inotify = 1;
|
||||
SYSCALL(pInfo->fd = inotify_init());
|
||||
if (pInfo->fd < 0) {
|
||||
xf86Msg(X_ERROR, "%s: Unable to initialize inotify, using fallback. (errno: %d)\n", pInfo->name, errno);
|
||||
evdev_inotify = 0;
|
||||
}
|
||||
SYSCALL (i = inotify_add_watch (pInfo->fd, "/dev/input/", IN_CREATE | IN_DELETE));
|
||||
if (i < 0) {
|
||||
xf86Msg(X_ERROR, "%s: Unable to initialize inotify, using fallback. (errno: %d)\n", pInfo->name, errno);
|
||||
evdev_inotify = 0;
|
||||
SYSCALL (close (pInfo->fd));
|
||||
pInfo->fd = -1;
|
||||
}
|
||||
if ((flags = fcntl(pInfo->fd, F_GETFL)) < 0) {
|
||||
xf86Msg(X_ERROR, "%s: Unable to NONBLOCK inotify, using fallback. "
|
||||
"(errno: %d)\n", pInfo->name, errno);
|
||||
evdev_inotify = 0;
|
||||
SYSCALL (close (pInfo->fd));
|
||||
pInfo->fd = -1;
|
||||
} else if (fcntl(pInfo->fd, F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||
xf86Msg(X_ERROR, "%s: Unable to NONBLOCK inotify, using fallback. "
|
||||
"(errno: %d)\n", pInfo->name, errno);
|
||||
evdev_inotify = 0;
|
||||
SYSCALL (close (pInfo->fd));
|
||||
pInfo->fd = -1;
|
||||
}
|
||||
|
||||
if (!evdev_inotify) {
|
||||
SYSCALL (pInfo->fd = open ("/proc/bus/usb/devices", O_RDONLY));
|
||||
if (pInfo->fd < 0) {
|
||||
xf86Msg(X_ERROR, "%s: cannot open /proc/bus/usb/devices.\n", pInfo->name);
|
||||
return BadRequest;
|
||||
}
|
||||
}
|
||||
xf86FlushInput(pInfo->fd);
|
||||
AddEnabledDevice(pInfo->fd);
|
||||
pPointer->public.on = TRUE;
|
||||
evdevRescanDevices (pInfo);
|
||||
break;
|
||||
|
||||
case DEVICE_OFF:
|
||||
case DEVICE_CLOSE:
|
||||
if (pInfo->fd != -1) {
|
||||
RemoveEnabledDevice(pInfo->fd);
|
||||
SYSCALL (close (pInfo->fd));
|
||||
pInfo->fd = -1;
|
||||
}
|
||||
pPointer->public.on = FALSE;
|
||||
break;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
Bool
|
||||
evdevStart (InputDriverPtr drv)
|
||||
{
|
||||
InputInfoRec *pInfo;
|
||||
|
||||
if (evdev_alive)
|
||||
return TRUE;
|
||||
|
||||
if (!(pInfo = xf86AllocateInput(drv, 0)))
|
||||
return FALSE;
|
||||
|
||||
evdev_alive = TRUE;
|
||||
|
||||
pInfo->name = "evdev brain";
|
||||
pInfo->type_name = "evdev brain";
|
||||
pInfo->device_control = evdevControl;
|
||||
pInfo->read_input = evdevReadInput;
|
||||
pInfo->fd = -1;
|
||||
pInfo->flags = XI86_CONFIGURED | XI86_OPEN_ON_INIT;
|
||||
|
||||
evdev_pInfo = pInfo;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
evdevNewDriver (evdevDriverPtr driver)
|
||||
{
|
||||
if (!evdev_alive)
|
||||
return FALSE;
|
||||
/* FIXME: Make this check valid given all the ways to look. */
|
||||
#if 0
|
||||
if (!(driver->name || driver->phys || driver->device))
|
||||
return FALSE;
|
||||
#endif
|
||||
if (!driver->callback)
|
||||
return FALSE;
|
||||
|
||||
driver->next = evdev_drivers;
|
||||
evdev_drivers = driver;
|
||||
|
||||
evdevRescanDevices (evdev_pInfo);
|
||||
driver->configured = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
evdevGetBits (int fd, evdevBitsPtr bits)
|
||||
{
|
||||
#define get_bitmask(fd, which, where) \
|
||||
if (ioctl(fd, EVIOCGBIT(which, sizeof (where)), where) < 0) { \
|
||||
xf86Msg(X_ERROR, "ioctl EVIOCGBIT %s failed: %s\n", #which, strerror(errno)); \
|
||||
return FALSE; \
|
||||
}
|
||||
|
||||
get_bitmask (fd, 0, bits->ev);
|
||||
get_bitmask (fd, EV_KEY, bits->key);
|
||||
get_bitmask (fd, EV_REL, bits->rel);
|
||||
get_bitmask (fd, EV_ABS, bits->abs);
|
||||
get_bitmask (fd, EV_MSC, bits->msc);
|
||||
get_bitmask (fd, EV_LED, bits->led);
|
||||
get_bitmask (fd, EV_SND, bits->snd);
|
||||
get_bitmask (fd, EV_FF, bits->ff);
|
||||
|
||||
#undef get_bitmask
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
237
src/evdev_btn.c
237
src/evdev_btn.c
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2006 Zephaniah E. Hull
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL 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 PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Author: Zephaniah E. Hull (warp@aehallh.com)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evdev.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/extensions/XIproto.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <misc.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86str.h>
|
||||
#include <xf86_OSproc.h>
|
||||
#include <xf86Xinput.h>
|
||||
#include <exevents.h>
|
||||
#include <mipointer.h>
|
||||
|
||||
#include <xf86Module.h>
|
||||
|
||||
void
|
||||
EvdevBtnPostFakeClicks(InputInfoPtr pInfo, int button, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0);
|
||||
xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
EvdevBtnInit (DeviceIntPtr device)
|
||||
{
|
||||
InputInfoPtr pInfo = device->public.devicePrivate;
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
CARD8 *map;
|
||||
int i;
|
||||
|
||||
if (!pEvdev->state.btn)
|
||||
return Success;
|
||||
|
||||
map = Xcalloc (sizeof (CARD8) * (pEvdev->state.btn->buttons + 1));
|
||||
|
||||
for (i = 0; i <= pEvdev->state.btn->buttons; i++)
|
||||
map[i] = i;
|
||||
|
||||
xf86Msg(X_CONFIG, "%s (%d): Registering %d buttons.\n", __FILE__, __LINE__,
|
||||
pEvdev->state.btn->buttons);
|
||||
if (!InitButtonClassDeviceStruct (device, pEvdev->state.btn->buttons, map)) {
|
||||
pEvdev->state.btn->buttons = 0;
|
||||
|
||||
return !Success;
|
||||
}
|
||||
|
||||
Xfree (map);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
EvdevBtnOn (DeviceIntPtr device)
|
||||
{
|
||||
InputInfoPtr pInfo = device->public.devicePrivate;
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
int i, blocked;
|
||||
|
||||
if (!pEvdev->state.btn)
|
||||
return Success;
|
||||
|
||||
blocked = xf86BlockSIGIO ();
|
||||
for (i = 1; i <= pEvdev->state.btn->buttons; i++)
|
||||
xf86PostButtonEvent (device, 0, i, 0, 0, 0);
|
||||
xf86UnblockSIGIO (blocked);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
EvdevBtnOff (DeviceIntPtr device)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
/*
|
||||
* Warning, evil lives here.
|
||||
*/
|
||||
static void
|
||||
EvdevBtnCalcRemap (InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int i, j, base, clear, fake;
|
||||
|
||||
for (i = 0, base = 1, fake = 0; i < pEvdev->state.btn->real_buttons; i++) {
|
||||
if (state->rel) {
|
||||
do {
|
||||
clear = 1;
|
||||
for (j = 0; j < REL_MAX; j++) {
|
||||
if (state->axes->btnMap[j][0] == (i + base)) {
|
||||
base++;
|
||||
clear = 0;
|
||||
break;
|
||||
}
|
||||
if (state->axes->btnMap[j][1] == (i + base)) {
|
||||
base++;
|
||||
clear = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!clear);
|
||||
}
|
||||
|
||||
if (!fake && base != 1)
|
||||
fake = i;
|
||||
|
||||
state->btn->buttons = state->btn->map[i] = i + base;
|
||||
}
|
||||
|
||||
if (state->btn->real_buttons >= 3 && (!fake || fake >= 3)) {
|
||||
base = state->btn->map[1];
|
||||
state->btn->map[1] = state->btn->map[2];
|
||||
state->btn->map[2] = base;
|
||||
}
|
||||
|
||||
if (state->rel) {
|
||||
for (i = 0; i < REL_MAX; i++) {
|
||||
if (state->axes->btnMap[i][0] > state->btn->buttons)
|
||||
state->btn->buttons = state->axes->btnMap[i][0];
|
||||
if (state->axes->btnMap[i][1] > state->btn->buttons)
|
||||
state->btn->buttons = state->axes->btnMap[i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
EvdevBtnNew(InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int i, bit;
|
||||
|
||||
state->btn = Xcalloc (sizeof (evdevBtnRec));
|
||||
|
||||
for (i = BTN_MISC; i < (KEY_OK - 1); i++)
|
||||
if (test_bit (i, pEvdev->bits.key)) {
|
||||
bit = i;
|
||||
if ((bit >= BTN_MOUSE) && (bit < BTN_JOYSTICK)) {
|
||||
bit -= BTN_MOUSE - BTN_MISC;
|
||||
} else if ((bit >= BTN_MISC) && (bit < BTN_MOUSE)) {
|
||||
bit += BTN_MOUSE - BTN_MISC;
|
||||
}
|
||||
bit -= BTN_MISC;
|
||||
state->btn->real_buttons = bit + 1;
|
||||
}
|
||||
|
||||
if (state->btn->real_buttons)
|
||||
xf86Msg(X_INFO, "%s: Found %d mouse buttons\n", pInfo->name, state->btn->real_buttons);
|
||||
|
||||
EvdevBtnCalcRemap (pInfo);
|
||||
|
||||
if (state->btn->buttons)
|
||||
xf86Msg(X_INFO, "%s: Configured %d mouse buttons\n", pInfo->name, state->btn->buttons);
|
||||
else {
|
||||
Xfree (state->btn);
|
||||
state->btn = NULL;
|
||||
return !Success;
|
||||
}
|
||||
|
||||
pInfo->flags |= XI86_SEND_DRAG_EVENTS | XI86_CONFIGURED;
|
||||
/*
|
||||
* FIXME: Mouse may not be accurate.
|
||||
* Check buttons to see if we're actually a joystick or something.
|
||||
*/
|
||||
pInfo->type_name = XI_MOUSE;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
EvdevBtnProcess (InputInfoPtr pInfo, struct input_event *ev)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int button;
|
||||
|
||||
if (!state->btn)
|
||||
return;
|
||||
|
||||
button = ev->code - BTN_MISC;
|
||||
|
||||
if ((ev->code >= BTN_MOUSE) && (ev->code < BTN_JOYSTICK)) {
|
||||
button -= BTN_MOUSE - BTN_MISC;
|
||||
} else if ((ev->code >= BTN_MISC) && (ev->code < BTN_MOUSE)) {
|
||||
button += BTN_MOUSE - BTN_MISC;
|
||||
}
|
||||
|
||||
if (state->btn->state[button])
|
||||
*state->btn->state[button] = ev->value;
|
||||
|
||||
button = state->btn->map[button];
|
||||
xf86PostButtonEvent (pInfo->dev, 0, button, ev->value, 0, 0);
|
||||
}
|
||||
451
src/evdev_key.c
451
src/evdev_key.c
@@ -1,451 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2006 Zephaniah E. Hull
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL 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 PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Author: Zephaniah E. Hull (warp@aehallh.com)
|
||||
*/
|
||||
/*
|
||||
* Copyright © 2004 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.
|
||||
*
|
||||
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL RED HAT 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.
|
||||
*
|
||||
* Author: Kristian Høgsberg (krh@redhat.com)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evdev.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/extensions/XIproto.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <misc.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86str.h>
|
||||
#include <xf86_OSproc.h>
|
||||
#include <xf86Xinput.h>
|
||||
#include <exevents.h>
|
||||
#include <mipointer.h>
|
||||
|
||||
#include <xf86Module.h>
|
||||
|
||||
#include <X11/extensions/XKB.h>
|
||||
#include <X11/extensions/XKBstr.h>
|
||||
#include <X11/extensions/XKBsrv.h>
|
||||
|
||||
|
||||
#define ArrayLength(a) (sizeof(a) / (sizeof((a)[0])))
|
||||
|
||||
#define MIN_KEYCODE 8
|
||||
#define GLYPHS_PER_KEY 2
|
||||
#define AltMask Mod1Mask
|
||||
#define NumLockMask Mod2Mask
|
||||
#define AltLangMask Mod3Mask
|
||||
#define KanaMask Mod4Mask
|
||||
#define ScrollLockMask Mod5Mask
|
||||
|
||||
#define CAPSFLAG 1
|
||||
#define NUMFLAG 2
|
||||
#define SCROLLFLAG 4
|
||||
#define MODEFLAG 8
|
||||
#define COMPOSEFLAG 16
|
||||
|
||||
/* FIXME: this map works with evdev keyboards, but all the xkb maps
|
||||
* probably don't. The easiest is to remap the event keycodes. */
|
||||
|
||||
static KeySym map[] = {
|
||||
/* 0x00 */ NoSymbol, NoSymbol,
|
||||
/* 0x01 */ XK_Escape, NoSymbol,
|
||||
/* 0x02 */ XK_1, XK_exclam,
|
||||
/* 0x03 */ XK_2, XK_at,
|
||||
/* 0x04 */ XK_3, XK_numbersign,
|
||||
/* 0x05 */ XK_4, XK_dollar,
|
||||
/* 0x06 */ XK_5, XK_percent,
|
||||
/* 0x07 */ XK_6, XK_asciicircum,
|
||||
/* 0x08 */ XK_7, XK_ampersand,
|
||||
/* 0x09 */ XK_8, XK_asterisk,
|
||||
/* 0x0a */ XK_9, XK_parenleft,
|
||||
/* 0x0b */ XK_0, XK_parenright,
|
||||
/* 0x0c */ XK_minus, XK_underscore,
|
||||
/* 0x0d */ XK_equal, XK_plus,
|
||||
/* 0x0e */ XK_BackSpace, NoSymbol,
|
||||
/* 0x0f */ XK_Tab, XK_ISO_Left_Tab,
|
||||
/* 0x10 */ XK_Q, NoSymbol,
|
||||
/* 0x11 */ XK_W, NoSymbol,
|
||||
/* 0x12 */ XK_E, NoSymbol,
|
||||
/* 0x13 */ XK_R, NoSymbol,
|
||||
/* 0x14 */ XK_T, NoSymbol,
|
||||
/* 0x15 */ XK_Y, NoSymbol,
|
||||
/* 0x16 */ XK_U, NoSymbol,
|
||||
/* 0x17 */ XK_I, NoSymbol,
|
||||
/* 0x18 */ XK_O, NoSymbol,
|
||||
/* 0x19 */ XK_P, NoSymbol,
|
||||
/* 0x1a */ XK_bracketleft, XK_braceleft,
|
||||
/* 0x1b */ XK_bracketright,XK_braceright,
|
||||
/* 0x1c */ XK_Return, NoSymbol,
|
||||
/* 0x1d */ XK_Control_L, NoSymbol,
|
||||
/* 0x1e */ XK_A, NoSymbol,
|
||||
/* 0x1f */ XK_S, NoSymbol,
|
||||
/* 0x20 */ XK_D, NoSymbol,
|
||||
/* 0x21 */ XK_F, NoSymbol,
|
||||
/* 0x22 */ XK_G, NoSymbol,
|
||||
/* 0x23 */ XK_H, NoSymbol,
|
||||
/* 0x24 */ XK_J, NoSymbol,
|
||||
/* 0x25 */ XK_K, NoSymbol,
|
||||
/* 0x26 */ XK_L, NoSymbol,
|
||||
/* 0x27 */ XK_semicolon, XK_colon,
|
||||
/* 0x28 */ XK_quoteright, XK_quotedbl,
|
||||
/* 0x29 */ XK_quoteleft, XK_asciitilde,
|
||||
/* 0x2a */ XK_Shift_L, NoSymbol,
|
||||
/* 0x2b */ XK_backslash, XK_bar,
|
||||
/* 0x2c */ XK_Z, NoSymbol,
|
||||
/* 0x2d */ XK_X, NoSymbol,
|
||||
/* 0x2e */ XK_C, NoSymbol,
|
||||
/* 0x2f */ XK_V, NoSymbol,
|
||||
/* 0x30 */ XK_B, NoSymbol,
|
||||
/* 0x31 */ XK_N, NoSymbol,
|
||||
/* 0x32 */ XK_M, NoSymbol,
|
||||
/* 0x33 */ XK_comma, XK_less,
|
||||
/* 0x34 */ XK_period, XK_greater,
|
||||
/* 0x35 */ XK_slash, XK_question,
|
||||
/* 0x36 */ XK_Shift_R, NoSymbol,
|
||||
/* 0x37 */ XK_KP_Multiply, NoSymbol,
|
||||
/* 0x38 */ XK_Alt_L, XK_Meta_L,
|
||||
/* 0x39 */ XK_space, NoSymbol,
|
||||
/* 0x3a */ XK_Caps_Lock, NoSymbol,
|
||||
/* 0x3b */ XK_F1, NoSymbol,
|
||||
/* 0x3c */ XK_F2, NoSymbol,
|
||||
/* 0x3d */ XK_F3, NoSymbol,
|
||||
/* 0x3e */ XK_F4, NoSymbol,
|
||||
/* 0x3f */ XK_F5, NoSymbol,
|
||||
/* 0x40 */ XK_F6, NoSymbol,
|
||||
/* 0x41 */ XK_F7, NoSymbol,
|
||||
/* 0x42 */ XK_F8, NoSymbol,
|
||||
/* 0x43 */ XK_F9, NoSymbol,
|
||||
/* 0x44 */ XK_F10, NoSymbol,
|
||||
/* 0x45 */ XK_Num_Lock, NoSymbol,
|
||||
/* 0x46 */ XK_Scroll_Lock, NoSymbol,
|
||||
/* These KP keys should have the KP_7 keysyms in the numlock
|
||||
* modifer... ? */
|
||||
/* 0x47 */ XK_KP_Home, XK_KP_7,
|
||||
/* 0x48 */ XK_KP_Up, XK_KP_8,
|
||||
/* 0x49 */ XK_KP_Prior, XK_KP_9,
|
||||
/* 0x4a */ XK_KP_Subtract, NoSymbol,
|
||||
/* 0x4b */ XK_KP_Left, XK_KP_4,
|
||||
/* 0x4c */ XK_KP_Begin, XK_KP_5,
|
||||
/* 0x4d */ XK_KP_Right, XK_KP_6,
|
||||
/* 0x4e */ XK_KP_Add, NoSymbol,
|
||||
/* 0x4f */ XK_KP_End, XK_KP_1,
|
||||
/* 0x50 */ XK_KP_Down, XK_KP_2,
|
||||
/* 0x51 */ XK_KP_Next, XK_KP_3,
|
||||
/* 0x52 */ XK_KP_Insert, XK_KP_0,
|
||||
/* 0x53 */ XK_KP_Delete, XK_KP_Decimal,
|
||||
/* 0x54 */ NoSymbol, NoSymbol,
|
||||
/* 0x55 */ XK_F13, NoSymbol,
|
||||
/* 0x56 */ XK_less, XK_greater,
|
||||
/* 0x57 */ XK_F11, NoSymbol,
|
||||
/* 0x58 */ XK_F12, NoSymbol,
|
||||
/* 0x59 */ XK_F14, NoSymbol,
|
||||
/* 0x5a */ XK_F15, NoSymbol,
|
||||
/* 0x5b */ XK_F16, NoSymbol,
|
||||
/* 0x5c */ XK_F17, NoSymbol,
|
||||
/* 0x5d */ XK_F18, NoSymbol,
|
||||
/* 0x5e */ XK_F19, NoSymbol,
|
||||
/* 0x5f */ XK_F20, NoSymbol,
|
||||
/* 0x60 */ XK_KP_Enter, NoSymbol,
|
||||
/* 0x61 */ XK_Control_R, NoSymbol,
|
||||
/* 0x62 */ XK_KP_Divide, NoSymbol,
|
||||
/* 0x63 */ XK_Print, XK_Sys_Req,
|
||||
/* 0x64 */ XK_Alt_R, XK_Meta_R,
|
||||
/* 0x65 */ NoSymbol, NoSymbol, /* KEY_LINEFEED */
|
||||
/* 0x66 */ XK_Home, NoSymbol,
|
||||
/* 0x67 */ XK_Up, NoSymbol,
|
||||
/* 0x68 */ XK_Prior, NoSymbol,
|
||||
/* 0x69 */ XK_Left, NoSymbol,
|
||||
/* 0x6a */ XK_Right, NoSymbol,
|
||||
/* 0x6b */ XK_End, NoSymbol,
|
||||
/* 0x6c */ XK_Down, NoSymbol,
|
||||
/* 0x6d */ XK_Next, NoSymbol,
|
||||
/* 0x6e */ XK_Insert, NoSymbol,
|
||||
/* 0x6f */ XK_Delete, NoSymbol,
|
||||
/* 0x6f */ NoSymbol, NoSymbol, /* KEY_MACRO */
|
||||
/* 0x70 */ NoSymbol, NoSymbol,
|
||||
/* 0x71 */ NoSymbol, NoSymbol,
|
||||
/* 0x72 */ NoSymbol, NoSymbol,
|
||||
/* 0x73 */ NoSymbol, NoSymbol,
|
||||
/* 0x74 */ NoSymbol, NoSymbol,
|
||||
/* 0x75 */ XK_KP_Equal, NoSymbol,
|
||||
/* 0x76 */ NoSymbol, NoSymbol,
|
||||
/* 0x77 */ NoSymbol, NoSymbol,
|
||||
/* 0x78 */ XK_F21, NoSymbol,
|
||||
/* 0x79 */ XK_F22, NoSymbol,
|
||||
/* 0x7a */ XK_F23, NoSymbol,
|
||||
/* 0x7b */ XK_F24, NoSymbol,
|
||||
/* 0x7c */ XK_KP_Separator, NoSymbol,
|
||||
/* 0x7d */ XK_Meta_L, NoSymbol,
|
||||
/* 0x7e */ XK_Meta_R, NoSymbol,
|
||||
/* 0x7f */ XK_Multi_key, NoSymbol,
|
||||
};
|
||||
|
||||
/*
|
||||
* FIXME: We have no way of ringing the bell ourselves.
|
||||
* So use the system bell for now.
|
||||
*/
|
||||
static void
|
||||
EvdevKbdBell (int percent, DeviceIntPtr device, pointer ctrl, int unused)
|
||||
{
|
||||
xf86SoundKbdBell(percent, ((KeybdCtrl*) ctrl)->bell_pitch,
|
||||
((KeybdCtrl*) ctrl)->bell_duration);
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
|
||||
{
|
||||
static struct { int xbit, code; } bits[] = {
|
||||
{ CAPSFLAG, LED_CAPSL },
|
||||
{ NUMFLAG, LED_NUML },
|
||||
{ SCROLLFLAG, LED_SCROLLL },
|
||||
{ MODEFLAG, LED_KANA },
|
||||
{ COMPOSEFLAG, LED_COMPOSE }
|
||||
};
|
||||
|
||||
InputInfoPtr pInfo;
|
||||
struct input_event ev[ArrayLength(bits)];
|
||||
int i;
|
||||
|
||||
pInfo = device->public.devicePrivate;
|
||||
for (i = 0; i < ArrayLength(bits); i++) {
|
||||
ev[i].type = EV_LED;
|
||||
ev[i].code = bits[i].code;
|
||||
ev[i].value = (ctrl->leds & bits[i].xbit) > 0;
|
||||
|
||||
write(pInfo->fd, ev, sizeof ev);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
EvdevKeyInit (DeviceIntPtr device)
|
||||
{
|
||||
InputInfoPtr pInfo = device->public.devicePrivate;
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
KeySymsRec keySyms;
|
||||
CARD8 modMap[MAP_LENGTH];
|
||||
KeySym sym;
|
||||
int i, j;
|
||||
|
||||
static struct { KeySym keysym; CARD8 mask; } modifiers[] = {
|
||||
{ XK_Shift_L, ShiftMask },
|
||||
{ XK_Shift_R, ShiftMask },
|
||||
{ XK_Control_L, ControlMask },
|
||||
{ XK_Control_R, ControlMask },
|
||||
{ XK_Caps_Lock, LockMask },
|
||||
{ XK_Alt_L, AltMask },
|
||||
{ XK_Alt_R, AltMask },
|
||||
{ XK_Num_Lock, NumLockMask },
|
||||
{ XK_Scroll_Lock, ScrollLockMask },
|
||||
{ XK_Mode_switch, AltLangMask }
|
||||
};
|
||||
|
||||
/* TODO:
|
||||
* Ctrl-Alt-Backspace and other Ctrl-Alt-stuff should work
|
||||
* XKB, let's try without the #ifdef nightmare
|
||||
* Get keyboard repeat under control (right now caps lock repeats!)
|
||||
*/
|
||||
|
||||
pInfo = device->public.devicePrivate;
|
||||
|
||||
/* Compute the modifier map */
|
||||
memset(modMap, 0, sizeof modMap);
|
||||
|
||||
for (i = 0; i < ArrayLength(map) / GLYPHS_PER_KEY; i++) {
|
||||
sym = map[i * GLYPHS_PER_KEY];
|
||||
for (j = 0; j < ArrayLength(modifiers); j++) {
|
||||
if (modifiers[j].keysym == sym)
|
||||
modMap[i + MIN_KEYCODE] = modifiers[j].mask;
|
||||
}
|
||||
}
|
||||
|
||||
keySyms.map = map;
|
||||
keySyms.mapWidth = GLYPHS_PER_KEY;
|
||||
keySyms.minKeyCode = MIN_KEYCODE;
|
||||
keySyms.maxKeyCode = MIN_KEYCODE + ArrayLength(map) / GLYPHS_PER_KEY - 1;
|
||||
|
||||
|
||||
XkbSetRulesDflts (state->key->xkb_rules, state->key->xkb_model,
|
||||
state->key->xkb_layout, state->key->xkb_variant,
|
||||
state->key->xkb_options);
|
||||
|
||||
XkbInitKeyboardDeviceStruct (device, &state->key->xkbnames, &keySyms, modMap,
|
||||
EvdevKbdBell, EvdevKbdCtrl);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
SetXkbOption(InputInfoPtr pInfo, char *name, char *value, char **option)
|
||||
{
|
||||
char *s;
|
||||
|
||||
if ((s = xf86SetStrOption(pInfo->options, name, value))) {
|
||||
if (!s[0]) {
|
||||
xfree(s);
|
||||
*option = NULL;
|
||||
} else {
|
||||
*option = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
EvdevKeyNew (InputInfoPtr pInfo)
|
||||
{
|
||||
evdevDevicePtr pEvdev = pInfo->private;
|
||||
evdevStatePtr state = &pEvdev->state;
|
||||
int i, keys = 0;
|
||||
|
||||
for (i = 0; i <= KEY_UNKNOWN; i++)
|
||||
if (test_bit (i, pEvdev->bits.key)) {
|
||||
keys = 1;
|
||||
break;
|
||||
}
|
||||
if (!keys)
|
||||
for (i = KEY_OK; i <= KEY_MAX; i++)
|
||||
if (test_bit (i, pEvdev->bits.key)) {
|
||||
keys = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!keys)
|
||||
return !Success;
|
||||
|
||||
state->key = Xcalloc (sizeof (evdevKeyRec));
|
||||
|
||||
pInfo->type_name = XI_KEYBOARD;
|
||||
|
||||
pInfo->flags |= XI86_KEYBOARD_CAPABLE | XI86_CONFIGURED;
|
||||
|
||||
SetXkbOption (pInfo, "XkbRules", __XKBDEFRULES__, &state->key->xkb_rules);
|
||||
SetXkbOption (pInfo, "XkbModel", "evdev", &state->key->xkb_model);
|
||||
SetXkbOption (pInfo, "XkbLayout", "us", &state->key->xkb_layout);
|
||||
SetXkbOption (pInfo, "XkbVariant", NULL, &state->key->xkb_variant);
|
||||
SetXkbOption (pInfo, "XkbOptions", NULL, &state->key->xkb_options);
|
||||
|
||||
/*
|
||||
SetXkbOption (pInfo, "XkbKeycodes", NULL, &state->key->xkbnames.keycodes);
|
||||
SetXkbOption (pInfo, "XkbTypes", NULL, &state->key->xkbnames.types);
|
||||
SetXkbOption (pInfo, "XkbCompat", NULL, &state->key->xkbnames.compat);
|
||||
SetXkbOption (pInfo, "XkbSymbols", NULL, &state->key->xkbnames.symbols);
|
||||
SetXkbOption (pInfo, "XkbGeometry", NULL, &state->key->xkbnames.geometry);
|
||||
*/
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
EvdevKeyOn (DeviceIntPtr device)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
EvdevKeyOff (DeviceIntPtr device)
|
||||
{
|
||||
unsigned int i;
|
||||
KeyClassRec *keyc = device->key;
|
||||
KeySym *map = keyc->curKeySyms.map;
|
||||
|
||||
/*
|
||||
* A bit of a hack, vaguely stolen from xf86-input-keyboard.
|
||||
*
|
||||
* Don't leave any keys in the down state if we are getting turned
|
||||
* off, as they are likely to be released before we are turned back
|
||||
* on.
|
||||
* (For example, if the user switches VTs, or if we are unplugged.)
|
||||
*/
|
||||
for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
|
||||
i < keyc->curKeySyms.maxKeyCode;
|
||||
i++, map += keyc->curKeySyms.mapWidth)
|
||||
if ((keyc->down[i >> 3] & (1 << (i & 7))))
|
||||
{
|
||||
switch (*map) {
|
||||
/* Don't release the lock keys */
|
||||
case XK_Caps_Lock:
|
||||
case XK_Shift_Lock:
|
||||
case XK_Num_Lock:
|
||||
case XK_Scroll_Lock:
|
||||
case XK_Kana_Lock:
|
||||
break;
|
||||
default:
|
||||
xf86PostKeyboardEvent(device, i, 0);
|
||||
}
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
EvdevKeyProcess (InputInfoPtr pInfo, struct input_event *ev)
|
||||
{
|
||||
int keycode = ev->code + MIN_KEYCODE;
|
||||
|
||||
/* filter repeat events for chording keys */
|
||||
if (ev->value == 2) {
|
||||
DeviceIntPtr device = pInfo->dev;
|
||||
KeyClassRec *keyc = device->key;
|
||||
KbdFeedbackClassRec *kbdfeed = device->kbdfeed;
|
||||
int num = keycode >> 3;
|
||||
int bit = 1 << (keycode & 7);
|
||||
|
||||
if (keyc->modifierMap[keycode] ||
|
||||
!(kbdfeed->ctrl.autoRepeats[num] & bit))
|
||||
return;
|
||||
}
|
||||
|
||||
xf86PostKeyboardEvent(pInfo->dev, keycode, ev->value);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
#ifndef _LINUX_INOTIFY_SYSCALLS_H
|
||||
#define _LINUX_INOTIFY_SYSCALLS_H
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#if defined(__i386__)
|
||||
# define __NR_inotify_init 291
|
||||
# define __NR_inotify_add_watch 292
|
||||
# define __NR_inotify_rm_watch 293
|
||||
#elif defined(__x86_64__)
|
||||
# define __NR_inotify_init 253
|
||||
# define __NR_inotify_add_watch 254
|
||||
# define __NR_inotify_rm_watch 255
|
||||
#elif defined(__powerpc__) || defined(__powerpc64__)
|
||||
# define __NR_inotify_init 275
|
||||
# define __NR_inotify_add_watch 276
|
||||
# define __NR_inotify_rm_watch 277
|
||||
#elif defined (__ia64__)
|
||||
# define __NR_inotify_init 1277
|
||||
# define __NR_inotify_add_watch 1278
|
||||
# define __NR_inotify_rm_watch 1279
|
||||
#elif defined (__s390__)
|
||||
# define __NR_inotify_init 284
|
||||
# define __NR_inotify_add_watch 285
|
||||
# define __NR_inotify_rm_watch 286
|
||||
#elif defined (__alpha__)
|
||||
# define __NR_inotify_init 444
|
||||
# define __NR_inotify_add_watch 445
|
||||
# define __NR_inotify_rm_watch 446
|
||||
#elif defined (__sparc__) || defined (__sparc64__)
|
||||
# define __NR_inotify_init 151
|
||||
# define __NR_inotify_add_watch 152
|
||||
# define __NR_inotify_rm_watch 156
|
||||
#elif defined (__arm__)
|
||||
# define __NR_inotify_init 316
|
||||
# define __NR_inotify_add_watch 317
|
||||
# define __NR_inotify_rm_watch 318
|
||||
#elif defined (__sh__)
|
||||
# define __NR_inotify_init 290
|
||||
# define __NR_inotify_add_watch 291
|
||||
# define __NR_inotify_rm_watch 292
|
||||
#elif defined (__hppa__) || defined (__hppa64__)
|
||||
# define __NR_inotify_init 269
|
||||
# define __NR_inotify_add_watch 270
|
||||
# define __NR_inotify_rm_watch 271
|
||||
#elif defined (__mips__)
|
||||
# if _MIPS_SIM == _MIPS_SIM_ABI32
|
||||
# define __NR_inotify_init 4284
|
||||
# define __NR_inotify_add_watch 4285
|
||||
# define __NR_inotify_rm_watch 4286
|
||||
# elif _MIPS_SIM == _MIPS_SIM_NABI32
|
||||
# define __NR_inotify_init 6247
|
||||
# define __NR_inotify_add_watch 6248
|
||||
# define __NR_inotify_rm_watch 6249
|
||||
# elif _MIPS_SIM == _MIPS_SIM_ABI64
|
||||
# define __NR_inotify_init 5243
|
||||
# define __NR_inotify_add_watch 5244
|
||||
# define __NR_inotify_rm_watch 5245
|
||||
# endif
|
||||
#else
|
||||
# error "Unsupported architecture!"
|
||||
#endif
|
||||
|
||||
static inline int inotify_init (void)
|
||||
{
|
||||
return syscall (__NR_inotify_init);
|
||||
}
|
||||
|
||||
static inline int inotify_add_watch (int fd, const char *name, __u32 mask)
|
||||
{
|
||||
return syscall (__NR_inotify_add_watch, fd, name, mask);
|
||||
}
|
||||
|
||||
static inline int inotify_rm_watch (int fd, __u32 wd)
|
||||
{
|
||||
return syscall (__NR_inotify_rm_watch, fd, wd);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_INOTIFY_SYSCALLS_H */
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Inode based directory notification for Linux
|
||||
*
|
||||
* Copyright (C) 2005 John McCutchan
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_INOTIFY_H
|
||||
#define _LINUX_INOTIFY_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* struct inotify_event - structure read from the inotify device for each event
|
||||
*
|
||||
* When you are watching a directory, you will receive the filename for events
|
||||
* such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
|
||||
*/
|
||||
struct inotify_event {
|
||||
__s32 wd; /* watch descriptor */
|
||||
__u32 mask; /* watch mask */
|
||||
__u32 cookie; /* cookie to synchronize two events */
|
||||
__u32 len; /* length (including nulls) of name */
|
||||
char name[0]; /* stub for possible name */
|
||||
};
|
||||
|
||||
/* the following are legal, implemented events that user-space can watch for */
|
||||
#define IN_ACCESS 0x00000001 /* File was accessed */
|
||||
#define IN_MODIFY 0x00000002 /* File was modified */
|
||||
#define IN_ATTRIB 0x00000004 /* Metadata changed */
|
||||
#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
|
||||
#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
|
||||
#define IN_OPEN 0x00000020 /* File was opened */
|
||||
#define IN_MOVED_FROM 0x00000040 /* File was moved from X */
|
||||
#define IN_MOVED_TO 0x00000080 /* File was moved to Y */
|
||||
#define IN_CREATE 0x00000100 /* Subfile was created */
|
||||
#define IN_DELETE 0x00000200 /* Subfile was deleted */
|
||||
#define IN_DELETE_SELF 0x00000400 /* Self was deleted */
|
||||
|
||||
/* the following are legal events. they are sent as needed to any watch */
|
||||
#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */
|
||||
#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
|
||||
#define IN_IGNORED 0x00008000 /* File was ignored */
|
||||
|
||||
/* helper events */
|
||||
#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
|
||||
#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
|
||||
|
||||
/* special flags */
|
||||
#define IN_ISDIR 0x40000000 /* event occurred against dir */
|
||||
#define IN_ONESHOT 0x80000000 /* only send event once */
|
||||
|
||||
/*
|
||||
* All of the events - we build the list by hand so that we can add flags in
|
||||
* the future and not break backward compatibility. Apps will get only the
|
||||
* events that they originally wanted. Be sure to add new events here!
|
||||
*/
|
||||
#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
|
||||
IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
|
||||
IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF)
|
||||
#endif /* _LINUX_INOTIFY_H */
|
||||
6
xorg-evdev.pc.in
Normal file
6
xorg-evdev.pc.in
Normal file
@@ -0,0 +1,6 @@
|
||||
sdkdir=@sdkdir@
|
||||
|
||||
Name: xorg-evdev
|
||||
Description: X.Org evdev input driver.
|
||||
Version: @PACKAGE_VERSION@
|
||||
Cflags: -I${sdkdir}
|
||||
Reference in New Issue
Block a user