diff options
| author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-07-24 15:52:02 +1000 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-01 13:53:05 +1000 |
| commit | 699399f6533af79340b60da7fefd9a2600b0fc57 (patch) | |
| tree | af65785a7f0eb4cc8a7999d8eb58c447a07db8bd /libevdev | |
| parent | 00528f27d52287ff45a3e7d57e2a66c9a46417f2 (diff) | |
| download | libevdev-699399f6533af79340b60da7fefd9a2600b0fc57.tar.gz | |
Add abs setters for changing a single value on an abs axis
Changing a single value on an abs axis is slightly more common than
having to enable that axis outright. Provide a set of accessors for
doing so.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'libevdev')
| -rw-r--r-- | libevdev/libevdev.c | 22 | ||||
| -rw-r--r-- | libevdev/libevdev.h | 54 |
2 files changed, 76 insertions, 0 deletions
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index cdf338b..a17e388 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -821,6 +821,28 @@ ABS_GETTER(fuzz, fuzz) ABS_GETTER(flat, flat) ABS_GETTER(resolution, resolution) +#define ABS_SETTER(field) \ +void libevdev_set_abs_##field(struct libevdev *dev, unsigned int code, int val) \ +{ \ + if (!libevdev_has_event_code(dev, EV_ABS, code)) \ + return; \ + dev->abs_info[code].field = val; \ +} + +ABS_SETTER(maximum) +ABS_SETTER(minimum) +ABS_SETTER(fuzz) +ABS_SETTER(flat) +ABS_SETTER(resolution) + +void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs) +{ + if (!libevdev_has_event_code(dev, EV_ABS, code)) + return; + + dev->abs_info[code] = *abs; +} + int libevdev_enable_event_type(struct libevdev *dev, unsigned int type) { diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index c8159ca..427bf39 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -845,6 +845,60 @@ int libevdev_get_current_slot(const struct libevdev *dev); /** * @ingroup kernel * + * Change the minimum for the given EV_ABS event code, if the code exists. + * This function has no effect if libevdev_has_event_code() returns false for + * this code. + */ +void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min); + +/** + * @ingroup kernel + * + * Change the maximum for the given EV_ABS event code, if the code exists. + * This function has no effect if libevdev_has_event_code() returns false for + * this code. + */ +void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max); + +/** + * @ingroup kernel + * + * Change the fuzz for the given EV_ABS event code, if the code exists. + * This function has no effect if libevdev_has_event_code() returns false for + * this code. + */ +void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz); + +/** + * @ingroup kernel + * + * Change the flat for the given EV_ABS event code, if the code exists. + * This function has no effect if libevdev_has_event_code() returns false for + * this code. + */ +void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat); + +/** + * @ingroup kernel + * + * Change the resolution for the given EV_ABS event code, if the code exists. + * This function has no effect if libevdev_has_event_code() returns false for + * this code. + */ +void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution); + +/** + * @ingroup kernel + * + * Change the abs info for the given EV_ABS event code, if the code exists. + * This function has no effect if libevdev_has_event_code() returns false for + * this code. + */ +void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs); + +/** + * @ingroup kernel + * * Forcibly enable an event type on this device, even if the underlying * device does not support it. While this cannot make the device actually * report such events, it will now return true for libevdev_has_event_type(). |
