blob: 1147e3d34e41824efa52c2ca1360bb7742746918 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/*
* replay-input.c
*
* Copyright (c) 2010-2015 Institute for System Programming
* of the Russian Academy of Sciences.
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*
*/
#include "qemu/osdep.h"
#include "sysemu/replay.h"
#include "replay-internal.h"
#include "qemu/notify.h"
#include "ui/input.h"
#include "qapi/clone-visitor.h"
#include "qapi/qapi-visit-ui.h"
void replay_save_input_event(InputEvent *evt)
{
InputKeyEvent *key;
InputBtnEvent *btn;
InputMoveEvent *move;
replay_put_dword(evt->type);
switch (evt->type) {
case INPUT_EVENT_KIND_KEY:
key = evt->u.key.data;
replay_put_dword(key->key->type);
switch (key->key->type) {
case KEY_VALUE_KIND_NUMBER:
replay_put_qword(key->key->u.number.data);
replay_put_byte(key->down);
break;
case KEY_VALUE_KIND_QCODE:
replay_put_dword(key->key->u.qcode.data);
replay_put_byte(key->down);
break;
case KEY_VALUE_KIND__MAX:
/* keep gcc happy */
break;
}
break;
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn.data;
replay_put_dword(btn->button);
replay_put_byte(btn->down);
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel.data;
replay_put_dword(move->axis);
replay_put_qword(move->value);
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs.data;
replay_put_dword(move->axis);
replay_put_qword(move->value);
break;
case INPUT_EVENT_KIND__MAX:
/* keep gcc happy */
break;
}
}
InputEvent *replay_read_input_event(void)
{
InputEvent evt;
KeyValue keyValue;
InputKeyEvent key;
key.key = &keyValue;
InputBtnEvent btn;
InputMoveEvent rel;
InputMoveEvent abs;
evt.type = replay_get_dword();
switch (evt.type) {
case INPUT_EVENT_KIND_KEY:
evt.u.key.data = &key;
evt.u.key.data->key->type = replay_get_dword();
switch (evt.u.key.data->key->type) {
case KEY_VALUE_KIND_NUMBER:
evt.u.key.data->key->u.number.data = replay_get_qword();
evt.u.key.data->down = replay_get_byte();
break;
case KEY_VALUE_KIND_QCODE:
evt.u.key.data->key->u.qcode.data = (QKeyCode)replay_get_dword();
evt.u.key.data->down = replay_get_byte();
break;
case KEY_VALUE_KIND__MAX:
/* keep gcc happy */
break;
}
break;
case INPUT_EVENT_KIND_BTN:
evt.u.btn.data = &btn;
evt.u.btn.data->button = (InputButton)replay_get_dword();
evt.u.btn.data->down = replay_get_byte();
break;
case INPUT_EVENT_KIND_REL:
evt.u.rel.data = &rel;
evt.u.rel.data->axis = (InputAxis)replay_get_dword();
evt.u.rel.data->value = replay_get_qword();
break;
case INPUT_EVENT_KIND_ABS:
evt.u.abs.data = &abs;
evt.u.abs.data->axis = (InputAxis)replay_get_dword();
evt.u.abs.data->value = replay_get_qword();
break;
case INPUT_EVENT_KIND__MAX:
/* keep gcc happy */
break;
}
return QAPI_CLONE(InputEvent, &evt);
}
void replay_input_event(QemuConsole *src, InputEvent *evt)
{
if (replay_mode == REPLAY_MODE_PLAY) {
/* Nothing */
} else if (replay_mode == REPLAY_MODE_RECORD) {
replay_add_input_event(QAPI_CLONE(InputEvent, evt));
} else {
qemu_input_event_send_impl(src, evt);
}
}
void replay_input_sync_event(void)
{
if (replay_mode == REPLAY_MODE_PLAY) {
/* Nothing */
} else if (replay_mode == REPLAY_MODE_RECORD) {
replay_add_input_sync_event();
} else {
qemu_input_event_sync_impl();
}
}
|