diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2015-12-14 15:59:05 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-12-23 07:33:39 +1000 |
commit | c8a99cdf106ae6e1fd10ea8d72ca3fcd3ba6d11b (patch) | |
tree | 95aca19379253a3a1e77e8f614c2a1abaece3ee2 /src | |
parent | ea07cbcd891c1518e6569f22fdcfae3e80253668 (diff) |
tablet: simplify check for testing if an axis update is needed
We know when one of the bits is set we need to send an event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev-tablet.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index ead159e8..a46a9728 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -298,6 +298,13 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, int wheel_discrete = 0; struct device_coords point, old_point; const struct input_absinfo *absinfo; + const char tmp[sizeof(tablet->changed_axes)] = {0}; + + if (memcmp(tmp, tablet->changed_axes, sizeof(tmp))) + axis_update_needed = true; + + if (!axis_update_needed) + return; /* x/y are special for left-handed and calibration */ a = LIBINPUT_TABLET_TOOL_AXIS_X; @@ -305,7 +312,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, if (bit_is_set(tablet->changed_axes, a)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_X); - axis_update_needed = true; if (device->left_handed.enabled) tablet->axes[a] = invert_axis(absinfo); else @@ -318,8 +324,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, if (bit_is_set(tablet->changed_axes, a)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_Y); - axis_update_needed = true; - if (device->left_handed.enabled) tablet->axes[a] = invert_axis(absinfo); else @@ -335,7 +339,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, a = LIBINPUT_TABLET_TOOL_AXIS_PRESSURE; if (bit_is_set(tablet->changed_axes, a)) { - axis_update_needed = true; absinfo = libevdev_get_abs_info(device->evdev, ABS_PRESSURE); tablet->axes[a] = normalize_pressure(absinfo, tool); } @@ -343,7 +346,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, a = LIBINPUT_TABLET_TOOL_AXIS_DISTANCE; if (bit_is_set(tablet->changed_axes, a)) { - axis_update_needed = true; absinfo = libevdev_get_abs_info(device->evdev, ABS_DISTANCE); tablet->axes[a] = normalize_dist_slider(absinfo); } @@ -351,7 +353,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, a = LIBINPUT_TABLET_TOOL_AXIS_SLIDER; if (bit_is_set(tablet->changed_axes, a)) { - axis_update_needed = true; absinfo = libevdev_get_abs_info(device->evdev, ABS_WHEEL); tablet->axes[a] = normalize_dist_slider(absinfo); } @@ -359,7 +360,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, a = LIBINPUT_TABLET_TOOL_AXIS_TILT_X; if (bit_is_set(tablet->changed_axes, a)) { - axis_update_needed = true; absinfo = libevdev_get_abs_info(device->evdev, ABS_TILT_X); tablet->axes[a] = normalize_tilt(absinfo); } @@ -367,7 +367,6 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, a = LIBINPUT_TABLET_TOOL_AXIS_TILT_Y; if (bit_is_set(tablet->changed_axes, a)) { - axis_update_needed = true; absinfo = libevdev_get_abs_info(device->evdev, ABS_TILT_Y); tablet->axes[a] = normalize_tilt(absinfo); } @@ -389,13 +388,11 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, /* artpen has 0 with buttons pointing east */ tablet->axes[a] = convert_to_degrees(absinfo, 90); } - axis_update_needed = true; } axes[a] = tablet->axes[a]; a = LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL; if (bit_is_set(tablet->changed_axes, a)) { - axis_update_needed = true; wheel_discrete = tablet->deltas[a]; wheel_delta = normalize_wheel(tablet, tablet->deltas[a]); @@ -408,8 +405,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, * tablets will send axis events with incorrect values if the tablet * tool is close enough so that the tablet can partially detect that * it's there, but can't properly receive any data from the tool. */ - if (axis_update_needed && - !tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY) && + if (!tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY) && !tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) { if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) { |