* [patch] pvfb: Split mouse and keyboard into separate devices.
@ 2007-02-01 10:59 Gerd Hoffmann
2007-02-01 13:15 ` Markus Armbruster
2007-02-01 17:37 ` Markus Armbruster
0 siblings, 2 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2007-02-01 10:59 UTC (permalink / raw)
To: Xen devel list; +Cc: Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
Hi,
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.
please apply,
Gerd
--
Gerd Hoffmann <kraxel@suse.de>
[-- Attachment #2: fix-xenkbd.diff --]
[-- Type: text/x-patch, Size: 4826 bytes --]
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@suse.de>
Cc: Markus Armbruster <armbru@redhat.com>
---
linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c | 60 +++++++++++++---------
1 file changed, 38 insertions(+), 22 deletions(-)
Index: build-64-unstable-13762/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
===================================================================
--- build-64-unstable-13762.orig/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
+++ build-64-unstable-13762/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
@@ -29,7 +29,8 @@
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;
@@ -60,19 +61,21 @@ static irqreturn_t input_handler(int rq,
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(info->ptr, REL_X, event->motion.rel_x);
+ input_report_rel(info->ptr, REL_Y, event->motion.rel_y);
+ input_sync(info->ptr);
break;
case XENKBD_TYPE_KEY:
- input_report_key(info->dev, event->key.keycode, event->key.pressed);
+ input_report_key(info->kbd, event->key.keycode, event->key.pressed);
+ input_sync(info->kbd);
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(info->ptr, ABS_X, event->pos.abs_x);
+ input_report_abs(info->ptr, ABS_Y, event->pos.abs_y);
+ input_sync(info->ptr);
break;
}
}
- input_sync(info->dev);
mb(); /* ensure we got ring contents */
page->in_cons = cons;
notify_remote_via_irq(info->irq);
@@ -85,7 +88,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) {
@@ -101,32 +104,44 @@ 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)
+ kbd = input_allocate_device();
+ ptr = input_allocate_device();
+ if (!kbd || !ptr)
goto error_nomem;
- input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
- input_dev->keybit[LONG(BTN_MOUSE)]
+ ptr->evbit[0] = BIT(EV_REL) | BIT(EV_ABS);
+ ptr->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);
+ ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+ 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";
+ kbd->name = "Xen Virtual Keyboard";
+ ptr->name = "Xen Virtual Touchscreen";
- 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);
+ 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(kbd);
if (ret) {
- input_free_device(input_dev);
- xenbus_dev_fatal(dev, ret, "input_register_device");
+ input_free_device(kbd);
+ input_free_device(ptr);
+ xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
goto error;
}
- info->dev = input_dev;
+ info->kbd = kbd;
+
+ ret = input_register_device(ptr);
+ if (ret) {
+ input_free_device(ptr);
+ xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
+ goto error;
+ }
+ info->ptr = ptr;
ret = xenkbd_connect_backend(dev, info);
if (ret < 0)
@@ -155,7 +170,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;
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] pvfb: Split mouse and keyboard into separate devices.
2007-02-01 10:59 Gerd Hoffmann
@ 2007-02-01 13:15 ` Markus Armbruster
2007-02-01 13:47 ` Gerd Hoffmann
2007-02-01 17:37 ` Markus Armbruster
1 sibling, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2007-02-01 13:15 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen devel list
Gerd Hoffmann <kraxel@suse.de> writes:
> Hi,
>
> 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.
Review below.
I'll leave judging whether this is a good idea to those who know more
about X than I do.
> please apply,
> Gerd
>
> --
> Gerd Hoffmann <kraxel@suse.de>
[...]
> ---
> linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c | 60 +++++++++++++---------
> 1 file changed, 38 insertions(+), 22 deletions(-)
>
> Index: build-64-unstable-13762/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
> ===================================================================
> --- build-64-unstable-13762.orig/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
> +++ build-64-unstable-13762/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
> @@ -29,7 +29,8 @@
>
> 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;
> @@ -60,19 +61,21 @@ static irqreturn_t input_handler(int rq,
>
> 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(info->ptr, REL_X, event->motion.rel_x);
> + input_report_rel(info->ptr, REL_Y, event->motion.rel_y);
> + input_sync(info->ptr);
> break;
> case XENKBD_TYPE_KEY:
> - input_report_key(info->dev, event->key.keycode, event->key.pressed);
> + input_report_key(info->kbd, event->key.keycode, event->key.pressed);
> + input_sync(info->kbd);
> 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(info->ptr, ABS_X, event->pos.abs_x);
> + input_report_abs(info->ptr, ABS_Y, event->pos.abs_y);
> + input_sync(info->ptr);
> break;
> }
> }
> - input_sync(info->dev);
> mb(); /* ensure we got ring contents */
> page->in_cons = cons;
> notify_remote_via_irq(info->irq);
> @@ -85,7 +88,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) {
> @@ -101,32 +104,44 @@ 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)
> + kbd = input_allocate_device();
> + ptr = input_allocate_device();
> + if (!kbd || !ptr)
> goto error_nomem;
If just one of two fails, the other is leaked, I fear.
>
> - input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
> - input_dev->keybit[LONG(BTN_MOUSE)]
> + ptr->evbit[0] = BIT(EV_REL) | BIT(EV_ABS);
> + ptr->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);
> + ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
>
> + 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";
> + kbd->name = "Xen Virtual Keyboard";
> + ptr->name = "Xen Virtual Touchscreen";
Touchscreen is going to confuse people. I'd rather call it a mouse.
Or pointing device, if need be.
>
> - 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);
> + 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(kbd);
> if (ret) {
> - input_free_device(input_dev);
> - xenbus_dev_fatal(dev, ret, "input_register_device");
> + input_free_device(kbd);
> + input_free_device(ptr);
> + xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
> goto error;
> }
> - info->dev = input_dev;
> + info->kbd = kbd;
> +
> + ret = input_register_device(ptr);
> + if (ret) {
> + input_free_device(ptr);
> + xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
> + goto error;
> + }
> + info->ptr = ptr;
>
> ret = xenkbd_connect_backend(dev, info);
> if (ret < 0)
It *might* be simpler to have something like
error:
if (ptr)
input_free_device(ptr);
if (kbd)
input_free_device(kbd);
> @@ -155,7 +170,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;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] pvfb: Split mouse and keyboard into separate devices.
2007-02-01 13:15 ` Markus Armbruster
@ 2007-02-01 13:47 ` Gerd Hoffmann
0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2007-02-01 13:47 UTC (permalink / raw)
To: Markus Armbruster; +Cc: Xen devel list
[-- Attachment #1: Type: text/plain, Size: 650 bytes --]
Markus Armbruster wrote:
> Review below.
>> + kbd = input_allocate_device();
>> + ptr = input_allocate_device();
>> + if (!kbd || !ptr)
>> goto error_nomem;
>
> If just one of two fails, the other is leaked, I fear.
Yep, you are right, fixed version attached.
> It *might* be simpler to have something like
>
> error:
> if (ptr)
> input_free_device(ptr);
> if (kbd)
> input_free_device(kbd);
I don't think it would simplify the code because you'll have to take
care then that the xenkbd_remove() call in the error path doesn't result
in a double-free ...
cheers,
Gerd
--
Gerd Hoffmann <kraxel@suse.de>
[-- Attachment #2: fix-xenkbd.diff --]
[-- Type: text/x-patch, Size: 5063 bytes --]
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@suse.de>
Cc: Markus Armbruster <armbru@redhat.com>
---
linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c | 64 ++++++++++++++--------
1 file changed, 42 insertions(+), 22 deletions(-)
Index: build-64-unstable-13762/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
===================================================================
--- build-64-unstable-13762.orig/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
+++ build-64-unstable-13762/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
@@ -29,7 +29,8 @@
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;
@@ -60,19 +61,21 @@ static irqreturn_t input_handler(int rq,
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(info->ptr, REL_X, event->motion.rel_x);
+ input_report_rel(info->ptr, REL_Y, event->motion.rel_y);
+ input_sync(info->ptr);
break;
case XENKBD_TYPE_KEY:
- input_report_key(info->dev, event->key.keycode, event->key.pressed);
+ input_report_key(info->kbd, event->key.keycode, event->key.pressed);
+ input_sync(info->kbd);
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(info->ptr, ABS_X, event->pos.abs_x);
+ input_report_abs(info->ptr, ABS_Y, event->pos.abs_y);
+ input_sync(info->ptr);
break;
}
}
- input_sync(info->dev);
mb(); /* ensure we got ring contents */
page->in_cons = cons;
notify_remote_via_irq(info->irq);
@@ -85,7 +88,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) {
@@ -101,32 +104,46 @@ 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)
+ kbd = input_allocate_device();
+ if (!kbd)
goto error_nomem;
+ ptr = input_allocate_device();
+ if (!ptr)
+ goto error_nomem_2;
- input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
- input_dev->keybit[LONG(BTN_MOUSE)]
+ ptr->evbit[0] = BIT(EV_REL) | BIT(EV_ABS);
+ ptr->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);
+ ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+ 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";
+ kbd->name = "Xen Virtual Keyboard";
+ ptr->name = "Xen Virtual Touchscreen";
- 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);
+ 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(kbd);
if (ret) {
- input_free_device(input_dev);
- xenbus_dev_fatal(dev, ret, "input_register_device");
+ input_free_device(kbd);
+ input_free_device(ptr);
+ xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
goto error;
}
- info->dev = input_dev;
+ info->kbd = kbd;
+
+ ret = input_register_device(ptr);
+ if (ret) {
+ input_free_device(ptr);
+ xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
+ goto error;
+ }
+ info->ptr = ptr;
ret = xenkbd_connect_backend(dev, info);
if (ret < 0)
@@ -134,6 +151,8 @@ int __devinit xenkbd_probe(struct xenbus
return 0;
+ error_nomem_2:
+ input_free_device(kbd);
error_nomem:
ret = -ENOMEM;
xenbus_dev_fatal(dev, ret, "allocating device memory");
@@ -155,7 +174,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;
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] pvfb: Split mouse and keyboard into separate devices.
2007-02-01 10:59 Gerd Hoffmann
2007-02-01 13:15 ` Markus Armbruster
@ 2007-02-01 17:37 ` Markus Armbruster
1 sibling, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2007-02-01 17:37 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen devel list
Gerd Hoffmann <kraxel@suse.de> writes:
> Hi,
>
> 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.
>
> please apply,
I tried it out. With the configuration sketched above, I get a
working keyboard and mouse, and the mouse behaves much better than
before. However, with the default configuration, the mouse doesn't
work at all.
The drawbacks of just applying the patch are obvious, I think.
Gerd, any ideas how to make X recognize the split devices
automatically?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch] pvfb: Split mouse and keyboard into separate devices.
@ 2007-02-07 11:31 Gerd Hoffmann
2007-02-07 14:31 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2007-02-07 11:31 UTC (permalink / raw)
To: Xen devel list; +Cc: Daniel P. Berrange, Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
Hi,
This patch creates two separate input devices for keyboard and mouse
events. Also includes some key bitmap fixes (allow all keyboard keys,
allow eight mouse buttons).
I hope everyone is happy with that now after the lengthy discussion ;)
please apply,
Gerd
--
Gerd Hoffmann <kraxel@suse.de>
[-- Attachment #2: fix-xenkbd.diff --]
[-- Type: text/x-patch, Size: 6006 bytes --]
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"
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, at least
with older Xorg (6.9) versions.
Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
---
linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c | 93 +++++++++++++++-------
1 file changed, 65 insertions(+), 28 deletions(-)
Index: build-32-unstable-13816/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
===================================================================
--- build-32-unstable-13816.orig/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
+++ build-32-unstable-13816/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,36 @@ 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);
+ dev = NULL;
+ if (test_bit(event->key.keycode, info->kbd->keybit))
+ dev = info->kbd;
+ if (test_bit(event->key.keycode, info->ptr->keybit))
+ dev = info->ptr;
+ if (dev)
+ input_report_key(dev, event->key.keycode,
+ event->key.pressed);
+ else
+ printk("xenkbd: unhandled keycode 0x%x\n",
+ event->key.keycode);
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;
}
+ if (dev)
+ 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 +100,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 +109,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 +117,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;
+ 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);
+ for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
+ set_bit(i, kbd->keybit);
+ for (i = KEY_OK; i < KEY_MAX; i++)
+ set_bit(i, kbd->keybit);
- 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);
-
- /* FIXME not sure this is quite right */
- for (i = 0; i < 256; i++)
- set_bit(i, input_dev->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);
+ for (i = BTN_LEFT; i <= BTN_TASK; i++)
+ set_bit(i, ptr->keybit);
+ 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 +191,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;
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] pvfb: Split mouse and keyboard into separate devices.
2007-02-07 11:31 [patch] pvfb: Split mouse and keyboard into separate devices Gerd Hoffmann
@ 2007-02-07 14:31 ` Markus Armbruster
2007-02-07 14:36 ` Daniel P. Berrange
0 siblings, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2007-02-07 14:31 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Xen devel list, Daniel P. Berrange
Gerd Hoffmann <kraxel@suse.de> writes:
> Hi,
>
> This patch creates two separate input devices for keyboard and mouse
> events. Also includes some key bitmap fixes (allow all keyboard keys,
> allow eight mouse buttons).
>
> I hope everyone is happy with that now after the lengthy discussion ;)
>
> please apply,
> Gerd
>
> --
> Gerd Hoffmann <kraxel@suse.de>
> 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"
> 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, at least
> with older Xorg (6.9) versions.
>
> Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
New, not mentioned in the changelog:
* Initialization of struct input_dev members phys, id.bustype,
id.vendor, id.product.
* Take care of the FIXME regarding initialization struct input_dev
member keybit (thanks!).
* Take care of the TODO to enable all pointer buttons. Perhaps should
better go in together with the fix to tools/xenfb/vncfb.c posted by
Daniel.
No objections to any of these. They ought to be documented in the
changelog, though. You might prefer separate changesets for some of
them.
> ---
> linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c | 93 +++++++++++++++-------
> 1 file changed, 65 insertions(+), 28 deletions(-)
>
> Index: build-32-unstable-13816/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
> ===================================================================
> --- build-32-unstable-13816.orig/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
> +++
> build-32-unstable-13816/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
[...]
> @@ -56,23 +58,36 @@ 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);
> + dev = NULL;
> + if (test_bit(event->key.keycode, info->kbd->keybit))
> + dev = info->kbd;
> + if (test_bit(event->key.keycode, info->ptr->keybit))
> + dev = info->ptr;
> + if (dev)
> + input_report_key(dev, event->key.keycode,
> + event->key.pressed);
> + else
> + printk("xenkbd: unhandled keycode 0x%x\n",
> + event->key.keycode);
> 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;
> }
> + if (dev)
> + input_sync(dev);
Can !dev happen?
> }
> - input_sync(info->dev);
> mb(); /* ensure we got ring contents */
> page->in_cons = cons;
> notify_remote_via_irq(info->irq);
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] pvfb: Split mouse and keyboard into separate devices.
2007-02-07 14:31 ` Markus Armbruster
@ 2007-02-07 14:36 ` Daniel P. Berrange
0 siblings, 0 replies; 7+ messages in thread
From: Daniel P. Berrange @ 2007-02-07 14:36 UTC (permalink / raw)
To: Markus Armbruster; +Cc: Gerd Hoffmann, Xen devel list
On Wed, Feb 07, 2007 at 03:31:24PM +0100, Markus Armbruster wrote:
> Gerd Hoffmann <kraxel@suse.de> writes:
>
> > Hi,
> >
> > This patch creates two separate input devices for keyboard and mouse
> > events. Also includes some key bitmap fixes (allow all keyboard keys,
> > allow eight mouse buttons).
> >
> > I hope everyone is happy with that now after the lengthy discussion ;)
> >
> > please apply,
> > Gerd
> >
> > --
> > Gerd Hoffmann <kraxel@suse.de>
> > 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"
> > 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, at least
> > with older Xorg (6.9) versions.
> >
> > Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
>
> New, not mentioned in the changelog:
>
> * Initialization of struct input_dev members phys, id.bustype,
> id.vendor, id.product.
>
> * Take care of the FIXME regarding initialization struct input_dev
> member keybit (thanks!).
>
> * Take care of the TODO to enable all pointer buttons. Perhaps should
> better go in together with the fix to tools/xenfb/vncfb.c posted by
> Daniel.
Yep, the kernel portion of my patches are obsoleted by Gerd's updated
patch. The userspace portion still needs applying.
I've no objections to Gerd's patch being applied.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-02-07 14:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-07 11:31 [patch] pvfb: Split mouse and keyboard into separate devices Gerd Hoffmann
2007-02-07 14:31 ` Markus Armbruster
2007-02-07 14:36 ` Daniel P. Berrange
-- strict thread matches above, loose matches on Subject: below --
2007-02-01 10:59 Gerd Hoffmann
2007-02-01 13:15 ` Markus Armbruster
2007-02-01 13:47 ` Gerd Hoffmann
2007-02-01 17:37 ` Markus Armbruster
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.