summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-07-25 13:21:09 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-07-31 10:05:49 +1000
commit6f7c5c558006bb69fdf0af73103097c012ccfed5 (patch)
tree28f65a8c130d095784d21c8759c81621c63e4e68 /src
parentb5d8e8e26c0116e4b6e556a0f6da8777bc55c590 (diff)
Replace hardcoded 11 with a define
The 11 comes from the legacy API that we need to be binary compatible with. Make this clear with a define and a comment. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/caps.c12
-rw-r--r--src/common.h12
-rw-r--r--src/state.h4
3 files changed, 18 insertions, 10 deletions
diff --git a/src/caps.c b/src/caps.c
index 45c185c..2e6b0d4 100644
--- a/src/caps.c
+++ b/src/caps.c
@@ -61,10 +61,10 @@ static struct input_absinfo *get_info(struct mtdev *dev, int code)
61 return NULL; 61 return NULL;
62 62
63 ix = mtdev_abs2mt(code); 63 ix = mtdev_abs2mt(code);
64 if (ix < 11) 64 if (ix < LEGACY_API_NUM_MT_AXES)
65 return &dev->abs[ix]; 65 return &dev->abs[ix];
66 else 66 else
67 return &dev->state->ext_abs[ix - 11]; 67 return &dev->state->ext_abs[ix - LEGACY_API_NUM_MT_AXES];
68} 68}
69 69
70static void set_info(struct mtdev *dev, int code, 70static void set_info(struct mtdev *dev, int code,
@@ -156,10 +156,10 @@ int mtdev_has_mt_event(const struct mtdev *dev, int code)
156 return 0; 156 return 0;
157 157
158 ix = mtdev_abs2mt(code); 158 ix = mtdev_abs2mt(code);
159 if (ix < 11) 159 if (ix < LEGACY_API_NUM_MT_AXES)
160 return dev->has_abs[ix]; 160 return dev->has_abs[ix];
161 else 161 else
162 return dev->state->has_ext_abs[ix - 11]; 162 return dev->state->has_ext_abs[ix - LEGACY_API_NUM_MT_AXES];
163} 163}
164 164
165int mtdev_get_abs_minimum(const struct mtdev *dev, int code) 165int mtdev_get_abs_minimum(const struct mtdev *dev, int code)
@@ -203,10 +203,10 @@ void mtdev_set_mt_event(struct mtdev *dev, int code, int value)
203 return; 203 return;
204 204
205 ix = mtdev_abs2mt(code); 205 ix = mtdev_abs2mt(code);
206 if (ix < 11) 206 if (ix < LEGACY_API_NUM_MT_AXES)
207 dev->has_abs[ix] = value; 207 dev->has_abs[ix] = value;
208 else 208 else
209 dev->state->has_ext_abs[ix - 11] = value; 209 dev->state->has_ext_abs[ix - LEGACY_API_NUM_MT_AXES] = value;
210} 210}
211 211
212void mtdev_set_abs_maximum(struct mtdev *dev, int code, int value) 212void mtdev_set_abs_maximum(struct mtdev *dev, int code, int value)
diff --git a/src/common.h b/src/common.h
index 2ec8eb8..80a3d6e 100644
--- a/src/common.h
+++ b/src/common.h
@@ -87,6 +87,14 @@ static inline int bitcount(unsigned v)
87/* robust system ioctl calls */ 87/* robust system ioctl calls */
88#define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) 88#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
89 89
90/* To be compatible to the original, non-opaque mtdev API, we can only use 11
91 * axes in the basic struct. Everything else is hidden in the state, see the
92 * use of dev->abs[idx] vs dev->state->ext_abs[idx]
93 *
94 * See MT_ABS_SIZE in include/mtdev.h
95 */
96#define LEGACY_API_NUM_MT_AXES 11
97
90/** 98/**
91 * struct mtdev - represents an input MT device 99 * struct mtdev - represents an input MT device
92 * @has_mtdata: true if the device has MT capabilities 100 * @has_mtdata: true if the device has MT capabilities
@@ -105,9 +113,9 @@ static inline int bitcount(unsigned v)
105struct mtdev { 113struct mtdev {
106 int has_mtdata; 114 int has_mtdata;
107 int has_slot; 115 int has_slot;
108 int has_abs[11]; 116 int has_abs[LEGACY_API_NUM_MT_AXES];
109 struct input_absinfo slot; 117 struct input_absinfo slot;
110 struct input_absinfo abs[11]; 118 struct input_absinfo abs[LEGACY_API_NUM_MT_AXES];
111 struct mtdev_state *state; 119 struct mtdev_state *state;
112}; 120};
113 121
diff --git a/src/state.h b/src/state.h
index 256858a..06e86ae 100644
--- a/src/state.h
+++ b/src/state.h
@@ -72,8 +72,8 @@ static inline void set_sval(struct mtdev_slot *slot, int ix, int value)
72 */ 72 */
73struct mtdev_state { 73struct mtdev_state {
74 74
75 int has_ext_abs[MT_ABS_SIZE - 11]; 75 int has_ext_abs[MT_ABS_SIZE - LEGACY_API_NUM_MT_AXES];
76 struct input_absinfo ext_abs[MT_ABS_SIZE - 11]; 76 struct input_absinfo ext_abs[MT_ABS_SIZE - LEGACY_API_NUM_MT_AXES];
77 77
78 struct mtdev_iobuf iobuf; 78 struct mtdev_iobuf iobuf;
79 struct mtdev_evbuf inbuf; 79 struct mtdev_evbuf inbuf;