2016-01-30 01:49:51 +08:00
|
|
|
#include "qemu/osdep.h"
|
2018-05-04 03:51:00 +08:00
|
|
|
#include "keymaps.h"
|
2014-03-11 19:15:39 +08:00
|
|
|
#include "ui/input.h"
|
|
|
|
|
2017-07-26 23:29:15 +08:00
|
|
|
#include "standard-headers/linux/input.h"
|
|
|
|
|
2018-01-18 00:47:15 +08:00
|
|
|
#include "ui/input-keymap-atset1-to-qcode.c"
|
2017-09-29 18:11:59 +08:00
|
|
|
#include "ui/input-keymap-linux-to-qcode.c"
|
2018-01-18 00:41:15 +08:00
|
|
|
#include "ui/input-keymap-qcode-to-atset1.c"
|
|
|
|
#include "ui/input-keymap-qcode-to-atset2.c"
|
|
|
|
#include "ui/input-keymap-qcode-to-atset3.c"
|
2018-01-18 00:41:17 +08:00
|
|
|
#include "ui/input-keymap-qcode-to-linux.c"
|
2017-09-29 18:11:59 +08:00
|
|
|
#include "ui/input-keymap-qcode-to-qnum.c"
|
2018-01-18 00:41:16 +08:00
|
|
|
#include "ui/input-keymap-qcode-to-sun.c"
|
2017-09-29 18:11:59 +08:00
|
|
|
#include "ui/input-keymap-qnum-to-qcode.c"
|
2018-01-18 00:47:14 +08:00
|
|
|
#include "ui/input-keymap-usb-to-qcode.c"
|
2018-01-18 00:47:15 +08:00
|
|
|
#include "ui/input-keymap-win32-to-qcode.c"
|
|
|
|
#include "ui/input-keymap-x11-to-qcode.c"
|
|
|
|
#include "ui/input-keymap-xorgevdev-to-qcode.c"
|
|
|
|
#include "ui/input-keymap-xorgkbd-to-qcode.c"
|
|
|
|
#include "ui/input-keymap-xorgxquartz-to-qcode.c"
|
|
|
|
#include "ui/input-keymap-xorgxwin-to-qcode.c"
|
2018-06-14 07:51:56 +08:00
|
|
|
#include "ui/input-keymap-osx-to-qcode.c"
|
2014-03-11 19:15:39 +08:00
|
|
|
|
2017-07-26 23:29:15 +08:00
|
|
|
int qemu_input_linux_to_qcode(unsigned int lnx)
|
|
|
|
{
|
2017-09-29 18:11:59 +08:00
|
|
|
if (lnx >= qemu_input_map_linux_to_qcode_len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return qemu_input_map_linux_to_qcode[lnx];
|
2017-07-26 23:29:15 +08:00
|
|
|
}
|
|
|
|
|
2014-03-11 19:15:39 +08:00
|
|
|
int qemu_input_key_value_to_number(const KeyValue *value)
|
|
|
|
{
|
2015-10-27 06:34:58 +08:00
|
|
|
if (value->type == KEY_VALUE_KIND_QCODE) {
|
2017-09-29 18:11:59 +08: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 19:15:39 +08:00
|
|
|
} else {
|
2015-10-27 06:34:58 +08: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 06:48:37 +08:00
|
|
|
return value->u.number.data;
|
2014-03-11 19:15:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-29 18:11:59 +08:00
|
|
|
int qemu_input_key_number_to_qcode(unsigned int nr)
|
2014-03-11 19:15:39 +08:00
|
|
|
{
|
2017-09-29 18:11:59 +08:00
|
|
|
if (nr >= qemu_input_map_qnum_to_qcode_len) {
|
|
|
|
return 0;
|
2014-03-11 19:15:39 +08:00
|
|
|
}
|
2017-09-29 18:11:59 +08:00
|
|
|
return qemu_input_map_qnum_to_qcode[nr];
|
2014-05-21 19:28:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int qemu_input_key_value_to_qcode(const KeyValue *value)
|
|
|
|
{
|
2015-10-27 06:34:58 +08: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 06:48:37 +08:00
|
|
|
return value->u.qcode.data;
|
2014-03-11 19:15:39 +08:00
|
|
|
} else {
|
2015-10-27 06:34:58 +08: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 06:48:37 +08:00
|
|
|
return qemu_input_key_number_to_qcode(value->u.number.data);
|
2014-03-11 19:15:39 +08: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 06:34:58 +08: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 06:48:37 +08:00
|
|
|
value->u.qcode.data == Q_KEY_CODE_PAUSE) {
|
2014-03-11 19:15:39 +08: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;
|
|
|
|
}
|