[systemd-devel] [PATCH] udev: input_id: tag accelerometers as ID_INPUT_ACCELEROMETER

Hans de Goede hdegoede at redhat.com
Fri Apr 3 07:19:26 PDT 2015


Hi,

On 03-04-15 15:51, David Herrmann wrote:
> Hi
>
> On Fri, Apr 3, 2015 at 12:07 PM, Hans de Goede <hdegoede at redhat.com> wrote:
>> input_id already (tries to) tag accelerometers as such, but this only works
>> for absolute accelerometers. Recent kernels mark accelerometers through an
>> input prop. Trust that prop and always tag devices with it with
>> ID_INPUT_ACCELEROMETER.
>>
>> Note that detection by the prop bit works the same as the existing detection
>> and will ensure that no other tags get set on the device.
>>
>> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
>> ---
>>   src/shared/missing.h             | 4 ++++
>>   src/udev/udev-builtin-input_id.c | 5 +++++
>>   2 files changed, 9 insertions(+)
>>
>> diff --git a/src/shared/missing.h b/src/shared/missing.h
>> index 3bdfd8f..4464e35 100644
>> --- a/src/shared/missing.h
>> +++ b/src/shared/missing.h
>> @@ -944,3 +944,7 @@ static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, uns
>>   #ifndef INPUT_PROP_POINTING_STICK
>>   #define INPUT_PROP_POINTING_STICK 0x05
>>   #endif
>> +
>> +#ifndef INPUT_PROP_ACCELEROMETER
>> +#define INPUT_PROP_ACCELEROMETER  0x06
>> +#endif
>> diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
>> index d4c38ca..ecfc447 100644
>> --- a/src/udev/udev-builtin-input_id.c
>> +++ b/src/udev/udev-builtin-input_id.c
>> @@ -136,6 +136,11 @@ static void test_pointers (struct udev_device *dev,
>>           int is_mouse = 0;
>>           int is_touchpad = 0;
>>
>> +        if (test_bit (INPUT_PROP_ACCELEROMETER, bitmask_props)) {
>> +                udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", "1");
>> +                return;
>> +        }
>> +
>
> So this property is only set for accelerometer-only devices?

Hmm, good question. Currently I see only one user of it in the kernel:

drivers/hid/wacom_wac.c

Which most likely does not count as an accelerometer only device, so maybe
my idea to follow the existing accelerometer detection code and short-circuit
the other tests was not such a good idea.

Benjamin, do you have any input on this ?

Regards,

Hans


More information about the systemd-devel mailing list