2016-01-29 20:49:51 +03:00
|
|
|
#include "qemu/osdep.h"
|
2018-05-03 22:51:00 +03:00
|
|
|
#include "keymaps.h"
|
2014-03-11 15:15:39 +04:00
|
|
|
#include "ui/input.h"
|
|
|
|
|
2017-07-26 18:29:15 +03:00
|
|
|
#include "standard-headers/linux/input.h"
|
|
|
|
|
2020-02-04 14:41:01 +03:00
|
|
|
#include "ui/input-keymap-atset1-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-linux-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-qcode-to-atset1.c.inc"
|
|
|
|
#include "ui/input-keymap-qcode-to-atset2.c.inc"
|
|
|
|
#include "ui/input-keymap-qcode-to-atset3.c.inc"
|
|
|
|
#include "ui/input-keymap-qcode-to-linux.c.inc"
|
|
|
|
#include "ui/input-keymap-qcode-to-qnum.c.inc"
|
|
|
|
#include "ui/input-keymap-qcode-to-sun.c.inc"
|
|
|
|
#include "ui/input-keymap-qnum-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-usb-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-win32-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-x11-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-xorgevdev-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-xorgkbd-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-xorgxquartz-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-xorgxwin-to-qcode.c.inc"
|
|
|
|
#include "ui/input-keymap-osx-to-qcode.c.inc"
|
2014-03-11 15:15:39 +04:00
|
|
|
|
2017-07-26 18:29:15 +03:00
|
|
|
int qemu_input_linux_to_qcode(unsigned int lnx)
|
|
|
|
{
|
2017-09-29 13:11:59 +03:00
|
|
|
if (lnx >= qemu_input_map_linux_to_qcode_len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return qemu_input_map_linux_to_qcode[lnx];
|
2017-07-26 18:29:15 +03:00
|
|
|
}
|
|
|
|
|
2014-03-11 15:15:39 +04:00
|
|
|
int qemu_input_key_value_to_number(const KeyValue *value)
|
|
|
|
{
|
2015-10-27 01:34:58 +03:00
|
|
|
if (value->type == KEY_VALUE_KIND_QCODE) {
|
2017-09-29 13:11:59 +03:00
|
|
|
if (value->u.qcode.data >= qemu_input_map_qcode_to_qnum_len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return qemu_input_map_qcode_to_qnum[value->u.qcode.data];
|
2014-03-11 15:15:39 +04:00
|
|
|
} else {
|
2015-10-27 01:34:58 +03:00
|
|
|
assert(value->type == KEY_VALUE_KIND_NUMBER);
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
return value->u.number.data;
|
2014-03-11 15:15:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-29 13:11:59 +03:00
|
|
|
int qemu_input_key_number_to_qcode(unsigned int nr)
|
2014-03-11 15:15:39 +04:00
|
|
|
{
|
2017-09-29 13:11:59 +03:00
|
|
|
if (nr >= qemu_input_map_qnum_to_qcode_len) {
|
|
|
|
return 0;
|
2014-03-11 15:15:39 +04:00
|
|
|
}
|
2017-09-29 13:11:59 +03:00
|
|
|
return qemu_input_map_qnum_to_qcode[nr];
|
2014-05-21 15:28:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int qemu_input_key_value_to_qcode(const KeyValue *value)
|
|
|
|
{
|
2015-10-27 01:34:58 +03:00
|
|
|
if (value->type == KEY_VALUE_KIND_QCODE) {
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
return value->u.qcode.data;
|
2014-03-11 15:15:39 +04:00
|
|
|
} else {
|
2015-10-27 01:34:58 +03:00
|
|
|
assert(value->type == KEY_VALUE_KIND_NUMBER);
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
return qemu_input_key_number_to_qcode(value->u.number.data);
|
2014-03-11 15:15:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
|
|
|
|
int *codes)
|
|
|
|
{
|
|
|
|
int keycode = qemu_input_key_value_to_number(value);
|
|
|
|
int count = 0;
|
|
|
|
|
2015-10-27 01:34:58 +03:00
|
|
|
if (value->type == KEY_VALUE_KIND_QCODE &&
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
value->u.qcode.data == Q_KEY_CODE_PAUSE) {
|
2014-03-11 15:15:39 +04:00
|
|
|
/* specific case */
|
|
|
|
int v = down ? 0 : 0x80;
|
|
|
|
codes[count++] = 0xe1;
|
|
|
|
codes[count++] = 0x1d | v;
|
|
|
|
codes[count++] = 0x45 | v;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
if (keycode & SCANCODE_GREY) {
|
|
|
|
codes[count++] = SCANCODE_EMUL0;
|
|
|
|
keycode &= ~SCANCODE_GREY;
|
|
|
|
}
|
|
|
|
if (!down) {
|
|
|
|
keycode |= SCANCODE_UP;
|
|
|
|
}
|
|
|
|
codes[count++] = keycode;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|