Commit graph

5731 commits

Author SHA1 Message Date
Kristian Høgsberg
f6caf57b00 evdev: Use a has_keyboard flag instead of EVDEV_KEYBOARD bit 2013-12-21 12:44:03 +01:00
Kristian Høgsberg
4124ca1433 evdev: Replace EVDEV_BUTTON with local has_button flag 2013-12-21 12:35:43 +01:00
Kristian Høgsberg
a847278c4a evdev: Replace EVDEV_MOTION_ABS with local has_abs flag 2013-12-21 12:34:26 +01:00
Kristian Høgsberg
7226e8c368 evdev: Use has_abs only for ABS_X and ABS_Y, introduce has_mt for MT events
We split up has_abs into plain ABS_X/Y and MT events, but this shouldn't
introduce any logic changes.
2013-12-21 12:32:31 +01:00
Kristian Høgsberg
606706f87f evdev: Drop EVDEV_MOTION_REL flag
This is only used inside evdev_configure_device() and we now use a local
has_rel flag instead.
2013-12-21 12:32:06 +01:00
Kristian Høgsberg
a5db876938 evdev: Combine evdev_handle_device() and evdev_configure_device()
We split the device probing and idenfication somewhat arbitrarily between
these two functions.  This commit combines them into one.  Return of -1
indicates error, 0 success, but succesful probing can return a device
with device->caps == 0, which means we don't handle the device.
2013-12-21 12:25:17 +01:00
Peter Hutterer
e13d0c8248 doc: extract static members as well
We only run doxygen over the public headers, so if we have a static function
in those make sure they show up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:11:03 +01:00
Peter Hutterer
ea246471d3 Documentation typo fix 2013-12-21 12:10:45 +01:00
Peter Hutterer
727b21f366 Fix typo in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:38 +01:00
Peter Hutterer
ecc8d6c42d Document the open/close_restricted interface
Specifically, document that it needs to return a negative errno on failure.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:32 +01:00
Peter Hutterer
ed87c6dbb0 Add libudev and -lm to Requires.private
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:19 +01:00
Peter Hutterer
c7af6193b6 Add -lm to library
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:09 +01:00
Peter Hutterer
ac1f1acb41 udev: print errno if we can't open a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:03 +01:00
Peter Hutterer
b59d9c537b util: add ARRAY_FOR_EACH helper
Requires c99, but that's the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:09:55 +01:00
Peter Hutterer
95c6ac638f doc: group li_fixed_t into the fixed point functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:09:39 +01:00
Peter Hutterer
e4f4389341 Move zalloc() up to libinput-util.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:09:27 +01:00
Jonas Ådahl
58a33bd51c Unref seats and devices in libinput_destroy()
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-16 22:52:05 +01:00
Jonas Ådahl
3bf28bfc14 udev-seat: Remove unused declaration
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-15 21:25:10 +01:00
Peter Hutterer
1ad76d584f udev: include libinput-private.h for struct libinput
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:10:06 +01:00
Peter Hutterer
c869aeda9e fix typo in documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:08:05 +01:00
Peter Hutterer
ce5a068daf configure: require c99
This enables a few nice things that gcc would otherwise not allow.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:07:50 +01:00
Peter Hutterer
4f9c0839fb udev: fail libinput_create_from_udev for NULL values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:07:42 +01:00
Peter Hutterer
48608f1f6a configure: add libudev dependency
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:07:30 +01:00
Peter Hutterer
2ee299afcc Allow for NULL in libinput_destroy
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:07:21 +01:00
Peter Hutterer
c188943568 Allow for NULL in libevdev_event_destroy
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-15 21:07:03 +01:00
Jonas Ådahl
1dad790a7f Introduce libinput_device_get_sysname() API
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-15 17:50:04 +01:00
Jonas Ådahl
8ac43ac5b8 Export li_fixed_to_(int|double) converters
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-15 17:47:45 +01:00
Jonas Ådahl
d791a7ab09 Introduce libinput_device_has_capability() API
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-15 17:45:02 +01:00
Jonas Ådahl
0c43efb9bd doc: Document basic event accessor functions
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-08 21:26:11 +01:00
Jonas Ådahl
67455487f8 Put libinput_event_destroy() together with other event functions
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-08 16:30:13 +01:00
Jonas Ådahl
ef2deab618 Make even structs private
To ease the possibility to extend messages with more information, make
every event struct private, while providing functions used for accessing
the parameters previously found directly in the public structs.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-08 12:36:27 +01:00
Jonas Ådahl
aae7b4e0bc Put libinput_interface struct below base doxygen group
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-08 12:35:53 +01:00
Jonas Ådahl
758e553645 Reference count event target struct when applicable
If the target of an event is a reference counted object, such as
libinput_seat and libinput_device, make events own its own reference to
the object, releasing it when destroyed.

In order to do this, a new API requirement and function are introduced;
libinput_event_destroy(). The user is required to use
libinput_event_destroy() instead of free() after having retrieved an
event using libinput_get_event().

This fixes a race that would be triggered if a device or seat would be
added and removed before the user calling libinput_get_event().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-07 16:41:43 +01:00
Jonas Ådahl
5836054306 Remove unused disabled code
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-07 16:01:17 +01:00
Jonas Ådahl
caf19d5968 doc: Clarify that the caller need to free retrieved event
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-07 14:06:55 +01:00
Peter Hutterer
2d2df7842c doc: hook up doxygen to generate the public API documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-07 14:06:46 +01:00
Peter Hutterer
075119dd5a Rename libinput_create_udev to libinput_create_from_udev
A lot more obvious what it does, it creates a libinput context from a udev
handler (rather than creating the udev handler).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-07 13:55:37 +01:00
Peter Hutterer
d50c5108c1 udev-seat: fix leak when failing to add devices
udev-monitor and the udev_monitor_source would leak.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-07 13:55:31 +01:00
Peter Hutterer
7b09c753de Drop include of evdev.h from evdev.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
c06804b643 Drop unused libinput_fd_handle and libinput_fd_callback
Obsolete with ce787552bc

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
9e6cf91f48 evdev: fix memcopy for calibration
Function arguments with fixed length are still just pointers, so
sizeof(calibration) here is sizeof(float*), not sizeof(float) * 6.

evdev.c: In function 'evdev_device_calibrate':
evdev.c:693:54: warning: argument to 'sizeof' in 'memcpy' call is the same
  pointer type 'float *' as the destination; expected 'float' or an explicit
  length [-Wsizeof-pointer-memaccess]
  memcpy(device->abs.calibration, calibration, sizeof calibration);

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
adf859c2e9 Move libinput, libinput_seat and libinput_device to the top
Declare all three before they are used.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
8999445894 Declare libinput_seat explicitly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
3a3a0c87a7 libinput_dispatch: return -EAGAIN if no events are ready
Notify the caller that no events are currently ready to be processed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
f583cb7f6c libinput_dispatch: return negative error number on failure
Might as well tell the caller what went wrong without having to worry about
errno.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:16 +10:00
Peter Hutterer
2aec703c2e Make the slots unsigned, the kernel guarantees a base of 0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:12 +10:00
Peter Hutterer
74955e0b95 Make buttons unsigned, there are no negative button numbers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 13:52:07 +10:00
Jonas Ådahl
56f7ddec82 Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.

The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.

Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.

The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().

The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.

There is one known problem with the current API that is the potentially
racy initialization.

The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-24 21:19:18 +01:00
Jonas Ådahl
c0af815eae util: Add logging utilities
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 12:55:44 +01:00
Jonas Ådahl
97a277a9f0 Merge branch 'master' into udev 2013-11-19 22:29:38 +01:00