diff options
author | Jason Gerecke <killertofu@gmail.com> | 2016-06-21 15:52:48 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2016-06-22 11:10:32 +1000 |
commit | 4714bfe3e7f154b9ef522c120db35936e692a9d6 (patch) | |
tree | 4a842388f5e67e2620212e1d822d5c344bae3e81 | |
parent | 34f5bfbbdbf2e67f6ebf1640e93b43b9168baf36 (diff) | |
download | libwacom-4714bfe3e7f154b9ef522c120db35936e692a9d6.tar.gz |
test: Require reversible tablets to have left/right buttons
The "reversible" flag is supposed to indicate if a device can be rotated
180 degrees for left-handed use. A number of tablets currently set this
flag even though they only have buttons along the top, which makes no
sense -- rotating the tablet (though possible) gains a left-handed user
absolutely nothing.
This updates the device tests to require that reversible tablets have
buttons on the left or right. The no-button case is specifically ignored
to allow several tablets in a family of reversible tablets to continue
to pass.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | test/tablet-validity.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/tablet-validity.c b/test/tablet-validity.c index 2fc1142..f942cc5 100644 --- a/test/tablet-validity.c +++ b/test/tablet-validity.c @@ -112,6 +112,29 @@ static int eraser_is_present(WacomDeviceDatabase *db, const int *styli, int nsty return 0; } +static int tablet_has_lr_buttons(WacomDevice *device) +{ + int nleft = 0; + int nright = 0; + int num_buttons; + char button; + + num_buttons = libwacom_get_num_buttons (device); + + for (button = 'A'; button < 'A' + num_buttons; button++) { + WacomButtonFlags f = libwacom_get_button_flag(device, button); + if (f & WACOM_BUTTON_POSITION_LEFT) + nleft++; + if (f & WACOM_BUTTON_POSITION_RIGHT) + nright++; + } + + if (nleft > 0 || nright > 0) + return 1; + + return 0; +} + static void verify_tablet(WacomDeviceDatabase *db, WacomDevice *device) { const char *name; @@ -226,6 +249,9 @@ static void verify_tablet(WacomDeviceDatabase *db, WacomDevice *device) assert(match_mode_switch (device, libwacom_get_strips_num_modes, WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH)); if (libwacom_get_num_strips(device) > 0) assert(match_mode_switch (device, libwacom_get_strips_num_modes, WACOM_BUTTON_TOUCHSTRIP_MODESWITCH)); + + if (libwacom_is_reversible(device) && libwacom_get_num_buttons(device) > 0) + assert(tablet_has_lr_buttons(device)); } int main(int argc, char **argv) |