replay: Use Linux key codes

QemuInputEvent now stores Linux key codes for key events. Use those
codes directly instead of translating between internal key code
representations.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260520-input-v3-16-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>
[ Marc-André - update replay-dump.py ]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Akihiko Odaki
2026-05-20 15:47:59 +09:00
committed by Marc-André Lureau
parent 7725e540a3
commit 44a4d0623d
3 changed files with 11 additions and 19 deletions

View File

@@ -23,8 +23,7 @@ void replay_save_input_event(QemuInputEvent *evt)
switch (evt->type) {
case INPUT_EVENT_KIND_KEY:
replay_put_dword(KEY_VALUE_KIND_QCODE);
replay_put_dword(qemu_input_linux_to_qcode(evt->key.key));
replay_put_dword(evt->key.key);
replay_put_byte(evt->key.down);
break;
case INPUT_EVENT_KIND_BTN:
@@ -55,25 +54,12 @@ void replay_save_input_event(QemuInputEvent *evt)
QemuInputEvent *replay_read_input_event(void)
{
QemuInputEvent *evt = g_new(QemuInputEvent, 1);
int qcode;
evt->type = replay_get_dword();
switch (evt->type) {
case INPUT_EVENT_KIND_KEY:
switch (replay_get_dword()) {
case KEY_VALUE_KIND_NUMBER:
qcode = qemu_input_key_number_to_qcode(replay_get_qword());
evt->key.down = replay_get_byte();
break;
case KEY_VALUE_KIND_QCODE:
qcode = (QKeyCode)replay_get_dword();
evt->key.down = replay_get_byte();
break;
default:
g_assert_not_reached();
}
evt->key.key = qcode < qemu_input_map_qcode_to_linux_len ?
qemu_input_map_qcode_to_linux[qcode] : 0;
evt->key.key = replay_get_dword();
evt->key.down = replay_get_byte();
break;
case INPUT_EVENT_KIND_BTN:
evt->btn.button = (InputButton)replay_get_dword();

View File

@@ -22,7 +22,7 @@
/* Current version of the replay mechanism.
Increase it when file format changes. */
#define REPLAY_VERSION 0xe0200d
#define REPLAY_VERSION 0xe0200e
/* Size of replay log header */
#define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t))

View File

@@ -398,6 +398,9 @@ v12_event_table = [Decoder(0, "EVENT_INSTRUCTION", decode_instruction),
# EVENT_AUDIO_IN has changed
v13_event_table = v12_event_table
# EVENT_ASYNC_INPUT has changed
v14_event_table = v13_event_table
def parse_arguments():
"Grab arguments for script"
parser = argparse.ArgumentParser()
@@ -416,7 +419,10 @@ def decode_file(filename):
# see REPLAY_VERSION
print("HEADER: version 0x%x" % (version))
if version == 0xe0200d:
if version == 0xe0200e:
event_decode_table = v14_event_table
replay_state.checkpoint_start = 30
elif version == 0xe0200d:
event_decode_table = v13_event_table
replay_state.checkpoint_start = 30
elif version == 0xe0200c: