On Fri, Dec 14, 2012 at 12:16:41PM +0100, Olivier Fourdan wrote: > >From 5fe5a58ad6eada45471e670625b60cd10b52b0be Mon Sep 17 00:00:00 2001 > From: Olivier Fourdan <ofour...@redhat.com> > Date: Fri, 14 Dec 2012 12:08:09 +0100 > Subject: [PATCH] test: check number of switches against number of modes > > Most tablets have one mode-switch button and multiple > modes, but some like the Cintiq 24HD have dedicated mode- > switch buttons. > > In this case, the number of modes must match the number of > switches otherwise client applications have no way to tell > if a button is used as a mode-switch button to cycle through > all the modes or a mode-switch button to select a given mode. > > Add this in the tablet-validity check, ie make sure that > if we have more than one mode-switch button, then the > number of modes matches the number of mode-switch buttons. > > Also checks that if more than one mode is declared, at least > one mode-switch button is found. > > Signed-off-by: Olivier Fourdan <ofour...@redhat.com>
merged, thanks. sorry missed it before the 0.7 release, so it didn't make it. Cheers, Peter > --- > test/tablet-validity.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 46 insertions(+), 0 deletions(-) > > diff --git a/test/tablet-validity.c b/test/tablet-validity.c > index 75fe265..19a4b98 100644 > --- a/test/tablet-validity.c > +++ b/test/tablet-validity.c > @@ -40,6 +40,8 @@ > #include <assert.h> > #include <unistd.h> > > +typedef int (*NumModesFn) (const WacomDevice *device); > + > static int buttons_have_direction (WacomDevice *device) > { > char button; > @@ -59,6 +61,42 @@ static int buttons_have_direction (WacomDevice *device) > return 0; > } > > +static int match_mode_switch (WacomDevice *device, NumModesFn get_num_modes, > WacomButtonFlags flag) > +{ > + char button; > + int num_buttons; > + int num_switches; > + int num_modes; > + > + num_buttons = libwacom_get_num_buttons (device); > + num_modes = get_num_modes (device); > + num_switches = 0; > + > + for (button = 'A'; button < 'A' + num_buttons; button++) { > + WacomButtonFlags flags; > + flags = libwacom_get_button_flag(device, button); > + > + if (flags & flag) > + num_switches++; > + } > + > + /* > + * If we have more than one mode-switch button, then the > + * number of modes must match the number of mode-switch buttons. > + */ > + if (num_switches > 1 && num_modes != num_switches) > + return 0; > + > + /* > + * If we have more than one mode, then we should find at least > + * one mode-switch button. > + */ > + if (num_modes > 1 && num_switches == 0) > + return 0; > + > + return 1; > +} > + > static int eraser_is_present(WacomDeviceDatabase *db, const int *styli, int > nstyli, WacomStylusType type) > { > int i; > @@ -146,6 +184,14 @@ static void verify_tablet(WacomDeviceDatabase *db, > WacomDevice *device) > assert(libwacom_get_strips_num_modes(device) >= 0); > assert(libwacom_get_bustype(device) != WBUSTYPE_UNKNOWN); > assert(buttons_have_direction(device) > 0); > + if (libwacom_has_ring(device)) > + assert(match_mode_switch (device, libwacom_get_ring_num_modes, > WACOM_BUTTON_RING_MODESWITCH)); > + if (libwacom_has_ring2(device)) > + assert(match_mode_switch (device, libwacom_get_ring2_num_modes, > WACOM_BUTTON_RING2_MODESWITCH)); > + if (libwacom_get_num_strips(device) > 1) > + 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)); > } > > int main(int argc, char **argv) > -- > 1.7.1 > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > Linuxwacom-devel mailing list > Linuxwacom-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel