Udate to xinput version 1.5.0

This commit is contained in:
matthieu 2009-10-24 14:17:46 +00:00
parent 8a4dfaafb9
commit f8f52ab1fb
18 changed files with 2823 additions and 1122 deletions

View File

@ -1,10 +1,455 @@
commit 5600d953531f377b5be114c9b72aca281f9bbca5
commit 09b075863708e43b9c1202dd052f36d5f865f571
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 15:21:16 2009 +1000
Date: Tue Oct 13 15:25:19 2009 +1000
xinput 1.4.2
xinput 1.5.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 0996eebd20b017078b7a61e42b13b3c1c5acd1b8
commit 5f49354072a3d331fe359eac0ebff09506668952
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Oct 9 15:28:34 2009 +1000
Clean up --version, don't require a DISPLAY and display the server version too.
version.c was removed, seemed a bit excessive for the 20 lines of code.
--version is integrated separate from the other commands now, checked before
opening the display. xinput now prints its own version in all cases, even if
the display is unavailable. If the display is available, it prints the
server version too. Example output:
$> xinput --version
xinput version 1.4.99.3
XI version on server: 2.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 7ecd7d55d7a7ab9f5cea5f34f28c7c221171c2bf
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Oct 9 15:07:30 2009 +1000
man: clean up the man page.
Several changes to the man page to tidy it up a bit:
- RCS tag removed
- synopsis shortened, OPTIONS section added instead
- "xinput" dropped before the option descriptions, options in manpage
prefixed with '--'.
- device_name replaced with just device, since it may be a deviceid.
- Removed references to XI man page calls that some options use, it really
doesn't matter to users what the underlying Xlib call is.
- mark set-int-prop and set-float-prop as deprecated in the man page.
- add --test_xi2 flag
- Added a few more authors.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@sun.com>
commit 7010a6c924ce6937c8e040c837a118663d6dfdb3
Author: Thomas Jaeger <ThJaeger@gmail.com>
Date: Wed Oct 7 13:05:15 2009 -0400
Rework 'xinput list' code
* Drop the questionable --loop option
* Add a --long option (opposite of --short)
* Make --short the default if no device argument is given
* XI2: Make it possible to query a single device
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
squashed in a man page update for --short and --long.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 7d930a42e6c294ecaaf42585e37b8dc24be8a805
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Sep 24 10:45:54 2009 +1000
Bump to 1.4.99.3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a2392f62a93fd288abb8000556d1b34eadaf697f
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Sep 21 17:30:55 2009 -0700
Use __xorgversion__ instead of RCS $Date in man page header/footer
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
commit 2ba793d412608dcad61dbca1c8c76740d4982e2b
Author: Julien Cristau <jcristau@debian.org>
Date: Tue Sep 15 17:37:34 2009 +0200
Use do_set_prop for set_{atom,float,int}_prop
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 79800e1e0fa3b45b6ed37453851df24c98da4435
Author: Julien Cristau <jcristau@debian.org>
Date: Tue Sep 15 17:55:35 2009 +0200
set-prop: add --type={atom,float,int} and --format={8,16,32} options
Allows creating new properties or modifying the type and format of
existing ones.
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 1665fa4e24930f7e3f1cfbc8bf50119ab7d6ca04
Author: Julien Cristau <jcristau@debian.org>
Date: Tue Sep 15 17:33:54 2009 +0200
Add a format and type argument to the set_prop functions
This will allow the addition of command-line options to set format and
type, and the reuse of this code for the set-{atom,float,int}-prop
paths.
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 650c52db8b30cebca3386ac350154a6b3a0abbe1
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Sep 16 12:29:26 2009 +1000
Require xorg-macros 1.3 for XORG_DEFAULT_OPTIONS.
commit 22fdd63f4521c89ae43bbfc6741e872b4a74d18f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Aug 21 15:56:19 2009 +1000
test_xi2: Print the key repeat flag if it is set.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 6c362c67ec7fb62d2d7bab5ab4e779147f941a33
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Aug 3 15:59:16 2009 +1000
Bump to 1.4.99.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 10a5596e9cd6dbca0826929e03e9495703279822
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Jul 21 16:20:03 2009 +1000
test-xi2: Update to keycode grabs instead of keysym grabs.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 6aa2dbd555ca4d659acbebffabe28bf648eed32d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Jul 16 16:14:01 2009 +1000
Print XINotifyPassiveGrab detail in enter events too.
commit b6949c809c69d824fa5fdb2825f045ed716237d8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Jul 14 16:27:36 2009 +1000
test_xi: Print deviceid for enter events too
commit 59fc7423bf0e8d29747074449e7a3484cafb2f42
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Jul 14 16:13:48 2009 +1000
Use XI2 defines for enter/leave modes and detail.
Doesn't matter much since they are the same as the core ones anyway, but
nicer for consistency.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 9a20ce005c12cea9cf215125c96a00c7cbe988c7
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Jul 13 16:05:25 2009 +1000
Adjust to new, split-up raw event types.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 7baaba9fbef48b1f45a51c1654e605df074800b8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Jul 13 09:18:35 2009 +1000
test_xi2: Plug memory leak with XGetAtomName.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit cb93b032989907e5274d9a5d95ae01535001ec19
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Jul 13 09:15:49 2009 +1000
test_xi2: Update to use cookie events - require libXi 1.2.99.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit d7f6f7eda435b550d782b545cd7828b21c19b7b4
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Jun 30 16:18:20 2009 +1000
Plug memory leak from XGetAtomName.
commit 248faefc957a9b0877384842540b2d935e1b5c07
Author: Benjamin Close <Benjamin.Close@clearchain.com>
Date: Wed Jun 24 11:55:00 2009 +0930
Obtain the XInput opcode and check that GenericEvents are actually XI events
Signed-off-by: Benjamin Close <Benjamin.Close@clearchain.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 1c28ba44958389892470688ce394c034dc8efa21
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jun 24 10:30:45 2009 +1000
test_xi2: don't map the window before selecting for events.
Mapping the window before selecting for XI2 events leaves some events out
(e.g. enter events if the pointer is already in the area where the window is
being mapped).
Reported-by: Thomas Jaeger
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit f00f6b1c58b3ded52d8cb0002e0bacd558bc874c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jun 24 10:29:12 2009 +1000
test_xi2: use %#x alternative printf format.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 97fbbe671827194fa175d6bd15f6189e921393c5
Author: Thomas Jaeger <ThJaeger@gmail.com>
Date: Tue Jun 23 12:49:56 2009 -0400
remove-master: document possible return modes in --help
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit f1e11109acae93f2d9cbee2333dcf7b65cf6151b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Jun 23 13:26:56 2009 +1000
Fix --help output for create-master and remove-master.
Missing <> added. All parameters in the --help output have surrounding <> if
the parameter is something the user has to substitute.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 863423141a3347a013004c809e9d8ce29e11d377
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sat Jun 20 17:59:59 2009 +1000
Bump to 1.4.99.1
We've had a 1.4 branch for a while now, this bump is way overdue.
commit e8ca8fa459eb2eb4d9e9faf294d7172fb4fdb17b
Author: Thomas Jaeger <ThJaeger@gmail.com>
Date: Sun Jun 14 13:58:39 2009 -0400
reattach: Default to return to VCP/VCK when returnMode is AttachToMaster
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit f8b3dc4e1c43140514d20fbc9fddd0f352cbe40b
Author: Thomas Jaeger <ThJaeger@gmail.com>
Date: Mon Jun 15 21:45:32 2009 -0400
test-xi2: Report correct event coordinates
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit cddc199d10952ec2a851e4b120061701e664be1b
Author: Thomas Jaeger <ThJaeger@gmail.com>
Date: Mon Jun 15 21:37:56 2009 -0400
test-xi2: Use standard macros instead of BitIsOn/SetBit
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 82d338548e22ae271f50592e759794dd7536a207
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jun 17 21:23:17 2009 +1000
Require inputproto 1.9.99.12
commit efab9cff2a3605c803786ff9a69ff1aeb155479d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jun 17 21:23:06 2009 +1000
Print the valuator value for absolute axes.
commit a4efa37a0646497ed46f4462d8c745ab17339f62
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jun 17 21:22:23 2009 +1000
Print button and valuator labels when listing a device.
commit 632ef53adf1e18509dfa2a1ae820910aa0a88545
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Jun 15 14:10:30 2009 +1000
Print button state when listing XI2 devices.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit e119d872c74f0190d40d5c4cd742c196aab6bf48
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Jun 12 16:31:02 2009 +1000
Print the sourceid when listing device classes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a97520d6e5245ad15d7b7edbf355a343db53e144
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Jun 12 16:29:37 2009 +1000
Use the XI2 class defines for listing device classes in XI2 mode.
Purely cosmetic change, the values are the same anyway.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 47983fbd12366ee8ce89b293955b43f7e49b1785
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Jun 12 15:47:02 2009 +1000
Fix build errors introduced by inputproto 1.9.99.11.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 8659d4f88c805e764d671ae50dc110f742727dd7
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jun 3 12:57:10 2009 +1000
xi2 test: add two missing breaks.
Printing a hierarchy event would always print only "master keyboard" or
"slave keyboard", never pointers.
commit 8917716f37e4acbd848ea0c6abd1c943bde2f24d
Author: Thomas Jaeger <ThJaeger@gmail.com>
Date: Fri May 29 19:23:04 2009 -0400
test-xi2: fix modifiers for XIGrabButton call
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 6c701334d13aabc832b41a3a060dedb8978943d3
Author: Benjamin Close <Benjamin.Close@clearchain.com>
Date: Thu May 28 18:44:47 2009 +1000
Remove superfluous dev assignment.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 969aad3967e58acfcb3da3583858cae09694652a
Merge: 9aa8f48 5ad5edc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 27 07:34:32 2009 +1000
Merge branch 'master' into xi2
commit 5ad5edc65e55fe4be63ba31acec4bc1fca96e81b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 27 07:33:31 2009 +1000
Print empty properties as <no items>.
commit 9aa8f4826ed7120ae0ff759c6df40a0d3f37c720
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 27 07:33:52 2009 +1000
Print empty XI2 properties as <no items>
commit 13e9758b2ebd5d545c08903aab0eccd423851a30
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 27 07:33:31 2009 +1000
Print empty properties as <no items>.
commit 5fcd16638abf156a47d4d1c2e3caf0206b97b953
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 20 12:11:07 2009 +1000
Print None properties in XI2 mode too.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 7458e7dde70f5d9ff281848fb1a56e9a5f1dd783
Merge: 14f47c2 aae3bfe
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 20 12:10:44 2009 +1000
Merge branch 'master' into xi2
commit aae3bfee098567a80444b970aea4c737c736254c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 20 12:02:31 2009 +1000
Deal with None atoms.
An atom may in some cases be 0 (None). Deal with this instead of failing with
BadAtom values.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 14f47c23f56c06058673748755b3e31a6d18edf1
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue May 19 15:28:16 2009 +1000
Print floating slaves in XI2 list mode.
Floating slaves are always printed last.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 1c72fd55d61371de81f44be5d92982a3012ad24b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed May 13 14:20:58 2009 +1000
Update to new inputproto and libXi naming conventions.
Require inputproto 1.9.99.9.
commit 9c6a51e8aaba50b8f3a0f3ad767c34a80aee55a1
Merge: 239cd6a 4832dc1
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri May 8 15:15:45 2009 +1000
Merge branch 'master' into xi2
Conflicts:
src/xinput.h
commit 239cd6a673be2821915301c1b3c3bae063e9dd94
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri May 8 14:21:17 2009 +1000
Update to new inputproto defines.
commit 5d973706f4f706b7576bb6feac4beb7273438b78
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Apr 30 16:53:05 2009 +1000
update test_xi2 with a few more tests.
commit 4832dc1f3ee8d11eadc99b5cd4e8158773d11f9b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 14:00:46 2009 +1000
@ -13,9 +458,77 @@ Date: Thu May 7 14:00:46 2009 +1000
This isn't really necessary, but we might as well be correct.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4832dc1f3ee8d11eadc99b5cd4e8158773d11f9b)
commit c6c2736a31c00717c5915e97a22b85d96ce163fe
commit d15a6c0c4cbf2b7d3feec0c829145e3036d84e4d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 12:56:58 2009 +1000
Clean up xinput.h a bit
Remove the unnecessary NeedFunctionPrototypes ifdef.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 125074488dc27f484a30a8d076133c73f4d9ef48
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 14:37:58 2009 +1000
Add support for XI2 property requests.
If XI2 is available, we use XI2 for list-props, delete-prop and set-prop.
commit ff1b12265de1010aa22011c5db829274a8a3dab1
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 14:13:45 2009 +1000
Get the XIDeviceInfo instead of just the id.
This way we leak the XIDeviceInfo array, but then again it doesn't matter
since we exit after the command anyway.
And with the XIDeviceInfo around, we can actually print the name and
whatnot.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit ba2396b40a427c30c58f8c17b64f4cf7bfaa2909
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 14:00:46 2009 +1000
XCloseDisplay when we're done.
This isn't really necessary, but we might as well be correct.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit ea87f587e4090d2881ce8957476411b6de1c260b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 13:59:12 2009 +1000
Remove one more unnecessary ifdef.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a783c19f94e6fed28aeaf0550558cd0b63402b9c
Merge: 65e3e12 4e6e0dd
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 13:06:05 2009 +1000
Merge branch 'master' into xi2
Conflicts:
src/property.c
src/xinput.c
src/xinput.h
commit 4e6e0dd562e8e844bede349bd11c339644447d78
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu May 7 12:56:58 2009 +1000
Clean up xinput.h a bit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 4b4b2e3f31cf08073887d8583997eb3340a6c2e1
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri May 1 11:22:53 2009 +1000
@ -27,9 +540,8 @@ Date: Fri May 1 11:22:53 2009 +1000
Reported-by: Simon Thum <simon.thum@gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4b4b2e3f31cf08073887d8583997eb3340a6c2e1)
commit c7df478676b6573a07f74484668f9130706c4a1f
commit 42dca922d287ffddcf2185ca96738f1505a04c27
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Apr 30 14:50:08 2009 +1000
@ -37,18 +549,85 @@ Date: Thu Apr 30 14:50:08 2009 +1000
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Simon Thum <simon.thum@gmx.de>
(cherry picked from commit 42dca922d287ffddcf2185ca96738f1505a04c27)
commit 0616fc2e8c76c70d95173377abf39b2c7edfce19
commit e9af7c5f602b5580df36c77ee1c2ed22ccf72134
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri May 1 09:14:46 2009 +1000
The float_atom should actually be an Atom
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit e9af7c5f602b5580df36c77ee1c2ed22ccf72134)
commit 4fa194b42a5a6a15b533be070d21d981751b9b83
commit 65e3e12fa6fc2043fbb0122c72a4f7df09b1c659
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Apr 30 14:50:08 2009 +1000
If there's multiple null-terminated strings in the property, print all.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit e7cd0436689b54d14e05a601e426cd600994db89
Author: Julien Cristau <jcristau@debian.org>
Date: Mon Apr 20 13:58:03 2009 +0200
xinput: add set-prop command
There's no reason to require the user to know the difference between
set-int-prop, set-float-prop and set-atom-prop, and to know the required
format for each integer property, since we can just ask
XGetDeviceProperty.
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 167034ba2798fbe34abf4748068ae480e45bfe13
Author: Julien Cristau <jcristau@debian.org>
Date: Thu Apr 16 18:55:46 2009 +0200
Factorize atom parsing in its own function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 2722d1a177c9482989e314e0177c782563a0b54e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Apr 20 08:28:53 2009 +1000
XSync the display before jumping in the grab code.
The grab code only handles button presses, so we need to remove all events
before (exposures, enter/leave, etc.).
commit 0df21cff5cdf2cf4af0af353f0dbfc7c33388b32
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sun Apr 19 21:28:25 2009 +1000
Add a hunk to test XI2 sync'd grabs.
commit dd27752cbff03ea79ac76801d3748edc348570dc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sun Apr 19 21:27:40 2009 +1000
Register for exposure events and block until we're mapped.
commit a7de225eea0c7561e73d44c63844a8e98dea9676
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sun Apr 19 21:09:49 2009 +1000
Print event/root x/y on device events.
commit 795799eff591be1fa8ce5199aa89a86dcb4b04e8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sun Apr 19 20:33:40 2009 +1000
Actually print event_y when trying to print event_y in Enter/Leave events.
commit 57d367b74d1068d38ce313a06a36654fd82ad460
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sat Apr 18 08:43:43 2009 +1000
replace BYTE with an unsigned char.
commit a577bada8dddf3241a59cab812f5128131c46b29
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date: Thu Apr 16 09:20:16 2009 -0400
@ -58,9 +637,8 @@ Date: Thu Apr 16 09:20:16 2009 -0400
typecast around a bit.
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
(cherry picked from commit a577bada8dddf3241a59cab812f5128131c46b29)
commit 7abb366e80d3a309d4ab8cd459ce184c6806b6d1
commit de6326a75de810752a5b4e4c2f5fe98a2f7241a9
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Apr 14 09:13:15 2009 -0400
@ -69,25 +647,32 @@ Date: Tue Apr 14 09:13:15 2009 -0400
libX11 uses longs for 32 bit values, increasing hilarity on 64 bit machines.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit de6326a75de810752a5b4e4c2f5fe98a2f7241a9)
commit 4dc5f13e13c9434d6fa9ed9f10a8e12a55aedc24
commit 1e3da5be51efebdd75df540a1c94baa6505cfc9a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Apr 14 13:54:40 2009 +1000
Fix 64 bit issues with set-int-prop.
libX11 expects longs for 32 bit numbers.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 2f8f2193fdfe783c0854772cc46f1b2e0b2e3ec4
Author: Simon Thum <simon.thum@gmx.de>
Date: Thu Mar 26 13:52:15 2009 +0100
xinput: include device type in device list
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 2f8f2193fdfe783c0854772cc46f1b2e0b2e3ec4)
commit 61b2df1cd0135d90c65219cfa17caedbe60a44a2
commit 17d537fd65ba9b1c99a0dde7833eb4069cc624a8
Author: Simon Thum <simon.thum@gmx.de>
Date: Thu Mar 26 15:19:47 2009 +0100
xinput: mention set-float-prop in manpage
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 17d537fd65ba9b1c99a0dde7833eb4069cc624a8)
commit 286724a1417ffda447be918e8bcf46cc37ed715b
Author: Peter Hutterer <peter.hutterer@who-t.net>
@ -107,6 +692,108 @@ Date: Thu Feb 19 14:39:29 2009 +1030
Signed-off-by: Benjamin Close <Benjamin.Close@clearchain.com>
commit b04e8b472022c185123638a3d4639fbbcf0f144f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Mar 11 09:52:08 2009 +1000
Print enter/leave and focus events.
commit 70aac046bb4fb0028fcf018ae72bf29acfe6abac
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Mar 10 15:41:15 2009 +1000
Register for raw events
commit 54136f2c2a37e92a5b5e49035d27ce6728e12e3a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Mar 10 13:23:53 2009 +1000
Change event registration a bit, using SetBit instead.
commit 959faacf2e125312b3ff0cc71f4e0b4ee059757f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sun Mar 8 17:41:23 2009 +1000
Print out hierarchy events
commit ab0632284539460dd66c76e023894540fe77fcd2
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sun Mar 8 12:25:15 2009 +1000
Print DeviceChanged events.
commit 57940c7995a3779792213468cafe7d982d009035
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Mar 3 15:44:45 2009 +1000
Add test_xi2 for xi2 testing.
commit 3cad22debfaceca754fc166ca766d92b7a8faf70
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Mar 4 21:57:54 2009 +1000
If XI2 is available, list devices through XIQueryDevice.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 5aa923fc560718b9a093ad18966f4530eef0efd7
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Feb 26 16:14:21 2009 +1000
Update to new XI2 requests and sanitize the check for XI2 in configure.
Check for the actual library version, not for some random function inside the
library.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a12acdea9e289c9495bc14dd886e9a68cf9a533f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Mar 4 21:25:50 2009 +1000
Change is_xinput_present() to xinput_version().
Returns major version of XI.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a197551573663cab9e79e07e2de9d423c7a7a572
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Mar 6 22:13:17 2009 +1000
add xi2_find_device_id
commit 4ad33929e0f640dbc91004857ed2168006d21a71
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Feb 26 16:09:17 2009 +1000
Rip HAVE_XI2 conditional functionality out.
XI2 needs to be harder separated now.
commit 10f5f9da1d4d7f6eb75d10316f318a7c9d7dc28b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Feb 26 15:53:24 2009 +1000
Clean up xinput.h a bit.
All functions have to look the same anyway, so might as well use a one-line
macro to declare them.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 199c323332dac782b45dcb092da0322149843d5a
Author: Benjamin Close <Benjamin.Close@clearchain.com>
Date: Thu Mar 12 21:17:53 2009 +1000
Error out when more than one instance of a name exists
Previously the check was in place for the duplicate name, however the first
device with the requested name was still selected regardless.
Correct this by exiting out forcing the user to select by id instead.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 49ef8a40f96c0383a8a42a78fda3a990ac934e59
Author: Simon Thum <simon.thum@gmx.de>
Date: Wed Jan 21 14:09:29 2009 +0100

View File

@ -154,6 +154,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XI2_CFLAGS = @XI2_CFLAGS@
XI2_LIBS = @XI2_LIBS@
XINPUT_CFLAGS = @XINPUT_CFLAGS@
XINPUT_LIBS = @XINPUT_LIBS@
ac_ct_CC = @ac_ct_CC@

89
app/xinput/aclocal.m4 vendored
View File

@ -995,7 +995,7 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
dnl xorg-macros.m4. Generated from xorg-macros.m4.in:xorgversion.m4 by configure.
dnl xorg-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure.
dnl
dnl Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved.
dnl
@ -1032,27 +1032,24 @@ dnl of the copyright holder.
# your configure.ac with the minimum required version, such as:
# XORG_MACROS_VERSION(1.1)
#
# To force at least a version with this macro defined, also add:
# m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.1 or later before running autoconf/autogen])])
# To ensure that this macro is defined, also add:
# m4_ifndef([XORG_MACROS_VERSION],
# [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
#
#
# See the "minimum version" comment for each macro you use to see what
# version you require.
AC_DEFUN([XORG_MACROS_VERSION],[
[XORG_MACROS_needed_version=$1
XORG_MACROS_needed_major=`echo $XORG_MACROS_needed_version | sed 's/\..*$//'`
XORG_MACROS_needed_minor=`echo $XORG_MACROS_needed_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`]
AC_MSG_CHECKING([if xorg-macros used to generate configure is at least ${XORG_MACROS_needed_major}.${XORG_MACROS_needed_minor}])
[XORG_MACROS_version=1.2.1
XORG_MACROS_major=`echo $XORG_MACROS_version | sed 's/\..*$//'`
XORG_MACROS_minor=`echo $XORG_MACROS_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`]
if test $XORG_MACROS_major -ne $XORG_MACROS_needed_major ; then
AC_MSG_ERROR([configure built with incompatible version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.x])
fi
if test $XORG_MACROS_minor -lt $XORG_MACROS_needed_minor ; then
AC_MSG_ERROR([configure built with too old of a version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.${XORG_MACROS_minor}.0 or newer])
fi
AC_MSG_RESULT([yes, $XORG_MACROS_version])
m4_defun([XORG_MACROS_VERSION],[
m4_define([vers_have], [1.3.0])
m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
m4_if(m4_cmp(maj_have, maj_needed), 0,,
[m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
m4_if(m4_version_compare(vers_have, [$1]), -1,
[m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
m4_undefine([vers_have])
m4_undefine([maj_have])
m4_undefine([maj_needed])
]) # XORG_MACROS_VERSION
# XORG_PROG_RAWCPP()
@ -1319,7 +1316,7 @@ AC_SUBST(MAKE_HTML)
# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
AC_ARG_ENABLE(malloc0returnsnull,
AC_HELP_STRING([--enable-malloc0returnsnull],
AS_HELP_STRING([--enable-malloc0returnsnull],
[malloc(0) returns NULL (default: auto)]),
[MALLOC_ZERO_RETURNS_NULL=$enableval],
[MALLOC_ZERO_RETURNS_NULL=auto])
@ -1371,7 +1368,7 @@ AC_SUBST([XTMALLOC_ZERO_CFLAGS])
AC_DEFUN([XORG_WITH_LINT],[
# Allow checking code with lint, sparse, etc.
AC_ARG_WITH(lint, [AC_HELP_STRING([--with-lint],
AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
[Use a lint-style source code checker (default: disabled)])],
[use_lint=$withval], [use_lint=no])
if test "x$use_lint" = "xyes" ; then
@ -1412,7 +1409,7 @@ AM_CONDITIONAL(LINT, [test x$LINT != xno])
AC_DEFUN([XORG_LINT_LIBRARY],[
AC_REQUIRE([XORG_WITH_LINT])
# Build lint "library" for more indepth checks of programs calling this library
AC_ARG_ENABLE(lint-library, [AC_HELP_STRING([--enable-lint-library],
AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
[Create lint library (default: disabled)])],
[make_lint_lib=$enableval], [make_lint_lib=no])
if test "x$make_lint_lib" != "xno" ; then
@ -1442,9 +1439,9 @@ if test "x$GCC" = xyes ; then
CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
-Wbad-function-cast"
case `gcc -dumpversion` in
case `$CC -dumpversion` in
3.4.* | 4.*)
CWARNFLAGS+=" -Wold-style-definition -Wdeclaration-after-statement"
CWARNFLAGS="$CWARNFLAGS -Wold-style-definition -Wdeclaration-after-statement"
;;
esac
else
@ -1454,7 +1451,51 @@ else
fi
fi
AC_SUBST(CWARNFLAGS)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
]) # XORG_CWARNFLAGS
# XORG_STRICT_OPTION
# -----------------------
# Minimum version: 1.3.0
#
# Add configure option to enable strict compilation
AC_DEFUN([XORG_STRICT_OPTION], [
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CC_C99])
AC_REQUIRE([XORG_CWARNFLAGS])
AC_ARG_ENABLE(strict-compilation,
AS_HELP_STRING([--enable-strict-compilation],
[Enable all warnings from compiler and make them errors (default: disabled)]),
[STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
if test "x$STRICT_COMPILE" = "xyes"; then
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
if test "x$GCC" = xyes ; then
STRICT_CFLAGS="-pedantic -Werror"
elif test "x$SUNCC" = "xyes"; then
STRICT_CFLAGS="-errwarn"
elif test "x$INTELCC" = "xyes"; then
STRICT_CFLAGS="-Werror"
fi
fi
CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
AC_SUBST([CWARNFLAGS])
]) # XORG_STRICT_OPTION
# XORG_DEFAULT_OPTIONS
# --------------------
# Minimum version: 1.3.0
#
# Defines default options for X.Org modules.
#
AC_DEFUN([XORG_DEFAULT_OPTIONS], [
XORG_CWARNFLAGS
XORG_STRICT_OPTION
XORG_RELEASE_VERSION
XORG_CHANGELOG
XORG_MANPAGE_SECTIONS
]) # XORG_DEFAULT_OPTIONS
dnl Copyright 2005 Red Hat, Inc
dnl
dnl Permission to use, copy, modify, distribute, and sell this software and its
@ -1489,7 +1530,7 @@ dnl
AC_DEFUN([XORG_RELEASE_VERSION],[
AC_ARG_WITH(release-version,
AC_HELP_STRING([--with-release-version=STRING],
AS_HELP_STRING([--with-release-version=STRING],
[Use release version string in package name]),
[RELEASE_VERSION="$withval"],
[RELEASE_VERSION=""])

View File

@ -27,7 +27,7 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* XInput Version 2 Enabled */
/* XI2 available */
#undef HAVE_XI2
/* Name of package */

981
app/xinput/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -2,39 +2,36 @@ dnl Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
AC_INIT(xinput,[1.4.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xinput)
AC_INIT(xinput,[1.5.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xinput)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.2)
# Require xorg-macros: XORG_DEFAULT_OPTIONS
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.3 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.3)
AM_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_INSTALL
XORG_CWARNFLAGS
XORG_DEFAULT_OPTIONS
# Checks for pkg-config packages
PKG_CHECK_MODULES(XINPUT, x11 xext [xi >= 1.2] [inputproto >= 1.5])
LIBS="$XINPUT_LIBS $LIBS"
AC_CHECK_FUNC(XSetClientPointer,AC_DEFINE(HAVE_XI2,1,[XInput Version 2 Enabled]))
AM_CONDITIONAL(HAVE_XI2, [test "x$ac_cv_func_XSetClientPointer" = "xyes"] )
# XI2 support
PKG_CHECK_MODULES(XI2, [xi >= 1.2.99.2] [inputproto >= 1.9.99.15],
HAVE_XI2="yes"; AC_DEFINE(HAVE_XI2, 1, [XI2 available]),
HAVE_XI2="no");
AM_CONDITIONAL(HAVE_XI2, [ test "$HAVE_XI2" = "yes" ])
XINPUT_CFLAGS="$CWARNFLAGS $XINPUT_CFLAGS"
AC_SUBST(XINPUT_CFLAGS)
AC_SUBST(XINPUT_LIBS)
AC_SUBST(HAVE_XI2)
AC_SUBST(VERSION)
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION
XORG_CHANGELOG
AC_OUTPUT([Makefile
src/Makefile
man/Makefile])

View File

@ -142,6 +142,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XI2_CFLAGS = @XI2_CFLAGS@
XI2_LIBS = @XI2_LIBS@
XINPUT_CFLAGS = @XINPUT_CFLAGS@
XINPUT_LIBS = @XINPUT_LIBS@
ac_ct_CC = @ac_ct_CC@

View File

@ -1,89 +1,104 @@
.\" $Id: xinput.man,v 1.3 2009/05/18 20:50:16 matthieu Exp $
.TH xinput 1 "$Date: 2009/05/18 20:50:16 $" "Frederic Lepied"
.TH xinput 1 __xorgversion__
.SH NAME
xinput - utility to configure and test XInput devices
xinput - utility to configure and test X input devices
.SH SYNOPSIS
.B xinput
[version] [list [\fIdevice_name\fP]] [set-pointer \fIdevice_name\fP]
[get-feedbacks \fIdevice_name\fP]
[set-mode \fIdevice_name\fP \fIABSOLUTE|RELATIVE\fP]
[set-ptr-feedback \fIdevice_name\fP \fIthreshold\fP \fInum\fP \fIdenom\fP]
[set-integer-feedback \fIdevice_name\fP \fIindex\fP \fIvalue\fP]
[set-button-map \fIdevice_name\fP \fImap button 1\fP [\fImap button 2\fP [\fI...\fP]]]
[query-state \fIdevice_name\fP]
[test [-proximity] \fIdevice_name\fP]
.B xinput [OPTIONS] [DEVICE]
.SH DESCRIPTION
xinput is a utility to list available input devices, query information about
a device and change input device settings.
.SH OPTIONS
.TP 8
.B xinput version
test if the XInput extension is available and return the version number
of the program.
.B --version
Test if the X Input extension is available and return the version number
of the program and the version supported by the server. This option does not
require a device name.
.PP
.TP 8
.B xinput list [\fIdevice_name\fP]
If no argument is given list all the input devices showing all their
features. If an argument is given, show all the feature of \fIdevice_name\fP.
Uses XListInputDevices(3).
.B --list [--short || --long] [\fIdevice\fP]
If no argument is given list all the input devices. If an argument is given,
show all the features of \fIdevice\fP. Uses XListInputDevices(3).
If --long is provided, the output includes detailed information about the
capabilities of each devices. Otherwise, or if --short is provided, only the
device names and some minimal information is listed.
.PP
.TP 8
.B xinput get-feedbacks \fIdevice_name\fP
Display the feedbacks of \fIdevice_name\fP. Uses XGetFeedbackControl(3).
.B --get-feedbacks \fIdevice\fP
Display the feedbacks of \fIdevice\fP.
.PP
.TP 8
.B xinput set-pointer \fIdevice_name\fP
Switch \fIdevice_name\fP in core pointer. Uses XChangePointerDevice(3).
.B --set-pointer \fIdevice\fP
Switch \fIdevice\fP in core pointer.
This option does nothing on X servers 1.5 and later.
.PP
.TP 8
.B xinput set-mode \fIdevice_name\fP \fIABSOLUTE|RELATIVE\fP
Change the mode of \fIdevice_name\fP. Uses XSetDeviceMode(3).
.B --set-mode \fIdevice\fP \fIABSOLUTE|RELATIVE\fP
Change the mode of \fIdevice\fP.
.PP
.TP 8
.B xinput set-ptr-feedback \fIdevice_name\fP \fIthreshold\fP \fInum\fP \fIdenom\fP
Change the acceleration of \fIdevice_name\fP. Uses XChangeFeedbackControl(3).
.B --set-ptr-feedback \fIdevice\fP \fIthreshold\fP \fInum\fP \fIdenom\fP
Change the acceleration of \fIdevice\fP.
.PP
.TP 8
.B xinput set-integer-feedback \fIdevice_name\fP \fIindex\fP \fIvalue\fP
Change the value of an integer feedback of \fIdevice_name\fP. Uses XChangeFeedbackControl(3).
.B --set-integer-feedback \fIdevice\fP \fIindex\fP \fIvalue\fP
Change the value of an integer feedback of \fIdevice\fP.
.PP
.TP 8
.B xinput set-button-map \fIdevice_name\fP \fImap button 1\fP [\fImap button 2\fP [\fI...\fP]]
Change the button mapping of \fIdevice_name\fP. Uses XSetDeviceButtonMapping(3).
.B --set-button-map \fIdevice\fP \fImap_button_1\fP [\fImap_button_2\fP [\fI...\fP]]
Change the button mapping of \fIdevice\fP. The buttons are specified in
physical order (starting with button 1) and are mapped to the logical button
provided. 0 disables a button. The default button mapping for a device is 1
2 3 4 5 6 etc.
.PP
.TP 8
.B xinput query-state \fIdevice_name\fP
Query the device state. Uses XQueryDeviceState(3).
.B --query-state \fIdevice\fP
Query the device state.
.PP
.TP 8
.B xinput list-props \fIdevice_name\fP [\fIdevice_name\fP...]
.B --list-props \fIdevice\fP [\fIdevice\fP [\fI...\fP]]
Lists properties that can be set for the given device(s).
.PP
.TP 8
.B xinput set-int-prop \fIdevice_name\fP \fIproperty\fP \fIformat\fP \fIvalue\fP
.B --set-int-prop \fIdevice\fP \fIproperty\fP \fIformat\fP \fIvalue\fP
Sets an integer property for the device. Appropriate values for \fIformat\fP
are 8, 16, or 32, depending on the property.
are 8, 16, or 32, depending on the property. Deprecated, use
.B --set-prop
instead.
.PP
.TP 8
.B xinput set-float-prop \fIdevice_name\fP \fIproperty\fP \fIvalue\fP
Sets a float property for the device.
.B --set-float-prop \fIdevice\fP \fIproperty\fP \fIvalue\fP
Sets a float property for the device. Deprecated, use
.B --set-prop
instead.
.PP
.TP 8
.B xinput watch-props \fIdevice_name\fP
.B --set\-prop [\-\-type=\fIatom|float|int\fP] [\-\-format=\fI8|16|32\fP] \fIdevice\fP \fIproperty\fP \fIvalue\fP [...]
Set the property to the given value(s). If not specified, the format and type
of the property are left as-is. The arguments are interpreted according to the
property type.
.PP
.TP 8
.B --watch-props \fIdevice\fP
Prints to standard out when property changes occur.
.PP
.TP 8
.B xinput delete-prop \fIdevice_name\fP \fIproperty\fP
.B --delete-prop \fIdevice\fP \fIproperty\fP
Delete the property from the device.
.PP
.PP
.TP 8
.B xinput test [-proximity] \fIdevice_name\fP
Register all extended events from \fIdevice_name\fP and enter an endless
.B --test [-proximity] \fIdevice\fP
Register all extended events from \fIdevice\fP and enter an endless
loop displaying events received. If the -proximity is given, ProximityIn
and ProximityOut are registered.
.PP
\fIdevice_name\fP can be the device name as a string or the XID of the
.TP 8
.B --test_xi2
Register for a number of XI2 events and display them. This option does not
take a device argument.
.PP
\fIdevice\fP can be the device name as a string or the XID of the
device.
.PP
\fIproperty\fP can be the property as a string or the Atom value.
@ -94,11 +109,13 @@ Copyright 1996,1997, Frederic Lepied.
.PP
Copyright 2008, Philip Langdale.
.SH AUTHOR
.SH AUTHORS
.nf
Philip Langdale, <philipl@alumni.utexas.net>
Frederic Lepied, France <Frederic.Lepied@sugix.frmug.org>
Peter Hutterer <peter.hutterer@who-t.net>
Julien Cristau <jcristau@debian.org>
Thomas Jaeger <ThJaeger@gmail.com>
and more.
.fi
Patches, bug reports, and suggestions are welcome.

View File

@ -26,8 +26,8 @@ xinput_LDADD = $(XINPUT_LIBS)
if HAVE_XI2
xinput2_files = hierarchy.c setcp.c
endif # HAVE_XI2
xinput2_files = hierarchy.c setcp.c test_xi2.c
endif
xinput_SOURCES = \
buttonmap.c \
@ -39,7 +39,6 @@ xinput_SOURCES = \
state.c \
property.c \
test.c \
version.c \
xinput.c \
xinput.h \
$(xinput2_files)

View File

@ -71,14 +71,14 @@ am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am__xinput_SOURCES_DIST = buttonmap.c feedback.c list.c setint.c \
setmode.c setptr.c state.c property.c test.c version.c \
xinput.c xinput.h hierarchy.c setcp.c
@HAVE_XI2_TRUE@am__objects_1 = hierarchy.$(OBJEXT) setcp.$(OBJEXT)
setmode.c setptr.c state.c property.c test.c xinput.c xinput.h \
hierarchy.c setcp.c test_xi2.c
@HAVE_XI2_TRUE@am__objects_1 = hierarchy.$(OBJEXT) setcp.$(OBJEXT) \
@HAVE_XI2_TRUE@ test_xi2.$(OBJEXT)
am_xinput_OBJECTS = buttonmap.$(OBJEXT) feedback.$(OBJEXT) \
list.$(OBJEXT) setint.$(OBJEXT) setmode.$(OBJEXT) \
setptr.$(OBJEXT) state.$(OBJEXT) property.$(OBJEXT) \
test.$(OBJEXT) version.$(OBJEXT) xinput.$(OBJEXT) \
$(am__objects_1)
test.$(OBJEXT) xinput.$(OBJEXT) $(am__objects_1)
xinput_OBJECTS = $(am_xinput_OBJECTS)
am__DEPENDENCIES_1 =
xinput_DEPENDENCIES = $(am__DEPENDENCIES_1)
@ -158,6 +158,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XI2_CFLAGS = @XI2_CFLAGS@
XI2_LIBS = @XI2_LIBS@
XINPUT_CFLAGS = @XINPUT_CFLAGS@
XINPUT_LIBS = @XINPUT_LIBS@
ac_ct_CC = @ac_ct_CC@
@ -206,7 +208,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
AM_CFLAGS = $(XINPUT_CFLAGS)
xinput_LDADD = $(XINPUT_LIBS)
@HAVE_XI2_TRUE@xinput2_files = hierarchy.c setcp.c
@HAVE_XI2_TRUE@xinput2_files = hierarchy.c setcp.c test_xi2.c
xinput_SOURCES = \
buttonmap.c \
feedback.c \
@ -217,7 +219,6 @@ xinput_SOURCES = \
state.c \
property.c \
test.c \
version.c \
xinput.c \
xinput.h \
$(xinput2_files)
@ -299,7 +300,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setptr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_xi2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xinput.Po@am__quote@
.c.o:

View File

@ -40,7 +40,7 @@
int
create_master(Display* dpy, int argc, char** argv, char* name, char *desc)
{
XCreateMasterInfo c;
XIAddMasterInfo c;
if (argc == 0)
{
@ -48,12 +48,12 @@ create_master(Display* dpy, int argc, char** argv, char* name, char *desc)
return EXIT_FAILURE;
}
c.type = CH_CreateMasterDevice;
c.type = XIAddMaster;
c.name = argv[0];
c.sendCore = (argc >= 2) ? atoi(argv[1]) : 1;
c.send_core = (argc >= 2) ? atoi(argv[1]) : 1;
c.enable = (argc >= 3) ? atoi(argv[2]) : 1;
return XChangeDeviceHierarchy(dpy, (XAnyHierarchyChangeInfo*)&c, 1);
return XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&c, 1);
}
/**
@ -64,9 +64,8 @@ create_master(Display* dpy, int argc, char** argv, char* name, char *desc)
int
remove_master(Display* dpy, int argc, char** argv, char *name, char *desc)
{
XDeviceInfo *info;
XRemoveMasterInfo r;
XDevice* master = NULL, *ptr = NULL, *keybd = NULL;
XIRemoveMasterInfo r;
XIDeviceInfo *info;
int ret;
if (argc == 0)
@ -75,45 +74,67 @@ remove_master(Display* dpy, int argc, char** argv, char *name, char *desc)
return EXIT_FAILURE;
}
info = find_device_info(dpy, argv[0], False);
info = xi2_find_device_info(dpy, argv[0]);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
master = XOpenDevice(dpy, info->id);
if (!master)
Error(BadValue, "Unable to open device %s.\n", argv[0]);
r.type = CH_RemoveMasterDevice;
r.device = master;
r.type = XIRemoveMaster;
r.deviceid = info->deviceid;
if (argc >= 2)
{
if (!strcmp(argv[1], "Floating"))
r.returnMode = Floating;
r.return_mode = XIFloating;
else if (!strcmp(argv[1], "AttachToMaster"))
r.returnMode = AttachToMaster;
r.return_mode = XIAttachToMaster;
else
Error(BadValue, "Invalid returnMode.\n");
Error(BadValue, "Invalid return_mode.\n");
} else
r.returnMode = Floating;
r.return_mode = XIFloating;
if (r.returnMode == AttachToMaster)
if (r.return_mode == XIAttachToMaster)
{
ptr = XOpenDevice(dpy, atoi(argv[2]));
keybd = XOpenDevice(dpy, atoi(argv[3]));
if (!ptr || !keybd)
Error(BadValue, "Invalid fallback master.\n");
r.returnPointer = ptr;
r.returnKeyboard = keybd;
r.return_pointer = 0;
if (argc >= 3) {
info = xi2_find_device_info(dpy, argv[2]);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[2]);
return EXIT_FAILURE;
}
r.return_pointer = info->deviceid;
}
r.return_keyboard = 0;
if (argc >= 4) {
info = xi2_find_device_info(dpy, argv[3]);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[3]);
return EXIT_FAILURE;
}
r.return_keyboard = info->deviceid;
}
if (!r.return_pointer || !r.return_keyboard) {
int i, ndevices;
info = XIQueryDevice(dpy, XIAllMasterDevices, &ndevices);
for(i = 0; i < ndevices; i++) {
if (info[i].use == XIMasterPointer && !r.return_pointer)
r.return_pointer = info[i].deviceid;
if (info[i].use == XIMasterKeyboard && !r.return_keyboard)
r.return_keyboard = info[i].deviceid;
if (r.return_pointer && r.return_keyboard)
break;
}
XIFreeDeviceInfo(info);
}
}
ret = XChangeDeviceHierarchy(dpy, (XAnyHierarchyChangeInfo*)&r, 1);
if (ptr)
XCloseDevice(dpy, ptr);
if (keybd)
XCloseDevice(dpy, keybd);
ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&r, 1);
return ret;
}
@ -123,9 +144,8 @@ remove_master(Display* dpy, int argc, char** argv, char *name, char *desc)
int
change_attachment(Display* dpy, int argc, char** argv, char *name, char* desc)
{
XDeviceInfo *info_sd, *info_md;
XChangeAttachmentInfo c;
XDevice *slave, *master;
XIDeviceInfo *sd_info, *md_info;
XIAttachSlaveInfo c;
int ret;
if (argc < 2)
@ -134,36 +154,24 @@ change_attachment(Display* dpy, int argc, char** argv, char *name, char* desc)
return EXIT_FAILURE;
}
info_sd = find_device_info(dpy, argv[0], True);
info_md = find_device_info(dpy, argv[1], False);
sd_info = xi2_find_device_info(dpy, argv[0]);
md_info= xi2_find_device_info(dpy, argv[1]);
if (!info_sd) {
if (!sd_info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
if (!info_md) {
if (!md_info) {
fprintf(stderr, "unable to find device %s\n", argv[1]);
return EXIT_FAILURE;
}
slave = XOpenDevice(dpy, info_sd->id);
master = XOpenDevice(dpy, info_md->id);
c.type = XIAttachSlave;
c.deviceid = sd_info->deviceid;
c.new_master = md_info->deviceid;
if (!slave)
Error(BadValue, "Invalid slave device given %d\n", atoi(argv[0]));
if (!master)
Error(BadValue, "Invalid master device given %d\n", atoi(argv[1]));
c.type = CH_ChangeAttachment;
c.changeMode = AttachToMaster;
c.device = slave;
c.newMaster = master;
ret = XChangeDeviceHierarchy(dpy, (XAnyHierarchyChangeInfo*)&c, 1);
XCloseDevice(dpy, slave);
XCloseDevice(dpy, master);
ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&c, 1);
return ret;
}
@ -173,9 +181,8 @@ change_attachment(Display* dpy, int argc, char** argv, char *name, char* desc)
int
float_device(Display* dpy, int argc, char** argv, char* name, char* desc)
{
XDeviceInfo *info;
XChangeAttachmentInfo c;
XDevice *slave;
XIDeviceInfo *info;
XIDetachSlaveInfo c;
int ret;
if (argc < 1)
@ -184,24 +191,17 @@ float_device(Display* dpy, int argc, char** argv, char* name, char* desc)
return EXIT_FAILURE;
}
info = find_device_info(dpy, argv[0], True);
info = xi2_find_device_info(dpy, argv[0]);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
slave = XOpenDevice(dpy, info->id);
c.type = XIDetachSlave;
c.deviceid = info->deviceid;
if (!slave)
return BadValue;
c.type = CH_ChangeAttachment;
c.changeMode = Floating;
c.device = slave;
ret = XChangeDeviceHierarchy(dpy, (XAnyHierarchyChangeInfo*)&c, 1);
XCloseDevice(dpy, slave);
ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&c, 1);
return ret;
}

View File

@ -34,9 +34,6 @@ print_info(Display* dpy, XDeviceInfo *info, Bool shortformat)
XButtonInfoPtr b;
XValuatorInfoPtr v;
XAxisInfoPtr a;
#if HAVE_XI2
XAttachInfoPtr att;
#endif
printf("\"%s\"\tid=%ld\t[", info->name, info->id);
@ -98,12 +95,6 @@ print_info(Display* dpy, XDeviceInfo *info, Bool shortformat)
printf ("\t\tResolution is %d\n", a->resolution);
}
break;
#if HAVE_XI2
case AttachClass:
att = (XAttachInfoPtr)any;
printf("\tAttached to %d\n", att->attached);
break;
#endif
default:
printf ("unknown class\n");
}
@ -112,6 +103,176 @@ print_info(Display* dpy, XDeviceInfo *info, Bool shortformat)
}
}
static int list_xi1(Display *display,
int shortformat)
{
XDeviceInfo *info;
int loop;
int num_devices;
info = XListInputDevices(display, &num_devices);
for(loop=0; loop<num_devices; loop++) {
print_info(display, info+loop, shortformat);
}
return EXIT_SUCCESS;
}
#ifdef HAVE_XI2
/* also used from test_xi2.c */
void
print_classes_xi2(Display* display, XIAnyClassInfo **classes,
int num_classes)
{
int i, j;
printf("\tReporting %d classes:\n", num_classes);
for (i = 0; i < num_classes; i++)
{
printf("\t\tClass originated from: %d\n", classes[i]->sourceid);
switch(classes[i]->type)
{
case XIButtonClass:
{
XIButtonClassInfo *b = (XIButtonClassInfo*)classes[i];
char *name;
printf("\t\tButtons supported: %d\n", b->num_buttons);
printf("\t\tButton labels:");
for (j = 0; j < b->num_buttons; j++)
{
name = (b->labels[j]) ? XGetAtomName(display, b->labels[j]) : NULL;
printf(" %s", (name) ? name : "None");
XFree(name);
}
printf("\n");
printf("\t\tButton state:");
for (j = 0; j < b->state.mask_len * 8; j++)
if (XIMaskIsSet(b->state.mask, j))
printf(" %d", j);
printf("\n");
}
break;
case XIKeyClass:
{
XIKeyClassInfo *k = (XIKeyClassInfo*)classes[i];
printf("\t\tKeycodes supported: %d\n", k->num_keycodes);
}
break;
case XIValuatorClass:
{
XIValuatorClassInfo *v = (XIValuatorClassInfo*)classes[i];
char *name = v->label ? XGetAtomName(display, v->label) : NULL;
printf("\t\tDetail for Valuator %d:\n", v->number);
printf("\t\t Label: %s\n", (name) ? name : "None");
printf("\t\t Range: %f - %f\n", v->min, v->max);
printf("\t\t Resolution: %d units/m\n", v->resolution);
printf("\t\t Mode: %s\n", v->mode == Absolute ? "absolute" :
"relative");
if (v->mode == Absolute)
printf("\t\t Current value: %f\n", v->value);
XFree(name);
}
break;
}
}
printf("\n");
}
static void
print_info_xi2(Display* display, XIDeviceInfo *dev, Bool shortformat)
{
printf("%-40s\tid=%d\t[", dev->name, dev->deviceid);
switch(dev->use)
{
case XIMasterPointer:
printf("master pointer (%d)]\n", dev->attachment);
break;
case XIMasterKeyboard:
printf("master keyboard (%d)]\n", dev->attachment);
break;
case XISlavePointer:
printf("slave pointer (%d)]\n", dev->attachment);
break;
case XISlaveKeyboard:
printf("slave keyboard (%d)]\n", dev->attachment);
break;
case XIFloatingSlave:
printf("floating slave]\n");
break;
}
if (shortformat)
return;
if (!dev->enabled)
printf("\tThis device is disabled\n");
print_classes_xi2(display, dev->classes, dev->num_classes);
}
static int
list_xi2(Display *display,
int shortformat)
{
int major = XI_2_Major,
minor = XI_2_Minor;
int ndevices;
int i, j;
XIDeviceInfo *info, *dev;
if (XIQueryVersion(display, &major, &minor) != Success ||
(major * 1000 + minor) < (XI_2_Major * 1000 + XI_2_Minor))
{
fprintf(stderr, "XI2 not supported.\n");
return EXIT_FAILURE;
}
info = XIQueryDevice(display, XIAllDevices, &ndevices);
for(i = 0; i < ndevices; i++)
{
dev = &info[i];
if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard)
{
if (dev->use == XIMasterPointer)
printf("");
else
printf("");
print_info_xi2(display, dev, shortformat);
for (j = 0; j < ndevices; j++)
{
XIDeviceInfo* sd = &info[j];
if ((sd->use == XISlavePointer || sd->use == XISlaveKeyboard) &&
(sd->attachment == dev->deviceid))
{
printf("%s ↳ ", dev->use == XIMasterPointer ? "" : " ");
print_info_xi2(display, sd, shortformat);
}
}
}
}
for (i = 0; i < ndevices; i++)
{
dev = &info[i];
if (dev->use == XIFloatingSlave)
{
printf(" ");
print_info_xi2(display, dev, shortformat);
}
}
XIFreeDeviceInfo(info);
return EXIT_SUCCESS;
}
#endif
int
list(Display *display,
int argc,
@ -119,71 +280,44 @@ list(Display *display,
char *name,
char *desc)
{
XDeviceInfo *info;
int loop;
int shortformat = False;
int daemon = False;
int shortformat = (argc >= 1 && strcmp(argv[0], "--short") == 0);
int longformat = (argc >= 1 && strcmp(argv[0], "--long") == 0);
int arg_dev = shortformat || longformat;
shortformat = (argc == 1 && strcmp(argv[0], "--short") == 0);
daemon = (argc == 1 && strcmp(argv[0], "--loop") == 0);
if (argc == 0 || shortformat || daemon) {
int num_devices;
XEvent ev;
#if HAVE_XI2
if (daemon)
if (argc > arg_dev)
{
#ifdef HAVE_XI2
if (xinput_version(display) == XI_2_Major)
{
XiSelectEvent(display, DefaultRootWindow(display), NULL,
XI_DeviceHierarchyChangedMask |
XI_DeviceClassesChangedMask);
XIDeviceInfo *info = xi2_find_device_info(display, argv[arg_dev]);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[arg_dev]);
return EXIT_FAILURE;
} else {
print_info_xi2(display, info, shortformat);
return EXIT_SUCCESS;
}
} else
#endif
{
XDeviceInfo *info = find_device_info(display, argv[arg_dev], False);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[arg_dev]);
return EXIT_FAILURE;
} else {
print_info(display, info, shortformat);
return EXIT_SUCCESS;
}
}
#endif
do {
info = XListInputDevices(display, &num_devices);
for(loop=0; loop<num_devices; loop++) {
print_info(display, info+loop, shortformat);
}
#if HAVE_XI2
/* just wait for the next generic event to come along */
while (daemon && !XNextEvent(display, &ev))
{
if (ev.type == GenericEvent)
{
XGenericEvent* gev = (XGenericEvent*)&ev;
/* we just assume that extension is IReqCode, pretty save
since we don't register for other events. */
if (gev->evtype == XI_DeviceHierarchyChangedNotify)
{
printf("Hierarchy change.\n");
} else if (gev->evtype == XI_DeviceClassesChangedNotify)
{
printf("Device classes changed.\n");
free(((XDeviceClassesChangedEvent*)&ev)->inputclassinfo);
}
break;
}
}
#endif
} while(daemon);
} else {
int ret = EXIT_SUCCESS;
for(loop=0; loop<argc; loop++) {
info = find_device_info(display, argv[loop], False);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[loop]);
ret = EXIT_FAILURE;
} else {
print_info(display, info, shortformat);
}
}
return ret;
#ifdef HAVE_XI2
if (xinput_version(display) == XI_2_Major)
return list_xi2(display, !longformat);
#endif
return list_xi1(display, !longformat);
}
return EXIT_SUCCESS;
}
/* end of list.c */

View File

@ -34,6 +34,23 @@
#include "xinput.h"
static Atom parse_atom(Display *dpy, char *name) {
Bool is_atom = True;
int i;
for (i = 0; name[i] != '\0'; i++) {
if (!isdigit(name[i])) {
is_atom = False;
break;
}
}
if (is_atom)
return atoi(name);
else
return XInternAtom(dpy, name, False);
}
static void
print_property(Display *dpy, XDevice* dev, Atom property)
{
@ -55,6 +72,9 @@ print_property(Display *dpy, XDevice* dev, Atom property)
ptr = data;
if (nitems == 0)
printf("<no items>");
switch(act_format)
{
case 8: size = sizeof(char); break;
@ -94,8 +114,13 @@ print_property(Display *dpy, XDevice* dev, Atom property)
the terminating 0 */
break;
case XA_ATOM:
printf("\"%s\"", XGetAtomName(dpy, *(Atom*)ptr));
break;
{
Atom a = *(Atom*)ptr;
printf("\"%s\" (%d)",
(a) ? XGetAtomName(dpy, a) : "None",
(int)a);
break;
}
default:
if (float_atom != None && act_type == float_atom)
{
@ -111,10 +136,10 @@ print_property(Display *dpy, XDevice* dev, Atom property)
ptr += size;
if (j < nitems - 1)
printf(", ");
if (done == True)
break;
if (j < nitems - 1)
printf(", ");
}
printf("\n");
XFree(data);
@ -123,7 +148,8 @@ print_property(Display *dpy, XDevice* dev, Atom property)
}
int list_props(Display *dpy, int argc, char** argv, char* name, char *desc)
static int
list_props_xi1(Display *dpy, int argc, char** argv, char* name, char *desc)
{
XDeviceInfo *info;
XDevice *dev;
@ -172,166 +198,6 @@ int list_props(Display *dpy, int argc, char** argv, char* name, char *desc)
return EXIT_SUCCESS;
}
int
set_int_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
{
XDeviceInfo *info;
XDevice *dev;
Atom prop;
char *name;
int i;
Bool is_atom = True;
char *data;
int format, nelements = 0;
if (argc < 3)
{
fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
return EXIT_FAILURE;
}
info = find_device_info(dpy, argv[0], False);
if (!info)
{
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
dev = XOpenDevice(dpy, info->id);
if (!dev)
{
fprintf(stderr, "unable to open device %s\n", argv[0]);
return EXIT_FAILURE;
}
name = argv[1];
for(i = 0; i < strlen(name); i++) {
if (!isdigit(name[i])) {
is_atom = False;
break;
}
}
if (!is_atom)
prop = XInternAtom(dpy, name, False);
else
prop = atoi(name);
nelements = argc - 3;
format = atoi(argv[2]);
if (format != 8 && format != 16 && format != 32)
{
fprintf(stderr, "Invalid format %d\n", format);
return EXIT_FAILURE;
}
data = calloc(nelements, sizeof(long));
for (i = 0; i < nelements; i++)
{
switch(format)
{
case 8:
*(((char*)data) + i) = atoi(argv[3 + i]);
break;
case 16:
*(((short*)data) + i) = atoi(argv[3 + i]);
break;
case 32:
*(((long*)data) + i) = atoi(argv[3 + i]);
break;
}
}
XChangeDeviceProperty(dpy, dev, prop, XA_INTEGER, format, PropModeReplace,
(unsigned char*)data, nelements);
free(data);
XCloseDevice(dpy, dev);
return EXIT_SUCCESS;
}
int
set_float_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
{
XDeviceInfo *info;
XDevice *dev;
Atom prop, float_atom;
char *name;
int i;
Bool is_atom = True;
long *data;
int nelements = 0;
char* endptr;
if (argc < 2)
{
fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
return EXIT_FAILURE;
}
info = find_device_info(dpy, argv[0], False);
if (!info)
{
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
dev = XOpenDevice(dpy, info->id);
if (!dev)
{
fprintf(stderr, "unable to open device %s\n", argv[0]);
return EXIT_FAILURE;
}
name = argv[1];
for(i = 0; i < strlen(name); i++) {
if (!isdigit(name[i])) {
is_atom = False;
break;
}
}
if (!is_atom)
prop = XInternAtom(dpy, name, False);
else
prop = atoi(name);
nelements = argc - 2;
float_atom = XInternAtom(dpy, "FLOAT", False);
if (float_atom == (Atom)0)
{
fprintf(stderr, "no FLOAT atom present in server\n");
return EXIT_FAILURE;
}
if (sizeof(float) != 4)
{
fprintf(stderr, "sane FP required\n");
return EXIT_FAILURE;
}
data = calloc(nelements, sizeof(long));
for (i = 0; i < nelements; i++)
{
*((float*)(data + i)) = strtod(argv[2 + i], &endptr);
if(endptr == argv[2 + i]){
fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
return EXIT_FAILURE;
}
}
XChangeDeviceProperty(dpy, dev, prop, float_atom, 32, PropModeReplace,
(unsigned char*)data, nelements);
free(data);
XCloseDevice(dpy, dev);
return EXIT_SUCCESS;
}
int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
{
@ -379,13 +245,12 @@ int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
XCloseDevice(dpy, dev);
}
int delete_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
static int
delete_prop_xi1(Display *dpy, int argc, char** argv, char* n, char *desc)
{
XDevice *dev;
XDeviceInfo *info;
char *name;
int i;
Bool is_atom = True;
Atom prop;
info = find_device_info(dpy, argv[0], False);
@ -404,17 +269,7 @@ int delete_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
name = argv[1];
for(i = 0; i < strlen(name); i++) {
if (!isdigit(name[i])) {
is_atom = False;
break;
}
}
if (!is_atom)
prop = XInternAtom(dpy, name, False);
else
prop = atoi(name);
prop = parse_atom(dpy, name);
XDeleteDeviceProperty(dpy, dev, prop);
@ -422,17 +277,25 @@ int delete_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
return EXIT_SUCCESS;
}
int
set_atom_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
static int
do_set_prop_xi1(Display *dpy, Atom type, int format, int argc, char **argv, char *n, char *desc)
{
XDeviceInfo *info;
XDevice *dev;
Atom prop;
char *name;
int i, j;
Bool is_atom = True;
Atom *data;
int nelements = 0;
XDeviceInfo *info;
XDevice *dev;
Atom prop;
Atom old_type;
char *name;
int i;
Atom float_atom;
int old_format, nelements = 0;
unsigned long act_nitems, bytes_after;
char *endptr;
union {
unsigned char *c;
short *s;
long *l;
Atom *a;
} data;
if (argc < 3)
{
@ -456,46 +319,483 @@ set_atom_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
name = argv[1];
for(i = 0; i < strlen(name); i++) {
if (!isdigit(name[i])) {
is_atom = False;
break;
}
prop = parse_atom(dpy, name);
if (prop == None) {
fprintf(stderr, "invalid property %s\n", name);
return EXIT_FAILURE;
}
if (!is_atom)
prop = XInternAtom(dpy, name, False);
else
prop = atoi(name);
float_atom = XInternAtom(dpy, "FLOAT", False);
nelements = argc - 2;
data = calloc(nelements, sizeof(Atom));
for (i = 0; i < nelements; i++)
{
is_atom = True;
name = argv[2 + i];
for(j = 0; j < strlen(name); j++) {
if (!isdigit(name[j])) {
is_atom = False;
break;
}
if (type == None || format == 0) {
if (XGetDeviceProperty(dpy, dev, prop, 0, 0, False, AnyPropertyType,
&old_type, &old_format, &act_nitems,
&bytes_after, &data.c) != Success) {
fprintf(stderr, "failed to get property type and format for %s\n",
name);
return EXIT_FAILURE;
} else {
if (type == None)
type = old_type;
if (format == 0)
format = old_format;
}
if (!is_atom)
data[i] = XInternAtom(dpy, name, False);
else
{
data[i] = atoi(name);
XFree(XGetAtomName(dpy, data[i]));
XFree(data.c);
}
if (type == None) {
fprintf(stderr, "property %s doesn't exist, you need to specify "
"its type and format\n", name);
return EXIT_FAILURE;
}
data.c = calloc(nelements, sizeof(long));
for (i = 0; i < nelements; i++)
{
if (type == XA_INTEGER) {
switch (format)
{
case 8:
data.c[i] = atoi(argv[2 + i]);
break;
case 16:
data.s[i] = atoi(argv[2 + i]);
break;
case 32:
data.l[i] = atoi(argv[2 + i]);
break;
default:
fprintf(stderr, "unexpected size for property %s", name);
return EXIT_FAILURE;
}
} else if (type == float_atom) {
if (format != 32) {
fprintf(stderr, "unexpected format %d for property %s\n",
format, name);
return EXIT_FAILURE;
}
*(float *)(data.l + i) = strtod(argv[2 + i], &endptr);
if (endptr == argv[2 + i]) {
fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
return EXIT_FAILURE;
}
} else if (type == XA_ATOM) {
if (format != 32) {
fprintf(stderr, "unexpected format %d for property %s\n",
format, name);
return EXIT_FAILURE;
}
data.a[i] = parse_atom(dpy, argv[2 + i]);
} else {
fprintf(stderr, "unexpected type for property %s\n", name);
return EXIT_FAILURE;
}
}
XChangeDeviceProperty(dpy, dev, prop, XA_ATOM, 32, PropModeReplace,
(unsigned char*)data, nelements);
free(data);
XChangeDeviceProperty(dpy, dev, prop, type, format, PropModeReplace,
data.c, nelements);
free(data.c);
XCloseDevice(dpy, dev);
return EXIT_SUCCESS;
}
#if HAVE_XI2
static void
print_property_xi2(Display *dpy, int deviceid, Atom property)
{
Atom act_type;
char *name;
int act_format;
unsigned long nitems, bytes_after;
unsigned char *data, *ptr;
int j, done = False;
name = XGetAtomName(dpy, property);
printf("\t%s (%ld):\t", name, property);
if (XIGetProperty(dpy, deviceid, property, 0, 1000, False,
AnyPropertyType, &act_type, &act_format,
&nitems, &bytes_after, &data) == Success)
{
Atom float_atom = XInternAtom(dpy, "FLOAT", True);
ptr = data;
if (nitems == 0)
printf("<no items>");
for (j = 0; j < nitems; j++)
{
switch(act_type)
{
case XA_INTEGER:
switch(act_format)
{
case 8:
printf("%d", *((int8_t*)ptr));
break;
case 16:
printf("%d", *((int16_t*)ptr));
break;
case 32:
printf("%d", *((int32_t*)ptr));
break;
}
break;
case XA_STRING:
if (act_format != 8)
{
printf("Unknown string format.\n");
done = True;
break;
}
printf("\"%s\"", ptr);
j += strlen((char*)ptr); /* The loop's j++ jumps over the
terminating 0 */
ptr += strlen((char*)ptr); /* ptr += size below jumps over
the terminating 0 */
break;
case XA_ATOM:
{
Atom a = *(Atom*)ptr;
printf("\"%s\" (%d)",
(a) ? XGetAtomName(dpy, a) : "None",
(int)a);
break;
}
break;
default:
if (float_atom != None && act_type == float_atom)
{
printf("%f", *((float*)ptr));
break;
}
printf("\t... of unknown type %s\n",
XGetAtomName(dpy, act_type));
done = True;
break;
}
ptr += act_format/8;
if (done == True)
break;
if (j < nitems - 1)
printf(", ");
}
printf("\n");
XFree(data);
} else
printf("\tFetch failure\n");
}
static int
list_props_xi2(Display *dpy, int argc, char** argv, char* name, char *desc)
{
XIDeviceInfo *info;
int i;
int nprops;
Atom *props;
if (argc == 0)
{
fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
return EXIT_FAILURE;
}
for (i = 0; i < argc; i++)
{
info = xi2_find_device_info(dpy, argv[i]);
if (!info)
{
fprintf(stderr, "unable to find device %s\n", argv[i]);
continue;
}
props = XIListProperties(dpy, info->deviceid, &nprops);
if (!nprops)
{
printf("Device '%s' does not report any properties.\n", info->name);
continue;
}
printf("Device '%s':\n", info->name);
while(nprops--)
{
print_property_xi2(dpy, info->deviceid, props[nprops]);
}
XFree(props);
}
return EXIT_SUCCESS;
}
static int
delete_prop_xi2(Display *dpy, int argc, char** argv, char* n, char *desc)
{
XIDeviceInfo *info;
char *name;
Atom prop;
info = xi2_find_device_info(dpy, argv[0]);
if (!info)
{
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
name = argv[1];
prop = parse_atom(dpy, name);
XIDeleteProperty(dpy, info->deviceid, prop);
return EXIT_SUCCESS;
}
static int
do_set_prop_xi2(Display *dpy, Atom type, int format, int argc, char **argv, char *n, char *desc)
{
XIDeviceInfo *info;
Atom prop;
Atom old_type;
char *name;
int i;
Atom float_atom;
int old_format, nelements = 0;
unsigned long act_nitems, bytes_after;
char *endptr;
union {
unsigned char *c;
int16_t *s;
int32_t *l;
} data;
if (argc < 3)
{
fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
return EXIT_FAILURE;
}
info = xi2_find_device_info(dpy, argv[0]);
if (!info)
{
fprintf(stderr, "unable to find device %s\n", argv[0]);
return EXIT_FAILURE;
}
name = argv[1];
prop = parse_atom(dpy, name);
if (prop == None) {
fprintf(stderr, "invalid property %s\n", name);
return EXIT_FAILURE;
}
float_atom = XInternAtom(dpy, "FLOAT", False);
nelements = argc - 2;
if (type == None || format == 0) {
if (XIGetProperty(dpy, info->deviceid, prop, 0, 0, False,
AnyPropertyType, &old_type, &old_format, &act_nitems,
&bytes_after, &data.c) != Success) {
fprintf(stderr, "failed to get property type and format for %s\n",
name);
return EXIT_FAILURE;
} else {
if (type == None)
type = old_type;
if (format == 0)
format = old_format;
}
XFree(data.c);
}
if (type == None) {
fprintf(stderr, "property %s doesn't exist, you need to specify "
"its type and format\n", name);
return EXIT_FAILURE;
}
data.c = calloc(nelements, sizeof(int32_t));
for (i = 0; i < nelements; i++)
{
if (type == XA_INTEGER) {
switch (format)
{
case 8:
data.c[i] = atoi(argv[2 + i]);
break;
case 16:
data.s[i] = atoi(argv[2 + i]);
break;
case 32:
data.l[i] = atoi(argv[2 + i]);
break;
default:
fprintf(stderr, "unexpected size for property %s", name);
return EXIT_FAILURE;
}
} else if (type == float_atom) {
if (format != 32) {
fprintf(stderr, "unexpected format %d for property %s\n",
format, name);
return EXIT_FAILURE;
}
*(float *)(data.l + i) = strtod(argv[2 + i], &endptr);
if (endptr == argv[2 + i]) {
fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
return EXIT_FAILURE;
}
} else if (type == XA_ATOM) {
if (format != 32) {
fprintf(stderr, "unexpected format %d for property %s\n",
format, name);
return EXIT_FAILURE;
}
data.l[i] = parse_atom(dpy, argv[2 + i]);
} else {
fprintf(stderr, "unexpected type for property %s\n", name);
return EXIT_FAILURE;
}
}
XIChangeProperty(dpy, info->deviceid, prop, type, format, PropModeReplace,
data.c, nelements);
free(data.c);
return EXIT_SUCCESS;
}
#endif
int list_props(Display *display, int argc, char *argv[], char *name,
char *desc)
{
#ifdef HAVE_XI2
if (xinput_version(display) == XI_2_Major)
return list_props_xi2(display, argc, argv, name, desc);
#endif
return list_props_xi1(display, argc, argv, name, desc);
}
int delete_prop(Display *display, int argc, char *argv[], char *name,
char *desc)
{
#ifdef HAVE_XI2
if (xinput_version(display) == XI_2_Major)
return delete_prop_xi2(display, argc, argv, name, desc);
#endif
return delete_prop_xi1(display, argc, argv, name, desc);
}
static int
do_set_prop(Display *display, Atom type, int format, int argc, char *argv[], char *name, char *desc)
{
#ifdef HAVE_XI2
if (xinput_version(display) == XI_2_Major)
return do_set_prop_xi2(display, type, format, argc, argv, name, desc);
#endif
return do_set_prop_xi1(display, type, format, argc, argv, name, desc);
}
int
set_atom_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
{
return do_set_prop(dpy, XA_ATOM, 32, argc, argv, n, desc);
}
int
set_int_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
{
int i;
int format;
if (argc < 3)
{
fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
return EXIT_FAILURE;
}
format = atoi(argv[2]);
if (format != 8 && format != 16 && format != 32)
{
fprintf(stderr, "Invalid format %d\n", format);
return EXIT_FAILURE;
}
for (i = 3; i < argc; i++)
argv[i - 1] = argv[i];
return do_set_prop(dpy, XA_INTEGER, format, argc - 1, argv, n, desc);
}
int
set_float_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
{
Atom float_atom = XInternAtom(dpy, "FLOAT", False);
if (sizeof(float) != 4)
{
fprintf(stderr, "sane FP required\n");
return EXIT_FAILURE;
}
return do_set_prop(dpy, float_atom, 32, argc, argv, n, desc);
}
int set_prop(Display *display, int argc, char *argv[], char *name,
char *desc)
{
Atom type = None;
int format = 0;
int i = 0, j;
while (i < argc) {
char *option = strchr(argv[i], '=');
/* skip non-option arguments */
if (strncmp(argv[i], "--", 2) || !option) {
i++;
continue;
}
if (!strncmp(argv[i], "--type=", strlen("--type="))) {
if (!strcmp(option + 1, "int")) {
type = XA_INTEGER;
} else if (!strcmp(option + 1, "float")) {
type = XInternAtom(display, "FLOAT", False);
format = 32;
} else if (!strcmp(option + 1, "atom")) {
type = XA_ATOM;
format = 32;
} else {
fprintf(stderr, "unknown property type %s\n", option + 1);
return EXIT_FAILURE;
}
} else if (!strncmp(argv[i], "--format=", strlen("--format="))) {
format = atoi(option + 1);
if (format != 8 && format != 16 && format != 32) {
fprintf(stderr, "invalid property format %s\n", option + 1);
return EXIT_FAILURE;
}
} else {
fprintf(stderr, "invalid option %s\n", argv[i]);
return EXIT_FAILURE;
}
for (j = i; j + 1 < argc; j++)
argv[j] = argv[j + 1];
argc--;
}
return do_set_prop(display, type, format, argc, argv, name, desc);
}

View File

@ -32,9 +32,8 @@
int
set_clientpointer(Display* dpy, int argc, char** argv, char* name, char *desc)
{
XDeviceInfo* info;
XIDeviceInfo *info;
XID window;
XDevice* dev = NULL;
char* id;
char* dummy;
@ -50,19 +49,13 @@ set_clientpointer(Display* dpy, int argc, char** argv, char* name, char *desc)
window = strtol(argv[0], &dummy, (*id == 'x') ? 16 : 10);
info = find_device_info(dpy, argv[1], False);
info = xi2_find_device_info(dpy, argv[1]);
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[1]);
return EXIT_FAILURE;
}
dev = XOpenDevice(dpy, info->id);
if (!dev)
{
fprintf(stderr, "Cannot open device %s.\n", argv[1]);
} else
XSetClientPointer(dpy, window, dev);
XISetClientPointer(dpy, window, info->deviceid);
return 0;
}

381
app/xinput/src/test_xi2.c Normal file
View File

@ -0,0 +1,381 @@
/*
* Copyright © 2009 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* 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.
*
*/
#include "xinput.h"
#include <string.h>
extern void print_classes_xi2(Display*, XIAnyClassInfo **classes,
int num_classes);
static Window create_win(Display *dpy)
{
Window win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 200,
200, 0, 0, WhitePixel(dpy, 0));
Window subwindow = XCreateSimpleWindow(dpy, win, 50, 50, 50, 50, 0, 0,
BlackPixel(dpy, 0));
XMapWindow(dpy, subwindow);
XSelectInput(dpy, win, ExposureMask);
return win;
}
static void print_deviceevent(XIDeviceEvent* event)
{
double *val;
int i;
printf(" device: %d (%d)\n", event->deviceid, event->sourceid);
printf(" detail: %d\n", event->detail);
printf(" flags: %s\n", (event->flags & XIKeyRepeat) ? "repeat" : "");
printf(" root: %.2f/%.2f\n", event->root_x, event->root_y);
printf(" event: %.2f/%.2f\n", event->event_x, event->event_y);
printf(" buttons:");
for (i = 0; i < event->buttons.mask_len * 8; i++)
if (XIMaskIsSet(event->buttons.mask, i))
printf(" %d", i);
printf("\n");
printf(" modifiers: locked %#x latched %#x base %#x effective: %#x\n",
event->mods.locked, event->mods.latched,
event->mods.base, event->mods.effective);
printf(" group: locked %#x latched %#x base %#x effective: %#x\n",
event->group.locked, event->group.latched,
event->group.base, event->group.effective);
printf(" valuators:");
val = event->valuators.values;
for (i = 0; i < event->valuators.mask_len * 8; i++)
if (XIMaskIsSet(event->valuators.mask, i))
printf(" %.2f", *val++);
printf("\n");
printf(" windows: root 0x%lx event 0x%lx child 0x%ld\n",
event->root, event->event, event->child);
}
static void print_devicechangedevent(Display *dpy, XIDeviceChangedEvent *event)
{
printf(" device: %d (%d)\n", event->deviceid, event->sourceid);
printf(" reason: %s\n", (event->reason == XISlaveSwitch) ? "SlaveSwitch" :
"DeviceChanged");
print_classes_xi2(dpy, event->classes, event->num_classes);
}
static void print_hierarchychangedevent(XIHierarchyEvent *event)
{
int i;
printf(" Changes happened: %s %s %s %s %s %s %s %s\n",
(event->flags & XIMasterAdded) ? "[new master]" : "",
(event->flags & XIMasterRemoved) ? "[master removed]" : "",
(event->flags & XISlaveAdded) ? "[new slave]" : "",
(event->flags & XISlaveRemoved) ? "[slave removed]" : "",
(event->flags & XISlaveAttached) ? "[slave attached]" : "",
(event->flags & XISlaveDetached) ? "[slave detached]" : "",
(event->flags & XIDeviceEnabled) ? "[device enabled]" : "",
(event->flags & XIDeviceDisabled) ? "[device disabled]" : "");
for (i = 0; i < event->num_info; i++)
{
char *use;
switch(event->info[i].use)
{
case XIMasterPointer: use = "master pointer"; break;
case XIMasterKeyboard: use = "master keyboard"; break;
case XISlavePointer: use = "slave pointer"; break;
case XISlaveKeyboard: use = "slave keyboard"; break;
case XIFloatingSlave: use = "floating slave"; break;
break;
}
printf(" device %d [%s (%d)] is %s\n",
event->info[i].deviceid,
use,
event->info[i].attachment,
(event->info[i].enabled) ? "enabled" : "disabled");
if (event->info[i].flags)
{
printf(" changes: %s %s %s %s %s %s %s %s\n",
(event->info[i].flags & XIMasterAdded) ? "[new master]" : "",
(event->info[i].flags & XIMasterRemoved) ? "[master removed]" : "",
(event->info[i].flags & XISlaveAdded) ? "[new slave]" : "",
(event->info[i].flags & XISlaveRemoved) ? "[slave removed]" : "",
(event->info[i].flags & XISlaveAttached) ? "[slave attached]" : "",
(event->info[i].flags & XISlaveDetached) ? "[slave detached]" : "",
(event->info[i].flags & XIDeviceEnabled) ? "[device enabled]" : "",
(event->info[i].flags & XIDeviceDisabled) ? "[device disabled]" : "");
}
}
}
static void print_rawevent(XIRawEvent *event)
{
int i;
double *val, *raw_val;
printf(" device: %d\n", event->deviceid);
printf(" detail: %d\n", event->detail);
printf(" valuators:\n");
val = event->valuators.values;
raw_val = event->raw_values;
for (i = 0; i < event->valuators.mask_len * 8; i++)
if (XIMaskIsSet(event->valuators.mask, i))
printf(" %2d: %.2f (%.2f)\n", i, *val++, *raw_val++);
printf("\n");
}
static void print_enterleave(XILeaveEvent* event)
{
char *mode, *detail;
int i;
printf(" device: %d\n", event->deviceid);
printf(" windows: root 0x%lx event 0x%lx child 0x%ld\n",
event->root, event->event, event->child);
switch(event->mode)
{
case XINotifyNormal: mode = "NotifyNormal"; break;
case XINotifyGrab: mode = "NotifyGrab"; break;
case XINotifyUngrab: mode = "NotifyUngrab"; break;
case XINotifyWhileGrabbed: mode = "NotifyWhileGrabbed"; break;
case XINotifyPassiveGrab: mode = "NotifyPassiveGrab"; break;
case XINotifyPassiveUngrab:mode = "NotifyPassiveUngrab"; break;
}
switch (event->detail)
{
case XINotifyAncestor: detail = "NotifyAncestor"; break;
case XINotifyVirtual: detail = "NotifyVirtual"; break;
case XINotifyInferior: detail = "NotifyInferior"; break;
case XINotifyNonlinear: detail = "NotifyNonlinear"; break;
case XINotifyNonlinearVirtual: detail = "NotifyNonlinearVirtual"; break;
case XINotifyPointer: detail = "NotifyPointer"; break;
case XINotifyPointerRoot: detail = "NotifyPointerRoot"; break;
case XINotifyDetailNone: detail = "NotifyDetailNone"; break;
}
printf(" mode: %s (detail %s)\n", mode, detail);
printf(" flags: %s %s\n", event->focus ? "[focus]" : "",
event->same_screen ? "[same screen]" : "");
printf(" buttons:");
for (i = 0; i < event->buttons.mask_len * 8; i++)
if (XIMaskIsSet(event->buttons.mask, i))
printf(" %d", i);
printf("\n");
printf(" modifiers: locked %#x latched %#x base %#x effective: %#x\n",
event->mods.locked, event->mods.latched,
event->mods.base, event->mods.effective);
printf(" group: locked %#x latched %#x base %#x effective: %#x\n",
event->group.locked, event->group.latched,
event->group.base, event->group.effective);
printf(" root x/y: %.2f / %.2f\n", event->root_x, event->root_y);
printf(" event x/y: %.2f / %.2f\n", event->event_x, event->event_y);
}
static void print_propertyevent(Display *display, XIPropertyEvent* event)
{
char *changed;
char *name;
if (event->what == XIPropertyDeleted)
changed = "deleted";
else if (event->what == XIPropertyCreated)
changed = "created";
else
changed = "modified";
name = XGetAtomName(display, event->property);
printf(" property: %ld '%s'\n", event->property, name);
printf(" changed: %s\n", changed);
XFree(name);
}
void
test_sync_grab(Display *display, Window win)
{
int loop = 3;
int rc;
XIEventMask mask;
/* Select for motion events */
mask.deviceid = XIAllDevices;
mask.mask_len = 2;
mask.mask = calloc(2, sizeof(char));
XISetMask(mask.mask, XI_ButtonPress);
if ((rc = XIGrabDevice(display, 2, win, CurrentTime, None, GrabModeSync,
GrabModeAsync, False, &mask)) != GrabSuccess)
{
fprintf(stderr, "Grab failed with %d\n", rc);
return;
}
free(mask.mask);
XSync(display, True);
XIAllowEvents(display, 2, SyncPointer, CurrentTime);
XFlush(display);
printf("Holding sync grab for %d button presses.\n", loop);
while(loop--)
{
XIEvent ev;
XNextEvent(display, (XEvent*)&ev);
if (ev.type == GenericEvent && ev.extension == xi_opcode )
{
XIDeviceEvent *event = (XIDeviceEvent*)&ev;
print_deviceevent(event);
XIAllowEvents(display, 2, SyncPointer, CurrentTime);
}
}
XIUngrabDevice(display, 2, CurrentTime);
printf("Done\n");
}
int
test_xi2(Display *display,
int argc,
char *argv[],
char *name,
char *desc)
{
XIEventMask mask;
Window win;
list(display, argc, argv, name, desc);
win = create_win(display);
/* Select for motion events */
mask.deviceid = XIAllDevices;
mask.mask_len = XIMaskLen(XI_RawMotion);
mask.mask = calloc(mask.mask_len, sizeof(char));
XISetMask(mask.mask, XI_ButtonPress);
XISetMask(mask.mask, XI_ButtonRelease);
XISetMask(mask.mask, XI_KeyPress);
XISetMask(mask.mask, XI_KeyRelease);
XISetMask(mask.mask, XI_Motion);
XISetMask(mask.mask, XI_DeviceChanged);
XISetMask(mask.mask, XI_Enter);
XISetMask(mask.mask, XI_Leave);
XISetMask(mask.mask, XI_FocusIn);
XISetMask(mask.mask, XI_FocusOut);
XISetMask(mask.mask, XI_HierarchyChanged);
XISetMask(mask.mask, XI_PropertyEvent);
XISelectEvents(display, win, &mask, 1);
XMapWindow(display, win);
XSync(display, False);
{
XIGrabModifiers modifiers[] = {{0, 0}, {0, 0x10}, {0, 0x1}, {0, 0x11}};
int nmods = sizeof(modifiers)/sizeof(modifiers[0]);
mask.deviceid = 2;
memset(mask.mask, 0, 2);
XISetMask(mask.mask, XI_KeyPress);
XISetMask(mask.mask, XI_KeyRelease);
XISetMask(mask.mask, XI_ButtonPress);
XISetMask(mask.mask, XI_ButtonRelease);
XISetMask(mask.mask, XI_Motion);
XIGrabButton(display, 2, 1, win, None, GrabModeAsync, GrabModeAsync,
False, &mask, nmods, modifiers);
XIGrabKeycode(display, 3, 24 /* q */, win, GrabModeAsync, GrabModeAsync,
False, &mask, nmods, modifiers);
XIUngrabButton(display, 3, 1, win, nmods - 2, &modifiers[2]);
XIUngrabKeycode(display, 3, 24 /* q */, win, nmods - 2, &modifiers[2]);
}
mask.deviceid = XIAllMasterDevices;
memset(mask.mask, 0, 2);
XISetMask(mask.mask, XI_RawKeyPress);
XISetMask(mask.mask, XI_RawKeyRelease);
XISetMask(mask.mask, XI_RawButtonPress);
XISetMask(mask.mask, XI_RawButtonRelease);
XISetMask(mask.mask, XI_RawMotion);
XISelectEvents(display, DefaultRootWindow(display), &mask, 1);
free(mask.mask);
{
XEvent event;
XMaskEvent(display, ExposureMask, &event);
XSelectInput(display, win, 0);
}
/*
test_sync_grab(display, win);
*/
while(1)
{
XEvent ev;
XGenericEventCookie *cookie = (XGenericEventCookie*)&ev.xcookie;
XNextEvent(display, (XEvent*)&ev);
if (XGetEventData(display, cookie) &&
cookie->type == GenericEvent &&
cookie->extension == xi_opcode)
{
printf("EVENT type %d\n", cookie->evtype);
switch (cookie->evtype)
{
case XI_DeviceChanged:
print_devicechangedevent(display, cookie->data);
break;
case XI_HierarchyChanged:
print_hierarchychangedevent(cookie->data);
break;
case XI_RawKeyPress:
case XI_RawKeyRelease:
case XI_RawButtonPress:
case XI_RawButtonRelease:
case XI_RawMotion:
print_rawevent(cookie->data);
break;
case XI_Enter:
case XI_Leave:
case XI_FocusIn:
case XI_FocusOut:
print_enterleave(cookie->data);
break;
case XI_PropertyEvent:
print_propertyevent(display, cookie->data);
break;
default:
print_deviceevent(cookie->data);
break;
}
}
XFreeEventData(display, cookie);
}
XDestroyWindow(display, win);
return EXIT_SUCCESS;
}

View File

@ -1,43 +0,0 @@
/*
* Copyright 1996-1997 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
*
* 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.
*
*/
#include "xinput.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
static const char version_id[] = VERSION;
int
version(Display *display,
int argc,
char *argv[],
char *name,
char *desc)
{
printf("%s %s\n", name, version_id);
return EXIT_SUCCESS;
}
/* end of version.c */

View File

@ -25,12 +25,10 @@
#include <ctype.h>
#include <string.h>
typedef int (*prog)(
#if NeedFunctionPrototypes
Display* display, int argc, char *argv[],
char *prog_name, char *prog_desc
#endif
);
int xi_opcode;
typedef int (*prog)(Display* display, int argc, char *argv[],
char *prog_name, char *prog_desc);
typedef struct
{
@ -70,7 +68,7 @@ static entry drivers[] =
set_mode
},
{"list",
"[--loop || --short || <device name>...]",
"[--short || --long] [<device name>...]",
list
},
{"query-state",
@ -81,17 +79,13 @@ static entry drivers[] =
"[-proximity] <device name>",
test
},
{"version",
"",
version
},
#if HAVE_XI2
{ "create-master",
"<id> [sendCore (dflt:1)] [enable (dflt:1)]",
"<id> [<sendCore (dflt:1)>] [<enable (dflt:1)>]",
create_master
},
{ "remove-master",
"<id> [returnMode (dflt:Floating)] [returnPointer] [returnKeyboard]",
"<id> [Floating|AttachToMaster (dflt:Floating)] [<returnPointer>] [<returnKeyboard>]",
remove_master
},
{ "reattach",
@ -106,6 +100,10 @@ static entry drivers[] =
"<window> <device>",
set_clientpointer
},
{ "test-xi2",
"<device>",
test_xi2,
},
#endif
{ "list-props",
"<device> [<device> ...]",
@ -131,29 +129,62 @@ static entry drivers[] =
"<device> <property>",
delete_prop
},
{ "set-prop",
"<device> [--type=atom|float|int] [--format=8|16|32] <property> <val> [<val> ...]",
set_prop
},
{NULL, NULL, NULL
}
};
static Bool
is_xinput_present(Display *display)
static const char version_id[] = VERSION;
int
print_version()
{
XExtensionVersion *version;
Bool present;
Display *display;
printf("xinput version %s\n", version_id);
display = XOpenDisplay(NULL);
printf("XI version on server: ");
if (display == NULL)
printf("Failed to open display.\n");
else {
version = XGetExtensionVersion(display, INAME);
if (!version || (version == (XExtensionVersion*) NoSuchExtension))
printf(" Extension not supported.\n");
else {
printf("%d.%d\n", version->major_version,
version->minor_version);
XFree(version);
return 0;
}
}
return 1;
}
int
xinput_version(Display *display)
{
XExtensionVersion *version;
static int vers = -1;
if (vers != -1)
return vers;
#if HAVE_XI2
version = XQueryInputVersion(display, XI_2_Major, XI_2_Minor);
#else
version = XGetExtensionVersion(display, INAME);
#endif
if (version && (version != (XExtensionVersion*) NoSuchExtension)) {
present = version->present;
vers = version->major_version;
XFree(version);
return present;
} else {
return False;
}
return vers;
}
XDeviceInfo*
@ -200,6 +231,41 @@ find_device_info(Display *display,
return found;
}
#ifdef HAVE_XI2
XIDeviceInfo*
xi2_find_device_info(Display *display, char *name)
{
XIDeviceInfo *info;
int ndevices;
Bool is_id = True;
int i, id = -1;
for(i = 0; i < strlen(name); i++) {
if (!isdigit(name[i])) {
is_id = False;
break;
}
}
if (is_id) {
id = atoi(name);
}
info = XIQueryDevice(display, XIAllDevices, &ndevices);
for(i = 0; i < ndevices; i++)
{
if ((is_id && info[i].deviceid == id) ||
(!is_id && strcmp(info[i].name, name) == 0))
{
return &info[i];
}
}
XIFreeDeviceInfo(info);
return NULL;
}
#endif
static void
usage(void)
{
@ -220,12 +286,20 @@ main(int argc, char * argv[])
Display *display;
entry *driver = drivers;
char *func;
int event, error;
if (argc < 2) {
usage();
return EXIT_FAILURE;
}
func = argv[1];
while((*func) == '-') func++;
if (strcmp("version", func) == 0) {
return print_version(argv[0]);
}
display = XOpenDisplay(NULL);
if (display == NULL) {
@ -233,10 +307,12 @@ main(int argc, char * argv[])
return EXIT_FAILURE;
}
func = argv[1];
while((*func) == '-') func++;
if (!XQueryExtension(display, "XInputExtension", &xi_opcode, &event, &error)) {
printf("X Input extension not available.\n");
return EXIT_FAILURE;
}
if (!is_xinput_present(display)) {
if (!xinput_version(display)) {
fprintf(stderr, "%s extension not available\n", INAME);
return EXIT_FAILURE;
}

View File

@ -27,6 +27,9 @@
#include <X11/Xlib.h>
#include <X11/extensions/XInput.h>
#ifdef HAVE_XI2
#include <X11/extensions/XInput2.h>
#endif
#include <X11/Xutil.h>
#include <stdio.h>
#include <stdlib.h>
@ -38,255 +41,41 @@
#define EXIT_FAILURE 0
#endif
XDeviceInfo*
find_device_info(
#if NeedFunctionPrototypes
Display *display,
char *name,
Bool only_extended
extern int xi_opcode; /* xinput extension op code */
XDeviceInfo* find_device_info( Display *display, char *name, Bool only_extended);
#if HAVE_XI2
XIDeviceInfo* xi2_find_device_info(Display *display, char *name);
int xinput_version(Display* display);
#endif
);
int
get_feedbacks(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_ptr_feedback(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int get_feedbacks( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_ptr_feedback( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int get_button_map( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_button_map( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_pointer( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int
get_button_map(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int set_mode( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int list( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int test( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int version( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_integer_feedback( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int query_state( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int
set_button_map(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
/* X Input 1.5 */
int list_props( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_int_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_float_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_atom_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int watch_props( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int delete_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int
set_pointer(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_mode(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
list(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
test(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
version(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_integer_feedback(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
query_state(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
create_master(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
remove_master(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
change_attachment(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
float_device(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_clientpointer(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
list_props(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_int_prop(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_float_prop(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
set_atom_prop(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
watch_props(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
int
delete_prop(
#if NeedFunctionPrototypes
Display* display,
int argc,
char *argv[],
char *prog_name,
char *prog_desc
#endif
);
/* X Input 2.0 */
int create_master( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int remove_master( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int change_attachment( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int float_device( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int set_clientpointer( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
int test_xi2( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
/* end of xinput.h */