}
}
-int
+bool
tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE) &&
libevdev_fetch_slot_value(evdev, slot, ABS_MT_DISTANCE, &t->distance);
}
-static int
+static bool
tp_init_slots(struct tp_dispatch *tp,
struct evdev_device *device)
{
tp->ntouches = max(tp->num_slots, n_btn_tool_touches);
tp->touches = calloc(tp->ntouches, sizeof(struct tp_touch));
if (!tp->touches)
- return -1;
+ return false;
for (i = 0; i < tp->ntouches; i++)
tp_init_touch(tp, &tp->touches[i]);
for (i = 1; i < tp->num_slots; i++)
tp_sync_touch(tp, device, &tp->touches[i], i);
- return 0;
+ return true;
}
static uint32_t
return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
}
-static int
+static bool
tp_init_accel(struct tp_dispatch *tp)
{
struct evdev_device *device = tp->device;
filter = create_pointer_accelerator_filter_touchpad(tp->device->dpi);
if (!filter)
- return -1;
+ return false;
evdev_device_init_pointer_acceleration(tp->device, filter);
device->pointer.config.get_profile = tp_accel_config_get_profile;
device->pointer.config.get_default_profile = tp_accel_config_get_default_profile;
- return 0;
+ return true;
}
static uint32_t
tp_init_default_resolution(tp, device);
- if (tp_init_slots(tp, device) != 0)
- return -1;
+ if (!tp_init_slots(tp, device))
+ return false;
width = device->abs.dimensions.x;
height = device->abs.dimensions.y;
tp_init_hysteresis(tp);
- if (tp_init_accel(tp) != 0)
- return -1;
+ if (!tp_init_accel(tp))
+ return false;
tp_init_tap(tp);
tp_init_buttons(tp, device);
if (tp->gesture.enabled)
device->seat_caps |= EVDEV_DEVICE_GESTURE;
- return 0;
+ return true;
}
static uint32_t
if (!tp)
return NULL;
- if (tp_init(tp, device) != 0) {
+ if (!tp_init(tp, device)) {
tp_interface_destroy(&tp->base);
return NULL;
}
long_set_bit_state(device->hw_key_mask, code, pressed);
}
-static int
+static bool
hw_is_key_down(struct evdev_device *device, int code)
{
return long_bit_is_set(device->hw_key_mask, code);
}
}
-static inline int
+static inline bool
evdev_init_accel(struct evdev_device *device,
enum libinput_config_accel_profile which)
{
filter = create_pointer_accelerator_filter_linear(device->dpi);
if (!filter)
- return -1;
+ return false;
evdev_device_init_pointer_acceleration(device, filter);
- return 0;
+ return true;
}
static int
speed = filter_get_speed(filter);
device->pointer.filter = NULL;
- if (evdev_init_accel(device, profile) == 0) {
+ if (evdev_init_accel(device, profile)) {
evdev_accel_config_set_speed(libinput_device, speed);
filter_destroy(filter);
} else {
}
}
-static inline int
+static inline bool
evdev_need_mtdev(struct evdev_device *device)
{
struct libevdev *evdev = device->evdev;
return model_flags;
}
-static inline int
+static inline bool
evdev_read_attr_res_prop(struct evdev_device *device,
size_t *xres,
size_t *yres)
return parse_dimension_property(res_prop, xres, yres);
}
-static inline int
+static inline bool
evdev_read_attr_size_prop(struct evdev_device *device,
size_t *size_x,
size_t *size_y)
libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y));
}
-static inline int
+static inline bool
evdev_check_min_max(struct evdev_device *device, unsigned int code)
{
struct libevdev *evdev = device->evdev;
const struct input_absinfo *absinfo;
if (!libevdev_has_event_code(evdev, EV_ABS, code))
- return 0;
+ return true;
absinfo = libevdev_get_abs_info(evdev, code);
if (absinfo->minimum == absinfo->maximum) {
"Device '%s' has min == max on %s\n",
device->devname,
libevdev_event_code_get_name(EV_ABS, code));
- return -1;
+ return false;
}
}
- return 0;
+ return true;
}
-static int
+static bool
evdev_reject_device(struct evdev_device *device)
{
struct libinput *libinput = evdev_libinput_context(device);
if (libevdev_has_event_code(evdev, EV_ABS, ABS_X) ^
libevdev_has_event_code(evdev, EV_ABS, ABS_Y))
- return -1;
+ return true;
if (libevdev_has_event_code(evdev, EV_REL, REL_X) ^
libevdev_has_event_code(evdev, EV_REL, REL_Y))
- return -1;
+ return true;
if (!evdev_is_fake_mt_device(device) &&
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ^
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
- return -1;
+ return true;
if (libevdev_has_event_code(evdev, EV_ABS, ABS_X)) {
absx = libevdev_get_abs_info(evdev, ABS_X);
(absx->resolution != 0 && absy->resolution == 0)) {
log_bug_kernel(libinput,
"Kernel has only x or y resolution, not both.\n");
- return -1;
+ return true;
}
}
(absx->resolution != 0 && absy->resolution == 0)) {
log_bug_kernel(libinput,
"Kernel has only x or y MT resolution, not both.\n");
- return -1;
+ return true;
}
}
case ABS_MT_TOOL_TYPE:
break;
default:
- if (evdev_check_min_max(device, code) == -1)
- return -1;
+ if (!evdev_check_min_max(device, code))
+ return true;
}
}
- return 0;
+ return false;
}
-static int
+static bool
evdev_configure_mt_device(struct evdev_device *device)
{
struct libevdev *evdev = device->evdev;
if (!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
- return 0;
+ return true;
if (evdev_fix_abs_resolution(device,
ABS_MT_POSITION_X,
if (evdev_need_mtdev(device)) {
device->mtdev = mtdev_new_open(device->fd);
if (!device->mtdev)
- return -1;
+ return false;
/* pick 10 slots as default for type A
devices. */
slots = calloc(num_slots, sizeof(struct mt_slot));
if (!slots)
- return -1;
+ return false;
for (slot = 0; slot < num_slots; ++slot) {
slots[slot].seat_slot = -1;
device->mt.hysteresis_margin.y = device->abs.absinfo_y->fuzz/2;
}
- return 0;
+ return true;
}
-static int
+static bool
evdev_configure_device(struct evdev_device *device)
{
struct libinput *libinput = evdev_libinput_context(device);
log_info(libinput,
"input device '%s', %s not tagged as input device\n",
device->devname, devnode);
- return -1;
+ return false;
}
log_info(libinput,
log_info(libinput,
"input device '%s', %s is an accelerometer, ignoring\n",
device->devname, devnode);
- return -1;
+ return false;
}
/* libwacom *adds* TABLET, TOUCHPAD but leaves JOYSTICK in place, so
log_info(libinput,
"input device '%s', %s is a joystick, ignoring\n",
device->devname, devnode);
- return -1;
+ return false;
}
- if (evdev_reject_device(device) == -1) {
+ if (evdev_reject_device(device)) {
log_info(libinput,
"input device '%s', %s was rejected.\n",
device->devname, devnode);
- return -1;
+ return false;
}
if (!evdev_is_fake_mt_device(device))
if (evdev_is_fake_mt_device(device)) {
udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN;
- } else if (evdev_configure_mt_device(device) == -1) {
- return -1;
+ } else if (!evdev_configure_mt_device(device)) {
+ return false;
}
}
log_info(libinput,
"input device '%s', %s is a tablet pad\n",
device->devname, devnode);
- return device->dispatch == NULL ? -1 : 0;
+ return device->dispatch != NULL;
} else if ((udev_tags & tablet_tags) == EVDEV_UDEV_TAG_TABLET) {
device->dispatch = evdev_tablet_create(device);
log_info(libinput,
"input device '%s', %s is a tablet\n",
device->devname, devnode);
- return device->dispatch == NULL ? -1 : 0;
+ return device->dispatch != NULL;
}
if (udev_tags & EVDEV_UDEV_TAG_TOUCHPAD) {
"input device '%s', %s is a touchpad\n",
device->devname, devnode);
- return device->dispatch == NULL ? -1 : 0;
+ return device->dispatch != NULL;
}
if (udev_tags & EVDEV_UDEV_TAG_MOUSE ||
if (device->seat_caps & EVDEV_DEVICE_POINTER &&
libevdev_has_event_code(evdev, EV_REL, REL_X) &&
libevdev_has_event_code(evdev, EV_REL, REL_Y) &&
- evdev_init_accel(device, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) == -1) {
+ !evdev_init_accel(device, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE)) {
log_error(libinput,
"failed to initialize pointer acceleration for %s\n",
device->devname);
- return -1;
+ return false;
}
- return 0;
+ return true;
}
static void
return rc;
}
-static int
+static bool
evdev_set_device_group(struct evdev_device *device,
struct udev_device *udev_device)
{
if (!group) {
group = libinput_device_group_create(libinput, udev_group);
if (!group)
- return 1;
+ return false;
libinput_device_set_device_group(&device->base, group);
libinput_device_group_unref(group);
} else {
libinput_device_set_device_group(&device->base, group);
}
- return 0;
+ return true;
}
static inline void
evdev_pre_configure_model_quirks(device);
- if (evdev_configure_device(device) == -1)
+ if (!evdev_configure_device(device))
goto err;
if (device->seat_caps == 0) {
if (!device->source)
goto err;
- if (evdev_set_device_group(device, udev_device))
+ if (!evdev_set_device_group(device, udev_device))
goto err;
list_insert(seat->devices_list.prev, &device->base.link);
matrix_mult(&device->abs.calibration, &transform, &scale);
}
-int
+bool
evdev_device_has_capability(struct evdev_device *device,
enum libinput_device_capability capability)
{
case LIBINPUT_DEVICE_CAP_TABLET_PAD:
return !!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD);
default:
- return 0;
+ return false;
}
}