4 * Copyright (c) 2010-2015 Institute for System Programming
5 * of the Russian Academy of Sciences.
7 * This work is licensed under the terms of the GNU GPL, version 2 or later.
8 * See the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
13 #include "sysemu/replay.h"
14 #include "replay-internal.h"
15 #include "qemu/notify.h"
17 #include "qapi/clone-visitor.h"
18 #include "qapi/qapi-visit-ui.h"
20 void replay_save_input_event(InputEvent
*evt
)
25 InputMultiTouchEvent
*mtt
;
26 replay_put_dword(evt
->type
);
29 case INPUT_EVENT_KIND_KEY
:
30 key
= evt
->u
.key
.data
;
31 replay_put_dword(key
->key
->type
);
33 switch (key
->key
->type
) {
34 case KEY_VALUE_KIND_NUMBER
:
35 replay_put_qword(key
->key
->u
.number
.data
);
36 replay_put_byte(key
->down
);
38 case KEY_VALUE_KIND_QCODE
:
39 replay_put_dword(key
->key
->u
.qcode
.data
);
40 replay_put_byte(key
->down
);
42 case KEY_VALUE_KIND__MAX
:
47 case INPUT_EVENT_KIND_BTN
:
48 btn
= evt
->u
.btn
.data
;
49 replay_put_dword(btn
->button
);
50 replay_put_byte(btn
->down
);
52 case INPUT_EVENT_KIND_REL
:
53 move
= evt
->u
.rel
.data
;
54 replay_put_dword(move
->axis
);
55 replay_put_qword(move
->value
);
57 case INPUT_EVENT_KIND_ABS
:
58 move
= evt
->u
.abs
.data
;
59 replay_put_dword(move
->axis
);
60 replay_put_qword(move
->value
);
62 case INPUT_EVENT_KIND_MTT
:
63 mtt
= evt
->u
.mtt
.data
;
64 replay_put_dword(mtt
->type
);
65 replay_put_qword(mtt
->slot
);
66 replay_put_qword(mtt
->tracking_id
);
67 replay_put_dword(mtt
->axis
);
68 replay_put_qword(mtt
->value
);
70 case INPUT_EVENT_KIND__MAX
:
76 InputEvent
*replay_read_input_event(void)
85 InputMultiTouchEvent mtt
;
87 evt
.type
= replay_get_dword();
89 case INPUT_EVENT_KIND_KEY
:
90 evt
.u
.key
.data
= &key
;
91 evt
.u
.key
.data
->key
->type
= replay_get_dword();
93 switch (evt
.u
.key
.data
->key
->type
) {
94 case KEY_VALUE_KIND_NUMBER
:
95 evt
.u
.key
.data
->key
->u
.number
.data
= replay_get_qword();
96 evt
.u
.key
.data
->down
= replay_get_byte();
98 case KEY_VALUE_KIND_QCODE
:
99 evt
.u
.key
.data
->key
->u
.qcode
.data
= (QKeyCode
)replay_get_dword();
100 evt
.u
.key
.data
->down
= replay_get_byte();
102 case KEY_VALUE_KIND__MAX
:
107 case INPUT_EVENT_KIND_BTN
:
108 evt
.u
.btn
.data
= &btn
;
109 evt
.u
.btn
.data
->button
= (InputButton
)replay_get_dword();
110 evt
.u
.btn
.data
->down
= replay_get_byte();
112 case INPUT_EVENT_KIND_REL
:
113 evt
.u
.rel
.data
= &rel
;
114 evt
.u
.rel
.data
->axis
= (InputAxis
)replay_get_dword();
115 evt
.u
.rel
.data
->value
= replay_get_qword();
117 case INPUT_EVENT_KIND_ABS
:
118 evt
.u
.abs
.data
= &abs
;
119 evt
.u
.abs
.data
->axis
= (InputAxis
)replay_get_dword();
120 evt
.u
.abs
.data
->value
= replay_get_qword();
122 case INPUT_EVENT_KIND_MTT
:
123 evt
.u
.mtt
.data
= &mtt
;
124 evt
.u
.mtt
.data
->type
= (InputMultiTouchType
)replay_get_dword();
125 evt
.u
.mtt
.data
->slot
= replay_get_qword();
126 evt
.u
.mtt
.data
->tracking_id
= replay_get_qword();
127 evt
.u
.mtt
.data
->axis
= (InputAxis
)replay_get_dword();
128 evt
.u
.mtt
.data
->value
= replay_get_qword();
130 case INPUT_EVENT_KIND__MAX
:
135 return QAPI_CLONE(InputEvent
, &evt
);
138 void replay_input_event(QemuConsole
*src
, InputEvent
*evt
)
140 if (replay_mode
== REPLAY_MODE_PLAY
) {
142 } else if (replay_mode
== REPLAY_MODE_RECORD
) {
143 replay_add_input_event(QAPI_CLONE(InputEvent
, evt
));
145 qemu_input_event_send_impl(src
, evt
);
149 void replay_input_sync_event(void)
151 if (replay_mode
== REPLAY_MODE_PLAY
) {
153 } else if (replay_mode
== REPLAY_MODE_RECORD
) {
154 replay_add_input_sync_event();
156 qemu_input_event_sync_impl();