Commit Graph

50 Commits

Author SHA1 Message Date
Peter Hutterer
2285fe78c0 xfree86: add support for MatchIsTabletPad
The tablet pads have been separate kernel devices for a while now and
libwacom has labelled them with the udev ID_INPUT_TABLET_PAD for over a year
now. Add a new MatchIsTabletPad directive to apply configuration options
specifically to the Pad part of a tablet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-03 16:15:51 +10:00
Laércio de Sousa
daa6d2d58f config/udev: distinguish between real keyboards and other key devices
This patch introduces a new flag ATTR_KEY for hotplugged input devices,
so we can better distinguish between real keyboards (i.e. devices with
udev property ID_INPUT_KEYBOARD="1") and other key input devices like
lid switches, power buttons, etc.

All supported hotplug backends (udev, hal, and wscons) will set both
flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend
will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input
devices (hal and wscons will set both flags in any case). With this
distinction, kdrive input hotplugging mechanism will be allowed to only
grab real keyboards, as other key input devices are currently not
supported.

In order to don't break current behaviour, this patch will replace all
ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c.

[ajax: Just add ATTR_KEY, don't re-number the other attributes]

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Laércio de Sousa <laerciosousa@sme-mogidascruzes.sp.gov.br>
2016-03-01 10:46:48 -05:00
Peter Hutterer
795066477e config: search for PnPID on all parents (#75513)
The PnPID for a device may not be on the immediate parent, so search up the
device tree until we find one.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-03-12 07:43:16 +10:00
Hans de Goede
480590b90c dbus-core: Make dbus-core no longer mutually exclusive with udev
With systemd-logind the dbus-core will be used for more then just config, so
it should be possible to build it even when using a non dbus dependent config
backend.

This patch also removes the config_ prefix from the dbus-core symbols.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-01-29 15:28:58 -08:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Dave Airlie
8d3731a811 hal: free tmp_val in one missing case
Pointed out by coverity scan.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-12-06 16:01:50 +00:00
Peter Hutterer
05284a03f9 input: make InputOption opaque, provide interface functions.
InputOptions is not switched to use struct list for a future patch to unify
it with the XF86OptionRec.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2011-08-22 15:56:53 +10:00
Peter Hutterer
20a61845d3 config: use add_option for '_source' too
_source was being allocated manually, with all other options added to that
list through add_option. Skip the manual part, allocate the first option
_source with add_option too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-08-22 15:56:50 +10:00
Rami Ylimäki
4114533db6 config: Ensure that stolen option list elements are released.
NewInputDeviceRequest steals the contents of option list elements but
doesn't use the elements themselves for anything. Therefore the list
elements need to be released always.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 07:59:41 +10:00
Alan Coopersmith
3a9bb93dd1 Convert alloc+sprintf pairs into asprintf() & XNFasprintf() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Alan Coopersmith
03e8bfa1d1 Convert existing Xprintf style calls to asprintf style
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Peter Hutterer
31c71425ac config: expose config_info as an input option.
config_info is the only reliable indicator we have in the server for
duplicate devices (drivers can test for maj/min on fds as well). Don't set
this after the device has been initialized but assume it's important enough
to set during NIDR.

This makes the option "config_info" available to the drivers as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-09-01 15:26:46 +10:00
Mikhail Gusarov
6592db6bb5 Get rid of xstrdup when argument is definitely non-NULL
Replace xstrdup with strdup when either constant string is
being duplicated or argument is guarded by conditionals and
obviously can't be NULL

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-06-11 19:04:23 +07:00
Dan Nicholson
87a1507da7 xfree86: Match devices based on USB ID
Sometimes the vendor and product names aren't specific enough to target
a USB device, so expose the numeric codes in the ID. A MatchUSBID entry
has been added that supports shell pattern matching when fnmatch(3) is
available. For example:

	MatchUSBID "046d:*"

The IDs are stored in lowercase hex separated by a ':' like "lsusb" or
"lspci -n".

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11 09:30:33 +10:00
Dan Nicholson
645679c152 xfree86: Match devices based on PnP ID
Serial input devices lack properties such as product or vendor name. This
makes matching InputClass sections difficult. Add a MatchPnPID entry to
test against the PnP ID of the device. The entry supports a shell pattern
match on platforms that support fnmatch(3). For example:

	MatchPnPID "WACf*"

A match type for non-path pattern matching, match_pattern, has been added.
The difference between this and match_path_pattern is the FNM_PATHNAME
flag in fnmatch(3).

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11 09:30:07 +10:00
Dan Nicholson
61c35d8ac4 config/hal: Missing newline in log message
Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-10 14:33:08 +10:00
Dan Nicholson
94547b2d14 config/hal: don't leak the input.tags property
Signed-off-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-10 14:32:57 +10:00
Mikhail Gusarov
0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Mikhail Gusarov
3f3ff971ec Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Peter Hutterer
c6d9bc092c Add tag matching to input attributes.
Tags may be a list of comma-separated strings that match against a MatchTag
InputClass section. If any of the tags specified for a device match against
the MatchTag of the section, this match is evaluated true and passed on to
the next match condition.

Tags are specified as "input.tags" (hal) or "ID_INPUT.tags" (udev), the
value of the tags is case-sensitive and require an exact match (not a
substring match).

i.e. "quirk" will not match "QUIRK", "need_quirk" or "quirk_needed".

Example configuration:
udev:
    ENV{ID_INPUT.tags}="foo,bar"

hal:
    <merge key="input.tags" type="string">foo,bar</merge>

xorg.conf:
    Section "InputClass"
            Identifier "foobar quirks"
            MatchTag "foo|foobar"
            Option "Foobar" "on"
    EndSection

Where the xorg.conf section matches against any device with the tag "foo"
or tag "foobar" set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-02-11 19:25:49 +10:00
Julien Cristau
435f27667f config: add libudev input-hotplug backend
Add a backend using libudev for input hotplug, and disable the hal and
dbus backends if this one is enabled.

XKB configuration happens using xkb{rules,model,layout,variant,options}
properties (case-insensitive) on the device.  We fill in InputAttributes
to allow configuration through InputClass in Xorg.

Requires udev 148 for the input_id helper and ID_INPUT* properties.

Signed-off-by: Julien Cristau <jcristau@debian.org>
Acked-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-30 19:05:44 +00:00
Dan Nicholson
0711598dd3 config: Introduce InputAttributes in NewInputDeviceRequest
In order to give NewInputDeviceRequest more information, a new
InputAttributes type is introduced. Currently, this collects the product
and vendor name, device path, and sets booleans for attributes such as
having keys and/or a pointer. Only the HAL backend fills in the
attributes, though.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
2009-12-22 23:24:13 -08:00
Peter Hutterer
49046088f1 config: don't shutdown the libhal ctx if it failed to initialize (#23213)
Regression introduced by b1c3dc6ae2.
Shutting down the libhal_ctx if the init failed may cause an abort.
This can happen if hald is not yet running at server startup.

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

Tested-by: Stefan Dirsch
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-14 11:01:20 +10:00
Rémi Cardona
b1c3dc6ae2 config: add HAL error checks
This patch simplifies error handling in the HAL code and fixes a
segfault if libhal_find_device_by_capability() failed.

Fixes http://bugs.gentoo.org/278760

Based on a patch by Martin von Gagern <Martin.vGagern@gmx.net>

Signed-off-by: Rémi Cardona <remi@gentoo.org>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-28 11:58:45 +02:00
Alan Coopersmith
1e816065e5 Don't printf NULL pointers on HAL connection error
Fixes Solaris bug 6801386 Xorg core dumps on startup if hald not running
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6801386

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
2009-05-08 21:31:01 -07:00
Peter Hutterer
4844bff58f config: if we can't connect to HAL, listen for a startup notification.
If HAL isn't available when we try to connect, the registered NameOwnerChanged
signal handler waits until HAL is available. Once we connected to HAL, we
unregister the signal handler again.
This allows HAL to be started in parallel or after the server has started.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-10 15:01:44 +10:00
Alan Coopersmith
b4ca9dc239 When HAL returns a NULL property, print "(null)" instead of a NULL pointer
They've promised to fix Solaris printf soon to check for NULL pointers
instead of segfaulting, but that won't help people on existing releases.
2008-11-05 21:58:30 -08:00
Peter Hutterer
6c45185955 config: don't add duplicate devices through HAL.
If HAL is restarted, the device list is sent to the server again, leading
first to duplicate devices (and thus duplicate events), and later to a
FatalError "Too many input devices."

dev->config_info contains the UDI for the device. If the UDI of a new devices
is equal to one we already have in the device list, just ignore it.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-10-29 11:55:44 +10:30
Peter Hutterer
e58be0f342 config: print error code if NIDR fails. 2008-09-26 09:33:39 +09:30
Peter Hutterer
3c6a9c531f config: protect against potential out-of-bounds indexing. 2008-08-04 15:15:16 +09:30
Peter Hutterer
92c51b183c config: support type strlist for XkbOptions property.
For backwards compatibility with server 1.4.
2008-08-04 15:15:09 +09:30
Peter Hutterer
35b14519b4 config: add parsing for input.x11_options.XkbOptions. #16874
X.Org Bug 16874 <http://bugs.freedesktop.org/show_bug.cgi?id=16784>
2008-08-04 15:14:05 +09:30
Daniel Stone
b8dd07f855 HAL: Remove grotesque open-coded strcasestr
Not only was this pretty ugly, but it didn't even work on systems
without strcasestr anyway, due to the define not being in dix-config.h.
Lack of strcasestr is handled transparently with the version from
FreeBSD now anyway, so, huzzah.
2008-07-16 03:02:20 +03:00
Peter Hutterer
5ebe76f13f config: init dev to NULL to shut up a valgrind warning. 2008-06-02 10:26:03 +09:30
Adam Jackson
f52f6c5c7e Fix hal shutdown crash.
Removing the device invalidates its ->next pointer.  Copy it aside before
destroying the device.
2008-05-16 09:49:20 -04:00
Alan Coopersmith
ed65e8b4f0 Check for strcasestr and workaround it on systems without it 2008-05-12 18:50:04 -07:00
Peter Hutterer
ff013b0da4 config: override xkb_{r,m,l,v} with Xkb{r,m,l,v} if the latter is set.
The HAL spec says that input.xkb.{rmlv}* can be sent, but if the user
specifies a X-specific {rmlv}, then this is overridden through the use of
input.x11_options.Xkb{RMLV}.
However, the way how the server parses options--by ignoring capitalisation,
underscores and spaces--the HAL and the x11_options would override each other.

So we simply filter the options, letting Xkb{RMLV} override xkb_{rmlv} and
only actually add them to the device after parsing _all_ options.

* rmlv ... rules, model, layout, variant

See Bug 13037 <http://bugs.freedesktop.org/show_bug.cgi?id=13037>
(cherry picked from commit fc35d1e3be)
2008-05-09 10:09:35 +09:30
Peter Hutterer
901978ebe0 config: remove trailing whitespaces.
It makes my vim look ugly. Put "let c_space_errors=1" into your .vimrc.
(cherry picked from commit 1f54c05cf8)
2008-05-09 10:09:25 +09:30
Sascha Hlusiak
47eb658e80 Support to pass arbitrary options via HAL hotplugging
Parse "input.x11_options" and pass every key/name pair to the driver.
Remove check for input.capabilities, because that's part of the fdi files.

Thanks to Dustin Spicuzza <dustin@virtualroadside.com> for the patch.
2008-03-25 17:37:25 +01:00
Peter Hutterer
f0ba770716 config: only shutdown libhal if the connection is valid.
Thanks to libdbus' extensive use of assert we won't just get an error, it'll
bring the whole server down for us.
(cherry picked from commit fb07fab2c0)
2008-01-29 09:13:25 +10:30
Peter Hutterer
2cb0ebec2b config: add a debug message, fix a whitespace error.
(cherry picked from commit 7732898aaa)
2008-01-29 09:13:25 +10:30
Daniel Stone
190a050624 Config: HAL: Don't leak options on failure to add device
This showed up in Xephyr in particular, which denies new device requests.
2007-12-28 15:51:36 +02:00
Fatih Aşıcı
009f1e4e55 Config: Don't forget to add xkb_rules option 2007-12-26 02:08:12 +01:00
Fatih Aşıcı
389e8917f6 Config: Fix a memory leak 2007-12-26 02:07:52 +01:00
Kanru Chen
a8e27a108a Config: HAL: Fix XKB option parsing
Actually combine the XKB options into a string, rather than just repeatedly
writing a comma.
2007-12-05 18:29:54 +00:00
Markku Vire
3f1b6765aa Config: HAL: Touchpads are pointers too
Treat touchpads -- not just mice -- as pointer devices.
2007-11-04 16:46:21 +00:00
Daniel Stone
30259d5a4e Hotplug: HAL: Fix error handling
Don't use our DBusError for property getting, because we simply don't care:
this fixes D-Bus error spew to stderr.  Thanks Michel Dänzer for debugging
and testing.
2007-08-08 01:34:59 +03:00
Daniel Stone
aef255425a Config: HAL: Use input.xkb namespace
Use an explicit input.xkb.foo namespace, not input.xkb_foo.
2007-08-08 01:34:59 +03:00
Daniel Stone
1150969b82 Convert all my license statements to the standard form
Convert all my license statements to the standard, accepted form:
cf. <20070717142307.GD13478@fooishbar.org>
    http://lists.freedesktop.org/archives/xorg/2007-July/026451.html

keithp's license on configure.ac changed with his verbal permission.
2007-08-01 01:53:31 +03:00
Daniel Stone
8658f5d923 Hotplug: Add HAL support
Add support for HAL-based hotplugging, in which we just get the list of
input devices and properties from HAL.  Requires an FDI which is not yet
in mainline HAL.
2007-08-01 01:53:31 +03:00