aboutsummaryrefslogtreecommitdiff
path: root/ui/input.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-03-03 09:16:49 -0700
committerMarkus Armbruster <armbru@redhat.com>2016-03-05 10:41:55 +0100
commitb5a1b443183f56e0b9ad0f72614bdff7ace780d5 (patch)
tree7fde6bb5891be9df92ff7ec01f1062915eed09d9 /ui/input.c
parent0399293e5b9e5443b82103fa8e2c97deadef9825 (diff)
downloadqemu-b5a1b443183f56e0b9ad0f72614bdff7ace780d5.zip
qemu-b5a1b443183f56e0b9ad0f72614bdff7ace780d5.tar.gz
qemu-b5a1b443183f56e0b9ad0f72614bdff7ace780d5.tar.bz2
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>
Diffstat (limited to 'ui/input.c')
-rw-r--r--ui/input.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/ui/input.c b/ui/input.c
index 6fd48ef..13ee117 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -166,24 +166,25 @@ void qmp_input_send_event(bool has_device, const char *device,
static void qemu_input_transform_abs_rotate(InputEvent *evt)
{
+ InputMoveEvent *move = evt->u.abs;
switch (graphic_rotate) {
case 90:
- if (evt->u.abs->axis == INPUT_AXIS_X) {
- evt->u.abs->axis = INPUT_AXIS_Y;
- } else if (evt->u.abs->axis == INPUT_AXIS_Y) {
- evt->u.abs->axis = INPUT_AXIS_X;
- evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value;
+ if (move->axis == INPUT_AXIS_X) {
+ move->axis = INPUT_AXIS_Y;
+ } else if (move->axis == INPUT_AXIS_Y) {
+ move->axis = INPUT_AXIS_X;
+ move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
}
break;
case 180:
- evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value;
+ move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
break;
case 270:
- if (evt->u.abs->axis == INPUT_AXIS_X) {
- evt->u.abs->axis = INPUT_AXIS_Y;
- evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value;
- } else if (evt->u.abs->axis == INPUT_AXIS_Y) {
- evt->u.abs->axis = INPUT_AXIS_X;
+ if (move->axis == INPUT_AXIS_X) {
+ move->axis = INPUT_AXIS_Y;
+ move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
+ } else if (move->axis == INPUT_AXIS_Y) {
+ move->axis = INPUT_AXIS_X;
}
break;
}
@@ -193,22 +194,26 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
{
const char *name;
int qcode, idx = -1;
+ InputKeyEvent *key;
+ InputBtnEvent *btn;
+ InputMoveEvent *move;
if (src) {
idx = qemu_console_get_index(src);
}
switch (evt->type) {
case INPUT_EVENT_KIND_KEY:
- switch (evt->u.key->key->type) {
+ key = evt->u.key;
+ switch (key->key->type) {
case KEY_VALUE_KIND_NUMBER:
- qcode = qemu_input_key_number_to_qcode(evt->u.key->key->u.number);
+ qcode = qemu_input_key_number_to_qcode(key->key->u.number);
name = QKeyCode_lookup[qcode];
- trace_input_event_key_number(idx, evt->u.key->key->u.number,
- name, evt->u.key->down);
+ trace_input_event_key_number(idx, key->key->u.number,
+ name, key->down);
break;
case KEY_VALUE_KIND_QCODE:
- name = QKeyCode_lookup[evt->u.key->key->u.qcode];
- trace_input_event_key_qcode(idx, name, evt->u.key->down);
+ name = QKeyCode_lookup[key->key->u.qcode];
+ trace_input_event_key_qcode(idx, name, key->down);
break;
case KEY_VALUE_KIND__MAX:
/* keep gcc happy */
@@ -216,16 +221,19 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
}
break;
case INPUT_EVENT_KIND_BTN:
- name = InputButton_lookup[evt->u.btn->button];
- trace_input_event_btn(idx, name, evt->u.btn->down);
+ btn = evt->u.btn;
+ name = InputButton_lookup[btn->button];
+ trace_input_event_btn(idx, name, btn->down);
break;
case INPUT_EVENT_KIND_REL:
- name = InputAxis_lookup[evt->u.rel->axis];
- trace_input_event_rel(idx, name, evt->u.rel->value);
+ move = evt->u.rel;
+ name = InputAxis_lookup[move->axis];
+ trace_input_event_rel(idx, name, move->value);
break;
case INPUT_EVENT_KIND_ABS:
- name = InputAxis_lookup[evt->u.abs->axis];
- trace_input_event_abs(idx, name, evt->u.abs->value);
+ move = evt->u.abs;
+ name = InputAxis_lookup[move->axis];
+ trace_input_event_abs(idx, name, move->value);
break;
case INPUT_EVENT_KIND__MAX:
/* keep gcc happy */