[PATCHv2] evdev: add phys property (EVIOCGPHYS) as stable identifier

Peter Hutterer peter.hutterer at who-t.net
Tue May 4 22:40:46 PDT 2010


On Tue, May 04, 2010 at 11:40:19AM +0200, Peter Korsgaard wrote:
> xinput ids are not guaranteed to be stable between reboots (or hotplugs),
> so add a "Evdev physical" property containing the output of the
> EVIOCGPHYS ioctl as a stable identifier. This is needed to be able to
> apply device-specific parameters at runtime (E.G. touchscreen
> transformation in multi-head setups).
> 
> EVIOCGPHYS is used rather than E.G. the device node or sysfs path,
> as it is (supposed to be) unique, simple to access and the remaining
> information can be retrieved through /proc/bus/input/devices, which
> doesn't require any special privileges.
> 
> Signed-off-by: Peter Korsgaard <peter.korsgaard at barco.com>
> ---
> Changes since V1:
> Incorporated feedback from Peter:
> - Renamed property to "Evdev Physical Path"
> - Document in man page
> 

uhm, what happend to the idea of implementing this in the server and only
adding to it in the driver? Don't get me wrong, I appreciate that you fixed
up the patch but I thought we had agreed on the other approach? Did I
misunderstand this?

Cheers,
  Peter

>  include/evdev-properties.h |    3 +++
>  man/evdev.man              |    3 +++
>  src/evdev.c                |   16 ++++++++++++++--
>  3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/include/evdev-properties.h b/include/evdev-properties.h
> index 7df2876..6c30a59 100644
> --- a/include/evdev-properties.h
> +++ b/include/evdev-properties.h
> @@ -66,4 +66,7 @@
>  /* BOOL */
>  #define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap"
>  
> +/* Physical location of input device as defined by the kernel */
> +#define EVDEV_PROP_PHYSICAL "Evdev Physical Path"
> +
>  #endif
> diff --git a/man/evdev.man b/man/evdev.man
> index 49ab12c..4313204 100644
> --- a/man/evdev.man
> +++ b/man/evdev.man
> @@ -226,6 +226,9 @@ value.
>  .TP 7
>  .BI "Evdev Wheel Emulation Timeout"
>  1 16-bit positive value.
> +.TP 7
> +.BI "Evdev Physical Path"
> +1 string. Output of EVIOCGPHYS ioctl for device (readonly).
>  
>  .SH AUTHORS
>  Kristian Høgsberg.
> diff --git a/src/evdev.c b/src/evdev.c
> index 6d16611..4144108 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -119,6 +119,7 @@ static Atom prop_calibration = 0;
>  static Atom prop_swap = 0;
>  static Atom prop_axis_label = 0;
>  static Atom prop_btn_label = 0;
> +static Atom prop_phys = 0;
>  #endif
>  
>  /* All devices the evdev driver has allocated and knows about.
> @@ -2463,6 +2464,17 @@ EvdevInitProperty(DeviceIntPtr dev)
>      EvdevPtr     pEvdev = pInfo->private;
>      int          rc;
>      BOOL         invert[2];
> +    char         phys[256];
> +
> +    if (ioctl(pInfo->fd, EVIOCGPHYS(sizeof(phys) - 1), phys) >= 0)
> +    {
> +        prop_phys = MakeAtom(EVDEV_PROP_PHYSICAL,
> +                             strlen(EVDEV_PROP_PHYSICAL), TRUE);
> +        rc = XIChangeDeviceProperty(dev, prop_phys, XA_STRING, 8,
> +                                    PropModeReplace, strlen(phys), phys, FALSE);
> +        if (rc != Success)
> +            return;
> +    }
>  
>      if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS))
>      {
> @@ -2571,8 +2583,8 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
>  
>          if (!checkonly)
>              pEvdev->swap_axes = *((BOOL*)val->data);
> -    } else if (atom == prop_axis_label || atom == prop_btn_label)
> -        return BadAccess; /* Axis/Button labels can't be changed */
> +    } else if (atom == prop_axis_label || atom == prop_btn_label || atom == prop_phys)
> +        return BadAccess; /* Axis/Button labels + phys can't be changed */
>  
>      return Success;
>  }
> -- 
> 1.7.0
> 


More information about the xorg-devel mailing list