From 56a77e68fb91eef928d8a95c50ae14508e37ae0f Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 22 Dec 2010 18:29:00 +0100 Subject: Introduce a stable ABI The current mtdev is not ABI stable, and the upcoming additions to the kernel api will break ABI. This patch starts the process of keeping binary compatibility with old programs, by moving the abi-specific parts under a special flag, MTDEV_NO_LEGACY_API, and makes sure the internal parts compiles with MTDEV_NO_LEGACY_API set. This way, older programs will still work, old programs will still compile, and new programs will be able to use the additions. Signed-off-by: Henrik Rydberg --- src/common.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'src/common.h') diff --git a/src/common.h b/src/common.h index e06f7f7..43b5688 100644 --- a/src/common.h +++ b/src/common.h @@ -29,6 +29,8 @@ #ifndef COMMON_H #define COMMON_H +#define MTDEV_NO_LEGACY_API + #include #include #include @@ -85,4 +87,61 @@ static inline int bitcount(unsigned v) /* robust system ioctl calls */ #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) +/** + * struct mtdev - represents an input MT device + * @has_mtdata: true if the device has MT capabilities + * @has_slot: true if the device sends MT slots + * @slot: slot event properties + * @abs: ABS_MT event properties + * @state: internal mtdev parsing state + * + * The mtdev structure represents a kernel MT device type B, emitting + * MT slot events. The events put into mtdev may be from any MT + * device, specifically type A without contact tracking, type A with + * contact tracking, or type B with contact tracking. See the kernel + * documentation for further details. + * + */ +struct mtdev { + int has_mtdata; + int has_slot; + int has_abs[11]; + struct input_absinfo slot; + struct input_absinfo abs[11]; + struct mtdev_state *state; +}; + +#define MT_ABS_SIZE 11 + +static const unsigned int mtdev_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 mtdev_map_mt2abs[MT_ABS_SIZE] = { + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003a, +}; + +static inline int mtdev_is_absmt(unsigned int code) +{ + return mtdev_map_abs2mt[code]; +} + +static inline unsigned int mtdev_abs2mt(unsigned int code) +{ + return mtdev_map_abs2mt[code] - 1; +} + +static inline unsigned int mtdev_mt2abs(unsigned int mtcode) +{ + return mtdev_map_mt2abs[mtcode]; +} + #endif -- cgit v1.2.3