Compare commits

...

398 Commits

Author SHA1 Message Date
Peter Hutterer
990540fa19 evdev 2.5.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-23 10:34:36 +10:00
Peter Hutterer
b8945e61eb man: don't reference README.mouse
No real reason to refer to the mouse driver's readme.

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

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

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

This reverts commit c1f16a4f59.

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

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

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

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

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

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

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

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

Use Automake $() for variables in Makefile.am

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

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

Middle button emulation can be enabled with a configuration snippet:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This reverts commit 9dbace89be.

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

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

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

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

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

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

This is evidenced by the absence of XINPUT conditional code.

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

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

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

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

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

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

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

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

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

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

Fedora Bug 571639

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

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

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

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

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

Need xinputproto.

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

Tested on an HP Touchsmart and a Wacom tablet.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Previously the only way was via the properties interface.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Marty Jack <martyj19@comcast.net>
2009-03-10 16:04:49 +10:00
Peter Hutterer
3f06825a44 Bump to 2.2.99.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-09 10:01:35 +10:00
Peter Hutterer
31853c39bf Define MAX_VALUATORS if it's missing to allow for builds against 1.5.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-09 09:31:16 +10:00
Peter Hutterer
2c49e21a81 Check button label before fetching the Atom from the server. (#20524)
The server doesn't like NULL names, so don't call XIGetKnownProperty for
labels that don't exist.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Peter Henriksson
2009-03-09 09:23:57 +10:00
Peter Hutterer
4361b3efa0 Fix duplicate wheel button up mapping.
Reported by Simon Thum.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Simon Thum <simon.thum@gmx.de>
2009-03-06 19:45:28 +10:00
Peter Hutterer
281a7b4b88 evdev 2.1.99.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-02 16:27:57 +10:00
Peter Hutterer
051cb8b528 Add support for button labelling.
Buttons 4/5 and 6/7 are hardcoded for wheel buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-02 16:16:59 +10:00
Peter Hutterer
1abcc88171 Rename prop_label to prop_axis_label. 2009-03-02 16:16:58 +10:00
Peter Hutterer
c89bbf80be Don't double-assign the UKNOWN axis label.
All labels default to unknown anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-26 14:36:07 +10:00
Peter Hutterer
178435832f If scrollwheels are found, bump the button number by 4 (or up to 7).
Scrollwheel data is always posted as buttons, so we need to advertise at least
enough buttons to accommodate for 6/7 (horizontal wheel).

Note that this may mean that if you have a device that has scroll wheels and
axes, but no buttons, it may be interpreted as a mouse.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-26 14:35:46 +10:00
Peter Hutterer
c9cab83bac Ignore REL_WHEEL, REL_HWHEEL and REL_DIAL during axis initialisation.
We don't post the events for them anyway, so lets ignore them completely.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-26 09:11:14 +10:00
Peter Hutterer
43dd2a9592 Pass on all relative events, not just x/y.
9620fe776 added generic axes support for relativ values, but values from such
axes didn't get passed on to the server. Fix this.

Note that wheel events are not posted as motion events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-26 09:11:14 +10:00
Adam Jackson
7977947e0d Reduce the number of read calls in ReadInput.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2009-02-26 09:11:02 +10:00
Peter Hutterer
11a56d4a17 Split ReadInput into ReadInput and ProcessEvent.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-26 09:11:01 +10:00
Adam Jackson
7b0f613c7f Move relative motion and other magic up to EV_SYN processing.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2009-02-26 09:10:47 +10:00
Adam Jackson
75af278861 Open with O_NONBLOCK, and simplify EvdevReadInput to match.
xf86WaitForInput() would call select() with zero timeout to discover if
more input was ready.  But we know that's always true at least once,
since we're only ever called from the sigio handler (if silken is
active) or from the main loop (if it's not and we selected readable).
With nonblocking IO we can just spin around until we hit EAGAIN, which
gets us down to n+1 syscalls per event instead of 2n.
2009-02-23 16:01:14 -05:00
Peter Hutterer
4fd9cd2ea8 Revert "Remove useless include directive."
Necessary for builds against 1.6, but let's at least get rid of XKB defines.

This reverts commit aa5dfa1d6a.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-19 10:04:34 +10:00
Peter Hutterer
12c287df89 Label axes conditional on actual support.
Server 1.6 has device properties, but not axis labels.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-18 09:38:13 +10:00
Peter Hutterer
9f1b9aa6eb Accommodate for holes in the ABS label defines.
abs_labels[] has to be aligned with the defines in linux/input.h, but the
latter does not have continuous range. Pad the holes with
AXIS_LABEL_PROP_ABS_MISC.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-18 09:20:18 +10:00
Peter Hutterer
acb1d557e2 Add support for arbitrary relative axis labels.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-17 15:24:57 +10:00
Peter Hutterer
6a1f8f463d Remove superfluous (and duplicate) call to xf86MotionHistoryAllocate.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-17 14:55:11 +10:00
Peter Hutterer
9620fe7765 Add generic axis support for relative axes.
Just query the kernel what axes we actually have, rather than hard-coding x/y.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-17 14:54:17 +10:00
Peter Hutterer
a1714cac52 Add dynamic axis labelling for absolute devices.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-17 14:42:56 +10:00
Peter Hutterer
5a99ef7ed2 remove duplicate (code > 255) check. 2009-02-16 15:11:20 +10:00
Peter Hutterer
3b22e4703f man: list the options and properties in alphabetical order.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 14:48:45 +10:00
Peter Hutterer
0de20a8f1b man: Fix two minor typos in man page.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 14:48:40 +10:00
Peter Hutterer
978384ede7 Swap axes after scaling, not before.
If we swap before scaling, we scale with the wrong coordinate range.

Reported by Matt Helsley.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 14:08:12 +10:00
Peter Hutterer
df7ff12ed2 CacheCompare before probing the device.
Saves a few duplicate ioctls.

Suggested by Matt Helsley.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:55 +10:00
Matt Helsley
dd2c89ac93 General axis valuator support.
Instead of x/y and pressure, support any absolute axis that is reported on the
device. Note that there are still locations that special-case X and Y.

Minor modifications by Peter Hutterer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:53 +10:00
Peter Hutterer
4616c79f6c Change cached bitmasks from long to unsigned long.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:52 +10:00
Peter Hutterer
a31170718d Remove unused 'screen' variable from the EvdevRec.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:51 +10:00
Peter Hutterer
95099cb036 Log which EVIOCGABS ioctl failed.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:49 +10:00
Peter Hutterer
c58bae0b77 Remove superfluous motion history allocation.
The motion history buffer is allocated during InitValuatorClassDeviceStruct
anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:48 +10:00
Peter Hutterer
32242871f7 Remove duplicate MB emu finalization.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:47 +10:00
Peter Hutterer
aa5dfa1d6a Remove useless include directive.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:19:45 +10:00
Bryce Harrington
2a6c1d7a60 Add descriptive messages for device-has-changed errs
As can be seen in e.g. bugs 19819 & 20025, it can be unclear what
exactly caused a given "Device has changed - disabled" error.  This
patch adds some more specific messages to give a better clue on what
exactly was seen to have changed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-13 13:16:55 +10:00
Dan Nicholson
0f0743e3cf Really fix distcheck
distcheck has an annoying feature where it checks that all files install
under $prefix. Unfortunately, this conflicts with the desire to install
headers to the SDK directory. Workaround by passing --with-sdkdir during
distcheck.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-03 19:56:45 +10:00
Paulo Cesar Pereira de Andrade
095766ebb3 Janitor: make distcheck, .gitignore.
Remove non toplevel .gitignore and .cvsignore files.
  The "make distcheck correction" for $(sdkdir) probably has a better
approach using a "*-hook:" target, or possibly making $sdkdir a
configure time option that could be set with DISTCHECK_CONFIGURE_FLAGS.
2009-02-02 19:52:32 -02:00
Julien Plissonneau Duquene
0dbb88c52b EvdevCacheCompare: ignore changes in current device position
Input devices (especially touchscreens) were disabled when switching
virtual console back to X because EvdevCacheCompare() thought the device
was substituted by another while away from X. Actually only the current
position reported by the device changed from what was in the cache. Fixed
by ignoring the current position in the comparison.

Fixes bug #19819.

Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-03 07:21:27 +10:00
Peter Breitenlohner
c928156702 fix manpage formatting
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-02 22:02:26 +10:00
Peter Hutterer
07f40a04df Protect against zero-sized property values. #19882
X.Org Bug 19882 <http://bugs.freedesktop.org/show_bug.cgi?id=19882>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-02 11:03:08 +10:00
Alan Coopersmith
e260993b6a Add README with pointers to mailing list, bugzilla & git repos 2009-01-30 20:18:50 -08:00
Dan Nicholson
dc72e6d8ae Stop hammering XKB defaults
With the new InitKeyboardDeviceStruct, we can just pass the RMLVO we
want without setting the defaults first.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-01-29 11:52:46 -08:00
Peter Hutterer
1906e4d5c1 Reshuffle property initialization.
We don't need axis calibration, etc. on keyboards, so let's do it
conditionally on actually having axes.

Reported by Simon Thum.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 14:06:38 +11:00
Peter Hutterer
3047c25db2 Deal with XINPUT ABI 5.
Some XKB stuff has been removed, so let's deal with it.
2009-01-22 14:06:38 +11:00
Peter Hutterer
c158cf2b64 Require XKB.
Welcome to the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 14:06:38 +11:00
Peter Hutterer
dae1a78a52 Add automatic axis labeling.
Since we don't support anything but REL/ABS x/y and sometimes pressure this is
bordering on pointlessness, but once the year of the Linux desktop comes
around this will be really handy. Or so.

Also, we don't allow changing axis labels, but should eventually rearrange
them if swapaxis is on.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 14:06:38 +11:00
Peter Hutterer
263bf04a9d Don't print xkb options twice to the log file.
xf86SetStrOption already prints with X_CONFIG anyway, no need to do it again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 14:05:30 +11:00
Peter Hutterer
c035f3d0f5 Register the property handler AFTER setting all the properties.
Otherwise, we add a new property based on a setting in pEvdev, which triggers
the update handler to change the setting in pEvdev based on the property.
Truly pointless.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 09:45:40 +11:00
Peter Hutterer
a7e8af65fc Test for pressure BEFORE using has_pressure. 2009-01-19 21:23:34 +11:00
Michael Chapman
0592d97fbb Disable middle mouse button emulation when a middle mouse button event is registered
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-13 10:52:24 +10:00
Matt Helsley
4dfd86b220 Fix FOO_MAX off-by-one
In linux/input.h each section's (e.g. ABS) FOO_MAX is the maximum FOO
value. Recent kernels define FOO_CNT as the maximum number of FOO there
will ever be. Hence using FOO_MAX to size the bit vectors representing
the capabilities of an evdev device is off by one.

Define FOO_CNT values for use with Linux kernels which lack them. Use
FOO_CNT whenever we need to know the number of bits needed -- usually to
calculate the number of longs needed.

When iterating over the values FOO_MAX still seems appropriate however
the loop test should include FOO_MAX rather than skip it.

Signed-off-by: Matt Helsley <matt.helsley@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-12 13:17:40 +10:00
Matt Helsley
d3fd42d864 rename NBITS to NLONGS to reflect its actual meaning
NBITS really convers the number of bits passed as its argument
into a number of longs. This is somewhat atypical of many
function-like-macro names. Rename it to NLONGS.

Signed-off-by: Matt Helsley <matt.helsley@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-12 13:14:42 +10:00
Matt Helsley
dd1752ce3f Add pressure valuator
If it's available report pressure as third valuator.
(Use xf86PostMotionEventP instead of the varargs wrapper.)

Signed-off-by: Matt Helsley <matt.helsley@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-12 11:22:46 +10:00
Alan Coopersmith
0f0a149067 Remove xorgconfig & xorgcfg from See Also list in man page 2009-01-09 16:13:09 -08:00
Yan Li
d170cba0cd Fix XkbModel parsing error
Signed-off-by: Yan Li <yan.i.li@intel.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-06 08:41:24 +10:00
Peter Hutterer
2680382705 Add dummy test device - simple device that doesn't move at all.
Good for filling up the device list without getting distracted by spurious
events all the time.
2008-12-19 16:45:22 +10:00
Sascha Hlusiak
0f36384d06 Revert "Keyboard: Disable kernel autorepeat"
This reverts commit 6867652c2c.
Functionally replaced by commit ece72ce9e9

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2008-12-08 12:32:31 +01:00
Sascha Hlusiak
ece72ce9e9 Filter all repeated keys from kernel, because we do softrepeat in server
Discard all repeated events that come from the device. The server will handle
per-key autorepeat in software.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2008-12-08 12:27:34 +01:00
Peter Hutterer
2bf6e29b40 Finalize MB emu (and wakeup handlers) before closing the fd.
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-03 16:36:59 +10:00
Tibi Nagy
2bd24649ec Support keyboards with scroll wheels.
For keyboards, scroll events are reported by the kernel as EV_REL class events
of REL_WHEEL type. If, during probing, the device is found to support wheel
events, make sure it is set up as a pointing device, even if it doesn't have
buttons or doesn't report motion along the X and Y axis so that the scroll
events can be mapped to mouse wheel buttons (usually buttons 4 and 5).

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-03 16:36:29 +10:00
Daniel Stone
6867652c2c Keyboard: Disable kernel autorepeat
We handle autorepeat in software due to per-key repeat and whatnot, so
disable the kernel's, which just interferes with ours.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-12-02 19:00:33 +11:00
Peter Hutterer
63af314368 Store device file's minor/major to avoid duplicate devices.
Devices added that use the same min/maj as an already added device are ignored
by the driver. This way users can have an xorg.conf entry on
/dev/input/by-id/blahblah and not get the same device added by HAL.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-11-17 10:05:09 +10:00
Fernando Carrijo
4c5c9c111d Fix error message 2008-11-06 13:20:16 -05:00
Peter Hutterer
4826969f23 Add support for axes swapping.
New option: SwapAxes (boolean)
New property: EVDEV_PROP_SWAP_AXES.

Actual swapping code written by Donnie Berkholz.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-11-03 13:32:41 +10:30
Peter Hutterer
33eb36f266 Add support for run-time calibration.
Some devices require run-time axis calibration. We can't change the min/max
ranges once we've initialised the valuator structs though, so in-driver
run-time calibration is required.

If the property is set, the driver scales from the calibrated range to the
values reported to the X server (which then may scale to screen coordinates).
If the property is not set (i.e. zero items) no scaling is performed.
2008-10-30 16:55:29 +10:30
Peter Hutterer
d5cf24d3f0 Add test/ directory for uinput-based test devices.
Three test devices provided:
btn0 .... Provides BTN_0, BTN_1, BTN_2 instead of BTN_LEFT, BTN_MIDDLE,
          BTN_RIGHT.
abs ..... Provdes x/y absolute axes, jumps between 100/100 and 120/120.
absrel .. Provides relative x/y axes and absolute x/y axes at the same time.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-10-30 16:51:55 +10:30
Peter Hutterer
64554e4799 Treat BTN_[0-2] as LMR buttons if necessary.
Treat BTN_[0-2] as LMR buttons on devices that do not advertise BTN_LEFT,
BTN_MIDDLE, BTN_RIGHT (e.g. 3Dconnexion SpaceNavigator).

Otherwise, treat BTN_[0+n] as button 5+n. Note: This causes duplicate
mappings for BTN_0 + n and  BTN_SIDE + n.

This also fixes a bug where we could end up with negative button numbers after
trying to map BTN_0.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-10-29 17:05:58 +10:30
Peter Hutterer
b77f939857 Remove obsolete FIXME
xkeyboard-config's maps are perfectly able to cope with evdev now.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-10-29 13:28:46 +10:30
Peter Hutterer
a43ab4999b Flush input after re-opening the fd.
Suggested by Julien Cristau.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-10-29 13:25:46 +10:30
Peter Hutterer
af096e8c5d emuMB: add EvdevMBEmuOn and call from EvdevOn to register wakeup handlers.
This got broken in b0737bdbd1, when the
EmuMBPreInit call was removed from EvdevOn. As a result, VT switching away and
back wouldn't restore the wakeup handlers and mouse button presses
disappeared.
2008-10-28 09:09:14 +10:30
Peter Hutterer
12498042fc Fix axis inversion for absolute coordinates.
If min_x/y was not equal to 0, the inverted calculated range was off and leads
to inaccessible or out-of-range areas.
2008-10-24 13:09:46 +10:30
Peter Hutterer
0f8fcfccb3 emulate MB: fix confusing log message.
If we're forcing MB emulation behaviour as per config, then at least state
whether we're forcing it off or on.

Found by Michel Dänzer.
2008-10-24 09:21:36 +10:30
Peter Hutterer
0ab4c09e50 Silence compiler warning by memsetting the struct properly. 2008-10-23 14:05:41 +10:30
Peter Hutterer
d348eb8ce7 MB emulation timeout is stored as Time, make the property 32-bit too. 2008-10-23 13:22:17 +10:30
Peter Hutterer
2c1698fa61 Init ioctl bitmasks to 0, shuts up valgrind too. 2008-10-22 18:08:31 +10:30
Søren Hauberg
8c39302594 Add touchscreen support.
Touchscreens are devices that do not have buttons and only advertise
BTN_TOUCH. Add a new flag to note the device type.

If BTN_TOUCH is detected, change it to BTN_LEFT and process it normally.
2008-10-22 08:49:11 +10:30
Julien Cristau
f57e8face9 Fix TestBit() on 64bit
Reported by Albert Damen <albrt@gmx.net>
X.Org Bug#18150 <http://bugs.freedesktop.org/show_bug.cgi?id=18150>
2008-10-21 19:21:21 +02:00
Peter Hutterer
4912e2aa7f Add option "GrabDevice", don't grab the device by default.
We now have the matching code in the server to set the console to RAW mode and
don't need to grab the devices anymore.

This is an updated version of e8534d47c8, which
was reverted in 6dc4199155.
2008-10-17 11:18:39 +10:30
Peter Hutterer
7243116f55 Don't post keycodes > 255.
If we only have keys > 255 we don't set up a key class rec, so don't post
them. It makes the server unhappy.

Signed-off-by: Julien Cristau <jcristau@debian.org>
2008-10-16 15:47:31 +02:00
Peter Hutterer
0089d931ac Fix "Device reopened after N attempts" message. 2008-10-14 17:07:09 +10:30
Peter Hutterer
0f5a5ac09e Don't init draglock, etc. if we don't have the required capabilities. 2008-10-14 16:45:44 +10:30
Peter Hutterer
36d68b006d 8-bit properties should use 8-bit storage types... 2008-10-14 16:41:54 +10:30
Peter Hutterer
bb1f421687 Don't include the client-side header anymore. xkbstr.h is server SDK. 2008-10-14 16:25:27 +10:30
Peter Hutterer
0405f7b17f Tidy up evdev.h
This includes shuffling some functions around so we don't need the prototypes
in evdev.h.
2008-10-14 16:22:00 +10:30
Peter Hutterer
088e0a175a Rename DragLockInit to DragLockPreInit, remove superfluous "return". 2008-10-14 16:14:13 +10:30
Peter Hutterer
cefedeb205 Register property handler from within the modules, not the main evdev file. 2008-10-14 16:13:56 +10:30
Peter Hutterer
b0737bdbd1 Clean up program flow - don't call PreInit for "modules" on DEVICE_INIT.
Call the PreInit functions for MB Emulation, wheel emu, and draglock during
PreInit, not on DEVICE_INIT. This way, we only parse the options once and
don't overwrite with defaults when coming back from a VT switch.
2008-10-14 16:09:20 +10:30
Peter Hutterer
5f2c8a2dcd Janitor: clean up xf86Msg use, might as well use X_CONFIG directly. 2008-10-14 16:01:17 +10:30
Peter Hutterer
ff783fce65 Add property support for ReopenAttempts option. 2008-10-14 15:30:20 +10:30
Peter Hutterer
c638aa4a88 Document properties in man page. 2008-10-14 15:17:03 +10:30
Peter Hutterer
b46677e346 Document InvertX/Y options. 2008-10-14 15:17:03 +10:30
Peter Hutterer
680b41dc76 Bump to 2.1.99. 2008-10-13 17:08:22 +10:30
Peter Hutterer
9065d0ccb2 Remove "Path" option.
Path was just an alias for Device anyway, so we might as well not parse it.
By now you should be using HAL anyway which fills in Device for you.
2008-10-11 12:24:54 +10:30
Peter Hutterer
a9fcce1833 Remove parsing of ScreenNumber option.
Was unused anyway, so we might as well not parse it.
2008-10-11 12:24:54 +10:30
Peter Hutterer
ab934d840d Janitor: purge unused headers, reshuffle for readability, fix whitespace errors. 2008-10-11 12:24:54 +10:30
Peter Hutterer
6f6ac98295 Add checkonly handling to property handlers.
If checkonly is TRUE, we can only check if applying the value would succeed.
The value is actually applied if checkonly is FALSE.
2008-10-11 12:24:54 +10:30
Peter Hutterer
a2633c8078 Fix up bad return code in draglock property handler. 2008-10-11 12:24:54 +10:30
Peter Hutterer
e6c699dedc Stricter value checking for property changes. 2008-10-11 12:24:54 +10:30
Julien Cristau
847eac8262 Set pInfo->fd to -1 on DEVICE_CLOSE
This allows the reopen logic to kick in later.
DEVICE_CLOSE gets called on regen, so without this we'd keep a stale
file descriptor in pInfo->fd in subsequent sessions.

Debian bug#496101 (http://bugs.debian.org/496101)
2008-10-11 02:16:25 +02:00
Peter Hutterer
a196672a6b Add property support for axis inversion. 2008-10-03 14:42:02 +09:30
Søren Hauberg
3985d42320 Add support for axis inversion. 2008-10-03 14:41:58 +09:30
Peter Hutterer
e138e4b79a Install xorg-evdev.pc for clients who need evdev-properties.h 2008-10-03 14:39:25 +09:30
Peter Hutterer
125e2b8ce2 Close fd on DEVICE_OFF. (LP #276887)
Leaving the fd open means we still get keyboard events after VT switching
away. Coming back, some of these events are replayed on the application that
has the current focus.

Reproduceable:
1. open terminal, focus.
2. VT switch away
3. type something, preferably a password
4. VT switch back, trigger a mouse event
5. Observe the X server guessing your password.

Closing the fd on DEVICE_OFF fixes this. Reopen is handled by the reopen
code introduced with

    commit 9930477cbe
    Author: Peter Hutterer <peter.hutterer@redhat.com>
    Date:   Tue Aug 26 14:33:40 2008 +0930

        Attempt to re-open devices on read errors.

Launchpad Bug 276887
<https://bugs.edge.launchpad.net/ubuntu/+source/xorg-server/+bug/276887>
2008-10-02 12:09:13 +09:30
Peter Hutterer
91bc0a0ba3 Remove useless initialization of rc. 2008-10-02 12:09:12 +09:30
Peter Hutterer
4c55186aed Change DragLock atom name - prepend with Evdev. 2008-10-02 12:09:10 +09:30
Peter Hutterer
62069b97d2 Move misplaced #endif 2008-09-30 12:24:07 +09:30
Peter Hutterer
2718a5c56b Register property handlers directly, instead of abstracting them.
This removes a left-over from the early device property code where we could
only have a single handler. Now it's easier to just register the handlers for
each subsystem (emulate wheel, draglock and MB emulation).
2008-09-30 12:24:07 +09:30
Peter Hutterer
90d1d494f8 Cleanup: "valid_vals" should be "vals" now. 2008-09-30 12:24:07 +09:30
Peter Hutterer
a77c2622cc Add evdev-properties.h file with #defines for all property names. 2008-09-30 12:24:03 +09:30
Peter Hutterer
84a0e39c0d Use new property API (no ConfigureDP, less args to ChangeDP)
Return appropriate status codes from property handlers.
Make properties non-deletable.
2008-09-26 13:23:35 +09:30
Peter Hutterer
7386937221 draglock: Shut up compiler warning. 2008-09-26 12:56:36 +09:30
Peter Hutterer
fcf8375f2b Don't require randrproto. 2008-09-26 12:56:33 +09:30
Peter Hutterer
9930477cbe Attempt to re-open devices on read errors.
Coming back from resume may leave us with a file descriptor that can be opened
but fails on the first read (ENODEV).
In this case, try to open the device until it becomes available or until the
predefined count expires. To be safe, we cache the information from the device
and compare against it when we re-open. This way we ensure that if the
topology changes under us, we don't open a completely different device. If a
device has changed, we disable it.

Adds option "ReopenAttempts" <int>
2008-09-04 18:33:39 +09:30
Peter Hutterer
4509ec1daf Use HAVE_PROPERTIES define instead of GET_ABI_MAJOR for property compilation. 2008-09-04 18:22:56 +09:30
Peter Hutterer
a205dfc091 Shut up "unused variable" compiler warnings.
Hide properties behind ifdefs, fake use of "val".
2008-09-04 18:14:48 +09:30
Peter Hutterer
184206e717 Wheel emulation: initial values must be char.
parsing int* to char* in XIChangeDeviceProperty means we lose values.
2008-08-25 17:24:15 +09:30
Peter Hutterer
79ff677c52 Init all emulateWheel values, even if EmulateWheel is disabled.
Even if we don't want EmulateWheel, we can at least init everything to usable
values. This way we only need to toggle "enabled", rather than initialising
the whole lot before usage.
2008-08-22 09:04:33 +09:30
Dan Nicholson
37e3addf89 Add wheel timeout property support
Copied from the wheel inertia property support.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-08-22 09:04:16 +09:30
Dan Nicholson
e237de0dea Add timeout support for mouse wheel emulation
Support the EmulateWheelTimeout option as the mouse driver does.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-08-22 08:41:14 +09:30
Peter Hutterer
92c6611b6f Add property support for drag lock. 2008-08-18 13:44:02 +09:30
Chris Salch
bd405ddc83 Adding in DragLockButtons functionality.
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-08-18 12:03:07 +09:30
Daniel Stone
36d702006d Force rules, not model, to be evdev
xkeyboard-config recently changed to a separate ruleset for the evdev
driver, so match that by only forcing the ruleset, not the model, to be
evdev.
2008-08-16 15:34:03 +03:00
Peter Hutterer
6dc4199155 Revert "Don't grab devices unless specified through the config options."
Not such a good idea, CTRL+C terminates the server and other issues. Reverting
for now until a better solution is found, at least this way the driver is
usable.

See also: http://lists.freedesktop.org/archives/xorg/2008-August/038032.html

This reverts commit e8534d47c8.
2008-08-15 11:54:53 +09:30
Peter Hutterer
e8534d47c8 Don't grab devices unless specified through the config options.
Grabbing event devices stops in-kernel event forwarding, most notably rfkill
and the "Macintosh mouse button emulation" device. Let's not do that.

Option "GrabDevice" forces grabbing the device.
2008-08-14 13:44:11 +09:30
Chris Salch
555f5a7cbf Filter wheel events before middle mouse button emulation.
The Emulate3Button needs to be the last filter function, otherwise the timeout
code causes it to hijack button presses for the first 3 buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-08-08 16:04:26 +09:30
Peter Hutterer
134829d911 Simplify the property handler registration.
Instead of having separate handlers for each property, just handle all of them
in one handler for emuMB, and one handler for emuWheel.
2008-08-08 16:04:23 +09:30
Peter Hutterer
4e121b297e Add EVDEV_MAXBUTTONS instead of checking against 32.
Numbers are so lame, defines are all the rage now I've heard.
2008-08-08 15:51:09 +09:30
Peter Hutterer
9793de8137 Expose wheel emulation through device properties.
Don't enable wheel emulation with 0 inertia - bad things happen.
2008-08-08 15:50:55 +09:30
Chris Salch
a9d72b40fb Adding mouse wheel emulation code.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-08-07 16:04:31 +09:30
Adam Jackson
c1f7f8c3d2 Print a warning if a keycode exceeds the range accepted by the server.
Keycodes over 255 are silently ignored in the server. The least we can do is
put a warning in the logs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-08-07 09:36:02 +09:30
Chris Salch
40e1474d84 Adding a function to map button events to button numbers.
Remove code duplication, let the mapping function hand us the actual button
event to be passed up to the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-08-06 16:36:51 +09:30
Julien Cristau
d9097df01b Actually close the fd on DEVICE_CLOSE (bug#16948)
Fixes file descriptor leak.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-08-04 09:17:37 +09:30
Julien Cristau
5c074af5a9 Print the device name when we get a read error 2008-07-30 10:42:05 +02:00
Michel Dänzer
72551662a0 xf86-input-evdev: Fix EVIOCGBIT ioctl usage on big endian platforms.
With this fix, on my PowerBook HAL hotplugging correctly detects my USB mouse,
and no longer thinks keyboards have random numbers of mouse buttons. :)

The LONG_BITS and NBITS macro definitions are stolen from xf86-input-synaptics.

Signed-off-by: Michel Dänzer <michel@tungstengraphics.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-07-30 11:26:23 +09:30
Peter Hutterer
53e7525744 Add support for ButtonMapping option. 2008-07-22 11:49:33 +09:30
Peter Hutterer
5d13259a5d Guard property changes against ABI_XINPUT < 3. 2008-07-21 13:10:11 +09:30
Julien Cristau
2b7edaa4ab Fill up the version info
Report correct versions instead of
"compiled for 0.0.0, module version = 1.0.0"
2008-07-20 11:33:37 +02:00
Peter Hutterer
bf0d81011e Don't enable the device if the grab failed with ENODEV.
After suspend/resume, sometimes the device doesn't come back up on the same
node. Since we do not call PreInit for the device (which would detect this
situation), we continue to try to read a nonexisting file, spamming the log
file with "Read Error".
2008-07-14 13:10:34 +09:30
Peter Hutterer
ef4bb69c1a Add .gitignore file. 2008-07-10 19:32:22 +09:30
Peter Hutterer
d1818ef206 Add support for device properties, currently MB emulation and timeout. 2008-07-10 17:08:49 +09:30
Peter Hutterer
a9223edcd8 Clean out configure.ac
We're not building with or without XInput. Same with xkb.
2008-07-10 16:55:21 +09:30
Peter Hutterer
ec23c6b2f5 Remove static ChangeLog, autogenerate as part of make dist.
Hook taken from xserver's Makefile.am
2008-07-03 15:01:32 +09:30
Peter Hutterer
18d70d796f Update COPYING with the correct copyright info.
Fix up licence of emuMB.c, was using Red Hat instead of "The authors", but
this code wasn't contributed by RH anyway.
2008-07-03 14:59:27 +09:30
Peter Hutterer
37b854cb64 Remove stale comments.
Ctrl+Alt+Backspace works, I'm using it daily.
CapsLock doesn't repeat, otherwise we wouldn't have Bug 16318.
2008-07-03 14:45:41 +09:30
Peter Hutterer
8c06093191 Remove EvdevConvert, nobody calls it now anyway.
Conversion is now done in the DIX.
2008-07-03 14:44:52 +09:30
Ander Conselvan de Oliveira
0830676a0c Mice with a lot of buttons (e.g. Logitech MX1000) generate button events greater than BTN_TASK.
Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
2008-06-28 17:54:33 +09:30
Peter Hutterer
1cf7b8f7ee Count buttons at probe and print to log.
We don't really do anything with the number other than print it since I'm sure
that half the mice don't report the correct number anyway (especially with the
wheel button mapping). But having a bit more debug info is good.
2008-06-28 17:53:24 +09:30
Peter Hutterer
826e6e7dd4 Bump to 2.0.99. 2008-06-22 17:52:40 +09:30
Peter Hutterer
5a0ea39b79 No need to finalize MB emulation after EvdevProbe anymore.
Follow-up to 76800bfa75.
2008-06-22 10:56:44 +09:30
Simon Munton
373e13ae35 Close file descriptor if EvdevProbe fails.
Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
2008-06-22 10:56:00 +09:30
Keith Packard
76800bfa75 Enable middle button emulation at DEVICE_ON instead of DEVICE_INIT.
This ensures that the middle button emulation is re-enabled after VT switch,
otherwise the block handler that deals with the timeouts would not get
re-registered.

Signed-off-by: Keith Packard <keithp@keithp.com>
2008-06-21 18:14:35 -07:00
Peter Hutterer
04003a98a9 evdev 2.0.0 2008-06-17 14:01:49 +09:30
Peter Hutterer
0443fb430f Shut up compiler warning "implicit declaration of function 'xf86Msg'" 2008-06-17 13:59:15 +09:30
Peter Hutterer
998f52010f Finalize MB emulation if EvdevProbe fails.
This avoids segfaults when HAL is restarted behind our backs. Also, only init
MB emulation when the device actually has a button.
2008-06-12 11:24:04 +09:30
Peter Hutterer
de07c04f5c evdev 1.99.4
1.99.3 had a nasty bug, so here's a quick update.
2008-06-11 11:55:12 +09:30
Peter Hutterer
01355b9d4b If Emulate3Buttons is specified in the config, don't auto-deactivate it.
Default setting is still "on" until middle button is pressed.  If the options
is however explicitly stated in the config file, it takes the value from the
config file, no matter if a middle button is present.
2008-06-11 11:23:53 +09:30
Peter Hutterer
9591dc1f6c Remove wakeup handlers when device is closed.
Less SIGABRTs are less exciting, but sometimes boredom is what we want.
2008-06-11 11:23:38 +09:30
Adam Jackson
08ba40b253 evdev 1.99.3 2008-06-10 17:35:33 -04:00
Peter Hutterer
39dc453691 Disable middle mouse button emulation when a real middle MB event is detected.
Devices may report middle mouse buttons even if they don't have one (PS/2
devices just don't know any better), so we can't be sure until we see the
event.
2008-06-10 22:48:01 +09:30
Peter Hutterer
e8887435ac Enable middle-mouse button emulation.
Ported from xf86-input-mouse, with a few cleanups.
2008-06-10 22:46:20 +09:30
Peter Hutterer
b0f6987ee6 Plug a memory leak, we allocated pEvdev twice, dropping the first memory area. 2008-06-10 22:43:37 +09:30
Sven Wegener
fec73e1418 evdev: Port b4a5a204 "Fix pointer crossing screen bug." to current master branch
The commit b4a5a204 fixed an issue, where we can't move the pointer to
other screens and this happens in current master branch again. This commit
ports the old commit to the current master branch.

Signed-off-by: Sven Wegener <swegener@gentoo.org>
Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
2008-06-08 21:44:57 +09:30
Peter Hutterer
da112737eb Check for XINPUT ABI < 3 (corrected version)
Thanks to Sven Wegener for pointing out the incorrect previous version.
2008-06-08 00:15:26 +09:30
Peter Hutterer
d40125ea8c Revert "Check for XINPUT ABI, parameters of InitValuatorClassRec have changed."
GetMotionEvents() doesn't exist, led to compile errors with servers pre-MPX
merge. Thanks to Sven Wegener for pointing this out.

This reverts commit 42422d8f69.
2008-06-08 00:13:35 +09:30
Peter Hutterer
42422d8f69 Check for XINPUT ABI, parameters of InitValuatorClassRec have changed. 2008-05-26 19:29:32 +09:30
Peter Hutterer
15e0091f0b Fail if the device cannot be grabbed during the probe.
If the grab fails, this is most likely a sign that the device has been grabbed
already (probably by a device specified in xorg.conf). So let's not add the
device to the server's input device list, since it won't generate events
anyway.

Exception: keyboards and kernel 2.4 are not affected.
2008-05-23 09:52:46 +09:30
Adam Jackson
d45f315845 evdev 1.99.2 2008-05-21 15:05:10 -04:00
Dan A. Dickey
a4a7003f7c Fix a trivial bug in testing for absolute axes.
Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
2008-05-20 10:57:06 +09:30
Peter Hutterer
3e0dc9945d Shut up two compiler warnings. 2008-05-19 08:36:20 +09:30
Peter Hutterer
ff6251a2bd Remove unused EvdevOpts and EvdevOptions.
In the mouse driver, these options are only used if XFree86LOADER is
undefined. configure.ac in the xserver forces said define to 1 if we're
building the xfree86 DDX, so I don't see the point of having them around.
Especially since they weren't used in evdev anyway.
2008-05-19 08:24:55 +09:30
Peter Hutterer
e9222a8285 man: Option "Path" is supported in the code, add it to man page. 2008-05-18 11:04:43 +09:30
Peter Hutterer
8b7738457f Don't allow relative and absolute axes on the same device.
This is a bit of a mess. The MS Optical Desktop 2000 registers both relative
and absolute axes on the same device (the mouse). The absolute axes have a
valid min/max range for x/y and thus overwrite the x/y relative axes in the
server (no, this is not a server bug). And I wouldn't be surprised if other
devices have similar issues.

Since the device only sends relative events after that, the mouse is
essentially restricted to the min..max range of 0..255. The server simply
doesn't do unrestricted relative axis and restricted absolute axis on the same
device (not for the same axis numbers anyway).
2008-05-02 11:17:57 +09:30
Sascha Hlusiak
1b9deb8e7e Add XK_Meta_L and XK_Meta_R to list of modifiers
Stopps meta/super key from autorepeating
2008-04-01 17:24:13 +02:00
Daniel Stone
0ec391f51c Keyboard: Don't allow arbitrary keymap settings
Pretty much dead code anyway.
2008-03-28 17:46:38 +02:00
Adam Jackson
f77410e1f9 Map REL_DIAL to REL_HWHEEL.
Some Microsoft mice have this wrong.  And it seems like a sensible thing
to do anyway.
2008-03-14 11:15:01 -04:00
Adam Jackson
d28c2e1efb Filter out repeat events for mouse buttons.
Not many mice do this, but some do, Apple Mighty Mouse in particular, and
it makes click-and-drag pretty much impossible to use.

Arguably we should filter _all_ repeat events from the kernel and handle
synthesizing them in the server.
2008-03-12 13:54:10 -04:00
Adam Jackson
697e850a63 Fix middle/right button munging.
Don't do this in the button map.  That's writeable by clients, which means
they have the chance to get it wrong.  Just swap right and middle around
in event dispatch before you get to the user's map.
2008-03-11 19:07:58 -04:00
Adam Jackson
87037b9953 Force xkb_model to be "evdev".
Or at least, refuse to recognise the config option.  It's nonsensical to
use a model of something other than evdev, and it'll just break if you try.
2008-03-10 17:16:38 -04:00
Dan Nicholson
71f4eaec77 Fix cut-and-paste errors in xkb alternate spellings code
Fixes 2b334d6b69.
2008-03-09 22:52:13 +01:00
Adam Jackson
7208397612 Fix cut-and-paste error in abs-to-rel translation. 2008-03-09 16:15:14 -04:00
Adam Jackson
c250f84383 Fix the default XKB rules to be "base" instead of "xfree86". 2008-03-09 15:54:27 -04:00
Adam Jackson
2b334d6b69 Handle the alternate spellings of the xkb options. 2008-03-09 15:53:40 -04:00
Adam Jackson
9773dac623 Merge branch 'evdev-2.0-branch'
This resets to before the ad-hoc input hotplug state, ports that to
current server ABI, adds input hotplug integration, and re-adds support
for absolute coordinate events and XKB.  Several other small fixes were
cherry-picked from the new 1.2 branch.
2008-03-08 20:27:02 -05:00
Adam Jackson
1a0bc8e64a Force maximum keycode to be 255
Even though we don't have keycodes for anything above 127, make sure our
map always covers up to 255.  This ensures that the keycode range never
changes.

Spiritually cherry-picked from a9e87f29cc
and 6db4a9fb84.
2008-03-08 20:06:24 -05:00
Adam Jackson
6271494faa Add absolute coordinate event support.
There are two major classes here, touchscreens and touchpads.  Touchpads
are logically more like relative devices, in that your initial touch
should not warp the cursor.  So attempt to detect touchpads (via the
existence of BTN_TOUCH) and translate absolute events from those devices
to relative motion.
2008-03-08 19:54:44 -05:00
Adam Jackson
f5bfc7ec3c Nuke the keyboard bell code.
It did nothing, and the core won't invoke it anymore anyway.
2008-03-08 16:52:17 -05:00
Adam Jackson
bf0848ec8e Re-add XKB support.
Almost entirely taken from a patch I did ages ago in bug #3912, with
slight cleanups, and with the KcCGST options removed as per evdev 1.x.
2008-03-08 16:50:20 -05:00
Adam Jackson
f1445feac7 Parse Option "Path" as well as Option "Device".
The hotplug core passes Path not Device.  With this change, hotplugging
works.
2008-03-08 16:09:47 -05:00
Adam Jackson
ad5bdcb50f Ignore button events above BTN_TASK for now. 2008-03-07 20:29:58 -05:00
Adam Jackson
bb36ca65c6 Support the new DIX motion history API
Spiritually cherry-picked from 036b457c1b
2008-03-07 19:43:07 -05:00
Daniel Stone
40a1e1439c remove XFree86LOADER usage
Build evdevModuleData, et al, unconditionally.
2008-03-07 19:38:33 -05:00
Adam Jackson
946beb16f8 Unlibcwrap. 2008-03-07 19:09:35 -05:00
Adam Jackson
305f90d37a Branch for evdev 2.0 2008-03-07 19:06:14 -05:00
Sascha Hlusiak
11cf9c92c0 Updated manpage to reflect current state
Large parts of the manpage were obsolete and confused users. Current state should reflect all available driver options. Some details are still missing.
2008-03-03 13:40:52 +02:00
Sascha Hlusiak
7f1e8146d4 More accurate error messages on device open fail.
The message "cannot open input pEvdev" resulted in a lot of bug reports of confused users that did not
supply a device path. Now we tell them when it is missing or print out a reason when device open fails.
2008-02-20 20:41:08 +01:00
Sascha Hlusiak
8ae4d17ca3 Let kernel autorepeat pass when set on default values
xorg-server won't generate soft autorepeat, when interval/delay are at default of 40/660 (see xkb/ddxCtrls.c:
XkbDDXUsesSoftRepeat). When we hit the defaults, we let the kernel autorepeat pass, if we differ, we swallow them all
and let the server figure out autorepeat in software.
2008-02-19 22:49:51 +01:00
Sascha Hlusiak
134ce2e493 Set repeat_delay and repeat_interval to default values
Set ctrls->repeat_delay and ctrls->repeat_interval so that keys will be automatically repeated in software.
2008-02-19 21:12:36 +01:00
Sascha Hlusiak
10e7c3fbdf Filter all incoming repeated key events
Not just filter modifiers but every repeated key, because the software implementation will take care of what key to
repeat and what not. Otherwise the kernel's autorepeated keys interfere with the software generated ones.
2008-02-19 21:09:13 +01:00
Sascha Hlusiak
f766404fd9 Don't inform kernel evdev driver about autorepeat change
We do autorepeat in software now. Informing the kernel would change the autorepeat speed on virtual terminals, which is
probably not wanted so we leave the settings untouched.
2008-02-19 21:05:49 +01:00
Vinay Bondhugula
d032d3c8b4 Clear EV_ABS_V_USE_TOUCH for devices without a touch button
VMware's absolute pointing device does not have a pressure/touch button.
Although evdev correctly recognizes this, it sets "use_touch" for X and Y axes
regardless of the touch button. This patch clears the USE_TOUCH flag for the X
and Y axes if the device does not have a touch button.
2008-01-29 22:15:22 -08:00
Peter Hutterer
5adbc6b98c Initialise b_map_data to correct size. Bug #13991
X.Org Bug 13991 <http://bugs.freedesktop.org/show_bug.cgi?id=13991>
2008-01-29 14:07:49 +10:30
Julien Cristau
eeb3727004 Don't flush buttons on init (bug#12630) 2007-12-07 17:02:11 +01:00
Peter Samuelson
fa15e90993 Fix one additional typo in evdev.man (axis named BRAKE, not BREAK). 2007-10-11 07:27:30 +02:00
Peter Samuelson
12a27693b9 evdev.man minor fixes
* Use \- (ASCII dash) instead of - (hyphen), where appropriate
* Use a roff escape instead of a UTF-8 character.
* Consistent use of quote characters.
* Consistent use of typographic conventions:
  italic "n" in place of "<N>" or "integer" or "number",
  bold for option names, bit maps, etc.

Debian bug #446118
2007-10-11 00:09:40 +02:00
James Cloos
1c40c7db18 Add *~ to .gitignore to skip patch/emacs droppings 2007-09-03 05:52:08 -04:00
Daniel Stone
e2be2ffa47 Options: Accept differently-named options
Take some differently-named options for device and the XKB options.  These
should really be better-handled, but eh.
2007-08-07 15:44:33 +03:00
Brice Goglin
e86aab93c5 Multiple typos in evdev.man
Reported by "A. Costa" <agcosta@gis.net> in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=432063
2007-07-26 18:31:58 +02:00
Tiago Vignatti
c69f4bd570 Clean up a little bit the code. 2007-06-15 01:35:29 -03:00
Tiago Vignatti
64677ecc76 Remove inotify things. 2007-06-15 01:33:49 -03:00
Zephaniah E. Hull
08a09682f5 Update version using PACKAGE_VERSION_*. 2007-06-13 11:05:07 -04:00
Zephaniah E. Hull
9c9a47210a Move the mode option handling to the Init stage.
(Sorta ugly placement wise, but the other segfaults.)
2007-06-12 11:59:16 -04:00
Zephaniah E. Hull
2d2c4804f9 evdev.c:
Set and use the X mode control, letting XInput see it properly.

    Kill some cruft.

evdev.h:

    Set and use the X mode control, letting XInput see it properly.

evdev_axes.c:

    Set and use the X mode control, letting XInput see it properly.

evdev_key.c:

    Remove some cruft, the bell func can be NULL now, so do so.

    Don't bother looking for keys above 0xF7 until we can actually do
    something with them.
2007-06-11 09:08:24 -04:00
Zephaniah E. Hull
6b97bf7a4e Handle default remapping around existing button targets better. 2007-06-06 05:00:29 -04:00
Zephaniah E. Hull
5c6b3dd86f Move MapButtons_t closer to where it's used. 2007-06-06 04:42:51 -04:00
Zephaniah E. Hull
f15636ac52 Wheel mice work again!
(Old configs don't.)

evdev.c:

    Add EvdevParseMapToButton and EvdevParseMapToButtons to evdev_map_parsers.

    Add EvdevParseMapOption to search through evdev_map_parsers.

    Fix up EvdevTokenize to handle the evdev_option_token_t changes.

    EvdevAxesNew0 after BtnNew0 instead of before now.
    (This isn't the right fix.)

evdev.h:

    EVDEV_MAXBUTTONS -> BTN_MAX.

    Redid evdevBtnRec with the new mapping goodness.

    Removed v_min and v_max from evdevAbsRec.

    Reworked evdev_option_token_t, no union, no is_chain.
    If it's a chain, it still has a string, but the chain pointer is set.

    EvdevParseMapToButton, EvdevParseMapToButtons, and EvdevParseMapOption.

evdev_axes.c:

    Kill off EvdevAxesMapButton, a variant lives in evdev_btn.c now.

    Changes for the evdev_option_token_t changes.

    Use EvdevParseMapOption instead of repeating the contents twice.

    Disable EV_ABS_V_INVERT for the moment. (Better fix maybe needed.)

evdev_btn.c:

    s/Ptr /Rec */g

    EvdevMapButton and parser.

    EvdevMapButtons and parser.

    Nuke EvdevBtnCalcRemap as a whole.

    Move everything but the alloc to New1 from New0.

    New mapping code, same guts os the axes mapping code even.
2007-06-06 04:41:54 -04:00
Zephaniah E. Hull
276685fa1d Fix REL mode.
Make buttons mostly work again. (Short term fix.)

NOTE: Wheel to button remapping is still missing!
2007-06-05 23:55:50 -04:00
Zephaniah E. Hull
27a86f8168 Update the copyright notices for me to include 2007.
Finish merging copyright notices. (evdev_key.c was missed.)
2007-06-05 23:19:59 -04:00
Zephaniah E. Hull
26dbf38041 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-input-evdev
Conflicts:

	src/evdev.h
2007-06-05 23:14:46 -04:00
Zephaniah E. Hull
294355842b Alright, this is a really big commit that breaks stuff.
evdev.h:

    Switch to flags in the abs and rel structs.

    Add the axes struct, and defines.

    Rework the abs and rel structs, moving stuff to the axes struct and moving
    everything to the new mapping handling.

    Add the structs and function declarations for the new tokenization stuff,
    parsing stuff, and mapping stuff.

evdev.c: Add EvdevTokenize, and the evdev_map_parsers list.

evdev_axes.c:

    Basicly a full rewrite, big, messy.

    We now use a completely different mapping setup for axes, and mapping to
    buttons is currently missing.

    However we now handle ABS_CALIB and ABS_AREA, including rotation in both
    rel and abs modes.

evdev_btn.c:

    Disable lots of code and break things horribly, we compile but we don't
    work very well.

    Fixing this is next on my todo list.
2007-06-05 23:12:58 -04:00
Kristian Høgsberg
9eb546e0e0 Fix header file #ifdef guard. 2007-06-05 18:26:07 -04:00
Kristian Høgsberg
daf926081d Merge copyright notices. 2007-06-05 18:24:33 -04:00
Peter Hutterer
c22c955c48 Disable and remove the device when a read error occurs. 2007-04-24 23:20:43 +09:30
Zephaniah E. Hull
f87c44b90c Try harder to make unplugging work. 2007-04-24 07:44:26 -04:00
Zephaniah E. Hull
23309b334c Kill some more unused bits. 2007-04-24 07:34:53 -04:00
Zephaniah E. Hull
1716ec88bb Handle driver removal cleanly, we now xfree everything we Xcalloc.
NOTE: Someone needs to check for memory leaks, I'd be willing to bet
a fair bit that we've got tons in the mouse and xkb code, but.
2007-04-24 07:34:25 -04:00
Zephaniah E. Hull
246812bfbc Remove the evil xf86ActivateDevice declaration, don't need it anymore.
Fix the crash on device unplug.

NOTE: We still don't properly get rid of ourselves.
2007-04-24 07:01:54 -04:00
Zephaniah E. Hull
a0ea7363f5 Remove all of evdev_brain.c and all callers.
Remove the non-functional 2.4 kernel compiling compatibility.

Remove the XInput 1.4+ SendCoreEvents/DontSendCoreEvents define replacements.

Remove evdevDriver, some stuff from evdevDevice, all users.

NOTE: This WILL BREAK all existing configurations.

NOTE: Device read failure segfaults, don't unplug stuff.
2007-04-24 06:49:11 -04:00
Zephaniah E. Hull
3c4a96fbd8 Updated configure to 1.2.0, no changes yet.
This branch is the great xserver input-hotplug rewrite, consider it unstable
but usable with the 'current' (as of this commit) git xserver.

(Once it's more done that is.)

NOTE: This branch will _not_ remain source or binary compatable with
pre-input-hotplug xservers, you have been warned.
2007-04-24 06:12:14 -04:00
Peter Hutterer
ba65c34068 Remove driver from list if no device is associated any more.
This effectively stops the driver from hotplugging new devices. Devices have
to be added with the dbus hotplugging events.
2007-04-23 10:08:48 +09:30
Peter Hutterer
9644a4afbf Remove direct call to DEVICE_INIT, ActivateDevice() takes care of that. 2007-04-19 18:47:05 +09:30
Peter Hutterer
d37ba205bb Add some documentation to evdev.c and evdev_brain.c. 2007-04-19 18:46:57 +09:30
Peter Hutterer
9875e2f7f9 ActivateDevice() before EnableDevice() in EvdevNew. 2007-04-19 12:58:16 +09:30
Peter Hutterer
6db4a9fb84 Key: Remove duplicate of keycode 0x6f, remove index 0xf8 to get a
maxKeyCode of 255. This way keycode range is in sync with core keyboard range.
2007-03-25 15:40:47 +09:30
Daniel Stone
a9e87f29cc Key: Force maximum keycode to be 255
Even though we don't have keycodes for anything above 127, make sure our
map always covers up to 255.  This ensures that the keycode range never
changes.
2007-03-21 12:19:48 +02:00
Tiago Vignatti
b4a5a20476 Fix pointer crossing screen bug. Possibly the others input drivers must update
this on the same manner.
2007-02-14 19:23:21 -02:00
Philip Langdale
24f9e67a8f Stop caching the screen size for scaling.
Do be able to correctly scale absolute inputs, the actual
screen size must be used as this changes when the screen
resizes.
2007-02-10 22:17:01 -08:00
root
d8d8f114ca For reasons related to handling pathological remapping cases, and
differences between HID and X, pretend a middle button exists
whenever a right button exists.
2007-01-17 19:27:40 -05:00
root
ebb30a554f Fix a bug where we potentially wrote garbage events when LEDs change.
Support setting keyboard repeat rate/period.
2007-01-13 07:33:49 -05:00
root
3d8bb262e4 Handle swapping of right and middle buttons better in some odder cases. 2007-01-11 22:42:19 -05:00
root
987c6b1597 No more call to xf86OSRingBell in any cases,
maybe do some conditional stuff later.
2007-01-11 22:41:23 -05:00
root
8155e49e76 Pad out button_names so we can loop over things more sanely.
Support for ignoring the existance of buttons,
and for not telling X about them.

By default don't tell X about tools and touch as buttons.
TODO: Revisit this choice later.
2007-01-08 08:59:44 -05:00
Daniel Stone
e1fe72e7fe bump to 1.1.5 2006-12-16 01:42:18 +02:00
Daniel Stone
9f3be57929 Makefile.am: make ChangeLog hook safer
Make ChangeLog hook as safe as possible.
2006-12-06 18:50:15 +02:00
Daniel Stone
5a5457e69c bump to 1.1.4 2006-11-02 03:42:57 +02:00
Daniel Stone
3fc70342aa Merge branch 'input-hotplug' 2006-11-02 03:42:14 +02:00
Daniel Stone
1a8cea3dc4 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-input-evdev 2006-11-02 03:42:13 +02:00
Daniel Stone
ef01c2ef65 key: use os bell-ringing function
Use the OS bell-ringing function to ding the bell.
2006-11-02 03:41:48 +02:00
Daniel Stone
036b457c1b support new DIX motion history API
Use the DIX motion history if we have ABI version 1 or higher.
2006-10-25 02:22:46 +03:00
Daniel Stone
79eb7dcac8 Merge branch 'input-hotplug' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-input-evdev into input-hotplug 2006-10-17 11:32:39 +03:00
Daniel Stone
d7f686bfa3 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-input-evdev into input-hotplug 2006-10-17 11:31:58 +03:00
Daniel Stone
ec09e0d55d brain: call xf86DeleteInput when removing device
Call xf86DeleteInput from evdevRemoveDevice, so it also gets removed from
xf86InputDevs in the DDX.
2006-10-15 19:37:46 +03:00
Adam Jackson
4c72fb7b76 Bump to 1.1.3 2006-10-13 18:25:10 -04:00
Daniel Stone
77cbbc20b6 key: remove usage of OS keyboard layer for bell
Right now, bell is a no-op.
2006-10-08 16:14:12 +03:00
Drew Parsons
5c5ef3fbd6 m68k support (thanks Geert Uytterhoeven for the inotify codes). 2006-10-06 10:56:24 +10:00
Zephaniah E. Hull
a96b048e56 Make some debugging messages optional.
Correctly handle emulating relative mode from absolute data in the case where
we do not get X and Y data at the same time on touching.
2006-10-02 17:50:55 -04:00
Zephaniah E. Hull
d8ea40dc4a Use XORG_VERSION_CURRENT in the module version struct. 2006-10-02 17:49:20 -04:00
Zephaniah E. Hull
ab65184d47 Fix compilation. 2006-09-10 06:47:15 -04:00
Zephaniah E. Hull
63f7edf786 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-input-evdev into input-hotplug 2006-07-25 16:00:44 -04:00
Zephaniah E. Hull
771eee9682 Replace the old two buffer approach to handling rel emulation of abs axes,
should help with some of the reported jitter problems.
2006-07-23 22:40:51 -04:00
Daniel Stone
e468150448 fix InitValuatorClassDeviceStruct call
I don't know how the last parameter got there.  Sorry.
2006-07-21 14:38:12 -04:00
Zephaniah E. Hull
fa03de438e Move the axis to button map code back into the rel code.
This might solve some problems, but should at least prevent some odd behavior.
2006-07-19 23:06:23 -04:00
Daniel Stone
7b91f9277a pass maxval correctly to xf86InitValuatorAxisDeviceStruct
Pass a maxval of -1 (i.e., fill this in appropriately), rather than 0 (0).
2006-07-19 19:45:27 -04:00
Daniel Stone
7defeb0aef pass number of axes to InitValuatorClassDeviceStruct
This is now required with the input-hotplug server.
2006-07-19 19:43:08 -04:00
Daniel Stone
1cb568c0a6 prune device list on DEVICE_CLOSE
Remove a device from the device list when we get DEVICE_CLOSE.
2006-07-19 19:41:54 -04:00
Zephaniah E. Hull
dc88668839 Split the New functions so that structs can be allocated and buttons
detected, and then stuff that depends on _other_ areas.
(Specificly, axes and btn have a circular dependency on which one has to
run first, this solves that.)

Add button names, and a way to get a button number from a name.

Add a function for checking to see if a button exists, takes the number from the previous function.

Change the (unused) state array of pointers in the button struct to an array of pointers to functions for callback.

Implemented the 'touch' feature, on by default if BTN_DIGI_TOUCH exists,
won't, in rel mode, process x/y data unless it's down, and is used to
try and make 'pick up stencil, move to other side of digitizer, set back
down' not jump to the other side of the screen in rel mode.
(This doesn't work as well as it could, but I'm fairly sure that it's
due to the quality of the absolute input device I'm using, but feedback
would be really nice.)

FIXME: Update the manpage for this.
2006-07-13 11:59:25 -04:00
Zephaniah E. Hull
090d43acf3 Update the .gitignore files to remove some more noise. 2006-07-11 16:47:15 -04:00
Zephaniah E. Hull
1b9a9599a4 Rename .cvsignore to .gitignore. 2006-07-11 16:44:43 -04:00
Zephaniah E. Hull
f7a9c74fbc Grab the ChangeLog generation rule from libX11. 2006-07-11 16:42:41 -04:00
Zephaniah E. Hull
9cb7c3dbad (Hope this works.)
Remove the ChangeLog file, as the entire contents can be gotten via 'git log'.
2006-07-11 12:48:10 -04:00
Zephaniah E. Hull
eba5ea8d5a Set pInfo->fd to -1 when we close it in EvdevProc. 2006-07-11 03:08:30 -04:00
Daniel Stone
51d21a3694 remove XFree86LOADER usage
Build evdevModuleData, et al, unconditionally.
2006-07-09 18:08:50 +01:00
26 changed files with 4344 additions and 3184 deletions

View File

@@ -1,19 +0,0 @@
Makefile
Makefile.in
*.la
*.lo
aclocal.m4
autom4te.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
stamp-h1

78
.gitignore vendored Normal file
View File

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

73
COPYING
View File

@@ -1,12 +1,69 @@
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.
Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
Copyright 1993 by David Dawes <dawes@xfree86.org>
Copyright 2002 by SuSE Linux AG, Author: Egbert Eich
Copyright 1994-2002 by The XFree86 Project, Inc.
Copyright 2002 by Paul Elliott
Copyright © 2008 University of South Australia
Copyright 2008 by Chris Salch
Copyright © 2008 Red Hat, Inc.
Please submit updated COPYING files to the Xorg bugzilla:
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.
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
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.
All licensing questions regarding this software should be directed at the
Xorg mailing list:
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Copyright 2005 Adam Jackson.
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
View File

@@ -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.

View File

@@ -18,5 +18,23 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src man
# Provide an sdk location that is writable by the evdev module
DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg'
SUBDIRS = src man include
MAINTAINERCLEANFILES = ChangeLog INSTALL
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-evdev.pc
.PHONY: ChangeLog INSTALL
INSTALL:
$(INSTALL_CMD)
ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL

20
README Normal file
View 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

View File

@@ -20,48 +20,34 @@
#
# Process this file with autoconf to produce a configure script
AC_PREREQ(2.57)
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-evdev],
1.1.2,
[2.5.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
xf86-input-evdev)
[xf86-input-evdev])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE([dist-bzip2])
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
DRIVER_NAME=evdev
AC_SUBST([DRIVER_NAME])
AM_CONFIG_HEADER([config.h])
# Checks for programs.
# Initialize libtool
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_CC
AH_TOP([#include "xorg-server.h"])
# Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
#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
# Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, xorg-server xproto inputproto)
# Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir,
AC_HELP_STRING([--with-xorg-module-dir=DIR],
[Default xorg module directory [[default=$libdir/xorg/modules]]]),
@@ -70,24 +56,21 @@ AC_ARG_WITH(xorg-module-dir,
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)
# X Server SDK location is required to install evdev header files
# This location is also relayed in the xorg-evdev.pc file
sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
# Checks for pkg-config packages
PKG_CHECK_MODULES(XORG, xorg-server xproto $REQUIRED_MODULES)
sdkdir=$(pkg-config --variable=sdkdir xorg-server)
# Workaround overriding sdkdir to be able to create a tarball when user has no
# write permission in sdkdir. See DISTCHECK_CONFIGURE_FLAGS in Makefile.am
AC_ARG_WITH([sdkdir], [], [sdkdir="$withval"])
AC_SUBST([sdkdir])
CFLAGS="$CFLAGS $XORG_CFLAGS "' -I$(top_srcdir)/src'
AC_SUBST([CFLAGS])
DRIVER_NAME=evdev
AC_SUBST([DRIVER_NAME])
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION
AC_OUTPUT([Makefile src/Makefile man/Makefile])
AC_CONFIG_FILES([Makefile
src/Makefile
man/Makefile
include/Makefile
xorg-evdev.pc])
AC_OUTPUT

1
include/Makefile.am Normal file
View File

@@ -0,0 +1 @@
sdk_HEADERS = evdev-properties.h

View 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 always scroll */
#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" /* OBSOLETE */
/* 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

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

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

View File

@@ -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
@@ -16,15 +19,24 @@ evdev \- Generic Linux input driver
.B evdev
is an __xservername__ input driver for Linux\'s generic event devices. It
therefore supports all input devices that the kernel knows about, including
most mice and keyboards.
most mice, keyboards, tablets and touchscreens.
.B evdev
is the default driver on the major Linux distributions.
.PP
The
.B evdev
driver can serve as both a pointer and a keyboard input device, and may be
used as both the core keyboard and the core pointer. Multiple input devices
are supported by multiple instances of this driver, with one Load
directive for evdev in the Module section of your __xconfigfile__ for each
input device that will use this driver.
driver can serve as both a pointer and a keyboard input device. Multiple
input devices are supported by multiple instances of this driver, with one
InputDevice section of your __xconfigfile__ for each input device that will
use this driver.
.PP
It is recommended that
.B evdev
devices are configured through the
.B InputClass
directive (refer to __xconfigfile__(__filemansuffix__)) instead of manual
per-device configuration. Devices configured in the
__xconfigfile__(__filemansuffix__) are not hot-plug capable.
.PP
.SH SUPPORTED HARDWARE
In general, any input device that the kernel has a driver for can be accessed
@@ -37,286 +49,193 @@ 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 \*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 \*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 \*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 \*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 \*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 \*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.
.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 \*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: off. Property: "Evdev Middle
Button Emulation".
.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 \*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 \*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. 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. If the button is 0 and
.BR EmulateWheel
is on, any motion of the device is converted into wheel events. 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 \*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.
.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 \*qIgnoreRelativeAxes\*q \*q" Bool \*q
.TP 7
.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q
Ignore the specified type of axis. Default: unset. The X server cannot deal
with devices that have both relative and absolute axes. Evdev tries to guess
wich axes to ignore given the device type and disables absolute axes for
mice and relative axes for tablets, touchscreens and touchpad. These options
allow to forcibly disable an axis type. Mouse wheel axes are exempt and will
work even if relative axes are ignored. No property, this configuration must
be set in the configuration.
.br
If either option is set to False, the driver will not ignore the specified
axes regardless of the presence of other axes. This may trigger buggy
behavior and events from this axis are always forwarded. Users are
discouraged from setting this option.
.TP 7
.BI "Option \*qCalibration\*q \*q" "min-x max-x min-y max-y" \*q
Calibrates the X and Y axes for devices that need to scale to a different
coordinate system than reported to the X server. This feature is required
for devices that need to scale to a different coordinate system than
originally reported by the kernel (e.g. touchscreens). The scaling to the
custom coordinate system is done in-driver and the X server is unaware of
the transformation. Property: "Evdev Axis Calibration".
.TP 7
.B Option \*qMode\*q \*qRelative\*q\fP|\fP\*qAbsolute\*q
Sets the mode of the device if device has absolute axes.
The default value for touchpads is relative, for other absolute.
This option has no effect on devices without absolute axes.
.TP 7
.BI "Option \*qSwapAxes\*q \*q" Bool \*q
Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
.TP 7
.BI "Option \*qXAxisMapping\*q \*q" "N1 N2" \*q
Specifies which buttons are mapped to motion in the X direction in wheel
emulation mode. Button number
.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".
.SH SUPPORTED PROPERTIES
The following properties are provided by the
.B evdev
driver.
.TP 7
.BI "Evdev Axis Calibration"
4 32-bit values, order min-x, max-x, min-y, max-y or 0 values to disable
in-driver axis calibration.
.TP 7
.BI "Evdev Axis Inversion"
2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
.TP 7
.BI "Evdev Axes Swap"
1 boolean value (8 bit, 0 or 1). 1 swaps x/y axes.
.TP 7
.BI "Evdev Drag Lock Buttons"
8-bit. Either 1 value or pairs of values. Value range 0-32, 0 disables a
value.
.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 Button"
1 8-bit value, allowed range 0-32, 0 disables the button.
.TP 7
.BI "Evdev Wheel Emulation Inertia"
1 16-bit positive value.
.TP 7
.BI "Evdev Wheel Emulation Timeout"
1 16-bit positive value.
.PP
.SH AUTHORS
Zephaniah E. Hull.
.fi
Kristian Høgsberg.
Kristian Høgsberg, Peter Hutterer
.SH "SEE ALSO"
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__).
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)

View File

@@ -1,6 +0,0 @@
.deps
.libs
Makefile
Makefile.in
*.la
*.lo

View File

@@ -24,9 +24,17 @@
# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
# _ladir passes a dummy rpath to libtool so the thing will actually link
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
AM_CPPFLAGS =-I$(top_srcdir)/include
@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
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \
@DRIVER_NAME@.h \
emuMB.c \
emuWheel.c \
draglock.c

323
src/draglock.c Normal file
View File

@@ -0,0 +1,323 @@
/*
* 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 "evdev.h"
#include <xf86.h>
#include <xf86Xinput.h>
#include <X11/Xatom.h>
#include <exevents.h>
#include <evdev-properties.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;
}
free(option_string);
}
/* Updates DragLock button state and fires 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;
EvdevQueueButtonEvent(pInfo, button, state);
}
/* 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
*/
static 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 if ((val->size % 2) == 0)
{
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 += 2)
pEvdev->dragLock.lock_pair[vals[i] - 1] = vals[i + 1];
}
} else
return BadMatch;
}
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

394
src/emuMB.c Normal file
View File

@@ -0,0 +1,394 @@
/*
* 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 "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
#include <xf86Xinput.h>
#include <exevents.h>
#include <evdev-properties.h>
#ifdef HAVE_PROPERTIES
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
static Atom prop_mbtimeout = 0; /* Middle button timeout property */
#endif
/*
* Lets create a simple finite-state machine for 3 button emulation:
*
* 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) {
EvdevPostButtonEvent(pInfo, abs(id), (id >= 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;
/* 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)
{
EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
ret = TRUE;
}
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0)
{
EvdevQueueButtonEvent(pInfo, abs(id), (id >= 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 = xf86SetBoolOption(pInfo->options,
"Emulate3Buttons",
FALSE);
pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
"Emulate3Timeout", 50);
}
void
EvdevMBEmuOn(InputInfoPtr pInfo)
{
if (!pInfo->dev->button) /* don't init for keyboards */
return;
RegisterBlockAndWakeupHandlers (EvdevMBEmuBlockHandler,
EvdevMBEmuWakeupHandler,
(pointer)pInfo);
}
void
EvdevMBEmuFinalize(InputInfoPtr pInfo)
{
if (!pInfo->dev->button) /* don't cleanup for keyboards */
return;
RemoveBlockAndWakeupHandlers (EvdevMBEmuBlockHandler,
EvdevMBEmuWakeupHandler,
(pointer)pInfo);
}
#ifdef HAVE_PROPERTIES
static 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

488
src/emuWheel.c Normal file
View File

@@ -0,0 +1,488 @@
/*
* 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 "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
#include <xf86Xinput.h>
#include <exevents.h>
#include <evdev-properties.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 int 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
*/
EvdevQueueButtonClicks(pInfo, button, 1);
}
}
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, pOtherAxis = NULL;
int value = pEv->value;
int oldValue;
/* Has wheel emulation been configured to be enabled? */
if (!pEvdev->emulateWheel.enabled)
return FALSE;
/* Handle our motion events if the emuWheel button is pressed
* wheel button of 0 means always emulate wheel.
*/
if (pEvdev->emulateWheel.button_state || !pEvdev->emulateWheel.button) {
/* Just return if the timeout hasn't expired yet */
if (pEvdev->emulateWheel.button)
{
int ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
if (ms > 0)
return TRUE;
}
/* We don't want to intercept real mouse wheel events */
if(pEv->type == EV_ABS) {
oldValue = pEvdev->vals[pEvdev->axis_map[pEv->code]];
pEvdev->vals[pEvdev->axis_map[pEv->code]] = value;
value -= oldValue; /* make value into a differential measurement */
}
switch(pEv->code) {
/* ABS_X has the same value as REL_X, so this case catches both */
case REL_X:
pAxis = &(pEvdev->emulateWheel.X);
pOtherAxis = &(pEvdev->emulateWheel.Y);
break;
/* ABS_Y has the same value as REL_Y, so this case catches both */
case REL_Y:
pAxis = &(pEvdev->emulateWheel.Y);
pOtherAxis = &(pEvdev->emulateWheel.X);
break;
default:
break;
}
/* If we found REL_X, REL_Y, ABS_X or ABS_Y then emulate a mouse
wheel. Reset the inertia of the other axis when a scroll event
was sent to avoid the buildup of erroneous scroll events if the
user doesn't move in a perfectly straight line.
*/
if (pAxis)
{
if (EvdevWheelEmuInertia(pInfo, pAxis, value))
pOtherAxis->traveled_distance = 0;
}
/* Eat motion events while emulateWheel button pressed. */
return TRUE;
}
return FALSE;
}
/* Simulate inertia for our emulated mouse wheel.
Returns the number of wheel events generated.
*/
static int
EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
int button;
int inertia;
int rc = 0;
/* if this axis has not been configured, just eat the motion */
if (!axis->up_button)
return rc;
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;
EvdevQueueButtonClicks(pInfo, button, 1);
rc++;
}
return rc;
}
/* Handle button mapping here to avoid code duplication,
returns true if a button mapping was found. */
static BOOL
EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_name)
{
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->num_buttons) pEvdev->num_buttons = up_button;
if (down_button > pEvdev->num_buttons) pEvdev->num_buttons = down_button;
} else {
xf86Msg(X_WARNING, "%s: Invalid %s value:\"%s\"\n",
pInfo->name, axis_name, option_string);
}
free(option_string);
/* Clean up and log what happened */
if (msg) {
xf86Msg(X_CONFIG, "%s: %s: %s\n",pInfo->name, axis_name, msg);
free(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->num_buttons)
pEvdev->num_buttons = 5;
/* Display default Configuration */
xf86Msg(X_CONFIG, "%s: YAxisMapping: buttons %d and %d\n",
pInfo->name, pEvdev->emulateWheel.Y.up_button,
pEvdev->emulateWheel.Y.down_button);
}
/* 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
static 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);
}
}
}
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

File diff suppressed because it is too large Load Diff

View File

@@ -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,220 @@
* 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)
* Oliver McFadden (oliver.mcfadden@nokia.com)
*/
#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 <xorg-server.h>
#include <xf86Xinput.h>
#include <xf86_OSproc.h>
#include <xkbstr.h>
#ifndef BITS_PER_LONG
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
#ifndef EV_CNT /* linux 2.6.23 kernels and earlier lack _CNT defines */
#define EV_CNT (EV_MAX+1)
#endif
#ifndef KEY_CNT
#define KEY_CNT (KEY_MAX+1)
#endif
#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
#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)))
#define EVDEV_MAXBUTTONS 32
#define EVDEV_MAXQUEUE 32
#ifndef test_bit
#define test_bit(bit, array) (!!(array[LONG(bit)] & MASK(bit)))
#endif
#ifndef set_bit
#define set_bit(bit, array) (array[LONG(bit)] |= MASK(bit))
#endif
#ifndef clear_bit
#define clear_bit(bit, array) (array[LONG(bit)] &= ~MASK(bit))
/* evdev flags */
#define EVDEV_KEYBOARD_EVENTS (1 << 0)
#define EVDEV_BUTTON_EVENTS (1 << 1)
#define EVDEV_RELATIVE_EVENTS (1 << 2)
#define EVDEV_ABSOLUTE_EVENTS (1 << 3)
#define EVDEV_TOUCHPAD (1 << 4)
#define EVDEV_INITIALIZED (1 << 5) /* WheelInit etc. called already? */
#define EVDEV_TOUCHSCREEN (1 << 6)
#define EVDEV_CALIBRATED (1 << 7) /* run-time calibrated? */
#define EVDEV_TABLET (1 << 8) /* device looks like a tablet? */
#define EVDEV_UNIGNORE_ABSOLUTE (1 << 9) /* explicitly unignore abs axes */
#define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */
#define EVDEV_RELATIVE_MODE (1 << 11) /* Force relative events for devices with absolute axes */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
#define HAVE_PROPERTIES 1
#endif
/* 2.4 compatibility */
#ifndef EVIOCGSW
#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
#ifndef MAX_VALUATORS
#define MAX_VALUATORS 36
#endif
#ifndef EVIOCGRAB
#define EVIOCGRAB _IOW('E', 0x90, int)
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
typedef struct {
char *rules;
char *model;
char *layout;
char *variant;
char *options;
} XkbRMLVOSet;
#endif
#ifndef BTN_TASK
#define BTN_TASK 0x117
#endif
#ifndef EV_SYN
#define EV_SYN EV_RST
#endif
/* end compat */
#define LONG_BITS (sizeof(long) * 8)
#include <X11/extensions/XKB.h>
#include <X11/extensions/XKBstr.h>
/* Number of longs needed to hold the given number of bits */
#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
/* axis specific data for wheel emulation */
typedef struct {
int up_button;
int down_button;
int traveled_distance;
} WheelAxis, *WheelAxisPtr;
/*
* 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
/* Event queue used to defer keyboard/button events until EV_SYN time. */
typedef struct {
enum {
EV_QUEUE_KEY, /* xf86PostKeyboardEvent() */
EV_QUEUE_BTN, /* xf86PostButtonEvent() */
} type;
int key; /* May be either a key code or button number. */
int val; /* State of the key/button; pressed or released. */
} EventQueueRec, *EventQueuePtr;
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? */
typedef struct {
int real_buttons;
int buttons;
CARD8 map[EVDEV_MAXBUTTONS];
int *state[EVDEV_MAXBUTTONS];
} evdevBtnRec, *evdevBtnPtr;
int num_vals; /* number of valuators */
int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
int vals[MAX_VALUATORS];
int old_vals[MAX_VALUATORS]; /* Translate absolute inputs to relative */
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;
int flags;
int tool;
int num_buttons; /* number of buttons */
BOOL swap_axes;
BOOL invert_x;
BOOL invert_y;
typedef struct {
int axes;
int v[REL_MAX];
int count;
int map[REL_MAX];
} evdevRelRec, *evdevRelPtr;
int delta[REL_CNT];
unsigned int abs, rel;
typedef struct {
int axes;
int v[ABS_MAX];
int btnMap[ABS_MAX][2];
} evdevAxesRec, *evdevAxesPtr;
/* XKB stuff has to be per-device rather than per-driver */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
XkbComponentNamesRec xkbnames;
#endif
XkbRMLVOSet rmlvo;
typedef struct {
char *xkb_rules;
char *xkb_model;
char *xkb_layout;
char *xkb_variant;
char *xkb_options;
XkbComponentNamesRec xkbnames;
} evdevKeyRec, *evdevKeyPtr;
/* 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 _evdevState {
Bool can_grab;
Bool sync;
int mode; /* Either Absolute or Relative. */
unsigned char btnmap[32]; /* config-file specified button mapping */
evdevBtnPtr btn;
evdevAbsPtr abs;
evdevRelPtr rel;
evdevKeyPtr key;
evdevAxesPtr axes;
} evdevStateRec, *evdevStatePtr;
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 _evdevDevice {
const char *name;
const char *phys;
const char *device;
int seen;
/* Cached info from device. */
char name[1024];
unsigned long bitmask[NLONGS(EV_CNT)];
unsigned long key_bitmask[NLONGS(KEY_CNT)];
unsigned long rel_bitmask[NLONGS(REL_CNT)];
unsigned long abs_bitmask[NLONGS(ABS_CNT)];
unsigned long led_bitmask[NLONGS(LED_CNT)];
struct input_absinfo absinfo[ABS_CNT];
InputInfoPtr pInfo;
int (*callback)(DeviceIntPtr cb_data, int what);
/* minor/major number */
dev_t min_maj;
evdevBitsRec bits;
struct input_id id;
/* Event queue used to defer keyboard/button events until EV_SYN time. */
int num_queue;
EventQueueRec queue[EVDEV_MAXQUEUE];
} EvdevRec, *EvdevPtr;
evdevStateRec state;
/* Event posting functions */
void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value);
void EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count);
void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v,
int v[MAX_VALUATORS]);
void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v,
int v[MAX_VALUATORS]);
unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);
struct _evdevDevice *next;
} evdevDeviceRec, *evdevDevicePtr;
/* 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);
typedef struct _evdevDriver {
const char *name;
const char *phys;
const char *device;
/* Mouse Wheel emulation */
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
evdevBitsRec all_bits;
evdevBitsRec not_bits;
evdevBitsRec any_bits;
/* Draglock code */
void EvdevDragLockPreInit(InputInfoPtr pInfo);
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
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

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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 */

View File

@@ -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
View File

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