[PATCH v2 3/9] evdev: record valuators coordinates in evdev_input_device
Tiago Vignatti
tiago.vignatti at intel.com
Wed Oct 26 05:55:23 PDT 2011
No functional changes. It will ease the process of converting to a more
smart valuators scheme, similar to the one X evdev driver has.
Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
compositor/evdev.c | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/compositor/evdev.c b/compositor/evdev.c
index a0cd1d5..3027c7d 100644
--- a/compositor/evdev.c
+++ b/compositor/evdev.c
@@ -39,6 +39,7 @@ struct evdev_input_device {
struct wlsc_output *output;
int tool;
int fd;
+ int x, y, dx, dy;
struct {
int min_x;
int max_x;
@@ -96,8 +97,7 @@ evdev_process_key(struct evdev_input_device *device,
static inline void
evdev_process_absolute_motion(struct evdev_input_device *device,
- struct input_event *e, int value, int *x, int *y,
- int *absolute_event)
+ struct input_event *e, int value, int *absolute_event)
{
const int screen_width = device->output->current->width;
const int screen_height = device->output->current->height;
@@ -105,12 +105,12 @@ evdev_process_absolute_motion(struct evdev_input_device *device,
switch (e->code) {
case ABS_X:
*absolute_event = device->tool;
- *x = (value - device->calibration.min_x) * screen_width /
+ device->x = (value - device->calibration.min_x) * screen_width /
(device->calibration.max_x - device->calibration.min_x) + device->output->x;
break;
case ABS_Y:
*absolute_event = device->tool;
- *y = (value - device->calibration.min_y) * screen_height /
+ device->y = (value - device->calibration.min_y) * screen_height /
(device->calibration.max_y - device->calibration.min_y) + device->output->y;
break;
}
@@ -118,7 +118,7 @@ evdev_process_absolute_motion(struct evdev_input_device *device,
static inline void
evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
- struct input_event *e, int value, int *dx, int *dy)
+ struct input_event *e, int value)
{
/* FIXME: Make this configurable somehow. */
const int touchpad_speed = 700;
@@ -129,7 +129,7 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
if (device->reset_x_value)
device->reset_x_value = 0;
else {
- *dx = (value - device->old_x_value) * touchpad_speed /
+ device->dx = (value - device->old_x_value) * touchpad_speed /
(device->calibration.max_x - device->calibration.min_x);
}
device->old_x_value = value;
@@ -139,7 +139,7 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
if (device->reset_y_value)
device->reset_y_value = 0;
else {
- *dy = (value - device->old_y_value) * touchpad_speed /
+ device->dy = (value - device->old_y_value) * touchpad_speed /
/* maybe use x size here to have the same scale? */
(device->calibration.max_y - device->calibration.min_y);
}
@@ -149,15 +149,15 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
}
static inline void
-evdev_process_relative_motion(struct input_event *e, int value, int *dx,
- int *dy)
+evdev_process_relative_motion(struct evdev_input_device *device,
+ struct input_event *e, int value)
{
switch (e->code) {
case REL_X:
- *dx += value;
+ device->dx += value;
break;
case REL_Y:
- *dy += value;
+ device->dy += value;
break;
}
}
@@ -168,8 +168,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
struct wlsc_compositor *ec;
struct evdev_input_device *device = data;
struct input_event ev[8], *e, *end;
- int len, value, dx, dy, absolute_event;
- int x, y;
+ int len, value, absolute_event;
uint32_t time;
ec = (struct wlsc_compositor *)
@@ -177,11 +176,11 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
if (!ec->focus)
return 1;
- dx = 0;
- dy = 0;
+ device->dx = 0;
+ device->dy = 0;
absolute_event = 0;
- x = device->master->base.input_device.x;
- y = device->master->base.input_device.y;
+ device->x = device->master->base.input_device.x;
+ device->y = device->master->base.input_device.y;
len = read(fd, &ev, sizeof ev);
if (len < 0 || len % sizeof e[0] != 0) {
@@ -198,15 +197,15 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
switch (e->type) {
case EV_REL:
- evdev_process_relative_motion(e, value, &dx, &dy);
+ evdev_process_relative_motion(device, e, value);
break;
case EV_ABS:
if (device->is_touchpad)
evdev_process_absolute_motion_touchpad(device,
- e, value, &dx, &dy);
+ e, value);
else
evdev_process_absolute_motion(device, e, value,
- &x, &y, &absolute_event);
+ &absolute_event);
break;
case EV_KEY:
if (value == 2)
@@ -215,11 +214,12 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
}
}
- if (dx != 0 || dy != 0)
+ if (device->dx != 0 || device->dy != 0)
notify_motion(&device->master->base.input_device,
- time, x + dx, y + dy);
+ time, device->x + device->dx, device->y + device->dy);
if (absolute_event)
- notify_motion(&device->master->base.input_device, time, x, y);
+ notify_motion(&device->master->base.input_device, time,
+ device->x, device->y);
return 1;
}
--
1.7.5.4
More information about the wayland-devel
mailing list