input.h 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#ifndef INPUT_H
#define INPUT_H

#include "qapi-types.h"

#define INPUT_EVENT_MASK_KEY   (1<<INPUT_EVENT_KIND_KEY)
#define INPUT_EVENT_MASK_BTN   (1<<INPUT_EVENT_KIND_BTN)
#define INPUT_EVENT_MASK_REL   (1<<INPUT_EVENT_KIND_REL)
#define INPUT_EVENT_MASK_ABS   (1<<INPUT_EVENT_KIND_ABS)

11 12
#define INPUT_EVENT_ABS_MIN    0x0000
#define INPUT_EVENT_ABS_MAX    0x7FFF
13

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
typedef struct QemuInputHandler QemuInputHandler;
typedef struct QemuInputHandlerState QemuInputHandlerState;

typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
                                      InputEvent *evt);
typedef void (*QemuInputHandlerSync)(DeviceState *dev);

struct QemuInputHandler {
    const char             *name;
    uint32_t               mask;
    QemuInputHandlerEvent  event;
    QemuInputHandlerSync   sync;
};

QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
                                                   QemuInputHandler *handler);
void qemu_input_handler_activate(QemuInputHandlerState *s);
31
void qemu_input_handler_deactivate(QemuInputHandlerState *s);
32
void qemu_input_handler_unregister(QemuInputHandlerState *s);
33 34 35
void qemu_input_handler_bind(QemuInputHandlerState *s,
                             const char *device_id, int head,
                             Error **errp);
36
void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
37
void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt);
38
void qemu_input_event_sync(void);
39
void qemu_input_event_sync_impl(void);
40

41 42 43
void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
44
void qemu_input_event_send_key_delay(uint32_t delay_ms);
45
int qemu_input_key_number_to_qcode(unsigned int nr);
G
Gerd Hoffmann 已提交
46 47 48 49
int qemu_input_key_value_to_number(const KeyValue *value);
int qemu_input_key_value_to_qcode(const KeyValue *value);
int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
                                     int *codes);
50
int qemu_input_linux_to_qcode(unsigned int lnx);
51

52 53 54 55 56
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);

57
bool qemu_input_is_absolute(void);
58 59 60
int qemu_input_scale_axis(int value,
                          int min_in, int max_in,
                          int min_out, int max_out);
61 62 63
InputEvent *qemu_input_event_new_move(InputEventKind kind,
                                      InputAxis axis, int value);
void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
64 65
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
                          int min_in, int max_in);
66

67 68 69 70
void qemu_input_check_mode_change(void);
void qemu_add_mouse_mode_change_notifier(Notifier *notify);
void qemu_remove_mouse_mode_change_notifier(Notifier *notify);

71 72 73 74 75 76 77 78 79
extern const guint qemu_input_map_linux_to_qcode_len;
extern const guint16 qemu_input_map_linux_to_qcode[];

extern const guint qemu_input_map_qcode_to_qnum_len;
extern const guint16 qemu_input_map_qcode_to_qnum[];

extern const guint qemu_input_map_qnum_to_qcode_len;
extern const guint16 qemu_input_map_qnum_to_qcode[];

80
#endif /* INPUT_H */