mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260520-input-v3-7-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>
116 lines
2.8 KiB
C
116 lines
2.8 KiB
C
/*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or
|
|
* (at your option) any later version. See the COPYING file in the
|
|
* top-level directory.
|
|
*/
|
|
|
|
#ifndef QEMU_UI_KBD_STATE_H
|
|
#define QEMU_UI_KBD_STATE_H
|
|
|
|
#include "qapi/qapi-types-ui.h"
|
|
|
|
typedef enum QKbdModifier QKbdModifier;
|
|
|
|
enum QKbdModifier {
|
|
QKBD_MOD_NONE = 0,
|
|
|
|
QKBD_MOD_SHIFT,
|
|
QKBD_MOD_CTRL,
|
|
QKBD_MOD_ALT,
|
|
QKBD_MOD_ALTGR,
|
|
|
|
QKBD_MOD_NUMLOCK,
|
|
QKBD_MOD_CAPSLOCK,
|
|
|
|
QKBD_MOD__MAX
|
|
};
|
|
|
|
typedef struct QKbdState QKbdState;
|
|
|
|
/**
|
|
* qkbd_state_init: init keyboard state tracker.
|
|
*
|
|
* Allocates and initializes keyboard state struct.
|
|
*
|
|
* @con: QemuConsole for this state tracker. Gets passed down to
|
|
* qemu_input_*() functions when sending key events to the guest.
|
|
*/
|
|
QKbdState *qkbd_state_init(QemuConsole *con);
|
|
|
|
/**
|
|
* qkbd_state_free: free keyboard tracker state.
|
|
*
|
|
* @kbd: state tracker state.
|
|
*/
|
|
void qkbd_state_free(QKbdState *kbd);
|
|
|
|
/**
|
|
* qkbd_state_key_event: process key event.
|
|
*
|
|
* Update keyboard state, send event to the guest.
|
|
*
|
|
* This function takes care to not send suspious events (keyup event
|
|
* for a key not pressed for example).
|
|
*
|
|
* This function drops events with key codes outside the defined range.
|
|
*
|
|
* @kbd: state tracker state.
|
|
* @lnx: the key pressed or released.
|
|
* @down: true for key down events, false otherwise.
|
|
*/
|
|
void qkbd_state_key_event(QKbdState *kbd, unsigned int lnx, bool down);
|
|
|
|
/**
|
|
* qkbd_state_set_delay: set key press delay.
|
|
*
|
|
* When set the specified delay will be added after each key event,
|
|
* using qemu_input_event_send_key_delay().
|
|
*
|
|
* @kbd: state tracker state.
|
|
* @delay_ms: the delay in milliseconds.
|
|
*/
|
|
void qkbd_state_set_delay(QKbdState *kbd, int delay_ms);
|
|
|
|
/**
|
|
* qkbd_state_key_get: get key state.
|
|
*
|
|
* Returns true when the key code is in the defined range and the key is down.
|
|
*
|
|
* @kbd: state tracker state.
|
|
* @lnx: the key to query.
|
|
*/
|
|
bool qkbd_state_key_get(QKbdState *kbd, unsigned int lnx);
|
|
|
|
/**
|
|
* qkbd_state_modifier_get: get modifier state.
|
|
*
|
|
* Returns true when the modifier is active.
|
|
*
|
|
* @kbd: state tracker state.
|
|
* @mod: the modifier to query.
|
|
*/
|
|
bool qkbd_state_modifier_get(QKbdState *kbd, QKbdModifier mod);
|
|
|
|
/**
|
|
* qkbd_state_lift_all_keys: lift all pressed keys.
|
|
*
|
|
* This sends key up events to the guest for all keys which are in
|
|
* down state.
|
|
*
|
|
* @kbd: state tracker state.
|
|
*/
|
|
void qkbd_state_lift_all_keys(QKbdState *kbd);
|
|
|
|
/**
|
|
* qkbd_state_switch_console: Switch console.
|
|
*
|
|
* This sends key up events to the previous console for all keys which are in
|
|
* down state to prevent keys being stuck, and remembers the new console.
|
|
*
|
|
* @kbd: state tracker state.
|
|
* @con: new QemuConsole for this state tracker.
|
|
*/
|
|
void qkbd_state_switch_console(QKbdState *kbd, QemuConsole *con);
|
|
|
|
#endif /* QEMU_UI_KBD_STATE_H */
|