mirror of
https://github.com/qemu/qemu.git
synced 2024-11-30 15:23:34 +08:00
21635e121a
HID reorganziation broke the usb tablet in windows xp. The reason is that xp activates idle before it starts polling, which creates a chicken-and-egg issue: We don't call hid_pointer_poll because there are no pending events. We don't get any events because the activation code in hid_pointer_poll is never executed and thus all pointer events are routed to the PS/2 mouse by qemu. Fix this by creating a hid_pointer_activate function and call it from usb-hid when the guest sets the idle state. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
60 lines
1.5 KiB
C
60 lines
1.5 KiB
C
#ifndef QEMU_HID_H
|
|
#define QEMU_HID_H
|
|
|
|
#define HID_MOUSE 1
|
|
#define HID_TABLET 2
|
|
#define HID_KEYBOARD 3
|
|
|
|
typedef struct HIDPointerEvent {
|
|
int32_t xdx, ydy; /* relative iff it's a mouse, otherwise absolute */
|
|
int32_t dz, buttons_state;
|
|
} HIDPointerEvent;
|
|
|
|
#define QUEUE_LENGTH 16 /* should be enough for a triple-click */
|
|
#define QUEUE_MASK (QUEUE_LENGTH-1u)
|
|
#define QUEUE_INCR(v) ((v)++, (v) &= QUEUE_MASK)
|
|
|
|
typedef struct HIDState HIDState;
|
|
typedef void (*HIDEventFunc)(HIDState *s);
|
|
|
|
typedef struct HIDMouseState {
|
|
HIDPointerEvent queue[QUEUE_LENGTH];
|
|
int mouse_grabbed;
|
|
QEMUPutMouseEntry *eh_entry;
|
|
} HIDMouseState;
|
|
|
|
typedef struct HIDKeyboardState {
|
|
uint32_t keycodes[QUEUE_LENGTH];
|
|
uint16_t modifiers;
|
|
uint8_t leds;
|
|
uint8_t key[16];
|
|
int32_t keys;
|
|
} HIDKeyboardState;
|
|
|
|
struct HIDState {
|
|
union {
|
|
HIDMouseState ptr;
|
|
HIDKeyboardState kbd;
|
|
};
|
|
uint32_t head; /* index into circular queue */
|
|
uint32_t n;
|
|
int kind;
|
|
int32_t protocol;
|
|
uint8_t idle;
|
|
int64_t next_idle_clock;
|
|
HIDEventFunc event;
|
|
};
|
|
|
|
void hid_init(HIDState *hs, int kind, HIDEventFunc event);
|
|
void hid_reset(HIDState *hs);
|
|
void hid_free(HIDState *hs);
|
|
|
|
bool hid_has_events(HIDState *hs);
|
|
void hid_set_next_idle(HIDState *hs, int64_t curtime);
|
|
void hid_pointer_activate(HIDState *hs);
|
|
int hid_pointer_poll(HIDState *hs, uint8_t *buf, int len);
|
|
int hid_keyboard_poll(HIDState *hs, uint8_t *buf, int len);
|
|
int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len);
|
|
|
|
#endif /* QEMU_HID_H */
|