Commit graph

182 commits

Author SHA1 Message Date
Kristian Høgsberg
1625aa0fc2 evdev: Initliaze device->link so we can wl_list_remove() without crashing
We were testing for wl_list_empty() on a { NULL, NULL } list (which
returns false) and then wl_list_remove()ing the device (which crashes).
2013-11-10 17:51:33 +01:00
Kristian Høgsberg
6dc5a8e95d evdev: Ignore joystick devices
We don't handle them in any way now and having your steering wheel move
the cursor isn't useful.  Applications can still open evdev devices and
access them directly like they already do.
2013-11-10 17:51:33 +01:00
Rolf Morel
5a49ec0e83 evdev: write EV_SYN input_event along with led events to device
Other clients of an evdev device need to have the events they receive
be separated, in moment in time, from other events by an EV_SYN/
SYN_REPORT. This is the responsibility of the client who writes events
into the stream.
2013-11-10 17:51:33 +01:00
Rusty Lynch
3a65d85ad0 evdev: Use touch ID 0 when generating touch up event
device->mt.slot is uninitialized when we're not receiving the
evdev slot events.  Always use ID 0 as we do when we generate the
touch down and motion events.
2013-11-10 17:51:33 +01:00
Peter Hutterer
f22edd89cb evdev: log when a device is used as touchpad 2013-11-10 17:51:33 +01:00
Peter Hutterer
786bf52f8f evdev: call evdev_device_destroy on failure
Avoid keeping keeping what needs to be freed in sync in multiple places,
make evdev_device_destroy do the right thing instead.
2013-11-10 17:51:32 +01:00
Peter Hutterer
b23c3273bc evdev: plug a potential memleak
For touchpads, device->dispatch is set up when exiting
evdev_handle_device() and a potential source for a memleak.
This can't actually happen at the moment, as evdev_handle_device() won't
fail for touchpads after setting up the dispatch but prevent this from
happening in the future.
2013-11-10 17:51:32 +01:00
Peter Hutterer
3fe16ee03b evdev: get the current slot value from the absinfo struct or mtdev
If touches are already present on the device, absinfo has the currently
active touch slot. There's a race condition where the slot may change before
we enable the fd and we thus miss out on the ABS_MT_SLOT event. It's still
slightly more correct than assuming whatever comes next is slot 0.
2013-11-10 17:51:32 +01:00
Peter Hutterer
fe57a4e5fa evdev: only use mtdev for Protocol A devices
For Protocol B devices, mtdev merely routes the events and is not needed.
For Protocol A devices, mtdev is needed, so fail for those devices now if we
mtdev fails.
2013-11-10 17:51:32 +01:00
Peter Hutterer
3f0ee131e1 evdev: add comment why we're ignoring key value 2 2013-11-10 17:51:32 +01:00
Peter Hutterer
756785ec3e evdev: prevent unterminated device name
The kernel copies up to sizeof(devname) bytes but doesn't null-terminate the
string if the device name exceeds the size of the supplied buffer.
2013-11-10 17:51:32 +01:00
Peter Hutterer
297bac9802 evdev: check for ABS_MT_POSITION_X/Y to determine mt devices
mtdev as currently used in weston is a noop. mtdev's purpose is to convert
Protocol A devices (without ABS_MT_SLOT) to Protocol B devices (slots).
For Protocol B devices mtdev merely routes the events, so checking for
slots and then using mtdev based on that adds no functionality.

Check for ABS_MT_POSITION_X/Y instead and use that to categorise a device
as MT device. mtdev will provide us with a slotted protocol for all devices.

https://bugs.freedesktop.org/show_bug.cgi?id=54428
2013-11-10 17:51:32 +01:00
Peter Hutterer
420fbad8bb malloc + memset -> zalloc
And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-11-10 17:51:32 +01:00
Kristian Høgsberg
c1bb30da2f evdev: Suport old-style single-touch touch screens
These screens send only BTN_TOUCH and ABS_X/Y.
2013-11-10 17:51:32 +01:00
Kristian Høgsberg
7ff70db86d evdev: Use temporary x and y coordinates when applying calibration
Don't overwrite device->abs.x halfway through the matrix multiplication.
2013-11-10 17:51:32 +01:00
Kristian Høgsberg
95e1abf104 evdev: Don't add output offset in evdev_process_absolute_motion()
We do that in weston_output_transform_coordinate() now.
2013-11-10 17:51:32 +01:00
Kristian Høgsberg
23e4ec3e23 evdev: Use weston_output_transform_coordinate for evdev touch screens 2013-11-10 17:51:32 +01:00
Daniel Stone
17ea8f9e50 configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>

[pq: rebased and converted more files]
2013-11-10 17:51:32 +01:00
Kristian Høgsberg
6e5928ab41 input: Merge wl_seat into weston_seat 2013-11-10 17:51:32 +01:00
Rob Bradford
23b92d9dc6 compositor: Support notifying with absolute position too
With evdev input devices that generate absolute positions we need to provide
an infrastructure in the compositor for supporting those.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=61997
2013-11-10 17:51:31 +01:00
Kristian Høgsberg
9d92a07996 compositor: Change notify_motion to take relative motion events 2013-11-10 17:51:31 +01:00
Satyeshwar Singh
b3e195bd27 evdev: Wait for SYN event before sending events over to the client
The issue was that touch::down event from the compositor to client apps
would send the previous motion events coordinates and this obviously made
the client do the wrong thing. This happened because we were not waiting
for a SYN event to come from evdev before sending down, motion or up events.

https://bugs.freedesktop.org/show_bug.cgi?id=51909
2013-11-10 17:51:31 +01:00
Kristian Høgsberg
a74a372753 xkb: Don't call exit on failure in weston_compositor_xkb_init()
This will exit without cleaning vt modes and leave the system stuck.

https://bugs.freedesktop.org/show_bug.cgi?id=60817
2013-11-10 17:51:31 +01:00
Rob Bradford
60bc3610f3 evdev: Apply calibration values to absolute events
Store a set of calibration values per device - these calibration values are
just applied to the absolute motion events.
2013-11-10 17:51:31 +01:00
Rob Bradford
24eabf8bb1 evdev: Include the device capabilities in the debugging 2013-11-10 17:51:31 +01:00
Jonas Ådahl
62f9786646 evdev: Update axis notifications to follow protocol
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-10 17:51:31 +01:00
Rob Bradford
7e10eff8f3 evdev: Avoid unintended case drop through
e->code is in the same range for ABS_ and for REL_. As the code currently
stands and for the current values in Linux's input.h there is no risk of a
problem. However just in case it would be wise to break after evaluating the
relative events.

Signed-off-by: Rob Bradford <rob@linux.intel.com>
2013-11-10 17:51:31 +01:00
Kristian Høgsberg
c69e1fbe27 compositor: Change notify_* function to take a weston_seat
Fewer indirections and derefs, and it's also more appropriate for a
backend calling into weston core to pass a weston_seat.
2013-11-10 17:51:31 +01:00
Pekka Paalanen
1bf81b0c5b evdev: rename evdev_input_device to evdev_device
As said by krh: "Maybe we should also just call it an evdev_device
instead, shorter [and] not really ambiguous."

[krh: if my typo filled irc is going in a commit message, I'm at least going
to insert the missing words.]

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
4a75370823 evdev: do not pass a list to evdev_led_update()
evdev_led_update() does not really need the whole list of device at
once, it can be called one device at a time.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
7ef5852dff evdev: kill a warning in evdev_led_update()
evdev.c: In function 'evdev_led_update':
evdev.c:57:9: warning: ignoring return value of 'write', declared with
attribute warn_unused_result

Useless in this case.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
e427ef8cb7 compositor-drm, evdev: don't crash on missing keyboard
Weston's notify_keyboard_focus_*() assume that a keyboard is present, if
they are called. With evdev, there might not always be a keyboard.

Also clean up the variable definition in evdev_notify_keyborad_focus().
I read that function through many times and finally had to grep where
does 'all_keys' come from.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
b2d021b95e evdev: log input devices
Write information about found input devices into the log. Also fetch and
record the device name.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
50052b1d3c evdev: move udev code into compositor-drm.c
Move all udev-related and now drm backend specific code into
compositor-drm.c.

This makes evdev.c free of udev and launcher-util, and allows it to be
used on Android.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
921c8f4f33 evdev: expose the generic evdev API
This API does not depend on udev or launcher-util.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
d950781445 evdev: rename evdev_seat to drm_seat
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
8e02ad4efe evdev: pass weston_seat to evdev_input_device_create()
in preparation of removing evdev_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
1f6acefd70 evdev: make evdev_notify_keyboard_focus() independent of evdev_seat
in preparation of removing evdev_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
83d7662cbb evdev: make evdev_led_update independent from struct evdev_seat
in preparation of removing evdev_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
0e9fd6fa0a evdev: change evdev_seat into weston_seat in struct evdev_input_device
We are phasing out struct evdev_seat.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
216d16bece evdev: merge evdev-private.h into evdev.h
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
42a42240c9 evdev: move device opening out from evdev_input_device_create
This makes the generic evdev code (i.e. the functions not relying on
udev) independent of launcher-util too. The aim is to allow re-using the
generic evdev code in the Android backend, where neither udev nor
launcher-util are available.

evdev_input_device_create() signature is changed:
- add the opened device file descriptor
- remove wl_display as unused

Also add a bit of failure logging.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Pekka Paalanen
cac530ebae evdev: rename device_removed() to evdev_input_device_destroy()
evdev_input_device_destroy() will completement the API of
evdev_input_device_create(), both being independent from udev.

Since the udev-specific device_removed() would only call
evdev_input_device_destroy() and do nothing else, device_remove() calls
are simply replaced with evdev_input_device_destroy().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:30 +01:00
Kristian Høgsberg
ca9ef609b6 compositor: Fold the log prototypes into compositor.h and drop log.h
We're trying to keep the API exposed by the core compositor in compositor.h
2013-11-10 17:51:30 +01:00
Pekka Paalanen
701024fd90 evdev: query position ranges for MT, too
For a true multi-touch input device, the code ended up using
uninitialised fields of evdev_input_device::abs.

Fix it by querying the corresponding MT ranges.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-11-10 17:51:29 +01:00
Daniel Stone
19b5a3707a evdev: Release weston_seat with underlying evdev device
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-11-10 17:51:29 +01:00
Daniel Stone
9d67bb202a evdev: Don't ignore multitouch touchscreens
Most touchscreen drivers provide ABS_X and BTN_TOUCH for legacy
single-touch emulation modes, but this isn't mandatory.  Make sure we
don't ignore touchscreens with provide multitouch events with the new
API only.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-11-10 17:51:29 +01:00
Daniel Stone
f749baab42 notify_key: Add update_state argument
If update_state is true, then notify_key will continue to call
xkb_key_update_state to update the local state mask, as before this
commit.  Otherwise, it will rely on the compositor to manually update
the state itself, for nested compositors.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-11-10 17:51:29 +01:00
Daniel Stone
8e3bdd91bf Split notify_keyboard_focus into in/out variants
Since the two functions had nothing in common but the local variables.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-11-10 17:51:29 +01:00
Martin Minarik
07a21a261d Replace fprintf() by weston_log() 2013-11-10 17:51:29 +01:00