From acea9df3381825a634c000a574f58b4ca5293ee8 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 12 Oct 2010 15:38:43 +0200 Subject: Same version, but using the mtdev library. Signed-off-by: Henrik Rydberg --- include/abs2mt.h | 39 ---------------------------------- include/capabilities.h | 49 +++++++++++++++++++++++++++++++++++++++++++ include/common.h | 49 +------------------------------------------ include/hwstate.h | 6 +++--- include/match.h | 36 ------------------------------- include/mtbit.h | 14 ------------- include/mtdev-caps.h | 51 -------------------------------------------- include/mtdev-evbuf.h | 57 -------------------------------------------------- include/mtdev-iobuf.h | 38 --------------------------------- include/mtdev.h | 57 -------------------------------------------------- include/mtouch.h | 7 ++----- 11 files changed, 55 insertions(+), 348 deletions(-) delete mode 100644 include/abs2mt.h create mode 100644 include/capabilities.h delete mode 100644 include/match.h delete mode 100644 include/mtbit.h delete mode 100644 include/mtdev-caps.h delete mode 100644 include/mtdev-evbuf.h delete mode 100644 include/mtdev-iobuf.h delete mode 100644 include/mtdev.h (limited to 'include') diff --git a/include/abs2mt.h b/include/abs2mt.h deleted file mode 100644 index 6021d8d..0000000 --- a/include/abs2mt.h +++ /dev/null @@ -1,39 +0,0 @@ -/* generated by mapgen - do not edit */ - -#ifndef ABS2MT_H -#define ABS2MT_H - -#include "common.h" - -static const unsigned int map_abs2mt[ABS_CNT] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, - 0x0009, 0x000a, 0x000b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -}; - -static const unsigned int map_mt2abs[MT_ABS_SIZE] = { - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, - 0x0038, 0x0039, 0x003a, -}; - -static inline int has_abs2mt(unsigned int code) -{ - return map_abs2mt[code]; -} - -static inline unsigned int abs2mt(unsigned int code) -{ - return map_abs2mt[code] - 1; -} - -static inline unsigned int mt2abs(unsigned int mtcode) -{ - return map_mt2abs[mtcode]; -} - -#endif diff --git a/include/capabilities.h b/include/capabilities.h new file mode 100644 index 0000000..0dfc73b --- /dev/null +++ b/include/capabilities.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * + * Multitouch X driver + * Copyright (C) 2008 Henrik Rydberg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + **************************************************************************/ + +#ifndef CAPABILITIES_H +#define CAPABILITIES_H + +#include "common.h" +#include "button.h" + +struct Capabilities { + struct input_id devid; + char devname[32]; + int has_left, has_middle, has_right; + int has_mtdata, has_ibt; + int has_slot; + int has_abs[MT_ABS_SIZE]; + struct input_absinfo slot; + struct input_absinfo abs[MT_ABS_SIZE]; +}; + +int read_capabilities(struct Capabilities *cap, int fd); +int get_cap_xsize(const struct Capabilities *cap); +int get_cap_ysize(const struct Capabilities *cap); +int get_cap_wsize(const struct Capabilities *cap); + +int get_cap_xmid(const struct Capabilities *cap); +int get_cap_ymid(const struct Capabilities *cap); + +void output_capabilities(const struct Capabilities *cap); + +#endif diff --git a/include/common.h b/include/common.h index e13088f..6d00d6e 100644 --- a/include/common.h +++ b/include/common.h @@ -26,59 +26,12 @@ #include #include #include -#include #include - -/* includes available in 2.6.30-rc5 */ - -#ifndef BTN_TOOL_QUADTAP -#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ -#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ -#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ -#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ -#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ -#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ -#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ -#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ -#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ -#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ -#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ -#define SYN_MT_REPORT 2 -#define MT_TOOL_FINGER 0 -#define MT_TOOL_PEN 1 -#endif - -/* includes available in 2.6.33 */ -#ifndef ABS_MT_PRESSURE -#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ -#endif - -/* includes available in 2.6.36 */ -#ifndef ABS_MT_SLOT -#define ABS_MT_SLOT 0x2f /* MT slot being modified */ -#define MT_SLOT_ABS_EVENTS { \ - ABS_MT_TOUCH_MAJOR, \ - ABS_MT_TOUCH_MINOR, \ - ABS_MT_WIDTH_MAJOR, \ - ABS_MT_WIDTH_MINOR, \ - ABS_MT_ORIENTATION, \ - ABS_MT_POSITION_X, \ - ABS_MT_POSITION_Y, \ - ABS_MT_TOOL_TYPE, \ - ABS_MT_BLOB_ID, \ - ABS_MT_TRACKING_ID, \ - ABS_MT_PRESSURE, \ -} -#endif - -#define MT_ABS_SIZE 11 /* Size of MT_SLOT_ABS_EVENTS */ +#include #define DIM_FINGER 32 #define DIM2_FINGER (DIM_FINGER * DIM_FINGER) -/* event buffer size (must be a power of two) */ -#define DIM_EVENTS 512 - /* year-proof millisecond event time */ typedef __u64 mstime_t; diff --git a/include/hwstate.h b/include/hwstate.h index efd291f..4c59a1e 100644 --- a/include/hwstate.h +++ b/include/hwstate.h @@ -22,7 +22,7 @@ #ifndef HWSTATE_H #define HWSTATE_H -#include "mtdev.h" +#include "capabilities.h" struct FingerState { int touch_major, touch_minor; @@ -42,8 +42,8 @@ struct HWState { void init_hwstate(struct HWState *s, const struct Capabilities *caps); -int hwstate_read(struct HWState *s, const struct Capabilities *caps, - const struct input_event *ev); +int modify_hwstate(struct HWState *s, struct mtdev *dev, int fd, + const struct Capabilities *caps); void output_hwstate(const struct HWState *s); static inline int finger_dist2(const struct FingerState *a, diff --git a/include/match.h b/include/match.h deleted file mode 100644 index 25842fc..0000000 --- a/include/match.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * - * Multitouch X driver - * Copyright (C) 2008 Henrik Rydberg - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - **************************************************************************/ - -#ifndef MATCHER_H -#define MATCHER_H - -/** - * Special implementation of the hungarian algorithm. - * The maximum number of fingers matches a uint32. - * Bitmasks are used extensively. - */ - -#include "common.h" - -void match_fingers(int index[DIM_FINGER], int A[DIM2_FINGER], - int nrow, int ncol); - -#endif diff --git a/include/mtbit.h b/include/mtbit.h deleted file mode 100644 index 2c4dacb..0000000 --- a/include/mtbit.h +++ /dev/null @@ -1,14 +0,0 @@ -/* generated by mapgen - do not edit */ - -#ifndef MTBIT_H -#define MTBIT_H - -#define BIT_TRACKING_ID 9 -#define BIT_POSITION_X 5 -#define BIT_POSITION_Y 6 -#define BIT_TOUCH_MAJOR 0 -#define BIT_TOUCH_MINOR 1 -#define BIT_WIDTH_MAJOR 2 -#define BIT_WIDTH_MINOR 3 - -#endif diff --git a/include/mtdev-caps.h b/include/mtdev-caps.h deleted file mode 100644 index 727cd11..0000000 --- a/include/mtdev-caps.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * - * Multitouch X driver - * Copyright (C) 2008 Henrik Rydberg - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - **************************************************************************/ - -#ifndef MTDEV_CAPS_H -#define MTDEV_CAPS_H - -#include "common.h" -#include "button.h" -#include "abs2mt.h" -#include "mtbit.h" - -struct Capabilities { - struct input_id devid; - char devname[32]; - int has_left, has_middle, has_right; - int has_mtdata, has_ibt; - int has_slot, nullid; - int has_abs[MT_ABS_SIZE]; - struct input_absinfo slot; - struct input_absinfo abs[MT_ABS_SIZE]; -}; - -int read_capabilities(struct Capabilities *cap, int fd); -int get_cap_xsize(const struct Capabilities *cap); -int get_cap_ysize(const struct Capabilities *cap); -int get_cap_wsize(const struct Capabilities *cap); - -int get_cap_xmid(const struct Capabilities *cap); -int get_cap_ymid(const struct Capabilities *cap); - -void output_capabilities(const struct Capabilities *cap); - -#endif diff --git a/include/mtdev-evbuf.h b/include/mtdev-evbuf.h deleted file mode 100644 index 77fec41..0000000 --- a/include/mtdev-evbuf.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * - * Multitouch X driver - * Copyright (C) 2008 Henrik Rydberg - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - **************************************************************************/ - -#ifndef MTDEV_EVBUF_H -#define MTDEV_EVBUF_H - -#include "common.h" - -struct EventBuffer { - int head; - int tail; - struct input_event buffer[DIM_EVENTS]; -}; - -static inline void evbuf_init(struct EventBuffer *evbuf) -{ - memset(evbuf, 0, sizeof(*evbuf)); -} - -static inline int evbuf_empty(const struct EventBuffer *evbuf) -{ - return evbuf->head == evbuf->tail; -} - -static inline void evbuf_put(struct EventBuffer *evbuf, - const struct input_event *ev) -{ - evbuf->buffer[evbuf->head++] = *ev; - evbuf->head &= DIM_EVENTS - 1; -} - -static inline void evbuf_get(struct EventBuffer *evbuf, - struct input_event *ev) -{ - *ev = evbuf->buffer[evbuf->tail++]; - evbuf->tail &= DIM_EVENTS - 1; -} - -#endif diff --git a/include/mtdev-iobuf.h b/include/mtdev-iobuf.h deleted file mode 100644 index 7d4265c..0000000 --- a/include/mtdev-iobuf.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * - * Multitouch X driver - * Copyright (C) 2008 Henrik Rydberg - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - **************************************************************************/ - -#ifndef MTDEV_IOBUF_H -#define MTDEV_IOBUF_H - -#include "common.h" - -#define EVENT_SIZE sizeof(struct input_event) -#define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE) - -struct IOBuffer { - char begin[DIM_BUFFER], *at, *top, *end; -}; - -void init_iobuf(struct IOBuffer *buf); -const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd); -int poll_iobuf(struct IOBuffer *buf, int fd, int ms); - -#endif diff --git a/include/mtdev.h b/include/mtdev.h deleted file mode 100644 index 936d597..0000000 --- a/include/mtdev.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * - * Multitouch X driver - * Copyright (C) 2008 Henrik Rydberg - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - **************************************************************************/ - -#ifndef MTDEV_H -#define MTDEV_H - -#include "mtdev-caps.h" -#include "mtdev-evbuf.h" - -/** - * struct MTDev - represents an input MT device - * @inbuf: input event buffer - * @outbuf: output event buffer - * @priv: structure of private data - */ -struct MTDev { - struct EventBuffer inbuf; - struct EventBuffer outbuf; - struct MTDevState *priv; -}; - -int mtdev_init(struct MTDev *mtdev, const struct Capabilities *caps); - -static inline int mtdev_empty(struct MTDev *mtdev) -{ - return evbuf_empty(&mtdev->outbuf); -} - -void mtdev_put(struct MTDev *dev, const struct Capabilities *caps, - const struct input_event *ev); - -static inline void mtdev_get(struct MTDev *mtdev, struct input_event* ev) -{ - evbuf_get(&mtdev->outbuf, ev); -} - -void mtdev_destroy(struct MTDev *mtdev); - -#endif diff --git a/include/mtouch.h b/include/mtouch.h index 482d010..aedb02c 100644 --- a/include/mtouch.h +++ b/include/mtouch.h @@ -23,12 +23,10 @@ #define MTOUCH_H #include "memory.h" -#include "mtdev-iobuf.h" struct MTouch { struct Capabilities caps; - struct MTDev dev; - struct IOBuffer buf; + struct mtdev dev; struct HWState hs; struct MTState prev_state, state; struct Memory mem; @@ -36,10 +34,9 @@ struct MTouch { int configure_mtouch(struct MTouch *mt, int fd); int open_mtouch(struct MTouch *mt, int fd); -int get_mtouch(struct MTouch *mt, int fd, struct input_event* ev, int ev_max); int close_mtouch(struct MTouch *mt, int fd); -int parse_event(struct MTouch *mt, const struct input_event *ev); +int read_packet(struct MTouch *mt, int fd); int has_delayed_gestures(struct MTouch *mt, int fd); -- cgit v1.2.3