[PATCH evemu 5/5] Use accessors instead of direct access fields
Peter Hutterer
peter.hutterer at who-t.net
Thu Oct 24 08:03:52 CEST 2013
No functional changes, this is preparation work for the libevdev backend.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evemu.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/evemu.c b/src/evemu.c
index 039038e..3d88c8d 100644
--- a/src/evemu.c
+++ b/src/evemu.c
@@ -345,10 +345,10 @@ static void write_abs(FILE *fp, int index, const struct input_absinfo *abs)
static void write_desc(const struct evemu_device *dev, FILE *fp)
{
int i, j;
- fprintf(fp, "# Input device name: \"%s\"\n", dev->name);
+ fprintf(fp, "# Input device name: \"%s\"\n", evemu_get_name(dev));
fprintf(fp, "# Input device ID: bus %#04x vendor %#04x product %#04x version %#04x\n",
- dev->id.bustype, dev->id.vendor,
- dev->id.product, dev->id.version);
+ evemu_get_id_bustype(dev), evemu_get_id_vendor(dev),
+ evemu_get_id_product(dev), evemu_get_id_version(dev));
fprintf(fp, "# Supported events:\n");
for (i = 0; i < EV_MAX; i++) {
if (!evemu_has_bit(dev, i))
@@ -396,11 +396,13 @@ int evemu_write(const struct evemu_device *dev, FILE *fp)
write_desc(dev, fp);
- fprintf(fp, "N: %s\n", dev->name);
+ fprintf(fp, "N: %s\n", evemu_get_name(dev));
fprintf(fp, "I: %04x %04x %04x %04x\n",
- dev->id.bustype, dev->id.vendor,
- dev->id.product, dev->id.version);
+ evemu_get_id_bustype(dev),
+ evemu_get_id_vendor(dev),
+ evemu_get_id_product(dev),
+ evemu_get_id_version(dev));
write_prop(fp, dev->prop, dev->pbytes);
@@ -419,10 +421,8 @@ static int parse_name(struct evemu_device *dev, const char *line, struct version
int matched;
char *devname = NULL;
- if ((matched = sscanf(line, "N: %m[^\n]\n", &devname)) > 0) {
- strncpy(dev->name, devname, sizeof(dev->name));
- dev->name[sizeof(dev->name)-1] = '\0';
- }
+ if ((matched = sscanf(line, "N: %m[^\n]\n", &devname)) > 0)
+ evemu_set_name(dev, devname);
if (devname != NULL)
free(devname);
@@ -440,10 +440,10 @@ static int parse_bus_vid_pid_ver(struct evemu_device *dev, const char *line, str
if ((matched = sscanf(line, "I: %04x %04x %04x %04x\n",
&bustype, &vendor, &product, &version)) > 0) {
- dev->id.bustype = bustype;
- dev->id.vendor = vendor;
- dev->id.product = product;
- dev->id.version = version;
+ evemu_set_id_bustype(dev, bustype),
+ evemu_set_id_vendor(dev, vendor),
+ evemu_set_id_product(dev, product),
+ evemu_set_id_version(dev, version);
}
if (matched != 4)
@@ -522,7 +522,11 @@ static int parse_abs(struct evemu_device *dev, const char *line, struct version
return -1;
}
- dev->abs[index] = abs;
+ evemu_set_abs_minimum(dev, index, abs.minimum);
+ evemu_set_abs_maximum(dev, index, abs.maximum);
+ evemu_set_abs_fuzz(dev, index, abs.fuzz);
+ evemu_set_abs_flat(dev, index, abs.flat);
+ evemu_set_abs_resolution(dev, index, abs.resolution);
return 1;
}
--
1.8.3.1
More information about the Input-tools
mailing list