[PATCH:xf86-input-keyboard] Set XI_PROP_DEVICE_NODE property to string from "Device" option

Peter Hutterer peter.hutterer at who-t.net
Mon Apr 30 18:53:21 PDT 2012


On Fri, Apr 27, 2012 at 05:53:09PM -0700, Alan Coopersmith wrote:
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>  man/kbd.man |    2 +-
>  src/kbd.c   |   19 +++++++++++++++++++
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/man/kbd.man b/man/kbd.man
> index c8d70cc..b1bd082 100644
> --- a/man/kbd.man
> +++ b/man/kbd.man
> @@ -40,7 +40,7 @@ are supported:
>  .TP 7
>  .BI "Option \*qDevice\*q \*q" string \*q
>  Specify the keyboard device.  Default: the OS's default console keyboard
> -input source.
> +input source.  Property: "Device Node" (read-only).
>  .TP 7
>  .BI "Option \*qProtocol\*q \*q" string \*q
>  Specify the keyboard protocol.  Valid protocol types include:
> diff --git a/src/kbd.c b/src/kbd.c
> index e04c340..f77bc95 100644
> --- a/src/kbd.c
> +++ b/src/kbd.c
> @@ -38,6 +38,10 @@
>  #include "xf86OSKbd.h"
>  #include "compiler.h"
>  
> +#include "exevents.h"
> +#include <X11/Xatom.h>
> +#include "xserver-properties.h"
> +
>  #include "xkbstr.h"
>  #include "xkbsrv.h"
>  
> @@ -328,6 +332,21 @@ KbdProc(DeviceIntPtr device, int what)
>                   return BadValue;
>               }
>           }
> +# ifdef XI_PROP_DEVICE_NODE
> +	 {
> +             const char *device_node =
> +                 xf86CheckStrOption(pInfo->options, "Device", NULL);
> +
> +             if (device_node)
> +             {
> +                 Atom prop_device = MakeAtom(XI_PROP_DEVICE_NODE,
> +                                             strlen(XI_PROP_DEVICE_NODE), TRUE);
> +                 XIChangeDeviceProperty(device, prop_device, XA_STRING, 8,
> +                                        PropModeReplace, strlen(device_node),
> +                                        device_node, FALSE);
> +             }
> +         }
> +# endif /* XI_PROP_DEVICE_NODE */
>  #else
>           {
>               XkbComponentNamesRec xkbnames;
> -- 
> 1.7.9.2

does this actually work? Looks like in the default configuration (without
Option "Device" set) this will always be null. don't care much about Linux
here since we don't really use it anymore but you may want to add a
xf86ReplaceStrOption() in src/sun_kbd.c:OpenKeyboard to force the option to
whatever you ended up using.

Cheers,
  Peter


More information about the xorg-devel mailing list