[PATCH libevdev 3/4] memcpy instead of invidual bittoggle
Peter Hutterer
peter.hutterer at who-t.net
Thu Aug 29 18:06:39 PDT 2013
The ioctls return the number of bytes copied into the destination, so just
copy them into the device state instead of individually flipping bits.
For easier review: rc is the return value of the EVIOCG* ioctl, which is
the number of bytes copied.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
libevdev/libevdev.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index 73405bc..9b37f70 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -320,9 +320,10 @@ sync_key_state(struct libevdev *dev)
struct input_event *ev = queue_push(dev);
init_event(dev, ev, EV_KEY, i, new ? 1 : 0);
}
- set_bit_state(dev->key_values, i, new);
}
+ memcpy(dev->key_values, keystate, rc);
+
rc = 0;
out:
return rc ? -errno : 0;
@@ -347,9 +348,10 @@ sync_sw_state(struct libevdev *dev)
struct input_event *ev = queue_push(dev);
init_event(dev, ev, EV_SW, i, new ? 1 : 0);
}
- set_bit_state(dev->sw_values, i, new);
}
+ memcpy(dev->sw_values, swstate, rc);
+
rc = 0;
out:
return rc ? -errno : 0;
@@ -374,9 +376,10 @@ sync_led_state(struct libevdev *dev)
struct input_event *ev = queue_push(dev);
init_event(dev, ev, EV_LED, i, new ? 1 : 0);
}
- set_bit_state(dev->led_values, i, new);
}
+ memcpy(dev->led_values, ledstate, rc);
+
rc = 0;
out:
return rc ? -errno : 0;
--
1.8.2.1
More information about the Input-tools
mailing list