Commit d9c82509 authored by Tiago Vignatti's avatar Tiago Vignatti Committed by Kristian Høgsberg
Browse files

evdev: use a separate function for configuring devices



No semantical changes.
Signed-off-by: default avatarTiago Vignatti <tiago.vignatti@intel.com>
parent 90bc9e65
...@@ -200,16 +200,44 @@ evdev_input_device_data(int fd, uint32_t mask, void *data) ...@@ -200,16 +200,44 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
#define TEST_BIT(array, bit) ((array[LONG(bit)] >> OFF(bit)) & 1) #define TEST_BIT(array, bit) ((array[LONG(bit)] >> OFF(bit)) & 1)
/* end copied */ /* end copied */
static void
evdev_configure_device(struct evdev_input_device *device)
{
struct input_absinfo absinfo;
unsigned long ev_bits[NBITS(EV_MAX)];
unsigned long abs_bits[NBITS(ABS_MAX)];
unsigned long key_bits[NBITS(KEY_MAX)];
ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits);
if (TEST_BIT(ev_bits, EV_ABS)) {
ioctl(device->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)),
abs_bits);
if (TEST_BIT(abs_bits, ABS_X)) {
ioctl(device->fd, EVIOCGABS(ABS_X), &absinfo);
device->min_x = absinfo.minimum;
device->max_x = absinfo.maximum;
}
if (TEST_BIT(abs_bits, ABS_Y)) {
ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
device->min_y = absinfo.minimum;
device->max_y = absinfo.maximum;
}
}
if (TEST_BIT(ev_bits, EV_KEY)) {
ioctl(device->fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)),
key_bits);
if (TEST_BIT(key_bits, BTN_TOOL_FINGER) &&
!TEST_BIT(key_bits, BTN_TOOL_PEN))
device->is_touchpad = 1;
}
}
static struct evdev_input_device * static struct evdev_input_device *
evdev_input_device_create(struct evdev_input *master, evdev_input_device_create(struct evdev_input *master,
struct wl_display *display, const char *path) struct wl_display *display, const char *path)
{ {
struct evdev_input_device *device; struct evdev_input_device *device;
struct wl_event_loop *loop; struct wl_event_loop *loop;
struct input_absinfo absinfo;
unsigned long ev_bits[NBITS(EV_MAX)];
unsigned long abs_bits[NBITS(ABS_MAX)];
unsigned long key_bits[NBITS(KEY_MAX)];
device = malloc(sizeof *device); device = malloc(sizeof *device);
if (device == NULL) if (device == NULL)
...@@ -228,25 +256,7 @@ evdev_input_device_create(struct evdev_input *master, ...@@ -228,25 +256,7 @@ evdev_input_device_create(struct evdev_input *master,
return NULL; return NULL;
} }
ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits); evdev_configure_device(device);
if (TEST_BIT(ev_bits, EV_ABS)) {
ioctl(device->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)), abs_bits);
if (TEST_BIT(abs_bits, ABS_X)) {
ioctl(device->fd, EVIOCGABS(ABS_X), &absinfo);
device->min_x = absinfo.minimum;
device->max_x = absinfo.maximum;
}
if (TEST_BIT(abs_bits, ABS_Y)) {
ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
device->min_y = absinfo.minimum;
device->max_y = absinfo.maximum;
}
}
if (TEST_BIT(ev_bits, EV_KEY)) {
ioctl(device->fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)), key_bits);
if (TEST_BIT(key_bits, BTN_TOOL_FINGER) && !TEST_BIT(key_bits, BTN_TOOL_PEN))
device->is_touchpad = 1;
}
loop = wl_display_get_event_loop(display); loop = wl_display_get_event_loop(display);
device->source = wl_event_loop_add_fd(loop, device->fd, device->source = wl_event_loop_add_fd(loop, device->fd,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment