PVFB wheel events (z-axis)
I got questions on this changeset:
changeset: 354:c3ff0b26f664
date: Mon Dec 10 13:52:47 2007 +0000
Decode mouse event packet dz value and passes it as a wheel event into
the input stream.
Signed-off-by: Pat Campbell <[email protected]>
diff -r 7232a025140f -r c3ff0b26f664 drivers/xen/fbfront/xenkbd.c
--- a/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:51:57 2007 +0000
+++ b/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:52:47 2007 +0000
@@ -64,8 +64,13 @@ static irqreturn_t input_handler(int rq,
dev = info->ptr;
switch (event->type) {
case XENKBD_TYPE_MOTION:
- input_report_rel(dev, REL_X, event->motion.rel_x);
- input_report_rel(dev, REL_Y, event->motion.rel_y);
+ if ( event->motion.rel_z == 1 || event->motion.rel_z == -1 ) {
+ input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z);
+ }
+ else {
+ input_report_rel(dev, REL_X, event->motion.rel_x);
+ input_report_rel(dev, REL_Y, event->motion.rel_y);
+ }I don't understand the conditional. Why is rel_z to be used *only* when it's 1 or -1, and why are rel_x and rel_y to be used *only* when rel_z isn't? That sure is a weird protocol, and it isn't documented anywhere...
break;
case XENKBD_TYPE_KEY:
dev = NULL;
@@ -81,8 +86,13 @@ static irqreturn_t input_handler(int rq,
event->key.keycode);
break;
case XENKBD_TYPE_POS:
- input_report_abs(dev, ABS_X, event->pos.abs_x);
- input_report_abs(dev, ABS_Y, event->pos.abs_y);
+ if ( event->pos.abs_z == 1 || event->pos.abs_z == -1 ) {
+ input_report_rel(dev, REL_WHEEL, 0 - event->pos.abs_z);
+ }
+ else {
+ input_report_abs(dev, ABS_X, event->pos.abs_x);
+ input_report_abs(dev, ABS_Y, event->pos.abs_y);
+ }And why isn't this using REL_ABS?
break;
}
if (dev)
@@ -152,7 +162,7 @@ int __devinit xenkbd_probe(struct xenbus
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);
+ ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);Quoted 27 lines · Markus Armbruster
I got questions on this changeset:
changeset: 354:c3ff0b26f664 date: Mon Dec 10 13:52:47 2007 +0000 Decode mouse event packet dz value and passes it as a wheel event into the input stream. Signed-off-by: Pat Campbell <[email protected]> diff -r 7232a025140f -r c3ff0b26f664 drivers/xen/fbfront/xenkbd.c --- a/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:51:57 2007 +0000 +++ b/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:52:47 2007 +0000 @@ -64,8 +64,13 @@ static irqreturn_t input_handler(int rq, dev = info->ptr; switch (event->type) { case XENKBD_TYPE_MOTION: - input_report_rel(dev, REL_X, event->motion.rel_x); - input_report_rel(dev, REL_Y, event->motion.rel_y); + if ( event->motion.rel_z == 1 || event->motion.rel_z == -1 ) { + input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z); + } + else { + input_report_rel(dev, REL_X, event->motion.rel_x); + input_report_rel(dev, REL_Y, event->motion.rel_y); + }
Quoted 5 lines
I don't understand the conditional. Why is
rel_zto be used *only* when it's 1 or -1, and why arerel_xandrel_yto be used *only* whenrel_zisn't? That sure is a weird protocol, and it isn't documented anywhere...
In my testing I never saw a case where the rel_x and rel_y were not zero
or the abs_x and abs_y changed when a z event came thru. A small
attempt to not flood the input stream with redundant data. Probably for clarity should have been: (same for the abs case)
if (event->motion.rel_z != 0)
input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z);
input_report_rel(dev, REL_X, event->motion.rel_x); input_report_rel(dev, REL_Y, event->motion.rel_y);
Quoted 17 lines
break;
case XENKBD_TYPE_KEY:
dev = NULL;
@@ -81,8 +86,13 @@ static irqreturn_t input_handler(int rq,
event->key.keycode);
break;
case XENKBD_TYPE_POS:
- input_report_abs(dev, ABS_X, event->pos.abs_x);
- input_report_abs(dev, ABS_Y, event->pos.abs_y);
+ if ( event->pos.abs_z == 1 || event->pos.abs_z == -1 ) {
+ input_report_rel(dev, REL_WHEEL, 0 - event->pos.abs_z);
+ }
+ else {
+ input_report_abs(dev, ABS_X, event->pos.abs_x);
+ input_report_abs(dev, ABS_Y, event->pos.abs_y);
+ }Quoted 2 lines
And why isn't this using
REL_ABS?
I assume you meant to ask why not ABS_WHEEL. Xorg 6.9 evdev driver does not decode ABS_WHEEL. Xorg 7.3 decodes both REL and ABS WHEEL butABS_WHEEL requires extra xorg.conf input options. We get greater
coverage by using REL_WHEEL and reduce the need to edit xorg.conf.
Quoted 13 lines
break;
}
if (dev)
@@ -152,7 +162,7 @@ int __devinit xenkbd_probe(struct xenbus
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);
+ ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);Quoted 28 lines · Pat Campbell
Quoted 27 lines · Markus Armbruster
I got questions on this changeset:
changeset: 354:c3ff0b26f664 date: Mon Dec 10 13:52:47 2007 +0000 Decode mouse event packet dz value and passes it as a wheel event into the input stream. Signed-off-by: Pat Campbell <[email protected]> diff -r 7232a025140f -r c3ff0b26f664 drivers/xen/fbfront/xenkbd.c --- a/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:51:57 2007 +0000 +++ b/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:52:47 2007 +0000 @@ -64,8 +64,13 @@ static irqreturn_t input_handler(int rq, dev = info->ptr; switch (event->type) { case XENKBD_TYPE_MOTION: - input_report_rel(dev, REL_X, event->motion.rel_x); - input_report_rel(dev, REL_Y, event->motion.rel_y); + if ( event->motion.rel_z == 1 || event->motion.rel_z == -1 ) { + input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z); + } + else { + input_report_rel(dev, REL_X, event->motion.rel_x); + input_report_rel(dev, REL_Y, event->motion.rel_y); + }
Quoted 8 lines
Quoted 5 lines
I don't understand the conditional. Why is
rel_zto be used *only* when it's 1 or -1, and why arerel_xandrel_yto be used *only* whenrel_zisn't? That sure is a weird protocol, and it isn't documented anywhere...In my testing I never saw a case where the
rel_xandrel_ywere not zero
or theabs_xandabs_ychanged when a z event came thru. A small
attempt to not flood the input stream with redundant data.
Assuming conditions you observed in your tests will hold elsehwere in space or time is calling for trouble :)
Quoted 5 lines
Probably for clarity should have been: (same for the abs case)
if (event->motion.rel_z!= 0)input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z); input_report_rel(dev, REL_X, event->motion.rel_x); input_report_rel(dev, REL_Y, event->motion.rel_y);
Why use REL_WHEEL and not REL_Z?
Why suppress zero Z-axis motion, but not X/Y-axis?
Quoted 17 lines
Quoted 17 lines
break; case XENKBD_TYPE_KEY: dev = NULL; @@ -81,8 +86,13 @@ static irqreturn_t input_handler(int rq, event->key.keycode); break; case XENKBD_TYPE_POS: - input_report_abs(dev, ABS_X, event->pos.abs_x); - input_report_abs(dev, ABS_Y, event->pos.abs_y); + if ( event->pos.abs_z == 1 || event->pos.abs_z == -1 ) { + input_report_rel(dev, REL_WHEEL, 0 - event->pos.abs_z); + } + else { + input_report_abs(dev, ABS_X, event->pos.abs_x); + input_report_abs(dev, ABS_Y, event->pos.abs_y); + }
Quoted 3 lines
Quoted 2 lines
And why isn't this using
REL_ABS?I assume you meant to ask why not
ABS_WHEEL. Xorg 6.9 evdev driver does
Yes.
Quoted 3 lines
not decode
ABS_WHEEL. Xorg 7.3 decodes both REL and ABS WHEEL butABS_WHEELrequires extra xorg.conf input options. We get greater
coverage by usingREL_WHEELand reduce the need to edit xorg.conf.
Okay, that's fair.
[...]
Quoted 47 lines · Markus Armbruster
Quoted 35 lines · Pat Campbell
Quoted 27 lines · Markus Armbruster
I got questions on this changeset:
changeset: 354:c3ff0b26f664 date: Mon Dec 10 13:52:47 2007 +0000 Decode mouse event packet dz value and passes it as a wheel event into the input stream. Signed-off-by: Pat Campbell <[email protected]> diff -r 7232a025140f -r c3ff0b26f664 drivers/xen/fbfront/xenkbd.c --- a/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:51:57 2007 +0000 +++ b/drivers/xen/fbfront/xenkbd.c Mon Dec 10 13:52:47 2007 +0000 @@ -64,8 +64,13 @@ static irqreturn_t input_handler(int rq, dev = info->ptr; switch (event->type) { case XENKBD_TYPE_MOTION: - input_report_rel(dev, REL_X, event->motion.rel_x); - input_report_rel(dev, REL_Y, event->motion.rel_y); + if ( event->motion.rel_z == 1 || event->motion.rel_z == -1 ) { + input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z); + } + else { + input_report_rel(dev, REL_X, event->motion.rel_x); + input_report_rel(dev, REL_Y, event->motion.rel_y); + }Quoted 6 lines
I don't understand the conditional. Why is
rel_zto be used *only* when it's 1 or -1, and why arerel_xandrel_yto be used *only* whenrel_zisn't? That sure is a weird protocol, and it isn't documented anywhere...Quoted 4 lines
In my testing I never saw a case where the
rel_xandrel_ywere not zero
or theabs_xandabs_ychanged when a z event came thru. A small
attempt to not flood the input stream with redundant data.Assuming conditions you observed in your tests will hold elsehwere in space or time is calling for trouble :)
Quoted 9 lines
Quoted 6 lines
Probably for clarity should have been: (same for the abs case)
if (event->motion.rel_z!= 0)input_report_rel(dev, REL_WHEEL, 0 - event->motion.rel_z); input_report_rel(dev, REL_X, event->motion.rel_x); input_report_rel(dev, REL_Y, event->motion.rel_y);Why use
REL_WHEELand notREL_Z?
Same answer as below, Xorg 6.9 does not decode REL_Z. Xorg.7.3 handles REL_Z and REL_WHEEL as the same.
Quoted 3 lines
Why suppress zero Z-axis motion, but not X/Y-axis?
Hmm. Delving back into X
Xorg 6.9
case REL_WHEEL:
if (value > 0)
PostButtonClicks(pInfo, wheel_up_button, value);
if (value < 0)
PostButtonClicks(pInfo, wheel_down_button, -value);
break;
Xorg 7.3
Just sends the value up, gets ignored laterI guess I saw that sending a '0' for REL_WHEEL was a waste of time and
decided to filtered it out. Also not really necessary if it makes the
code easier to understand.
Quoted 40 lines
Quoted 17 lines
Quoted 17 lines
break; case XENKBD_TYPE_KEY: dev = NULL; @@ -81,8 +86,13 @@ static irqreturn_t input_handler(int rq, event->key.keycode); break; case XENKBD_TYPE_POS: - input_report_abs(dev, ABS_X, event->pos.abs_x); - input_report_abs(dev, ABS_Y, event->pos.abs_y); + if ( event->pos.abs_z == 1 || event->pos.abs_z == -1 ) { + input_report_rel(dev, REL_WHEEL, 0 - event->pos.abs_z); + } + else { + input_report_abs(dev, ABS_X, event->pos.abs_x); + input_report_abs(dev, ABS_Y, event->pos.abs_y); + }Quoted 5 lines
Quoted 3 lines
And why isn't this using
REL_ABS?I assume you meant to ask why not
ABS_WHEEL. Xorg 6.9 evdev driver doesYes.
Quoted 4 lines
not decode
ABS_WHEEL. Xorg 7.3 decodes both REL and ABS WHEEL butABS_WHEELrequires extra xorg.conf input options. We get greater
coverage by usingREL_WHEELand reduce the need to edit xorg.conf.Okay, that's fair.
[...]
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
All right, I think I understand now how this works.
1. X reports wheel motion as button 4 & 5.
2. VNC viewer duly transmits that into QEMU.
3. QEMU converts it to -1/+1 on z-axis (pointer_event() in vnc.c).
4. Your patch transmits that to the vkbd frontend.
Bug: struct xenkbd_position claims abs_z is absolute, which is not true.
Question: is that the protocol we want? More below.
5. The vkbd frontend stuffs the z-axis motion into the input layer as REL_WHEEL, with the sign reversed.
Bug: it ignores movement other than -1/+1. A case can be made for ignoring 0.
Bug: when it acts on z-axis movement, it ignores x/y movement / position.
6. X converts the wheel movement back to button 4 & 5.
Weird, isn't it?
I'm not sure we want to encode wheel events as z-axis motion in the vkbd frontend/backend protocol. Wouldn't it make more sense to encode it as buttons?
Quoted 4 lines · Markus Armbruster
All right, I think I understand now how this works.
1. X reports wheel motion as button 4 & 5.
Quoted 8 lines
2. VNC viewer duly transmits that into QEMU.
3. QEMU converts it to -1/+1 on z-axis (
pointer_event()invnc.c).4. Your patch transmits that to the vkbd frontend.
Bug: struct
xenkbd_positionclaimsabs_zis absolute, which is not true.
Patch appended.
Quoted 10 lines
Question: is that the protocol we want? More below.
5. The vkbd frontend stuffs the z-axis motion into the input layer as
REL_WHEEL, with the sign reversed.Bug: it ignores movement other than -1/+1. A case can be made for ignoring 0.
Bug: when it acts on z-axis movement, it ignores x/y movement / position.
Fixed in changeset 439:1edfea26a2a9
Quoted 1 line
6. X converts the wheel movement back to button 4 & 5.
[...]
drivers/xen/fbfront/xenkbd.c +3 -3
@@ -66,7 +66,7 @@ static irqreturn_t input_handler(int rq,case XENKBD_TYPE_MOTION :if (event->motion.rel_z)input_report_rel (dev,REL_WHEEL , -0 - event->motion.rel_z); + -event->motion.rel_z);input_report_rel (dev,REL_X , event->motion.rel_x);input_report_rel (dev,REL_Y , event->motion.rel_y);break ;
@@ -84,9 +84,9 @@ static irqreturn_t input_handler(int rq, event->key.keycode);break ;case XENKBD_TYPE_POS : -if (event->pos.abs_z) +if (event->pos.rel_z)input_report_rel (dev,REL_WHEEL , -0 - event->pos.abs_z); + -event->pos.rel_z);input_report_abs (dev,ABS_X , event->pos.abs_x);input_report_abs (dev,ABS_Y , event->pos.abs_y);break ;
include/xen/interface/io/kbdif.h +1 -1
@@ -65,7 +65,7 @@ struct xenkbd_positionuint8_t type;/* XENKBD_TYPE_POS */ int32_t abs_x;/* absolute X position (in FB pixels) */ int32_t abs_y;/* absolute Y position (in FB pixels) */ -int32_t abs_z;/* absolute Z position (wheel) */ +int32_t rel_z;/* relative Z motion (wheel) */ };#define XENKBD_IN_EVENT_SIZE 40
Quoted 6 lines · Markus Armbruster
Quoted 4 lines
4. Your patch transmits that to the vkbd frontend.
Bug: struct
xenkbd_positionclaimsabs_zis absolute, which is not true.Patch appended.
Also needs changes to xen/include/public/io/kbdif.h and to tools/ioemu/hw/xenfb.c. I won't check in the Linux side without having a patch for the other half too.
-- Keir
Buddy patch for ioemu:
Rename struct xenkbd_position member abs_z to rel_z
Z-axis motion is relative, not absolute.
tools/ioemu/hw/xenfb.c +5 -3
@@ -592,7 +592,8 @@ static int xenfb_send_key(struct xenfb * }/* Send a relative mouse movement event */ -static int xenfb_send_motion (struct xenfb *xenfb,int rel_x,int rel_y,int rel_z) +static int xenfb_send_motion (struct xenfb *xenfb, +int rel_x,int rel_y,int rel_z) {union xenkbd_in_event event;
@@ -606,7 +607,8 @@ static int xenfb_send_motion(struct xenf }/* Send an absolute mouse movement event */ -static int xenfb_send_position (struct xenfb *xenfb,int abs_x,int abs_y,int abs_z) +static int xenfb_send_position (struct xenfb *xenfb, +int abs_x,int abs_y,int rel_z) {union xenkbd_in_event event;
@@ -614,7 +616,7 @@ static int xenfb_send_position(struct xe event.type =XENKBD_TYPE_POS ; event.pos.abs_x = abs_x; event.pos.abs_y = abs_y; - event.pos.abs_z = abs_z; + event.pos.rel_z = rel_z;return xenfb_kbd_event (xenfb, &event); }
xen/include/public/io/kbdif.h +1 -1
@@ -65,7 +65,7 @@ struct xenkbd_positionuint8_t type;/* XENKBD_TYPE_POS */ int32_t abs_x;/* absolute X position (in FB pixels) */ int32_t abs_y;/* absolute Y position (in FB pixels) */ -int32_t abs_z;/* absolute Z position (wheel) */ +int32_t rel_z;/* relative Z motion (wheel) */ };#define XENKBD_IN_EVENT_SIZE 40
PATCH 1/1 stubdom [Re: PVFB wheel events (z-axis)]
stubdom: Fix compilation after abs_z to rel_z change
extras/mini-os/kernel.c +3 -3
@@ -360,13 +360,13 @@ static void kbdfront_thread(void *p)refresh_cursor (x, y);break ;case XENKBD_TYPE_POS : -printk ("pos x:%d y:%d z:%d\n" , +printk ("pos x:%d y:%d dz:%d\n" , event.pos.abs_x, event.pos.abs_y, - event.pos.abs_z); + event.pos.rel_z); x = event.pos.abs_x; y = event.pos.abs_y; - z = event.pos.abs_z; + z = event.pos.rel_z;clip_cursor (&x, &y);refresh_cursor (x, y);break ;
tools/ioemu/hw/xenfb.c +4 -6
@@ -1230,7 +1230,7 @@ static void xenfb_kbd_handler(void *opaqint n, i;DisplayState *s = opaque;static int buttons; -static int x, y, z; +static int x, y; n =kbdfront_receive (kbd_dev, buf,KBD_NUM_BATCH );for (i =0 ; i < n; i++) {
@@ -1244,7 +1244,6 @@ static void xenfb_kbd_handler(void *opaq {int new_x = buf[i].pos.abs_x;int new_y = buf[i].pos.abs_y; -int new_z = buf[i].pos.abs_z;if (new_x >= s->width) new_x = s->width -1 ;if (new_y >= s->height)
@@ -1253,18 +1252,17 @@ static void xenfb_kbd_handler(void *opaqkbd_mouse_event ( new_x *0x7FFF / (s->width -1 ), new_y *0x7FFF / (s->height -1 ), - new_z, + buf[i].pos.rel_z, buttons); }else {kbd_mouse_event ( new_x - x, new_y - y, - new_z - z, + buf[i].pos.rel_z, buttons); } x = new_x; y = new_y; - z = new_z;break ; }
@@ -1289,7 +1287,7 @@ static void xenfb_kbd_handler(void *opaqkbd_mouse_event ( x *0x7FFF / s->width, y *0x7FFF / s->height, - z, +0 , buttons); else kbd_mouse_event(0, 0, 0, buttons);