Re: [Linuxwacom-devel] [PATCH v2] Make sibling device name matching slightly more lenient

2017-02-12 Thread Peter Hutterer
On Fri, Feb 10, 2017 at 09:53:01PM -0800, Ping Cheng wrote:
> The wcmIsSiblingDevice function uses several tricks to try and determine
> if two devices should be considered siblings. If its 'logical_only'
> parameter is false, this includes comparing device names. Device name
> comparison is complicated by the fact that suffixes are added on by
> the X and kernel drivers. To deal with this, the wcmSplitName function
> tries to split a device name into three pieces: its "basename" that
> describes the model, its "subdevice" name that describes the interface,
> and its "tool" name which describes the X11 tool.
> 
> Spliting the name is a somewhat kludgy process which does not properly
> handle the device names for the MobileStudio Pro or Cintiq Pro. The
> kernel reads the name of these devices directly from the hardware's
> descriptors, and the names are slightly different between the pen and
> touch interfaces (the touch device has an extra "Touch" suffix).
> 
> This patch tweaks how wcmSplitName breaks apart device names in order
> to handle the MobileStudio Pro and Cintiq Pro. Specifically, it now
> allows the "subdevice" to contain an arbitrary number of "Pen", "Finger",
> :Touch", or "Pad" suffixes. For the MobileStudio Pro and Cintiq Pro,
> this should allow the "basename" that is considered for sibling device
> matches to be identical between both the pen and touch interfaces.
> 
> Signed-off-by: Jason Gerecke 
> Signed-off-by: Ping Cheng 
> ---
> v2: split a long if statement into two lines, as per Peter's suggestion.

pushed, thanks

Cheers,
   Peter

> ---
>  src/wcmConfig.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/src/wcmConfig.c b/src/wcmConfig.c
> index 27c686f..0924c43 100644
> --- a/src/wcmConfig.c
> +++ b/src/wcmConfig.c
> @@ -320,10 +320,19 @@ static void wcmSplitName(char* devicename, char 
> *basename, char *subdevice, char
>   {
>   *a = '\0';
>   b = strrchr(name, ' ');
> - if (b && (!strcmp(b, " Pen") || !strcmp(b, " Finger") || 
> !strcmp(b, " Pad")))
> +
> + while (b)
>   {
> - *b = '\0';
> - strncat(subdevice, b+1, len-1);
> + if (!strcmp(b, " Pen") || !strcmp(b, " Finger") ||
> + !strcmp(b, " Pad") || !strcmp(b, " Touch"))
> + {
> + *b = '\0';
> + strncpy(subdevice, b+1, len-1);
> + subdevice[len-1] = '\0';
> + b = strrchr(name, ' ');
> + }
> + else
> + b = NULL;
>   }
>   strncat(tool, a+1, len-1);
>   }
> -- 
> 1.8.3.1
> 

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH v2] Make sibling device name matching slightly more lenient

2017-02-10 Thread Ping Cheng
The wcmIsSiblingDevice function uses several tricks to try and determine
if two devices should be considered siblings. If its 'logical_only'
parameter is false, this includes comparing device names. Device name
comparison is complicated by the fact that suffixes are added on by
the X and kernel drivers. To deal with this, the wcmSplitName function
tries to split a device name into three pieces: its "basename" that
describes the model, its "subdevice" name that describes the interface,
and its "tool" name which describes the X11 tool.

Spliting the name is a somewhat kludgy process which does not properly
handle the device names for the MobileStudio Pro or Cintiq Pro. The
kernel reads the name of these devices directly from the hardware's
descriptors, and the names are slightly different between the pen and
touch interfaces (the touch device has an extra "Touch" suffix).

This patch tweaks how wcmSplitName breaks apart device names in order
to handle the MobileStudio Pro and Cintiq Pro. Specifically, it now
allows the "subdevice" to contain an arbitrary number of "Pen", "Finger",
:Touch", or "Pad" suffixes. For the MobileStudio Pro and Cintiq Pro,
this should allow the "basename" that is considered for sibling device
matches to be identical between both the pen and touch interfaces.

Signed-off-by: Jason Gerecke 
Signed-off-by: Ping Cheng 
---
v2: split a long if statement into two lines, as per Peter's suggestion.
---
 src/wcmConfig.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 27c686f..0924c43 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -320,10 +320,19 @@ static void wcmSplitName(char* devicename, char 
*basename, char *subdevice, char
{
*a = '\0';
b = strrchr(name, ' ');
-   if (b && (!strcmp(b, " Pen") || !strcmp(b, " Finger") || 
!strcmp(b, " Pad")))
+
+   while (b)
{
-   *b = '\0';
-   strncat(subdevice, b+1, len-1);
+   if (!strcmp(b, " Pen") || !strcmp(b, " Finger") ||
+   !strcmp(b, " Pad") || !strcmp(b, " Touch"))
+   {
+   *b = '\0';
+   strncpy(subdevice, b+1, len-1);
+   subdevice[len-1] = '\0';
+   b = strrchr(name, ' ');
+   }
+   else
+   b = NULL;
}
strncat(tool, a+1, len-1);
}
-- 
1.8.3.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel