<div dir="ltr">New versions sent!<div><br></div><div>Cheers,</div><div>David<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 21, 2016 at 10:41 PM, Ken Thomases <span dir="ltr"><<a href="mailto:ken@codeweavers.com" target="_blank">ken@codeweavers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On Jul 20, 2016, at 2:15 AM, David Lawrie <<a href="mailto:david.dljunk@gmail.com">david.dljunk@gmail.com</a>> wrote:<br>
><br>
> +static CFStringRef copy_device_name(IOHIDDeviceRef device)<br>
> +{<br>
> +    CFTypeRef ref_name, ref_man;<br>
> +    CFStringRef name;<br>
> +    long prodID;<br>
<br>
</span>I prefer variables to be declared at the narrowest scope in which they're used.<br>
<span class=""><br>
> +<br>
> +    if (device)<br>
> +    {<br>
> +        assert(IOHIDDeviceGetTypeID() == CFGetTypeID(device));<br>
> +<br>
> +        ref_name = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));<br>
> +<br>
> +        if (ref_name && CFStringGetTypeID() == CFGetTypeID(ref_name))<br>
> +            name = CFStringCreateCopy(kCFAllocatorDefault,ref_name);<br>
> +        else<br>
> +        {<br>
> +            ref_man = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDManufacturerKey));<br>
<br>
</span>I think it's simpler to use kIOHIDVendorIDKey with get_device_property_long().  Judging by the HID Calibrator code, kIOHIDManufacturerKey is not reliably available, but kIOHIDVendorIDKey should be.  It's also pretty fundamental to USB/HID.<br>
<span class=""><br>
> +            prodID = get_device_property_long(device, CFSTR(kIOHIDProductIDKey));<br>
> +<br>
> +            if(ref_man && CFStringGetTypeID() == CFGetTypeID(ref_man))<br>
> +                name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ %lu"), ref_man, prodID);<br>
<br>
</span>Better to format vendor and product IDs using "0x%04lx" since that's how they are usually represented (e.g. within HID Calibrator windows and System Profiler).  (Yes, I realize that Copy_DeviceName() which I cited previously formats them as decimal.)<br>
<br>
Thanks for persevering in the face of my picky-ness. :)<br></blockquote><div><br></div><div>:) </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-Ken<br>
<br>
</font></span></blockquote></div><br></div></div></div>