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.gere...@wacom.com>
---
 test/tablet-validity.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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)
-- 
2.8.3


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to