xenfb: Add [feature|request]-raw-pointer

Writes "feature-raw-pointer" during init to indicate the backend
can pass raw unscaled values for absolute axes to the frontend.
Frontends set "request-raw-pointer" to indicate the backend should
not attempt to scale absolute values to console size.
"request-raw-pointer" is only valid if "request-abs-pointer" is
also set. Raw unscaled pointer values are in the range [0, 0x7fff]

"feature-raw-pointer" and "request-raw-pointer" added to Xen
header in commit 7868654ff7fe5e4a2eeae2b277644fa884a5031e

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Owen Smith 2017-11-03 11:56:30 +00:00 committed by Stefano Stabellini
parent a1ccbafded
commit 34975e536f
1 changed files with 30 additions and 17 deletions

View File

@ -52,6 +52,7 @@ struct common {
struct XenInput { struct XenInput {
struct common c; struct common c;
int abs_pointer_wanted; /* Whether guest supports absolute pointer */ int abs_pointer_wanted; /* Whether guest supports absolute pointer */
int raw_pointer_wanted; /* Whether guest supports raw (unscaled) pointer */
QemuInputHandlerState *qkbd; QemuInputHandlerState *qkbd;
QemuInputHandlerState *qmou; QemuInputHandlerState *qmou;
int axis[INPUT_AXIS__MAX]; int axis[INPUT_AXIS__MAX];
@ -264,6 +265,9 @@ static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
case INPUT_EVENT_KIND_ABS: case INPUT_EVENT_KIND_ABS:
move = evt->u.abs.data; move = evt->u.abs.data;
if (xenfb->raw_pointer_wanted) {
xenfb->axis[move->axis] = move->value;
} else {
con = qemu_console_lookup_by_index(0); con = qemu_console_lookup_by_index(0);
if (!con) { if (!con) {
xen_pv_printf(&xenfb->c.xendev, 0, "No QEMU console available"); xen_pv_printf(&xenfb->c.xendev, 0, "No QEMU console available");
@ -282,6 +286,7 @@ static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
break; break;
} }
xenfb->axis[move->axis] = move->value * scale / 0x7fff; xenfb->axis[move->axis] = move->value * scale / 0x7fff;
}
break; break;
case INPUT_EVENT_KIND_REL: case INPUT_EVENT_KIND_REL:
@ -339,6 +344,7 @@ static QemuInputHandler xenfb_rel_mouse = {
static int input_init(struct XenDevice *xendev) static int input_init(struct XenDevice *xendev)
{ {
xenstore_write_be_int(xendev, "feature-abs-pointer", 1); xenstore_write_be_int(xendev, "feature-abs-pointer", 1);
xenstore_write_be_int(xendev, "feature-raw-pointer", 1);
return 0; return 0;
} }
@ -362,6 +368,13 @@ static void input_connected(struct XenDevice *xendev)
&in->abs_pointer_wanted) == -1) { &in->abs_pointer_wanted) == -1) {
in->abs_pointer_wanted = 0; in->abs_pointer_wanted = 0;
} }
if (xenstore_read_fe_int(xendev, "request-raw-pointer",
&in->raw_pointer_wanted) == -1) {
in->raw_pointer_wanted = 0;
}
if (in->raw_pointer_wanted && in->abs_pointer_wanted == 0) {
xen_pv_printf(xendev, 0, "raw pointer set without abs pointer");
}
if (in->qkbd) { if (in->qkbd) {
qemu_input_handler_unregister(in->qkbd); qemu_input_handler_unregister(in->qkbd);