evdev: Add device capabilities
Does what it says on the box: lists whether or not the device supports key, absolute, relative or touch classes. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
1d637772c8
commit
33965c242d
@@ -44,6 +44,14 @@ enum evdev_event_type {
|
|||||||
EVDEV_RELATIVE_MOTION = (1 << 4),
|
EVDEV_RELATIVE_MOTION = (1 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum evdev_device_capability {
|
||||||
|
EVDEV_KEYBOARD = (1 << 0),
|
||||||
|
EVDEV_BUTTON = (1 << 1),
|
||||||
|
EVDEV_MOTION_ABS = (1 << 2),
|
||||||
|
EVDEV_MOTION_REL = (1 << 3),
|
||||||
|
EVDEV_TOUCH = (1 << 4),
|
||||||
|
};
|
||||||
|
|
||||||
struct evdev_input_device {
|
struct evdev_input_device {
|
||||||
struct evdev_seat *master;
|
struct evdev_seat *master;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
@@ -69,6 +77,7 @@ struct evdev_input_device {
|
|||||||
} rel;
|
} rel;
|
||||||
|
|
||||||
enum evdev_event_type pending_events;
|
enum evdev_event_type pending_events;
|
||||||
|
enum evdev_device_capability caps;
|
||||||
|
|
||||||
int is_mt;
|
int is_mt;
|
||||||
};
|
};
|
||||||
|
|||||||
+26
@@ -336,11 +336,14 @@ evdev_configure_device(struct evdev_input_device *device)
|
|||||||
struct input_absinfo absinfo;
|
struct input_absinfo absinfo;
|
||||||
unsigned long ev_bits[NBITS(EV_MAX)];
|
unsigned long ev_bits[NBITS(EV_MAX)];
|
||||||
unsigned long abs_bits[NBITS(ABS_MAX)];
|
unsigned long abs_bits[NBITS(ABS_MAX)];
|
||||||
|
unsigned long rel_bits[NBITS(REL_MAX)];
|
||||||
unsigned long key_bits[NBITS(KEY_MAX)];
|
unsigned long key_bits[NBITS(KEY_MAX)];
|
||||||
int has_key, has_abs;
|
int has_key, has_abs;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
has_key = 0;
|
has_key = 0;
|
||||||
has_abs = 0;
|
has_abs = 0;
|
||||||
|
device->caps = 0;
|
||||||
|
|
||||||
ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits);
|
ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits);
|
||||||
if (TEST_BIT(ev_bits, EV_ABS)) {
|
if (TEST_BIT(ev_bits, EV_ABS)) {
|
||||||
@@ -352,17 +355,26 @@ evdev_configure_device(struct evdev_input_device *device)
|
|||||||
ioctl(device->fd, EVIOCGABS(ABS_X), &absinfo);
|
ioctl(device->fd, EVIOCGABS(ABS_X), &absinfo);
|
||||||
device->abs.min_x = absinfo.minimum;
|
device->abs.min_x = absinfo.minimum;
|
||||||
device->abs.max_x = absinfo.maximum;
|
device->abs.max_x = absinfo.maximum;
|
||||||
|
device->caps |= EVDEV_MOTION_ABS;
|
||||||
}
|
}
|
||||||
if (TEST_BIT(abs_bits, ABS_Y)) {
|
if (TEST_BIT(abs_bits, ABS_Y)) {
|
||||||
ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
|
ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
|
||||||
device->abs.min_y = absinfo.minimum;
|
device->abs.min_y = absinfo.minimum;
|
||||||
device->abs.max_y = absinfo.maximum;
|
device->abs.max_y = absinfo.maximum;
|
||||||
|
device->caps |= EVDEV_MOTION_ABS;
|
||||||
}
|
}
|
||||||
if (TEST_BIT(abs_bits, ABS_MT_SLOT)) {
|
if (TEST_BIT(abs_bits, ABS_MT_SLOT)) {
|
||||||
device->is_mt = 1;
|
device->is_mt = 1;
|
||||||
device->mt.slot = 0;
|
device->mt.slot = 0;
|
||||||
|
device->caps |= EVDEV_TOUCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TEST_BIT(ev_bits, EV_REL)) {
|
||||||
|
ioctl(device->fd, EVIOCGBIT(EV_REL, sizeof(rel_bits)),
|
||||||
|
rel_bits);
|
||||||
|
if (TEST_BIT(rel_bits, REL_X) || TEST_BIT(rel_bits, REL_Y))
|
||||||
|
device->caps |= EVDEV_MOTION_REL;
|
||||||
|
}
|
||||||
if (TEST_BIT(ev_bits, EV_KEY)) {
|
if (TEST_BIT(ev_bits, EV_KEY)) {
|
||||||
has_key = 1;
|
has_key = 1;
|
||||||
ioctl(device->fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)),
|
ioctl(device->fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)),
|
||||||
@@ -371,6 +383,20 @@ evdev_configure_device(struct evdev_input_device *device)
|
|||||||
!TEST_BIT(key_bits, BTN_TOOL_PEN) &&
|
!TEST_BIT(key_bits, BTN_TOOL_PEN) &&
|
||||||
has_abs)
|
has_abs)
|
||||||
device->dispatch = evdev_touchpad_create(device);
|
device->dispatch = evdev_touchpad_create(device);
|
||||||
|
for (i = KEY_ESC; i < KEY_MAX; i++) {
|
||||||
|
if (i >= BTN_MISC && i < KEY_OK)
|
||||||
|
continue;
|
||||||
|
if (TEST_BIT(key_bits, i)) {
|
||||||
|
device->caps |= EVDEV_KEYBOARD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = BTN_MISC; i < KEY_OK; i++) {
|
||||||
|
if (TEST_BIT(key_bits, i)) {
|
||||||
|
device->caps |= EVDEV_BUTTON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This rule tries to catch accelerometer devices and opt out. We may
|
/* This rule tries to catch accelerometer devices and opt out. We may
|
||||||
|
|||||||
Reference in New Issue
Block a user