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
@ -842,14 +842,16 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
|
|||||||
{
|
{
|
||||||
ChannelState *s = (ChannelState *)dev;
|
ChannelState *s = (ChannelState *)dev;
|
||||||
int qcode, keycode;
|
int qcode, keycode;
|
||||||
|
InputKeyEvent *key;
|
||||||
|
|
||||||
assert(evt->type == INPUT_EVENT_KIND_KEY);
|
assert(evt->type == INPUT_EVENT_KIND_KEY);
|
||||||
qcode = qemu_input_key_value_to_qcode(evt->u.key->key);
|
key = evt->u.key;
|
||||||
|
qcode = qemu_input_key_value_to_qcode(key->key);
|
||||||
trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode],
|
trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode],
|
||||||
evt->u.key->down);
|
key->down);
|
||||||
|
|
||||||
if (qcode == Q_KEY_CODE_CAPS_LOCK) {
|
if (qcode == Q_KEY_CODE_CAPS_LOCK) {
|
||||||
if (evt->u.key->down) {
|
if (key->down) {
|
||||||
s->caps_lock_mode ^= 1;
|
s->caps_lock_mode ^= 1;
|
||||||
if (s->caps_lock_mode == 2) {
|
if (s->caps_lock_mode == 2) {
|
||||||
return; /* Drop second press */
|
return; /* Drop second press */
|
||||||
@ -863,7 +865,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qcode == Q_KEY_CODE_NUM_LOCK) {
|
if (qcode == Q_KEY_CODE_NUM_LOCK) {
|
||||||
if (evt->u.key->down) {
|
if (key->down) {
|
||||||
s->num_lock_mode ^= 1;
|
s->num_lock_mode ^= 1;
|
||||||
if (s->num_lock_mode == 2) {
|
if (s->num_lock_mode == 2) {
|
||||||
return; /* Drop second press */
|
return; /* Drop second press */
|
||||||
@ -877,7 +879,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
keycode = qcode_to_keycode[qcode];
|
keycode = qcode_to_keycode[qcode];
|
||||||
if (!evt->u.key->down) {
|
if (!key->down) {
|
||||||
keycode |= 0x80;
|
keycode |= 0x80;
|
||||||
}
|
}
|
||||||
trace_escc_sunkbd_event_out(keycode);
|
trace_escc_sunkbd_event_out(keycode);
|
||||||
|
@ -116,37 +116,42 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src,
|
|||||||
};
|
};
|
||||||
HIDState *hs = (HIDState *)dev;
|
HIDState *hs = (HIDState *)dev;
|
||||||
HIDPointerEvent *e;
|
HIDPointerEvent *e;
|
||||||
|
InputMoveEvent *move;
|
||||||
|
InputBtnEvent *btn;
|
||||||
|
|
||||||
assert(hs->n < QUEUE_LENGTH);
|
assert(hs->n < QUEUE_LENGTH);
|
||||||
e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK];
|
e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK];
|
||||||
|
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
case INPUT_EVENT_KIND_REL:
|
case INPUT_EVENT_KIND_REL:
|
||||||
if (evt->u.rel->axis == INPUT_AXIS_X) {
|
move = evt->u.rel;
|
||||||
e->xdx += evt->u.rel->value;
|
if (move->axis == INPUT_AXIS_X) {
|
||||||
} else if (evt->u.rel->axis == INPUT_AXIS_Y) {
|
e->xdx += move->value;
|
||||||
e->ydy += evt->u.rel->value;
|
} else if (move->axis == INPUT_AXIS_Y) {
|
||||||
|
e->ydy += move->value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_EVENT_KIND_ABS:
|
case INPUT_EVENT_KIND_ABS:
|
||||||
if (evt->u.rel->axis == INPUT_AXIS_X) {
|
move = evt->u.abs;
|
||||||
e->xdx = evt->u.rel->value;
|
if (move->axis == INPUT_AXIS_X) {
|
||||||
} else if (evt->u.rel->axis == INPUT_AXIS_Y) {
|
e->xdx = move->value;
|
||||||
e->ydy = evt->u.rel->value;
|
} else if (move->axis == INPUT_AXIS_Y) {
|
||||||
|
e->ydy = move->value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_EVENT_KIND_BTN:
|
case INPUT_EVENT_KIND_BTN:
|
||||||
if (evt->u.btn->down) {
|
btn = evt->u.btn;
|
||||||
e->buttons_state |= bmap[evt->u.btn->button];
|
if (btn->down) {
|
||||||
if (evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) {
|
e->buttons_state |= bmap[btn->button];
|
||||||
|
if (btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||||
e->dz--;
|
e->dz--;
|
||||||
} else if (evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
} else if (btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||||
e->dz++;
|
e->dz++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
e->buttons_state &= ~bmap[evt->u.btn->button];
|
e->buttons_state &= ~bmap[btn->button];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -223,9 +228,10 @@ static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
|
|||||||
HIDState *hs = (HIDState *)dev;
|
HIDState *hs = (HIDState *)dev;
|
||||||
int scancodes[3], i, count;
|
int scancodes[3], i, count;
|
||||||
int slot;
|
int slot;
|
||||||
|
InputKeyEvent *key = evt->u.key;
|
||||||
|
|
||||||
count = qemu_input_key_value_to_scancode(evt->u.key->key,
|
count = qemu_input_key_value_to_scancode(key->key,
|
||||||
evt->u.key->down,
|
key->down,
|
||||||
scancodes);
|
scancodes);
|
||||||
if (hs->n + count > QUEUE_LENGTH) {
|
if (hs->n + count > QUEUE_LENGTH) {
|
||||||
fprintf(stderr, "usb-kbd: warning: key event queue full\n");
|
fprintf(stderr, "usb-kbd: warning: key event queue full\n");
|
||||||
|
@ -182,10 +182,11 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
|
|||||||
{
|
{
|
||||||
PS2KbdState *s = (PS2KbdState *)dev;
|
PS2KbdState *s = (PS2KbdState *)dev;
|
||||||
int scancodes[3], i, count;
|
int scancodes[3], i, count;
|
||||||
|
InputKeyEvent *key = evt->u.key;
|
||||||
|
|
||||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
||||||
count = qemu_input_key_value_to_scancode(evt->u.key->key,
|
count = qemu_input_key_value_to_scancode(key->key,
|
||||||
evt->u.key->down,
|
key->down,
|
||||||
scancodes);
|
scancodes);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
ps2_put_keycode(s, scancodes[i]);
|
ps2_put_keycode(s, scancodes[i]);
|
||||||
@ -389,6 +390,8 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
|
|||||||
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
|
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
|
||||||
};
|
};
|
||||||
PS2MouseState *s = (PS2MouseState *)dev;
|
PS2MouseState *s = (PS2MouseState *)dev;
|
||||||
|
InputMoveEvent *move;
|
||||||
|
InputBtnEvent *btn;
|
||||||
|
|
||||||
/* check if deltas are recorded when disabled */
|
/* check if deltas are recorded when disabled */
|
||||||
if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
|
if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
|
||||||
@ -396,23 +399,25 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
|
|||||||
|
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
case INPUT_EVENT_KIND_REL:
|
case INPUT_EVENT_KIND_REL:
|
||||||
if (evt->u.rel->axis == INPUT_AXIS_X) {
|
move = evt->u.rel;
|
||||||
s->mouse_dx += evt->u.rel->value;
|
if (move->axis == INPUT_AXIS_X) {
|
||||||
} else if (evt->u.rel->axis == INPUT_AXIS_Y) {
|
s->mouse_dx += move->value;
|
||||||
s->mouse_dy -= evt->u.rel->value;
|
} else if (move->axis == INPUT_AXIS_Y) {
|
||||||
|
s->mouse_dy -= move->value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_EVENT_KIND_BTN:
|
case INPUT_EVENT_KIND_BTN:
|
||||||
if (evt->u.btn->down) {
|
btn = evt->u.btn;
|
||||||
s->mouse_buttons |= bmap[evt->u.btn->button];
|
if (btn->down) {
|
||||||
if (evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) {
|
s->mouse_buttons |= bmap[btn->button];
|
||||||
|
if (btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||||
s->mouse_dz--;
|
s->mouse_dz--;
|
||||||
} else if (evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
} else if (btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||||
s->mouse_dz++;
|
s->mouse_dz++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s->mouse_buttons &= ~bmap[evt->u.btn->button];
|
s->mouse_buttons &= ~bmap[btn->button];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -191,46 +191,53 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
|
|||||||
VirtIOInput *vinput = VIRTIO_INPUT(dev);
|
VirtIOInput *vinput = VIRTIO_INPUT(dev);
|
||||||
virtio_input_event event;
|
virtio_input_event event;
|
||||||
int qcode;
|
int qcode;
|
||||||
|
InputKeyEvent *key;
|
||||||
|
InputMoveEvent *move;
|
||||||
|
InputBtnEvent *btn;
|
||||||
|
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
case INPUT_EVENT_KIND_KEY:
|
case INPUT_EVENT_KIND_KEY:
|
||||||
qcode = qemu_input_key_value_to_qcode(evt->u.key->key);
|
key = evt->u.key;
|
||||||
|
qcode = qemu_input_key_value_to_qcode(key->key);
|
||||||
if (qcode && keymap_qcode[qcode]) {
|
if (qcode && keymap_qcode[qcode]) {
|
||||||
event.type = cpu_to_le16(EV_KEY);
|
event.type = cpu_to_le16(EV_KEY);
|
||||||
event.code = cpu_to_le16(keymap_qcode[qcode]);
|
event.code = cpu_to_le16(keymap_qcode[qcode]);
|
||||||
event.value = cpu_to_le32(evt->u.key->down ? 1 : 0);
|
event.value = cpu_to_le32(key->down ? 1 : 0);
|
||||||
virtio_input_send(vinput, &event);
|
virtio_input_send(vinput, &event);
|
||||||
} else {
|
} else {
|
||||||
if (evt->u.key->down) {
|
if (key->down) {
|
||||||
fprintf(stderr, "%s: unmapped key: %d [%s]\n", __func__,
|
fprintf(stderr, "%s: unmapped key: %d [%s]\n", __func__,
|
||||||
qcode, QKeyCode_lookup[qcode]);
|
qcode, QKeyCode_lookup[qcode]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_BTN:
|
case INPUT_EVENT_KIND_BTN:
|
||||||
if (keymap_button[evt->u.btn->button]) {
|
btn = evt->u.btn;
|
||||||
|
if (keymap_button[btn->button]) {
|
||||||
event.type = cpu_to_le16(EV_KEY);
|
event.type = cpu_to_le16(EV_KEY);
|
||||||
event.code = cpu_to_le16(keymap_button[evt->u.btn->button]);
|
event.code = cpu_to_le16(keymap_button[btn->button]);
|
||||||
event.value = cpu_to_le32(evt->u.btn->down ? 1 : 0);
|
event.value = cpu_to_le32(btn->down ? 1 : 0);
|
||||||
virtio_input_send(vinput, &event);
|
virtio_input_send(vinput, &event);
|
||||||
} else {
|
} else {
|
||||||
if (evt->u.btn->down) {
|
if (btn->down) {
|
||||||
fprintf(stderr, "%s: unmapped button: %d [%s]\n", __func__,
|
fprintf(stderr, "%s: unmapped button: %d [%s]\n", __func__,
|
||||||
evt->u.btn->button,
|
btn->button,
|
||||||
InputButton_lookup[evt->u.btn->button]);
|
InputButton_lookup[btn->button]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_REL:
|
case INPUT_EVENT_KIND_REL:
|
||||||
|
move = evt->u.rel;
|
||||||
event.type = cpu_to_le16(EV_REL);
|
event.type = cpu_to_le16(EV_REL);
|
||||||
event.code = cpu_to_le16(axismap_rel[evt->u.rel->axis]);
|
event.code = cpu_to_le16(axismap_rel[move->axis]);
|
||||||
event.value = cpu_to_le32(evt->u.rel->value);
|
event.value = cpu_to_le32(move->value);
|
||||||
virtio_input_send(vinput, &event);
|
virtio_input_send(vinput, &event);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_ABS:
|
case INPUT_EVENT_KIND_ABS:
|
||||||
|
move = evt->u.abs;
|
||||||
event.type = cpu_to_le16(EV_ABS);
|
event.type = cpu_to_le16(EV_ABS);
|
||||||
event.code = cpu_to_le16(axismap_abs[evt->u.abs->axis]);
|
event.code = cpu_to_le16(axismap_abs[move->axis]);
|
||||||
event.value = cpu_to_le32(evt->u.abs->value);
|
event.value = cpu_to_le32(move->value);
|
||||||
virtio_input_send(vinput, &event);
|
virtio_input_send(vinput, &event);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -47,20 +47,24 @@ static InputEvent *qapi_clone_InputEvent(InputEvent *src)
|
|||||||
|
|
||||||
void replay_save_input_event(InputEvent *evt)
|
void replay_save_input_event(InputEvent *evt)
|
||||||
{
|
{
|
||||||
|
InputKeyEvent *key;
|
||||||
|
InputBtnEvent *btn;
|
||||||
|
InputMoveEvent *move;
|
||||||
replay_put_dword(evt->type);
|
replay_put_dword(evt->type);
|
||||||
|
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
case INPUT_EVENT_KIND_KEY:
|
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:
|
case KEY_VALUE_KIND_NUMBER:
|
||||||
replay_put_qword(evt->u.key->key->u.number);
|
replay_put_qword(key->key->u.number);
|
||||||
replay_put_byte(evt->u.key->down);
|
replay_put_byte(key->down);
|
||||||
break;
|
break;
|
||||||
case KEY_VALUE_KIND_QCODE:
|
case KEY_VALUE_KIND_QCODE:
|
||||||
replay_put_dword(evt->u.key->key->u.qcode);
|
replay_put_dword(key->key->u.qcode);
|
||||||
replay_put_byte(evt->u.key->down);
|
replay_put_byte(key->down);
|
||||||
break;
|
break;
|
||||||
case KEY_VALUE_KIND__MAX:
|
case KEY_VALUE_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
@ -68,16 +72,19 @@ void replay_save_input_event(InputEvent *evt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_BTN:
|
case INPUT_EVENT_KIND_BTN:
|
||||||
replay_put_dword(evt->u.btn->button);
|
btn = evt->u.btn;
|
||||||
replay_put_byte(evt->u.btn->down);
|
replay_put_dword(btn->button);
|
||||||
|
replay_put_byte(btn->down);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_REL:
|
case INPUT_EVENT_KIND_REL:
|
||||||
replay_put_dword(evt->u.rel->axis);
|
move = evt->u.rel;
|
||||||
replay_put_qword(evt->u.rel->value);
|
replay_put_dword(move->axis);
|
||||||
|
replay_put_qword(move->value);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_ABS:
|
case INPUT_EVENT_KIND_ABS:
|
||||||
replay_put_dword(evt->u.abs->axis);
|
move = evt->u.abs;
|
||||||
replay_put_qword(evt->u.abs->value);
|
replay_put_dword(move->axis);
|
||||||
|
replay_put_qword(move->value);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND__MAX:
|
case INPUT_EVENT_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
|
@ -110,12 +110,13 @@ static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
|
|||||||
{
|
{
|
||||||
QEMUPutKbdEntry *entry = (QEMUPutKbdEntry *)dev;
|
QEMUPutKbdEntry *entry = (QEMUPutKbdEntry *)dev;
|
||||||
int scancodes[3], i, count;
|
int scancodes[3], i, count;
|
||||||
|
InputKeyEvent *key = evt->u.key;
|
||||||
|
|
||||||
if (!entry || !entry->put_kbd) {
|
if (!entry || !entry->put_kbd) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
count = qemu_input_key_value_to_scancode(evt->u.key->key,
|
count = qemu_input_key_value_to_scancode(key->key,
|
||||||
evt->u.key->down,
|
key->down,
|
||||||
scancodes);
|
scancodes);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
entry->put_kbd(entry->opaque, scancodes[i]);
|
entry->put_kbd(entry->opaque, scancodes[i]);
|
||||||
@ -150,23 +151,25 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
|
|||||||
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
|
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
|
||||||
};
|
};
|
||||||
QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
|
QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
|
||||||
|
InputBtnEvent *btn;
|
||||||
|
InputMoveEvent *move;
|
||||||
|
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
case INPUT_EVENT_KIND_BTN:
|
case INPUT_EVENT_KIND_BTN:
|
||||||
if (evt->u.btn->down) {
|
btn = evt->u.btn;
|
||||||
s->buttons |= bmap[evt->u.btn->button];
|
if (btn->down) {
|
||||||
|
s->buttons |= bmap[btn->button];
|
||||||
} else {
|
} else {
|
||||||
s->buttons &= ~bmap[evt->u.btn->button];
|
s->buttons &= ~bmap[btn->button];
|
||||||
}
|
}
|
||||||
if (evt->u.btn->down && evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) {
|
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||||
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
|
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
|
||||||
s->axis[INPUT_AXIS_X],
|
s->axis[INPUT_AXIS_X],
|
||||||
s->axis[INPUT_AXIS_Y],
|
s->axis[INPUT_AXIS_Y],
|
||||||
-1,
|
-1,
|
||||||
s->buttons);
|
s->buttons);
|
||||||
}
|
}
|
||||||
if (evt->u.btn->down &&
|
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||||
evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
|
||||||
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
|
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
|
||||||
s->axis[INPUT_AXIS_X],
|
s->axis[INPUT_AXIS_X],
|
||||||
s->axis[INPUT_AXIS_Y],
|
s->axis[INPUT_AXIS_Y],
|
||||||
@ -175,10 +178,12 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_ABS:
|
case INPUT_EVENT_KIND_ABS:
|
||||||
s->axis[evt->u.abs->axis] = evt->u.abs->value;
|
move = evt->u.abs;
|
||||||
|
s->axis[move->axis] = move->value;
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_REL:
|
case INPUT_EVENT_KIND_REL:
|
||||||
s->axis[evt->u.rel->axis] += evt->u.rel->value;
|
move = evt->u.rel;
|
||||||
|
s->axis[move->axis] += move->value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
54
ui/input.c
54
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)
|
static void qemu_input_transform_abs_rotate(InputEvent *evt)
|
||||||
{
|
{
|
||||||
|
InputMoveEvent *move = evt->u.abs;
|
||||||
switch (graphic_rotate) {
|
switch (graphic_rotate) {
|
||||||
case 90:
|
case 90:
|
||||||
if (evt->u.abs->axis == INPUT_AXIS_X) {
|
if (move->axis == INPUT_AXIS_X) {
|
||||||
evt->u.abs->axis = INPUT_AXIS_Y;
|
move->axis = INPUT_AXIS_Y;
|
||||||
} else if (evt->u.abs->axis == INPUT_AXIS_Y) {
|
} else if (move->axis == INPUT_AXIS_Y) {
|
||||||
evt->u.abs->axis = INPUT_AXIS_X;
|
move->axis = INPUT_AXIS_X;
|
||||||
evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value;
|
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 180:
|
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;
|
break;
|
||||||
case 270:
|
case 270:
|
||||||
if (evt->u.abs->axis == INPUT_AXIS_X) {
|
if (move->axis == INPUT_AXIS_X) {
|
||||||
evt->u.abs->axis = INPUT_AXIS_Y;
|
move->axis = INPUT_AXIS_Y;
|
||||||
evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value;
|
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
|
||||||
} else if (evt->u.abs->axis == INPUT_AXIS_Y) {
|
} else if (move->axis == INPUT_AXIS_Y) {
|
||||||
evt->u.abs->axis = INPUT_AXIS_X;
|
move->axis = INPUT_AXIS_X;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -193,22 +194,26 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
|
|||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int qcode, idx = -1;
|
int qcode, idx = -1;
|
||||||
|
InputKeyEvent *key;
|
||||||
|
InputBtnEvent *btn;
|
||||||
|
InputMoveEvent *move;
|
||||||
|
|
||||||
if (src) {
|
if (src) {
|
||||||
idx = qemu_console_get_index(src);
|
idx = qemu_console_get_index(src);
|
||||||
}
|
}
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
case INPUT_EVENT_KIND_KEY:
|
case INPUT_EVENT_KIND_KEY:
|
||||||
switch (evt->u.key->key->type) {
|
key = evt->u.key;
|
||||||
|
switch (key->key->type) {
|
||||||
case KEY_VALUE_KIND_NUMBER:
|
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];
|
name = QKeyCode_lookup[qcode];
|
||||||
trace_input_event_key_number(idx, evt->u.key->key->u.number,
|
trace_input_event_key_number(idx, key->key->u.number,
|
||||||
name, evt->u.key->down);
|
name, key->down);
|
||||||
break;
|
break;
|
||||||
case KEY_VALUE_KIND_QCODE:
|
case KEY_VALUE_KIND_QCODE:
|
||||||
name = QKeyCode_lookup[evt->u.key->key->u.qcode];
|
name = QKeyCode_lookup[key->key->u.qcode];
|
||||||
trace_input_event_key_qcode(idx, name, evt->u.key->down);
|
trace_input_event_key_qcode(idx, name, key->down);
|
||||||
break;
|
break;
|
||||||
case KEY_VALUE_KIND__MAX:
|
case KEY_VALUE_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
@ -216,16 +221,19 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_BTN:
|
case INPUT_EVENT_KIND_BTN:
|
||||||
name = InputButton_lookup[evt->u.btn->button];
|
btn = evt->u.btn;
|
||||||
trace_input_event_btn(idx, name, evt->u.btn->down);
|
name = InputButton_lookup[btn->button];
|
||||||
|
trace_input_event_btn(idx, name, btn->down);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_REL:
|
case INPUT_EVENT_KIND_REL:
|
||||||
name = InputAxis_lookup[evt->u.rel->axis];
|
move = evt->u.rel;
|
||||||
trace_input_event_rel(idx, name, evt->u.rel->value);
|
name = InputAxis_lookup[move->axis];
|
||||||
|
trace_input_event_rel(idx, name, move->value);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND_ABS:
|
case INPUT_EVENT_KIND_ABS:
|
||||||
name = InputAxis_lookup[evt->u.abs->axis];
|
move = evt->u.abs;
|
||||||
trace_input_event_abs(idx, name, evt->u.abs->value);
|
name = InputAxis_lookup[move->axis];
|
||||||
|
trace_input_event_abs(idx, name, move->value);
|
||||||
break;
|
break;
|
||||||
case INPUT_EVENT_KIND__MAX:
|
case INPUT_EVENT_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
|
Loading…
Reference in New Issue
Block a user