Commit graph

131 commits

Author SHA1 Message Date
Peter Hutterer
50b82c19b5 Actually filter by log priority
If a message is higher than the current priority, filter it. And add a few
tests that the priority is handled the way it should.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-13 08:07:30 +10:00
Peter Hutterer
6c2b01d67f test: remove NULL test for SW_MAX, 3.13 defines SW_MUTE_DEVICE
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-29 15:08:12 +10:00
Peter Hutterer
642c91fc6a Warn about a SYN_DROPPED right after finishing a sync
If the first event after a completed device sync is a SYN_DROPPED, warn the
user that they're not fast enough handling this device.

The test for this is rather complicated since we can't write SYN_DROPPED
through uinput so we have to juggle the device fd and a pipe and switch
between the two at the right time (taking into account that libevdev will read
events from the fd whenever it can).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 09:15:14 +10:00
Peter Hutterer
0c01886985 test: abort on unexpected log messages
Add two log functions, one that aborts on a received message. We know when we
expect to receive an error, so anytime this happens unexpectedly should
terminate the test.

And for those tests do issue a log message, let them ignore it and don't
print anything.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 09:14:40 +10:00
Peter Hutterer
4eeda3bc47 test: fix typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 10:54:58 +10:00
Peter Hutterer
650f372c90 test: rename a test to match what it's testing better
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 10:54:58 +10:00
Peter Hutterer
d3c3486560 include: update linux/input.h for kernel 3.12
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2014-01-09 09:05:05 +10:00
Peter Hutterer
fd3118ea1a test: detect if we're running inside gdb and disable forking
The Check test framework forks by default which is annoying when running gdb.
Try to detect whether we're inside gdb by ptracing ourselves. If that works,
we're not inside a debugger. If it doesn't, then assume we're inside a
debugger and set CK_FORK to "no".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-24 09:14:12 +10:00
Peter Hutterer
e947fdc4c7 test: add basic link test
This test doesn't do anything but compile and link against libevdev. It's a
simple protection to avoid linker errors. If we ever have libs we depend on
and they don't get resolved properly, this test should warn us in time.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-12 13:19:52 +10:00
Peter Hutterer
2487950f65 test: split tests into run-time and build-time tests
The build-time tests don't do anything, we don't need to run them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-12 12:57:21 +10:00
Peter Hutterer
546efc783c Don't treat devices with (ABS_MT_SLOT - 1) as multitouch devices
Some devices (PS3 sixaxis controller) merely have a bunch of axes, without the
semantic information that linux/input.h requires. For those, the ABS_MT range
may be merely another axis, not the special range that we need to treat it
with.

Use a simple heuristic: if ABS_MT_SLOT - 1 is enabled, don't treat ABS_MT as
multitouch axes. The ABS_MT_SLOT - 1 axis is not used for a real axis.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-12-10 19:39:47 +10:00
Peter Hutterer
714c2ffa9e Merge branch 'ev-rep-handling' 2013-12-09 09:49:43 +10:00
Peter Hutterer
f66bf57baa State that the event is defined for a SYN_DROPPED
All clients that want to handle SYN_DROPPED correctly need to pass an EV_SYN
through their own handlers before starting with the syn events. Rather than
letting them synthesize that, guarantee that the event is defined the first
time LIBEVDEV_READ_STATUS_SYNC is returned.

This does not change existing behavior, it merely documents it so we can rely
on it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-09 09:49:28 +10:00
Peter Hutterer
a2f842bb8a Support EV_REP values through libevdev_get_event_value
We shouldn't have a separate API for that, the whole point of libevdev is to
abstract the quirkyness of the ioctls into a common interface. So let's
export the two EV_REP values through libevdev_get_event_value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-12-09 09:49:15 +10:00
Gaetan Nadon
81780fc4d2 test-compile-pedantic: replace -Wpedantic with -pedantic
-Wpedantic is a relatively new option, with -pedantic being the old version of
it that works on older gcc versions too.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-11-26 09:53:08 +10:00
Peter Hutterer
a742d253b7 test: add a build test for -Wpedantic
A user of libevdev may be compiled with -Wpedantic. Our header files should
not produce any warnings, so add a simple test that merely includes both
public header files and compiles with -Wpedantic -Werror.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-23 09:00:53 +10:00
Gaetan Nadon
4f0f1ca68c Review/update .gitignore files
Merge potentially useful patterns taken from other projects.

Some application specific patterns were move to their respective directories.

The only noticeable change is that *.patch is ignore to prevent accidental
checkin of patches. The pattern "test-driver" could not be found and was
removed.

The test directory had not been updated since the move of all test cases
in a single binary.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-11-19 09:34:23 +10:00
Peter Hutterer
2aa3d3f1b0 Provide separate lookup functions for zero-terminated strings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-01 08:18:41 +10:00
David Herrmann
523f34b2d9 Add name-resolver unit tests
A bunch of tests for the new name resolver.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31 11:24:26 +10:00
David Herrmann
12717d796c Add libevdev_event_type/code_from_name() resolvers
Three new helpers are added:
(1) libevdev_event_type_from_name() takes a string describing an EV_*
event type and returns the given event-type constant.
(2) libevdev_event_code_from_name() takes a string describing an event
code and returns the given event-code constant.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31 11:24:23 +10:00
David Herrmann
639a5a9b56 Fix wrong libevdev clock test
We can rely on CLOCK_MONOTONIC and CLOCK_REALTIME to be different at any
time. However, this does not apply to the ms/us/ns parts of the current
time. Both may be in sync regarding the current micro-seconds state. So
remove the wrong clock us-comparison.

I was able to trigger this on my machine. Chances that both are in sync
are very low so I assume my RTC only provides low granularity and thus
both clocks are sync during boot for higher granularity.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31 11:23:13 +10:00
Peter Hutterer
c4111f717a Check max to see if an event type is valid
There's a gap in the range between EV_SW and EV_LED. Trying to enable one
of those bits will segfault.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-24 15:13:41 +10:00
Peter Hutterer
03c3e4f975 Disallow disabling EV_SYN event codes
The documentation already says that, make it happen.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-24 15:13:41 +10:00
Peter Hutterer
2a3219f55d Add a copy of linux/input.h
This avoids a number of otherwise required ifdefs when building on older kernels

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 09:04:34 +10:00
Peter Hutterer
d9fcbd563a Mark three deprecated functions as such
These are deprecated, but were missing the deprecated attribute.
And fix up the tests that were still using those deprecated calls.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-04 16:02:22 +10:00
Peter Hutterer
1e81ac1e28 wrap EVIOCSCLOCKID into an API call
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-13 09:28:00 +10:00
Peter Hutterer
c299ab3c5e test: provide wrapper for fetching the devnode from a uinput test device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-13 08:59:06 +10:00
Peter Hutterer
b539cfd808 test: add a test for checking log data being passed around correctly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-12 14:28:05 +10:00
Peter Hutterer
661602fe3b Name-space the read flags better
Rename from LIBEVDEV_READ_foo to LIBEVDEV_READ_FLAG_foo to differentiate
better from LIBEVDEV_READ_STATUS_foo.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-11 12:10:15 +10:00
Peter Hutterer
5d2fc78138 Enumerate libevdev_next_event() return codes
Improved readability in callers, changing magic numbers 0 and 1 to

rc = libevdev_next_event();
if (rc == LIBEVDEV_READ_STATUS_SUCCESS)
    do_something();
else if (rc == LIBEVDEV_READ_STATUS_SYNC)
    do_something_else()

No ABI changes, the enum values are the previously documented values,
this is just a readability improvement.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-11 12:10:12 +10:00
Peter Hutterer
ab2f20bfd6 Revamp the API once again
Another look at the current API showed some inconsistencies, rectified
in this commit:

libevdev_kernel_*: modify the underlying kernel device
libevdev_event_type_*: something with an event type
libevdev_event_code_*: something with an event code
libevdev_event_*: struct input_event-related functions (i.e. not device-related)
libevdev_property_*: something with a property
libevdev_*: anything applying to a device

Hopefully that's the last API change. Current symbols deprecated and aliased.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-10 11:25:09 +10:00
Peter Hutterer
0adb75e2eb Merge branch 'logging-fix' 2013-09-10 09:59:11 +10:00
Peter Hutterer
112ac0351f test: test for logging function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-10 09:54:29 +10:00
Peter Hutterer
75b66c1fb5 Match the kernel define for SYN_MAX
Will be defined as 0xf in 3.12, see
http://git.kernel.org/cgit/linux/kernel/git/dtor/input.git/commit/?h=next&id=52764fed5049655926bcecaefd52f0a415ceb105

And add the required ifdef guards for kernels before that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-04 07:54:22 +10:00
Peter Hutterer
55d67a340b Drop per-device logging function, use per-library one instead
There's no need to have separate logging function for each device created.
More likely, libevdev will be hooked up once into the logging system and
expected to deal with it.

Plus, this allows us to log from the uinput code where we don't
have the context anyway.

Requires a rename to libevdev_set_log_function to avoid ABI breaks, and
while we're breaking the ABI make the logging function more sophisticated
to log line, number, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-03 16:58:54 +10:00
Peter Hutterer
9675287062 Use ENOMEM instead of ENOSPC
From errno(3):
   ENOMEM          Not enough space (POSIX.1)
   ENOSPC          No space left on device (POSIX.1)

when we run out memory the reason is a failed malloc, for which ENOMEM
seems more appropriate.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-31 12:27:23 +10:00
Peter Hutterer
69f89c8877 test: update to test for the various _MAX values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-31 09:40:41 +10:00
Peter Hutterer
e372c4a6bd test: add a test for uinput device properties
Specifically, test for INPUT_PROP_MAX, which is a valid property value

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-30 17:41:02 +10:00
Peter Hutterer
b77fea9c89 Fix off-by-one errors when dealing with *_MAX values.
LED_MAX, KEY_MAX, ABS_MT_MAX, etc. are all valid event codes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-30 17:40:54 +10:00
Peter Hutterer
a8871e7aea Use AC_USE_SYSTEM_EXTENSIONS
Defines _GNU_SOURCE for us.
http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Posix-Variants.html

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-29 13:54:50 +10:00
Peter Hutterer
da425202c1 test: fix ev_rep test for new uinput implementation
We can actually set EV_REP values now, though with limitations

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-29 13:54:49 +10:00
Peter Hutterer
cc2eaec4ed test: switch udev backend over to new libevdev-uinput bits
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-29 13:54:49 +10:00
Peter Hutterer
21356cca57 test: add uinput creation tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-29 13:54:49 +10:00
Peter Hutterer
1acbfb3579 Add support for uinput device creation
This lets libevdev provide a relatively generic interface for the
creation of uinput devices so we don't need to duplicate this across
multiple projects.

Most of this is lifted from the current test implementation, with a
couple of minor changes.

EV_REP needs special handling:
   Kernel allows to set the EV_REP bit, it doesn't set REP_* bits (which we
   wrap anyway) but it will also set the default values (500, 33).

Device node is guessed based on the sysfs path:
   The sysfs path contains a eventN file, that corresponds to our
   /dev/input/eventN number. Use it so clients can quickly get the device
   node, without a libudev dependency.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-29 13:54:46 +10:00
Peter Hutterer
dd4a1a49de test: add test for libevdev_is_event_code(EV_SYN...)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-29 11:36:20 +10:00
Peter Hutterer
b20becc942 Add support for EV_SW
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-29 11:13:47 +10:00
Peter Hutterer
bd35bd53f0 Merge branch 'led-handling' 2013-08-26 09:53:10 +10:00
Peter Hutterer
edc31cf12e Store the abs value after handling mt events
This way any ABS_MT_ event value that comes in will also be stored in abs_info.
That always corresponds to "current slot", so if a user calls
libevdev_set_event_value() or libevdev_get_event_value() they're actually
modifying the current slot value.

When the current slot changes, sync the state back into the absinfo values.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-26 09:52:33 +10:00
Martin Minarik
411031178e Fix build without MSC_TIMESTAMP
To build with older input.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-26 08:10:11 +10:00
Peter Hutterer
4d4293a65b Add functions to toggle LEDs on the device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-15 10:32:40 +10:00