slirp: remove slirp_instances list
[qemu/ar7.git] / include / ui / kbd-state.h
blobd87833553a573d382712f6578028fadd6341d65b
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 */
6 #ifndef QEMU_UI_KBD_STATE_H
7 #define QEMU_UI_KBD_STATE_H 1
9 #include "qapi/qapi-types-ui.h"
11 typedef enum QKbdModifier QKbdModifier;
13 enum QKbdModifier {
14 QKBD_MOD_NONE = 0,
16 QKBD_MOD_SHIFT,
17 QKBD_MOD_CTRL,
18 QKBD_MOD_ALT,
19 QKBD_MOD_ALTGR,
21 QKBD_MOD_NUMLOCK,
22 QKBD_MOD_CAPSLOCK,
24 QKBD_MOD__MAX
27 typedef struct QKbdState QKbdState;
29 /**
30 * qkbd_state_init: init keyboard state tracker.
32 * Allocates and initializes keyboard state struct.
34 * @con: QemuConsole for this state tracker. Gets passed down to
35 * qemu_input_*() functions when sending key events to the guest.
37 QKbdState *qkbd_state_init(QemuConsole *con);
39 /**
40 * qkbd_state_free: free keyboard tracker state.
42 * @kbd: state tracker state.
44 void qkbd_state_free(QKbdState *kbd);
46 /**
47 * qkbd_state_key_event: process key event.
49 * Update keyboard state, send event to the guest.
51 * This function takes care to not send suspious events (keyup event
52 * for a key not pressed for example).
54 * @kbd: state tracker state.
55 * @qcode: the key pressed or released.
56 * @down: true for key down events, false otherwise.
58 void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode, bool down);
60 /**
61 * qkbd_state_set_delay: set key press delay.
63 * When set the specified delay will be added after each key event,
64 * using qemu_input_event_send_key_delay().
66 * @kbd: state tracker state.
67 * @delay_ms: the delay in miliseconds.
69 void qkbd_state_set_delay(QKbdState *kbd, int delay_ms);
71 /**
72 * qkbd_state_key_get: get key state.
74 * Returns true when the key is down.
76 * @kbd: state tracker state.
77 * @qcode: the key to query.
79 bool qkbd_state_key_get(QKbdState *kbd, QKeyCode qcode);
81 /**
82 * qkbd_state_modifier_get: get modifier state.
84 * Returns true when the modifier is active.
86 * @kbd: state tracker state.
87 * @mod: the modifier to query.
89 bool qkbd_state_modifier_get(QKbdState *kbd, QKbdModifier mod);
91 /**
92 * qkbd_state_lift_all_keys: lift all pressed keys.
94 * This sends key up events to the guest for all keys which are in
95 * down state.
97 * @kbd: state tracker state.
99 void qkbd_state_lift_all_keys(QKbdState *kbd);
101 #endif /* QEMU_UI_KBD_STATE_H */