diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-07-25 13:21:09 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-07-31 10:05:49 +1000 |
commit | 6f7c5c558006bb69fdf0af73103097c012ccfed5 (patch) | |
tree | 28f65a8c130d095784d21c8759c81621c63e4e68 | |
parent | b5d8e8e26c0116e4b6e556a0f6da8777bc55c590 (diff) | |
download | mtdev-git-6f7c5c558006bb69fdf0af73103097c012ccfed5.tar.gz |
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>
-rw-r--r-- | src/caps.c | 12 | ||||
-rw-r--r-- | src/common.h | 12 | ||||
-rw-r--r-- | src/state.h | 4 |
3 files changed, 18 insertions, 10 deletions
@@ -61,10 +61,10 @@ static struct input_absinfo *get_info(struct mtdev *dev, int code) return NULL; ix = mtdev_abs2mt(code); - if (ix < 11) + if (ix < LEGACY_API_NUM_MT_AXES) return &dev->abs[ix]; else - return &dev->state->ext_abs[ix - 11]; + return &dev->state->ext_abs[ix - LEGACY_API_NUM_MT_AXES]; } static void set_info(struct mtdev *dev, int code, @@ -156,10 +156,10 @@ int mtdev_has_mt_event(const struct mtdev *dev, int code) return 0; ix = mtdev_abs2mt(code); - if (ix < 11) + if (ix < LEGACY_API_NUM_MT_AXES) return dev->has_abs[ix]; else - return dev->state->has_ext_abs[ix - 11]; + return dev->state->has_ext_abs[ix - LEGACY_API_NUM_MT_AXES]; } int 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) return; ix = mtdev_abs2mt(code); - if (ix < 11) + if (ix < LEGACY_API_NUM_MT_AXES) dev->has_abs[ix] = value; else - dev->state->has_ext_abs[ix - 11] = value; + dev->state->has_ext_abs[ix - LEGACY_API_NUM_MT_AXES] = value; } void 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) /* robust system ioctl calls */ #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) +/* To be compatible to the original, non-opaque mtdev API, we can only use 11 + * axes in the basic struct. Everything else is hidden in the state, see the + * use of dev->abs[idx] vs dev->state->ext_abs[idx] + * + * See MT_ABS_SIZE in include/mtdev.h + */ +#define LEGACY_API_NUM_MT_AXES 11 + /** * struct mtdev - represents an input MT device * @has_mtdata: true if the device has MT capabilities @@ -105,9 +113,9 @@ static inline int bitcount(unsigned v) struct mtdev { int has_mtdata; int has_slot; - int has_abs[11]; + int has_abs[LEGACY_API_NUM_MT_AXES]; struct input_absinfo slot; - struct input_absinfo abs[11]; + struct input_absinfo abs[LEGACY_API_NUM_MT_AXES]; struct mtdev_state *state; }; 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) */ struct mtdev_state { - int has_ext_abs[MT_ABS_SIZE - 11]; - struct input_absinfo ext_abs[MT_ABS_SIZE - 11]; + int has_ext_abs[MT_ABS_SIZE - LEGACY_API_NUM_MT_AXES]; + struct input_absinfo ext_abs[MT_ABS_SIZE - LEGACY_API_NUM_MT_AXES]; struct mtdev_iobuf iobuf; struct mtdev_evbuf inbuf; |