2016-01-29 18:49:51 +01:00
|
|
|
#include "qemu/osdep.h"
|
2014-03-11 12:15:39 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
#include "ui/keymaps.h"
|
|
|
|
#include "ui/input.h"
|
|
|
|
|
|
|
|
static const int qcode_to_number[] = {
|
|
|
|
[Q_KEY_CODE_SHIFT] = 0x2a,
|
|
|
|
[Q_KEY_CODE_SHIFT_R] = 0x36,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_ALT] = 0x38,
|
|
|
|
[Q_KEY_CODE_ALT_R] = 0xb8,
|
|
|
|
[Q_KEY_CODE_ALTGR] = 0x64,
|
|
|
|
[Q_KEY_CODE_ALTGR_R] = 0xe4,
|
|
|
|
[Q_KEY_CODE_CTRL] = 0x1d,
|
|
|
|
[Q_KEY_CODE_CTRL_R] = 0x9d,
|
|
|
|
|
2014-05-21 13:54:32 +02:00
|
|
|
[Q_KEY_CODE_META_L] = 0xdb,
|
|
|
|
[Q_KEY_CODE_META_R] = 0xdc,
|
2014-03-11 12:15:39 +01:00
|
|
|
[Q_KEY_CODE_MENU] = 0xdd,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_ESC] = 0x01,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_1] = 0x02,
|
|
|
|
[Q_KEY_CODE_2] = 0x03,
|
|
|
|
[Q_KEY_CODE_3] = 0x04,
|
|
|
|
[Q_KEY_CODE_4] = 0x05,
|
|
|
|
[Q_KEY_CODE_5] = 0x06,
|
|
|
|
[Q_KEY_CODE_6] = 0x07,
|
|
|
|
[Q_KEY_CODE_7] = 0x08,
|
|
|
|
[Q_KEY_CODE_8] = 0x09,
|
|
|
|
[Q_KEY_CODE_9] = 0x0a,
|
|
|
|
[Q_KEY_CODE_0] = 0x0b,
|
|
|
|
[Q_KEY_CODE_MINUS] = 0x0c,
|
|
|
|
[Q_KEY_CODE_EQUAL] = 0x0d,
|
|
|
|
[Q_KEY_CODE_BACKSPACE] = 0x0e,
|
|
|
|
|
|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P_3] = 0x51,
|
|
|
|
[Q_KEY_CODE_KP_4] = 0x4b,
|
|
|
|
[Q_KEY_CODE_KP_5] = 0x4c,
|
|
|
|
[Q_KEY_CODE_KP_6] = 0x4d,
|
|
|
|
[Q_KEY_CODE_KP_7] = 0x47,
|
|
|
|
[Q_KEY_CODE_KP_8] = 0x48,
|
|
|
|
[Q_KEY_CODE_KP_9] = 0x49,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_LESS] = 0x56,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_F11] = 0x57,
|
|
|
|
[Q_KEY_CODE_F12] = 0x58,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_PRINT] = 0xb7,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_HOME] = 0xc7,
|
|
|
|
[Q_KEY_CODE_PGUP] = 0xc9,
|
|
|
|
[Q_KEY_CODE_PGDN] = 0xd1,
|
|
|
|
[Q_KEY_CODE_END] = 0xcf,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_LEFT] = 0xcb,
|
|
|
|
[Q_KEY_CODE_UP] = 0xc8,
|
|
|
|
[Q_KEY_CODE_DOWN] = 0xd0,
|
|
|
|
[Q_KEY_CODE_RIGHT] = 0xcd,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_INSERT] = 0xd2,
|
|
|
|
[Q_KEY_CODE_DELETE] = 0xd3,
|
2015-05-26 10:39:10 +02:00
|
|
|
|
|
|
|
[Q_KEY_CODE_RO] = 0x73,
|
2016-12-27 20:55:51 +01:00
|
|
|
[Q_KEY_CODE_HIRAGANA] = 0x70,
|
|
|
|
[Q_KEY_CODE_HENKAN] = 0x79,
|
|
|
|
[Q_KEY_CODE_YEN] = 0x7d,
|
2015-05-26 10:39:10 +02:00
|
|
|
[Q_KEY_CODE_KP_COMMA] = 0x7e,
|
|
|
|
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 09:52:57 +01:00
|
|
|
[Q_KEY_CODE__MAX] = 0,
|
2014-03-11 12:15:39 +01:00
|
|
|
};
|
|
|
|
|
2014-05-21 13:28:32 +02:00
|
|
|
static int number_to_qcode[0x100];
|
2014-03-11 12:15:39 +01:00
|
|
|
|
|
|
|
int qemu_input_key_value_to_number(const KeyValue *value)
|
|
|
|
{
|
2015-10-26 23:34:58 +01: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-17 23:48:37 +01:00
|
|
|
return qcode_to_number[value->u.qcode.data];
|
2014-03-11 12:15:39 +01:00
|
|
|
} else {
|
2015-10-26 23:34:58 +01: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-17 23:48:37 +01:00
|
|
|
return value->u.number.data;
|
2014-03-11 12:15:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-21 13:28:32 +02:00
|
|
|
int qemu_input_key_number_to_qcode(uint8_t nr)
|
2014-03-11 12:15:39 +01:00
|
|
|
{
|
|
|
|
static int first = true;
|
|
|
|
|
|
|
|
if (first) {
|
|
|
|
int qcode, number;
|
|
|
|
first = false;
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 09:52:57 +01:00
|
|
|
for (qcode = 0; qcode < Q_KEY_CODE__MAX; qcode++) {
|
2014-03-11 12:15:39 +01:00
|
|
|
number = qcode_to_number[qcode];
|
|
|
|
assert(number < ARRAY_SIZE(number_to_qcode));
|
|
|
|
number_to_qcode[number] = qcode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-21 13:28:32 +02:00
|
|
|
return number_to_qcode[nr];
|
|
|
|
}
|
|
|
|
|
|
|
|
int qemu_input_key_value_to_qcode(const KeyValue *value)
|
|
|
|
{
|
2015-10-26 23:34:58 +01: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-17 23:48:37 +01:00
|
|
|
return value->u.qcode.data;
|
2014-03-11 12:15:39 +01:00
|
|
|
} else {
|
2015-10-26 23:34:58 +01: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-17 23:48:37 +01:00
|
|
|
return qemu_input_key_number_to_qcode(value->u.number.data);
|
2014-03-11 12:15:39 +01: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-26 23:34:58 +01: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-17 23:48:37 +01:00
|
|
|
value->u.qcode.data == Q_KEY_CODE_PAUSE) {
|
2014-03-11 12:15:39 +01: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;
|
|
|
|
}
|