[Spice-devel] [KEYVAL PATCH v1] add push_keyval callback to SpiceKbdInterface

Dietmar Maurer dietmar at proxmox.com
Tue Sep 3 01:02:29 PDT 2013


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 server/inputs_channel.c |   20 ++++++++++++++++++++
 server/spice.h          |    1 +
 2 files changed, 21 insertions(+)

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index 931dac1..248ecae 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -224,6 +224,20 @@ static void kbd_push_scan(SpiceKbdInstance *sin, uint8_t scan)
     sif->push_scan_freg(sin, scan);
 }
 
+static void kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keyval, int flags)
+{
+    SpiceKbdInterface *sif;
+
+    if (!sin) {
+        return;
+    }
+    sif = SPICE_CONTAINEROF(sin->base.sif, SpiceKbdInterface, base);
+
+    if (sif->push_keyval) {
+        sif->push_keyval(sin, keyval, flags);
+    }
+}
+
 static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
 {
     SpiceKbdInterface *sif;
@@ -339,6 +353,11 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         }
         break;
     }
+    case SPICE_MSGC_INPUTS_KEY_KEYVAL: {
+        SpiceMsgcKeyKeyval *key_keyval = (SpiceMsgcKeyKeyval *)buf;
+        kbd_push_keyval(keyboard, key_keyval->keyval, key_keyval->flags);
+        break;
+    }
     case SPICE_MSGC_INPUTS_MOUSE_MOTION: {
         SpiceMsgcMouseMotion *mouse_motion = (SpiceMsgcMouseMotion *)buf;
 
@@ -637,6 +656,7 @@ void inputs_init(void)
     red_channel_register_client_cbs(&g_inputs_channel->base, &client_cbs);
 
     red_channel_set_cap(&g_inputs_channel->base, SPICE_INPUTS_CAP_KEY_SCANCODE);
+    red_channel_set_cap(&g_inputs_channel->base, SPICE_INPUTS_CAP_KEY_KEYVAL);
     reds_register_channel(&g_inputs_channel->base);
 
     if (!(key_modifiers_timer = core->timer_add(key_modifiers_sender, NULL))) {
diff --git a/server/spice.h b/server/spice.h
index 6fbb7b2..a211575 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -270,6 +270,7 @@ typedef struct SpiceKbdState SpiceKbdState;
 struct SpiceKbdInterface {
     SpiceBaseInterface base;
 
+    void (*push_keyval)(SpiceKbdInstance *sin, uint32_t keyval, int flags);
     void (*push_scan_freg)(SpiceKbdInstance *sin, uint8_t frag);
     uint8_t (*get_leds)(SpiceKbdInstance *sin);
 };
-- 
1.7.10.4



More information about the Spice-devel mailing list