WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: [patch] pvfb: Split mouse and keyboard into separate

To: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [patch] pvfb: Split mouse and keyboard into separate devices.
From: Gerd Hoffmann <kraxel@xxxxxxx>
Date: Mon, 05 Feb 2007 15:19:29 +0100
Cc: Xen devel list <xen-devel@xxxxxxxxxxxxxxxxxxx>, Markus Armbruster <armbru@xxxxxxxxxx>
Delivery-date: Mon, 05 Feb 2007 06:20:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20070203035103.GA15384@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <45C36705.5080600@xxxxxxx> <C1E92F6A.8CB6%Keir.Fraser@xxxxxxxxxxxx> <20070203002825.GH18218@xxxxxxxxxx> <20070203035103.GA15384@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.9 (X11/20060911)
Daniel P. Berrange wrote:
>   Section "InputDevice"
>         Identifier  "XenInput0"
>         Driver      "evdev"
>         Option      "CorePointer"
>         Option      "SendCoreEvents"
>         Option      "Device" "/dev/input/event0"
>         Option      "XkbModel" "pc105"
>         Option      "XkbLayout" "us"
>   EndSection

That doesn't work with older Xorg (aka evdev driver) versions ...

I've attached a newer version of the patch, also my xorg.conf config
file (for Xorg 7.2+).  It is possible to match capability bits in the
config file.  Using this it is easy to make Xorg use evdev for pointing
devices which deliver absolute coordinates.

cheers,
  Gerd

-- 
Gerd Hoffmann <kraxel@xxxxxxx>
pvfb: Split mouse and keyboard into separate devices.

This patch creates two separate input devices for keyboard and mouse
events.  The reason for this is to separate them in the linux input
layer and allow them being routed different ways.

Use case:  Configure the X-Server like this to get the mouse
events directly from the linux input layer, which has the major
advantage that absolute coordinates work correctly:

Section "InputDevice"
  Driver       "evdev"
  Identifier   "Mouse[1]"
  Option       "Device" "/dev/input/event<nr>"
EndSection

This makes the keyboard stop working though in case mouse and
keyboard events are coming through the same input device.

Signed-off-by: Gerd Hoffmann <kraxel@xxxxxxx>
Cc: Markus Armbruster <armbru@xxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c |   80 ++++++++++++++--------
 1 file changed, 54 insertions(+), 26 deletions(-)

Index: build-32-unstable-13800/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
===================================================================
--- 
build-32-unstable-13800.orig/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
+++ build-32-unstable-13800/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
@@ -29,10 +29,12 @@
 
 struct xenkbd_info
 {
-       struct input_dev *dev;
+       struct input_dev *kbd;
+       struct input_dev *ptr;
        struct xenkbd_page *page;
        int irq;
        struct xenbus_device *xbdev;
+       char phys[32];
 };
 
 static int xenkbd_remove(struct xenbus_device *);
@@ -56,23 +58,27 @@ static irqreturn_t input_handler(int rq,
        rmb();                  /* ensure we see ring contents up to prod */
        for (cons = page->in_cons; cons != prod; cons++) {
                union xenkbd_in_event *event;
+               struct input_dev *dev;
                event = &XENKBD_IN_RING_REF(page, cons);
 
+               dev = info->ptr;
                switch (event->type) {
                case XENKBD_TYPE_MOTION:
-                       input_report_rel(info->dev, REL_X, event->motion.rel_x);
-                       input_report_rel(info->dev, REL_Y, event->motion.rel_y);
+                       input_report_rel(dev, REL_X, event->motion.rel_x);
+                       input_report_rel(dev, REL_Y, event->motion.rel_y);
                        break;
                case XENKBD_TYPE_KEY:
-                       input_report_key(info->dev, event->key.keycode, 
event->key.pressed);
+                       if (test_bit(event->key.keycode, info->kbd->keybit))
+                               dev = info->kbd;
+                       input_report_key(dev, event->key.keycode, 
event->key.pressed);
                        break;
                case XENKBD_TYPE_POS:
-                       input_report_abs(info->dev, ABS_X, event->pos.abs_x);
-                       input_report_abs(info->dev, ABS_Y, event->pos.abs_y);
+                       input_report_abs(dev, ABS_X, event->pos.abs_x);
+                       input_report_abs(dev, ABS_Y, event->pos.abs_y);
                        break;
                }
+               input_sync(dev);
        }
-       input_sync(info->dev);
        mb();                   /* ensure we got ring contents */
        page->in_cons = cons;
        notify_remote_via_irq(info->irq);
@@ -85,7 +91,7 @@ int __devinit xenkbd_probe(struct xenbus
 {
        int ret, i;
        struct xenkbd_info *info;
-       struct input_dev *input_dev;
+       struct input_dev *kbd, *ptr;
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {
@@ -94,6 +100,7 @@ int __devinit xenkbd_probe(struct xenbus
        }
        dev->dev.driver_data = info;
        info->xbdev = dev;
+       snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename);
 
        info->page = (void *)__get_free_page(GFP_KERNEL);
        if (!info->page)
@@ -101,32 +108,52 @@ int __devinit xenkbd_probe(struct xenbus
        info->page->in_cons = info->page->in_prod = 0;
        info->page->out_cons = info->page->out_prod = 0;
 
-       input_dev = input_allocate_device();
-       if (!input_dev)
+       /* keyboard */
+       kbd = input_allocate_device();
+       if (!kbd)
                goto error_nomem;
-
-       input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
-       input_dev->keybit[LONG(BTN_MOUSE)]
-               = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
-       /* TODO additional buttons */
-       input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
-
+       kbd->name = "Xen Virtual Keyboard";
+       kbd->phys = info->phys;
+       kbd->id.bustype = BUS_PCI;
+       kbd->id.vendor = 0x5853;
+       kbd->id.product = 0x2;
+       kbd->evbit[0] = BIT(EV_KEY);
        /* FIXME not sure this is quite right */
        for (i = 0; i < 256; i++)
-               set_bit(i, input_dev->keybit);
+               set_bit(i, kbd->keybit);
 
-       input_dev->name = "Xen Virtual Keyboard/Mouse";
+       ret = input_register_device(kbd);
+       if (ret) {
+               input_free_device(kbd);
+               xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
+               goto error;
+       }
+       info->kbd = kbd;
 
-       input_set_abs_params(input_dev, ABS_X, 0, XENFB_WIDTH, 0, 0);
-       input_set_abs_params(input_dev, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
+       /* pointing device */
+       ptr = input_allocate_device();
+       if (!ptr)
+               goto error_nomem;
+       ptr->name = "Xen Virtual Pointer";
+       ptr->phys = info->phys;
+       ptr->id.bustype = BUS_PCI;
+       ptr->id.vendor = 0x5853;
+       ptr->id.product = 0x3;
+       ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
+       ptr->keybit[LONG(BTN_MOUSE)]
+               = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+       /* TODO additional buttons */
+       ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+       input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
+       input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
 
-       ret = input_register_device(input_dev);
+       ret = input_register_device(ptr);
        if (ret) {
-               input_free_device(input_dev);
-               xenbus_dev_fatal(dev, ret, "input_register_device");
+               input_free_device(ptr);
+               xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
                goto error;
        }
-       info->dev = input_dev;
+       info->ptr = ptr;
 
        ret = xenkbd_connect_backend(dev, info);
        if (ret < 0)
@@ -155,7 +182,8 @@ static int xenkbd_remove(struct xenbus_d
        struct xenkbd_info *info = dev->dev.driver_data;
 
        xenkbd_disconnect_backend(info);
-       input_unregister_device(info->dev);
+       input_unregister_device(info->kbd);
+       input_unregister_device(info->ptr);
        free_page((unsigned long)info->page);
        kfree(info);
        return 0;
# xorg 7.2+ config file, fbdev

# default keyboard
Section "InputDevice"
  Driver        "kbd"
  Identifier    "Keyboard"
  Option        "XkbModel"      "pc105"
  Option        "XkbLayout"     "us"
EndSection

# default mouse
Section "InputDevice"
  Driver        "mouse"
  Identifier    "Mouse"
  Option        "Device"        "/dev/input/mice"
EndSection

# pointing device sending absolute x/y coordinates,
# works much better with evdev driver.
Section "InputDevice"
  Driver        "evdev"
  Identifier    "AbsPtr"
  Option        "SendCoreEvents" "true"
  Option        "evBits"        "+1 +3"         # ev_key, ev_abs
  Option        "keyBits"       "~256-287"      # btn_*
  Option        "absBits"       "+0 +1"         # abs_x, abs_y
EndSection

Section "Screen"
  Device        "fbdev"
  Identifier    "fbdev"
EndSection

Section "Device"
  Driver        "fbdev"
  Identifier    "fbdev"
EndSection

Section "ServerLayout"
  Identifier    "default"
  Screen        "fbdev"
  InputDevice   "Keyboard"      "CoreKeyboard"
  InputDevice   "Mouse"         "CorePointer"
  InputDevice   "AbsPtr"
EndSection

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>