mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
ui: Shorten references into InputEvent
An upcoming patch will alter how simple unions, like InputEvent, are laid out, which will impact all lines of the form 'evt->u.XXX' (expanding it to the longer 'evt->u.XXX.data'). For better legibility in that patch, and less need for line wrapping, it's better to use a temporary variable to reduce the effect of a layout change to just the variable initializations, rather than every reference within an InputEvent. There was one instance in hid.c:hid_pointer_event() where the code was referring to evt->u.rel inside the case label where evt->u.abs is the correct name; thankfully, both members of the union have the same type, so it happened to work, but it is now cleaner. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1457021813-10704-8-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
0399293e5b
commit
b5a1b44318
7 changed files with 129 additions and 89 deletions
|
@ -47,20 +47,24 @@ static InputEvent *qapi_clone_InputEvent(InputEvent *src)
|
|||
|
||||
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:
|
||||
replay_put_dword(evt->u.key->key->type);
|
||||
key = evt->u.key;
|
||||
replay_put_dword(key->key->type);
|
||||
|
||||
switch (evt->u.key->key->type) {
|
||||
switch (key->key->type) {
|
||||
case KEY_VALUE_KIND_NUMBER:
|
||||
replay_put_qword(evt->u.key->key->u.number);
|
||||
replay_put_byte(evt->u.key->down);
|
||||
replay_put_qword(key->key->u.number);
|
||||
replay_put_byte(key->down);
|
||||
break;
|
||||
case KEY_VALUE_KIND_QCODE:
|
||||
replay_put_dword(evt->u.key->key->u.qcode);
|
||||
replay_put_byte(evt->u.key->down);
|
||||
replay_put_dword(key->key->u.qcode);
|
||||
replay_put_byte(key->down);
|
||||
break;
|
||||
case KEY_VALUE_KIND__MAX:
|
||||
/* keep gcc happy */
|
||||
|
@ -68,16 +72,19 @@ void replay_save_input_event(InputEvent *evt)
|
|||
}
|
||||
break;
|
||||
case INPUT_EVENT_KIND_BTN:
|
||||
replay_put_dword(evt->u.btn->button);
|
||||
replay_put_byte(evt->u.btn->down);
|
||||
btn = evt->u.btn;
|
||||
replay_put_dword(btn->button);
|
||||
replay_put_byte(btn->down);
|
||||
break;
|
||||
case INPUT_EVENT_KIND_REL:
|
||||
replay_put_dword(evt->u.rel->axis);
|
||||
replay_put_qword(evt->u.rel->value);
|
||||
move = evt->u.rel;
|
||||
replay_put_dword(move->axis);
|
||||
replay_put_qword(move->value);
|
||||
break;
|
||||
case INPUT_EVENT_KIND_ABS:
|
||||
replay_put_dword(evt->u.abs->axis);
|
||||
replay_put_qword(evt->u.abs->value);
|
||||
move = evt->u.abs;
|
||||
replay_put_dword(move->axis);
|
||||
replay_put_qword(move->value);
|
||||
break;
|
||||
case INPUT_EVENT_KIND__MAX:
|
||||
/* keep gcc happy */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue