[PATCH 1/9] evdev: use struct calibration for those kind of fields
Tiago Vignatti
tiago.vignatti at intel.com
Mon Oct 24 07:42:14 PDT 2011
No functional changes.
Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
compositor/evdev.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/compositor/evdev.c b/compositor/evdev.c
index f0cdf30..3f8b9ad 100644
--- a/compositor/evdev.c
+++ b/compositor/evdev.c
@@ -40,7 +40,13 @@ struct evdev_input_device {
int tool, new_x, new_y;
int base_x, base_y;
int fd;
- int min_x, max_x, min_y, max_y;
+ struct {
+ int min_x;
+ int max_x;
+ int min_y;
+ int max_y;
+ } calibration;
+
int is_touchpad, old_x_value, old_y_value, reset_x_value, reset_y_value;
};
@@ -100,13 +106,13 @@ evdev_process_absolute_motion(struct evdev_input_device *device,
switch (e->code) {
case ABS_X:
*absolute_event = device->tool;
- *x = (value - device->min_x) * screen_width /
- (device->max_x - device->min_x) + device->output->x;
+ *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->min_y) * screen_height /
- (device->max_y - device->min_y) + device->output->y;
+ *y = (value - device->calibration.min_y) * screen_height /
+ (device->calibration.max_y - device->calibration.min_y) + device->output->y;
break;
}
}
@@ -120,23 +126,23 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
switch (e->code) {
case ABS_X:
- value -= device->min_x;
+ value -= device->calibration.min_x;
if (device->reset_x_value)
device->reset_x_value = 0;
else {
*dx = (value - device->old_x_value) * touchpad_speed /
- (device->max_x - device->min_x);
+ (device->calibration.max_x - device->calibration.min_x);
}
device->old_x_value = value;
break;
case ABS_Y:
- value -= device->min_y;
+ value -= device->calibration.min_y;
if (device->reset_y_value)
device->reset_y_value = 0;
else {
*dy = (value - device->old_y_value) * touchpad_speed /
/* maybe use x size here to have the same scale? */
- (device->max_y - device->min_y);
+ (device->calibration.max_y - device->calibration.min_y);
}
device->old_y_value = value;
break;
@@ -249,13 +255,13 @@ evdev_configure_device(struct evdev_input_device *device)
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;
+ device->calibration.min_x = absinfo.minimum;
+ device->calibration.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;
+ device->calibration.min_y = absinfo.minimum;
+ device->calibration.max_y = absinfo.maximum;
}
}
if (TEST_BIT(ev_bits, EV_KEY)) {
--
1.7.5.4
More information about the wayland-devel
mailing list