MAINTAINERS: Make section QOM cover hw/core/*bus.c as well
[qemu/armbru.git] / include / ui / kbd-state.h
blobeb9067dd532c2e76db336d8542b4d1e8424e8208
1 /*
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
4 * top-level directory.
5 */
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;
14 enum QKbdModifier {
15 QKBD_MOD_NONE = 0,
17 QKBD_MOD_SHIFT,
18 QKBD_MOD_CTRL,
19 QKBD_MOD_ALT,
20 QKBD_MOD_ALTGR,
22 QKBD_MOD_NUMLOCK,
23 QKBD_MOD_CAPSLOCK,
25 QKBD_MOD__MAX
28 typedef struct QKbdState QKbdState;
30 /**
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);
40 /**
41 * qkbd_state_free: free keyboard tracker state.
43 * @kbd: state tracker state.
45 void qkbd_state_free(QKbdState *kbd);
47 /**
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);
61 /**
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 miliseconds.
70 void qkbd_state_set_delay(QKbdState *kbd, int delay_ms);
72 /**
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);
82 /**
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);
92 /**
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
96 * down state.
98 * @kbd: state tracker state.
100 void qkbd_state_lift_all_keys(QKbdState *kbd);
102 #endif /* QEMU_UI_KBD_STATE_H */