summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-12-22 18:29:00 +0100
committerHenrik Rydberg <rydberg@euromail.se>2010-12-22 18:29:00 +0100
commit56a77e68fb91eef928d8a95c50ae14508e37ae0f (patch)
tree51af9bb9dd508bca58e8b9416479e79f8bb7ee10 /include
parent0e2ab3b5940e70493aaabdfe5e8da1c75db4db72 (diff)
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 <rydberg@euromail.se>
Diffstat (limited to 'include')
-rw-r--r--include/mtdev-mapping.h4
-rw-r--r--include/mtdev-plumbing.h37
-rw-r--r--include/mtdev.h117
3 files changed, 114 insertions, 44 deletions
diff --git a/include/mtdev-mapping.h b/include/mtdev-mapping.h
index 0e47970..0cdb39d 100644
--- a/include/mtdev-mapping.h
+++ b/include/mtdev-mapping.h
@@ -37,6 +37,8 @@ extern "C" {
37 37
38#include <mtdev.h> 38#include <mtdev.h>
39 39
40#ifndef MTDEV_NO_LEGACY_API
41
40#define MTDEV_TOUCH_MAJOR 0 42#define MTDEV_TOUCH_MAJOR 0
41#define MTDEV_TOUCH_MINOR 1 43#define MTDEV_TOUCH_MINOR 1
42#define MTDEV_WIDTH_MAJOR 2 44#define MTDEV_WIDTH_MAJOR 2
@@ -80,6 +82,8 @@ static inline unsigned int mtdev_mt2abs(unsigned int mtcode)
80 return mtdev_map_mt2abs[mtcode]; 82 return mtdev_map_mt2abs[mtcode];
81} 83}
82 84
85#endif
86
83#ifdef __cplusplus 87#ifdef __cplusplus
84} 88}
85#endif 89#endif
diff --git a/include/mtdev-plumbing.h b/include/mtdev-plumbing.h
index cadc1f7..21ca708 100644
--- a/include/mtdev-plumbing.h
+++ b/include/mtdev-plumbing.h
@@ -36,6 +36,15 @@ extern "C" {
36#include <mtdev.h> 36#include <mtdev.h>
37 37
38/** 38/**
39 * mtdev_new - allocate a new mtdev
40 *
41 * Allocate a new mtdev.
42 *
43 * Returns zero in case of memory allocation failure.
44 */
45struct mtdev *mtdev_new(void);
46
47/**
39 * mtdev_init - initialize mtdev converter 48 * mtdev_init - initialize mtdev converter
40 * @dev: the mtdev to initialize 49 * @dev: the mtdev to initialize
41 * 50 *
@@ -46,6 +55,26 @@ extern "C" {
46int mtdev_init(struct mtdev *dev); 55int mtdev_init(struct mtdev *dev);
47 56
48/** 57/**
58 * mtdev_set_mt_event - set event type
59 * @dev: the mtdev in use
60 * @code: the ABS_MT code to set
61 * @value: boolean value
62 *
63 * Returns true if the given event code is present.
64 */
65void mtdev_set_mt_event(struct mtdev *dev, int code, int value);
66
67/**
68 * mtdev_set_abs_<property> - set abs event property
69 * @dev: the mtdev in use
70 * @code: the ABS_MT code to set
71 */
72void mtdev_set_abs_minimum(struct mtdev *dev, int code, int value);
73void mtdev_set_abs_maximum(struct mtdev *dev, int code, int value);
74void mtdev_set_abs_fuzz(struct mtdev *dev, int code, int value);
75void mtdev_set_abs_resolution(struct mtdev *dev, int code, int value);
76
77/**
49 * mtdev_configure - configure the mtdev converter 78 * mtdev_configure - configure the mtdev converter
50 * @dev: the mtdev to configure 79 * @dev: the mtdev to configure
51 * @fd: file descriptor of the kernel device 80 * @fd: file descriptor of the kernel device
@@ -106,6 +135,14 @@ int mtdev_empty(struct mtdev *dev);
106 */ 135 */
107void mtdev_get_event(struct mtdev *dev, struct input_event* ev); 136void mtdev_get_event(struct mtdev *dev, struct input_event* ev);
108 137
138/**
139 * mtdev_delete - free a previously allocated mtdev
140 *
141 * Frees the memory associated with the mtdev and invalidates the
142 * mtdev pointer.
143 */
144void mtdev_delete(struct mtdev *dev);
145
109#ifdef __cplusplus 146#ifdef __cplusplus
110} 147}
111#endif 148#endif
diff --git a/include/mtdev.h b/include/mtdev.h
index 15bc53b..df74e95 100644
--- a/include/mtdev.h
+++ b/include/mtdev.h
@@ -62,59 +62,23 @@ extern "C" {
62#ifndef ABS_MT_SLOT 62#ifndef ABS_MT_SLOT
63#define ABS_MT_SLOT 0x2f /* MT slot being modified */ 63#define ABS_MT_SLOT 0x2f /* MT slot being modified */
64#endif 64#endif
65#ifndef MT_SLOT_ABS_EVENTS
66#define MT_SLOT_ABS_EVENTS { \
67 ABS_MT_TOUCH_MAJOR, \
68 ABS_MT_TOUCH_MINOR, \
69 ABS_MT_WIDTH_MAJOR, \
70 ABS_MT_WIDTH_MINOR, \
71 ABS_MT_ORIENTATION, \
72 ABS_MT_POSITION_X, \
73 ABS_MT_POSITION_Y, \
74 ABS_MT_TOOL_TYPE, \
75 ABS_MT_BLOB_ID, \
76 ABS_MT_TRACKING_ID, \
77 ABS_MT_PRESSURE, \
78}
79#endif
80
81#define MT_ABS_SIZE 11
82 65
83#define MT_ID_NULL (-1) 66#define MT_ID_NULL (-1)
84#define MT_ID_MIN 0 67#define MT_ID_MIN 0
85#define MT_ID_MAX 65535 68#define MT_ID_MAX 65535
86 69
87/** 70/**
88 * struct mt_caps - protocol capabilities of kernel device 71 * mtdev_new_open - create and open a new mtdev
89 * @has_mtdata: true if the device has MT capabilities 72 * @fd: file descriptor of the kernel device
90 * @has_slot: true if the device sends MT slots 73 *
91 * @slot: slot event properties 74 * Create a new mtdev and open the conversion.
92 * @abs: ABS_MT event properties
93 */
94struct mtdev_caps {
95 int has_mtdata;
96 int has_slot;
97 int has_abs[MT_ABS_SIZE];
98 struct input_absinfo slot;
99 struct input_absinfo abs[MT_ABS_SIZE];
100};
101
102/**
103 * struct mtdev - represents an input MT device
104 * @caps: the kernel device protocol capabilities
105 * @state: internal mtdev parsing state
106 * 75 *
107 * The mtdev structure represents a kernel MT device type B, emitting 76 * Returns zero in case of failure.
108 * MT slot events. The events put into mtdev may be from any MT
109 * device, specifically type A without contact tracking, type A with
110 * contact tracking, or type B with contact tracking. See the kernel
111 * documentation for further details.
112 * 77 *
78 * This call combines the plumbing functions mtdev_new() and
79 * mtdev_open().
113 */ 80 */
114struct mtdev { 81struct mtdev *mtdev_new_open(int fd);
115 struct mtdev_caps caps;
116 struct mtdev_state *state;
117};
118 82
119/** 83/**
120 * mtdev_open - open an mtdev converter 84 * mtdev_open - open an mtdev converter
@@ -132,6 +96,27 @@ struct mtdev {
132int mtdev_open(struct mtdev *dev, int fd); 96int mtdev_open(struct mtdev *dev, int fd);
133 97
134/** 98/**
99 * mtdev_has_mt_event - check for event type
100 * @dev: the mtdev in use
101 * @code: the ABS_MT code to look for
102 *
103 * Returns true if the given event code is present.
104 */
105int mtdev_has_mt_event(const struct mtdev *dev, int code);
106
107/**
108 * mtdev_get_abs_<property> - get abs event property
109 * @dev: the mtdev in use
110 * @code: the ABS_MT code to look for
111 *
112 * Returns NULL if code is not a valid ABS_MT code.
113 */
114int mtdev_get_abs_minimum(const struct mtdev *dev, int code);
115int mtdev_get_abs_maximum(const struct mtdev *dev, int code);
116int mtdev_get_abs_fuzz(const struct mtdev *dev, int code);
117int mtdev_get_abs_resolution(const struct mtdev *dev, int code);
118
119/**
135 * mtdev_idle - check state of kernel device 120 * mtdev_idle - check state of kernel device
136 * @dev: the mtdev in use 121 * @dev: the mtdev in use
137 * @fd: file descriptor of the kernel device 122 * @fd: file descriptor of the kernel device
@@ -173,6 +158,50 @@ int mtdev_get(struct mtdev *dev, int fd, struct input_event* ev, int ev_max);
173 */ 158 */
174void mtdev_close(struct mtdev *dev); 159void mtdev_close(struct mtdev *dev);
175 160
161/**
162 * mtdev_close_delete - close conversion and delete mtdev
163 * @dev: the mtdev in use
164 *
165 * Flush pending buffers and deallocate all memory associated with
166 * mtdev. The device pointer is invalidated. This call combines the
167 * plumbing functions mtdev_close() and mtdev_delete().
168 */
169void mtdev_close_delete(struct mtdev *dev);
170
171#ifndef MTDEV_NO_LEGACY_API
172
173#define MT_ABS_SIZE 11
174#ifndef MT_SLOT_ABS_EVENTS
175#define MT_SLOT_ABS_EVENTS { \
176 ABS_MT_TOUCH_MAJOR, \
177 ABS_MT_TOUCH_MINOR, \
178 ABS_MT_WIDTH_MAJOR, \
179 ABS_MT_WIDTH_MINOR, \
180 ABS_MT_ORIENTATION, \
181 ABS_MT_POSITION_X, \
182 ABS_MT_POSITION_Y, \
183 ABS_MT_TOOL_TYPE, \
184 ABS_MT_BLOB_ID, \
185 ABS_MT_TRACKING_ID, \
186 ABS_MT_PRESSURE, \
187}
188#endif
189
190struct mtdev_caps {
191 int has_mtdata;
192 int has_slot;
193 int has_abs[MT_ABS_SIZE];
194 struct input_absinfo slot;
195 struct input_absinfo abs[MT_ABS_SIZE];
196};
197
198struct mtdev {
199 struct mtdev_caps caps;
200 struct mtdev_state *state;
201};
202
203#endif
204
176#ifdef __cplusplus 205#ifdef __cplusplus
177} 206}
178#endif 207#endif