Skip to content

Commit

Permalink
input: add qemu_input_key_number_to_qcode
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
kraxel committed May 26, 2014
1 parent f5c0ab1 commit 11c7fa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/ui/input.h
Expand Up @@ -36,6 +36,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down);
void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
int qemu_input_key_number_to_qcode(uint8_t nr);
int qemu_input_key_value_to_number(const KeyValue *value);
int qemu_input_key_value_to_qcode(const KeyValue *value);
int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
Expand Down
11 changes: 8 additions & 3 deletions ui/input-keymap.c
Expand Up @@ -129,7 +129,7 @@ static const int qcode_to_number[] = {
[Q_KEY_CODE_MAX] = 0,
};

static int number_to_qcode[0xff];
static int number_to_qcode[0x100];

int qemu_input_key_value_to_number(const KeyValue *value)
{
Expand All @@ -141,7 +141,7 @@ int qemu_input_key_value_to_number(const KeyValue *value)
}
}

int qemu_input_key_value_to_qcode(const KeyValue *value)
int qemu_input_key_number_to_qcode(uint8_t nr)
{
static int first = true;

Expand All @@ -155,11 +155,16 @@ int qemu_input_key_value_to_qcode(const KeyValue *value)
}
}

return number_to_qcode[nr];
}

int qemu_input_key_value_to_qcode(const KeyValue *value)
{
if (value->kind == KEY_VALUE_KIND_QCODE) {
return value->qcode;
} else {
assert(value->kind == KEY_VALUE_KIND_NUMBER);
return number_to_qcode[value->number];
return qemu_input_key_number_to_qcode(value->number);
}
}

Expand Down

0 comments on commit 11c7fa7

Please sign in to comment.