#include "qemu/osdep.h"
#include "sysemu/sysemu.h"
-#include "qapi-types.h"
+#include "qapi/error.h"
+#include "qapi/qapi-commands-ui.h"
+#include "qapi/qmp/qdict.h"
#include "qemu/error-report.h"
-#include "qmp-commands.h"
#include "trace.h"
#include "ui/input.h"
#include "ui/console.h"
}
for (e = events; e != NULL; e = e->next) {
- InputEvent *event = e->value;
-
- qemu_input_event_send(con, event);
+ InputEvent *evt = e->value;
+
+ if (evt->type == INPUT_EVENT_KIND_KEY &&
+ evt->u.key.data->key->type == KEY_VALUE_KIND_NUMBER) {
+ KeyValue *key = evt->u.key.data->key;
+ QKeyCode code = qemu_input_key_number_to_qcode(key->u.number.data);
+ qemu_input_event_send_key_qcode(con, code, evt->u.key.data->down);
+ } else {
+ qemu_input_event_send(con, evt);
+ }
}
qemu_input_event_sync();
void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
{
+ /* Expect all parts of QEMU to send events with QCodes exclusively.
+ * Key numbers are only supported as end-user input via QMP */
+ assert(!(evt->type == INPUT_EVENT_KIND_KEY &&
+ evt->u.key.data->key->type == KEY_VALUE_KIND_NUMBER));
+
+
+ /*
+ * 'sysrq' was mistakenly added to hack around the fact that
+ * the ps2 driver was not generating correct scancodes sequences
+ * when 'alt+print' was pressed. This flaw is now fixed and the
+ * 'sysrq' key serves no further purpose. We normalize it to
+ * 'print', so that downstream receivers of the event don't
+ * neeed to deal with this mistake
+ */
+ if (evt->type == INPUT_EVENT_KIND_KEY &&
+ evt->u.key.data->key->u.qcode.data == Q_KEY_CODE_SYSRQ) {
+ evt->u.key.data->key->u.qcode.data = Q_KEY_CODE_PRINT;
+ }
+
if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
return;
}
replay_input_sync_event();
}
-InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
+static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
{
InputEvent *evt = g_new0(InputEvent, 1);
evt->u.key.data = g_new0(InputKeyEvent, 1);
} else if (queue_count < queue_limit) {
qemu_input_queue_event(&kbd_queue, src, evt);
qemu_input_queue_sync(&kbd_queue);
+ } else {
+ qapi_free_InputEvent(evt);
}
}
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down)
{
- KeyValue *key = g_new0(KeyValue, 1);
- key->type = KEY_VALUE_KIND_NUMBER;
- key->u.number.data = num;
- qemu_input_event_send_key(src, key, down);
+ QKeyCode code = qemu_input_key_number_to_qcode(num);
+ qemu_input_event_send_key_qcode(src, code, down);
}
void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down)