Commit graph

399 commits

Author SHA1 Message Date
Kristian Høgsberg
3fc0ec1bc3 evdev: Only init a pointer if the evdev device has a button
We used to test for abs | rel | button,  which inits a pointer device for
a device with just rel or abs capabilities.  We now make sure we have either
rel or abs as well as button.
2013-11-10 17:51:33 +01:00
Kristian Høgsberg
5d493ad6f4 evdev: Stop looking for pointer buttons when we get to BTN_JOYSTICK
We don't want to mark a touchscreen as a button device just because it
exposes the BTN_TOUCH and BTN_TOOL buttons.
2013-11-10 17:51:33 +01:00
Neil Roberts
ee5f763fc8 evdev: Process touch up events of single-touch devices
Previously only the touch up key event was used for single-touch
devices and the touch down event was generated on the first motion
event. This was breaking if the touch up and down events were sent
without a motion in-between because the evdev driver wouldn't generate
a touch down event and Weston would lose track of the number of touch
points that are down. This patch changes it to track the up and down
key events as pending events similar to how it does for multi-touch
devices.

https://bugs.freedesktop.org/show_bug.cgi?id=69759
2013-11-10 17:51:33 +01:00
Neil Roberts
96ec0936ca evdev: Only track one pending event
Instead of having a mask of pending events there is now an enum with a
single value to represent the one pending event. The event gets
flushed explicitly as part of the handling code for each event type
rather than in the outer event reading loop. The pending event is used
so that we can combine multiple motion events into one and to make
sure that we have recieved the latest position before sending a touch
up or down event. This should fix the following problems with the old
approach:

• If you release a finger and press it down again quickly you could
  get the up and down events in the same batch. However the pending
  events were always processed in the order down then up so it would
  end up notifying two down events and then an up. The pending event
  is now always flushed when there is a new up or down event so they
  will always be in the right order.

• When it got a slot event it would immediately change the slot number
  and then set the pending event. Then when it flushed the events it
  would use the new slot number to flush the old pending event so the
  events could have the wrong finger. The pending event is now
  immediately flushed when a slot event is received so it will have
  the right finger.

• If you get more than 32 events in one read then it was resetting the
  pending events before processing the next batch in
  evdev_process_events. If four fingers were pressed down at once then
  it ended up with more than 32 events and the sync message would be
  in the second batch. The pending flag for the last finger was
  getting cleared so it never got emitted. In this patch the pending
  event is no longer reset after reading nor is it explicitly flushed.
  Instead it is flushed when we receive a EV_SYN event or a different
  pending event needs to replace it.

The touchpad handling code was trying to use the pending event
mechanism to notify the relative motion events. I'm not sure why it
was doing this because it looks the event would effectively get
emitted as soon as the touchpad_process function is finished anyway
and it wasn't accumulating the values. Instead I've just changed it to
emit the event directly.

https://bugs.freedesktop.org/show_bug.cgi?id=67563
2013-11-10 17:51:33 +01:00
Neil Roberts
b3023f5d0a evdev: Flush motion events when the slot changes, not just after sync
If two fingers are released almost simultaneously then evdev can send
the touch up events in one bunch without sending a sync event
in-between. However, the evdev_device struct only keeps track of one
pending touch up event so in this case the second touch up event would
override the first and it would be lost. This patch changes it to also
flush the events whenever the slot changes so that it will flush the
previous touch up event before trying to queue the next one.

https://bugs.freedesktop.org/show_bug.cgi?id=67563
2013-11-10 17:51:33 +01:00
Hardening
6f96846e0a Rename current, origin, scale, origin_scale
This patch renames that fields to have consistent names.
2013-11-10 17:51:33 +01:00
Kristian Høgsberg
2f9f6b257a evdev: Don't parse config file again, use compositor->config 2013-11-10 17:51:33 +01:00
Kristian Høgsberg
51e2c3f40e evdev: Don't transform device->abs.x/y in place
We don't always get both an X and an Y event in a SYN report, so we end
up transforming the coordinate we don't get twice.  For example, if we
only receive an ABS_X event, we transform the already transformed
device->abs.y again in transform_absolute() when applying the calibration.
2013-11-10 17:51:33 +01:00
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
Daniel Stone
ef1f81dae7 Add more missing config.h includes
config.h includes were missing in a few files, including input.c, the
lack of which caused the X11 backend to segfault instantly due to not
having an xkbcommon context.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
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
Armin K
b0044ab4e2 evdev-touchpad: Set some options using weston.ini
This patch adds 3 new options to weston.ini to allow
the user to change default constant_accel_factor,
min_accel_factor and max_accel_factor. If no options
are set, it falls back using defaults as it did before.

v2: create weston_config_section_get_double and use it
instead of manualy converting string to double.

v3: add default values in weston_config_get_double
instead of using conditionals.

v4: don't pass diagonal as pointer.
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
Kristian Høgsberg
57334b7088 touchpad: Handle two-finger click as right click for button pads 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
Jonas Ådahl
049a7492dc evdev-touchpad: Disable tap FSM by default on touchpads with button pads
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
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
Dima Ryazanov
4135ccf315 Fix a typo. 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
Jonas Ådahl
64545a2977 evdev-touchpad: Implement two finger scroll
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-10 17:51:31 +01:00
Jonas Ådahl
68449fc8e8 evdev-touchpad: Add a finite-state machine
The finite-state machine is so far used to implement support for tapping
and dragging.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-10 17:51:31 +01:00
Jonas Ådahl
f4706c6779 evdev-touchpad: Cleanup and refactoring
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-10 17:51:31 +01:00
Rob Bradford
28833e880f evdev-touchpad: Iterate over the touchpad spec table correctly
The original code would overrun since the calculation of the range did not
take into consideration the size of the entries in the table.

Cc:Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Rob Bradford <rob@linux.intel.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
Rob Bradford
56b178cc00 evdev-touchpad: Twiddle finger_state correctly
The original code always set the finger_state to the appropriate bitmask
irrespective of whether the event was a press or a release. It would also blat
all members of the bitmask rather than ORing in the new bit for the event.

Cc:Jonas Ådahl <jadahl@gmail.com>
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