mirror of
https://gitlab.gnome.org/GNOME/libmks.git
synced 2024-12-22 05:35:21 +00:00
keyboard: Expose keycode translation helper
Useful for exposing keyboard shortcuts triggers on the UI Similar to what Boxes does for Ctrl+Shift+F
This commit is contained in:
parent
d4f52a7fdb
commit
57370d5a73
@ -27,8 +27,6 @@
|
||||
#include "mks-mouse.h"
|
||||
#include "mks-util-private.h"
|
||||
|
||||
#include "mks-keymap-xorgevdev2qnum-private.h"
|
||||
|
||||
struct _MksDisplayPicture
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
@ -54,22 +52,6 @@ G_DEFINE_FINAL_TYPE (MksDisplayPicture, mks_display_picture, GTK_TYPE_WIDGET)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
mks_display_picture_translate_keycode (MksDisplayPicture *self,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
guint *translated)
|
||||
{
|
||||
g_assert (MKS_IS_DISPLAY_PICTURE (self));
|
||||
g_assert (translated != NULL);
|
||||
|
||||
if (keycode < xorgevdev_to_qnum_len &&
|
||||
xorgevdev_to_qnum[keycode] != 0)
|
||||
*translated = xorgevdev_to_qnum[keycode];
|
||||
else
|
||||
*translated = keycode;
|
||||
}
|
||||
|
||||
static void
|
||||
mks_display_picture_keyboard_press_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
@ -319,7 +301,7 @@ mks_display_picture_legacy_event_cb (MksDisplayPicture *self,
|
||||
|
||||
g_assert (MKS_IS_KEYBOARD (self->keyboard));
|
||||
|
||||
mks_display_picture_translate_keycode (self, keyval, keycode, &qkeycode);
|
||||
mks_keyboard_translate (keyval, keycode, &qkeycode);
|
||||
|
||||
if (event_type == GDK_KEY_PRESS)
|
||||
mks_keyboard_press (self->keyboard,
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "mks-keyboard.h"
|
||||
#include "mks-util-private.h"
|
||||
|
||||
|
||||
#include "mks-keymap-xorgevdev2qnum-private.h"
|
||||
|
||||
struct _MksKeyboard
|
||||
{
|
||||
MksDevice parent_instance;
|
||||
@ -389,3 +392,25 @@ mks_keyboard_release_sync (MksKeyboard *self,
|
||||
|
||||
MKS_RETURN (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* mks_keyboard_translate:
|
||||
* @keyval: the keyval
|
||||
* @keycode: the hardware keycode
|
||||
* @translated: (out): the translated keycode
|
||||
*
|
||||
* Translate a keycode to a QEMU compatible one.
|
||||
*/
|
||||
void
|
||||
mks_keyboard_translate (guint keyval,
|
||||
guint keycode,
|
||||
guint *translated)
|
||||
{
|
||||
g_assert (translated != NULL);
|
||||
|
||||
if (keycode < xorgevdev_to_qnum_len &&
|
||||
xorgevdev_to_qnum[keycode] != 0)
|
||||
*translated = xorgevdev_to_qnum[keycode];
|
||||
else
|
||||
*translated = keycode;
|
||||
}
|
||||
|
@ -85,4 +85,9 @@ gboolean mks_keyboard_release_sync (MksKeyboard *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
MKS_AVAILABLE_IN_ALL
|
||||
void mks_keyboard_translate (guint keyval,
|
||||
guint keycode,
|
||||
guint *translated);
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user