mirror of https://gitee.com/openkylin/qemu.git
input: avoid malloc for mouse events
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJcOKekAAoJEEy22O7T6HE4dw0QAIGupK+U2XFcQ3eB9GZG0G6v ghU/ZTCEfXq1wzZwACrZFbwZrzFhivuQUfx6CSOEidHVsZXnXvJlpQ8tS5mQrPL2 Q/ox1jE4ywTPzRLw9TznC5Bs3ePyoYMqOiTW6Haev+64+wwWDwtEKg5MPIm9usgZ B18hb8IbJXD9KDaoHggRI/amB/Q4pgW7rsA4+VsKM17nFjc5cLp/Ke57fl4U288p AlgUWll7lDCAJYipx5UDRPgFuWrkngHbHqKn4gGigXjYUrVd3NqEwigtRdZcUtEg bnVUmewg3qkS+/DiKam211Q7pWRl8VhmCt6p45TXgWd0ggkHZkL1Wbdh4XY6XBhZ 1FWnx5FVzjqrirxBg6y5kd/QXI7hciaP2RUeAzdawF7TOYnm/FVZCUz9nFcH5RMg hHDw1o9jOZbWSqSoXNh9NmeLXqD9N7esSGAUwrgoILIT4SsqK3y53C6limmuIIy2 sgMJD/HoKwavdk+0Jj9tg0SsG/4whjIwJjbxU1pJIEpPj9lKyVsQZ/HhD2wVqnjM UE0Sex0lX7dwXu7KIw22jgio8zVeK7BLQRgKxhMHpjuIXLotPY+sZY8rs1Mq/hFx oujHzKiON+kkaRs8w88cbTRTDvmY4nloYHr46vx5VGanmUvv1ib+GFvpEMlUVHFa c/oY6HVtBiKHEBSJ8Uki =bR3M -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/input-20190111-pull-request' into staging input: avoid malloc for mouse events # gpg: Signature made Fri 11 Jan 2019 14:26:44 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/input-20190111-pull-request: input: avoid malloc for mouse events Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
4fbfedd12d
|
@ -49,7 +49,6 @@ int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
|
|||
int *codes);
|
||||
int qemu_input_linux_to_qcode(unsigned int lnx);
|
||||
|
||||
InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);
|
||||
void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
|
||||
void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
|
||||
uint32_t button_old, uint32_t button_new);
|
||||
|
@ -58,8 +57,6 @@ bool qemu_input_is_absolute(void);
|
|||
int qemu_input_scale_axis(int value,
|
||||
int min_in, int max_in,
|
||||
int min_out, int max_out);
|
||||
InputEvent *qemu_input_event_new_move(InputEventKind kind,
|
||||
InputAxis axis, int value);
|
||||
void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
|
||||
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
|
||||
int min_in, int max_in);
|
||||
|
|
68
ui/input.c
68
ui/input.c
|
@ -460,22 +460,18 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms)
|
|||
}
|
||||
}
|
||||
|
||||
InputEvent *qemu_input_event_new_btn(InputButton btn, bool down)
|
||||
{
|
||||
InputEvent *evt = g_new0(InputEvent, 1);
|
||||
evt->u.btn.data = g_new0(InputBtnEvent, 1);
|
||||
evt->type = INPUT_EVENT_KIND_BTN;
|
||||
evt->u.btn.data->button = btn;
|
||||
evt->u.btn.data->down = down;
|
||||
return evt;
|
||||
}
|
||||
|
||||
void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down)
|
||||
{
|
||||
InputEvent *evt;
|
||||
evt = qemu_input_event_new_btn(btn, down);
|
||||
qemu_input_event_send(src, evt);
|
||||
qapi_free_InputEvent(evt);
|
||||
InputBtnEvent bevt = {
|
||||
.button = btn,
|
||||
.down = down,
|
||||
};
|
||||
InputEvent evt = {
|
||||
.type = INPUT_EVENT_KIND_BTN,
|
||||
.u.btn.data = &bevt,
|
||||
};
|
||||
|
||||
qemu_input_event_send(src, &evt);
|
||||
}
|
||||
|
||||
void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
|
||||
|
@ -515,37 +511,35 @@ int qemu_input_scale_axis(int value,
|
|||
return ((int64_t)value - min_in) * range_out / range_in + min_out;
|
||||
}
|
||||
|
||||
InputEvent *qemu_input_event_new_move(InputEventKind kind,
|
||||
InputAxis axis, int value)
|
||||
{
|
||||
InputEvent *evt = g_new0(InputEvent, 1);
|
||||
InputMoveEvent *move = g_new0(InputMoveEvent, 1);
|
||||
|
||||
evt->type = kind;
|
||||
evt->u.rel.data = move; /* evt->u.rel is the same as evt->u.abs */
|
||||
move->axis = axis;
|
||||
move->value = value;
|
||||
return evt;
|
||||
}
|
||||
|
||||
void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value)
|
||||
{
|
||||
InputEvent *evt;
|
||||
evt = qemu_input_event_new_move(INPUT_EVENT_KIND_REL, axis, value);
|
||||
qemu_input_event_send(src, evt);
|
||||
qapi_free_InputEvent(evt);
|
||||
InputMoveEvent move = {
|
||||
.axis = axis,
|
||||
.value = value,
|
||||
};
|
||||
InputEvent evt = {
|
||||
.type = INPUT_EVENT_KIND_REL,
|
||||
.u.rel.data = &move,
|
||||
};
|
||||
|
||||
qemu_input_event_send(src, &evt);
|
||||
}
|
||||
|
||||
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
|
||||
int min_in, int max_in)
|
||||
{
|
||||
InputEvent *evt;
|
||||
int scaled = qemu_input_scale_axis(value, min_in, max_in,
|
||||
InputMoveEvent move = {
|
||||
.axis = axis,
|
||||
.value = qemu_input_scale_axis(value, min_in, max_in,
|
||||
INPUT_EVENT_ABS_MIN,
|
||||
INPUT_EVENT_ABS_MAX);
|
||||
evt = qemu_input_event_new_move(INPUT_EVENT_KIND_ABS, axis, scaled);
|
||||
qemu_input_event_send(src, evt);
|
||||
qapi_free_InputEvent(evt);
|
||||
INPUT_EVENT_ABS_MAX),
|
||||
};
|
||||
InputEvent evt = {
|
||||
.type = INPUT_EVENT_KIND_ABS,
|
||||
.u.abs.data = &move,
|
||||
};
|
||||
|
||||
qemu_input_event_send(src, &evt);
|
||||
}
|
||||
|
||||
void qemu_input_check_mode_change(void)
|
||||
|
|
Loading…
Reference in New Issue