The diffs below are a rewrite of the input-processing part of wsmouse. It
adds support for multitouch input.
I have split the set of diffs into three parts and I will post part 2 and 3
in separate messages. Part 1 below contains all patches for wscons, part 2
is for the hardware drivers, part 3 is a patch for the synaptics driver in
xenocara (compiling that driver will require the modified version of
wsconsio.h in /usr/include/dev/wscons).
For those who had a look at the test version from December: The code for
the internal touchpad driver ("wstpad") is not included here, I intend
to add and present it again later. Apart from that there are only minor
changes. I have moved the input-processing functions into wsmouse.c,
renamed various things, and improved the tracking functions and the
handling of overflows of the event queue.
The wsmouse_input function has been removed. Hardware drivers make one
or more calls to the new "state-reporting" functions of wsmouse (see
wsmousevar.h), and signal that a frame is complete by calling
wsmouse_input_sync, which generates the wscons events. Roughly, the set
of functions corresponds to the different types of state: button state,
relative motion, absolute positions, single-touch state, and (MT) slot
state. "Standard" combinations of calls are covered by the macros
WSMOUSE_INPUT and WSMOUSE_TOUCH. There is also a more generic function
which can be used for less common inputs or requirements (wsmouse_set).
I assume that support for multi-user touch devices is not required, the
maximal number of MT slots is defined in wsmousevar.h as 10. The technical
limit is sizeof(u_int) * 8.
The MT structures in wsmouse must be initialized with a call to
wsmouse_mt_init. Drivers for MT devices that associate touches with
"tracking IDs" can use wsmouse_id_to_slot() to assign or to look up slot
numbers, and call wsmouse_mtstate subsequently. hidmt may be a driver that
needs it. Drivers for MT devices that don't provide "MT tracking" - ubcmtp,
for example - must collect the contact points in an array of mtpoint
structures and pass it to wsmouse_mtframe, which computes a matching with
the points of the last frame and calls wsmouse_mtstate internally.
Currently MT state is always converted into a single-touch representation,
and wscons events are generated accordingly. No MT events have been defined
yet. However, minor changes in the set of events are necessary to make the
new code work cleanly with the synaptics driver (see 3/3).
I will comment on some more details in the next messages.
And, yes, this is a request for OKs.
Index: dev/wscons/wsmousevar.h
===
RCS file: /cvs/src/sys/dev/wscons/wsmousevar.h,v
retrieving revision 1.8
diff -u -p -r1.8 wsmousevar.h
--- dev/wscons/wsmousevar.h 21 Dec 2014 18:16:07 - 1.8
+++ dev/wscons/wsmousevar.h 12 Mar 2016 20:42:48 -
@@ -32,6 +32,22 @@
*/
/*
+ * Copyright (c) 2015, 2016 Ulf Brosziewski
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, 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.
+ */
+
+/*
* WSMOUSE interfaces.
*/
@@ -64,14 +80,151 @@ struct wsmousedev_attach_args {
*/
intwsmousedevprint(void *, const char *);
+
+/* Process standard mouse input. */
+#define WSMOUSE_INPUT(sc_wsmousedev, btns, dx, dy, dz, dw) \
+ do {\
+ wsmouse_buttons((sc_wsmousedev), (btns)); \
+ wsmouse_motion((sc_wsmousedev), (dx), (dy), (dz), (dw));\
+ wsmouse_input_sync(sc_wsmousedev); \
+ } while (0)
+
+
+/* Process standard touchpad input. */
+#define WSMOUSE_TOUCH(sc_wsmousedev, btns, x, y, pressure, contacts) \
+ do {\
+ wsmouse_buttons((sc_wsmousedev), (btns)); \
+ wsmouse_position((sc_wsmousedev), (x), (y));\
+ wsmouse_touch((sc_wsmousedev), (pressure), (contacts)); \
+ wsmouse_input_sync(sc_wsmousedev); \
+ } while (0)
+
+
+/*
+ * Drivers for touchpads that don't report pressure values can pass
+ * WSMOUSE_DEFAULT_PRESSURE to wsmouse_touch or wsmouse_mtstate.
+ *
+ * A pressure value of 0