Hi, Sorry for the late review. See in-line comments: On Jun 30, 2016, at 7:02 PM, David Lawrie <david.dljunk(a)gmail.com> wrote:
+static void get_device_property_long(IOHIDDeviceRef in_device, CFStringRef in_key, long * out_value)
As Dmitry suggested, you could make this simply return the property value rather than provide it through the indirect output parameter.
+{ + Boolean result = FALSE;
This variable isn't really used. It's assigned, but never read.
+ CFTypeRef type;
This variable isn't holding a type, it's holding a value or, if you prefer, an object reference. (The fact that its type is "CFTypeRef" doesn't imply it holds a type. Frankly, "CFTypeRef" is also a lousy name, but that's on Apple.)
+ + if (in_device) + { + assert(IOHIDDeviceGetTypeID() == CFGetTypeID(in_device)); + + type = IOHIDDeviceGetProperty(in_device, in_key); + + if (type) + { + if (CFNumberGetTypeID() == CFGetTypeID(type))
You could combine these two "if" statements using &&. -Ken