2 * This work is licensed under the terms of the GNU GPL, version 2 or
3 * (at your option) any later version. See the COPYING file in the
7 #ifndef QEMU_UI_KBD_STATE_H
8 #define QEMU_UI_KBD_STATE_H
10 #include "qapi/qapi-types-ui.h"
12 typedef enum QKbdModifier QKbdModifier
;
28 typedef struct QKbdState QKbdState
;
31 * qkbd_state_init: init keyboard state tracker.
33 * Allocates and initializes keyboard state struct.
35 * @con: QemuConsole for this state tracker. Gets passed down to
36 * qemu_input_*() functions when sending key events to the guest.
38 QKbdState
*qkbd_state_init(QemuConsole
*con
);
41 * qkbd_state_free: free keyboard tracker state.
43 * @kbd: state tracker state.
45 void qkbd_state_free(QKbdState
*kbd
);
48 * qkbd_state_key_event: process key event.
50 * Update keyboard state, send event to the guest.
52 * This function takes care to not send suspious events (keyup event
53 * for a key not pressed for example).
55 * @kbd: state tracker state.
56 * @qcode: the key pressed or released.
57 * @down: true for key down events, false otherwise.
59 void qkbd_state_key_event(QKbdState
*kbd
, QKeyCode qcode
, bool down
);
62 * qkbd_state_set_delay: set key press delay.
64 * When set the specified delay will be added after each key event,
65 * using qemu_input_event_send_key_delay().
67 * @kbd: state tracker state.
68 * @delay_ms: the delay in milliseconds.
70 void qkbd_state_set_delay(QKbdState
*kbd
, int delay_ms
);
73 * qkbd_state_key_get: get key state.
75 * Returns true when the key is down.
77 * @kbd: state tracker state.
78 * @qcode: the key to query.
80 bool qkbd_state_key_get(QKbdState
*kbd
, QKeyCode qcode
);
83 * qkbd_state_modifier_get: get modifier state.
85 * Returns true when the modifier is active.
87 * @kbd: state tracker state.
88 * @mod: the modifier to query.
90 bool qkbd_state_modifier_get(QKbdState
*kbd
, QKbdModifier mod
);
93 * qkbd_state_lift_all_keys: lift all pressed keys.
95 * This sends key up events to the guest for all keys which are in
98 * @kbd: state tracker state.
100 void qkbd_state_lift_all_keys(QKbdState
*kbd
);
103 * qkbd_state_switch_console: Switch console.
105 * This sends key up events to the previous console for all keys which are in
106 * down state to prevent keys being stuck, and remembers the new console.
108 * @kbd: state tracker state.
109 * @con: new QemuConsole for this state tracker.
111 void qkbd_state_switch_console(QKbdState
*kbd
, QemuConsole
*con
);
113 #endif /* QEMU_UI_KBD_STATE_H */