unsigned int type)
{
int max;
- bool first = true;
+ const char *sep = "";
max = libevdev_event_type_get_max(type);
if (max == -1)
if (!libevdev_has_event_code(dev, type, code))
continue;
- noiprintf(ctx, "%s%d", first ? "" : ", ", code);
- first = false;
+ noiprintf(ctx, "%s%d", sep, code);
+ sep = ", ";
}
noiprintf(ctx, "] # %s\n", libevdev_event_type_get_name(type));
static void
print_bits_props(struct record_context *ctx, struct libevdev *dev)
{
- bool first = true;
+ const char *sep = "";
iprintf(ctx, "properties: [");
for (unsigned int prop = 0; prop < INPUT_PROP_CNT; prop++) {
if (libevdev_has_property(dev, prop)) {
- noiprintf(ctx, "%s%d", first ? "" : ", ", prop);
- first = false;
+ noiprintf(ctx, "%s%d", sep, prop);
+ sep = ", ";
}
}
noiprintf(ctx, "]\n"); /* last entry, no comma */
unsigned char buf[1024];
int len;
int fd;
- bool first = true;
+ const char *sep = "";
/* we take the shortcut rather than the proper udev approach, the
report_descriptor is available in sysfs and two devices up from
while ((len = read(fd, buf, sizeof(buf))) > 0) {
for (int i = 0; i < len; i++) {
/* YAML requires decimal */
- noiprintf(ctx, "%s%u",first ? "" : ", ", buf[i]);
- first = false;
+ noiprintf(ctx, "%s%u", sep, buf[i]);
+ sep = ", ";
}
}
- noiprintf(ctx, " ]\n");
+ noiprintf(ctx, "]\n");
close(fd);
}
{LIBINPUT_DEVICE_CAP_SWITCH, "switch"},
};
struct cap *cap;
- bool is_first;
+ const char *sep = "";
if (!device)
return;
iprintf(ctx, "size: [%.f, %.f]\n", w, h);
iprintf(ctx, "capabilities: [");
- is_first = true;
ARRAY_FOR_EACH(caps, cap) {
if (!libinput_device_has_capability(device, cap->cap))
continue;
- noiprintf(ctx, "%s%s", is_first ? "" : ", ", cap->name);
- is_first = false;
+ noiprintf(ctx, "%s%s", sep, cap->name);
+ sep = ", ";
}
noiprintf(ctx, "]\n");