CP-21130: Support EXT_KEY_EVENT encoding for qemu VNC

qemu expects scan code to be passed using the following format,
+--------------+--------------+-------------------+
| No. of bytes | Type [Value] | Description       |
+--------------+--------------+-------------------+
| 1            | U8 [255]     | message-type      |
| 1            | U8 [0]       | qemu key extension|
| 1            | U8           | padding           |
| 1            | U8           | down-flag         |
| 4            | U32          | key symbol        |
| 4            | U32          | key scan code     |
+--------------+--------------+-------------------+
if EXT_KEY_EVENT encoding is supported.

XenCenter queries for EXT_KEY_EVENT encoding and uses EXT_KEY_EVENT for
sending key events to QEMU.

Signed-off-by: Anoob Soman <anoob.soman@citrix.com>
This commit is contained in:
Anoob Soman 2017-05-02 17:17:30 +01:00
parent a0c34c28bf
commit 5b407bde45

View File

@ -54,12 +54,14 @@ namespace DotNetVnc
private const int CURSOR_PSEUDO_ENCODING = -239;
private const int DESKTOP_SIZE_PSEUDO_ENCODING = -223;
private const int XENCENTER_ENCODING = -254;
private const int QEMU_EXT_KEY_ENCODING = -258;
private const int SET_PIXEL_FORMAT = 0;
private const int SET_ENCODINGS = 2;
private const int FRAMEBUFFER_UPDATE_REQUEST = 3;
private const int KEY_EVENT = 4;
private const int KEY_SCAN_EVENT = 254;
private const int QEMU_MSG = 255;
private const int POINTER_EVENT = 5;
private const int CLIENT_CUT_TEXT = 6;
@ -73,6 +75,8 @@ namespace DotNetVnc
private const int BELL = 2;
private const int SERVER_CUT_TEXT = 3;
private const int QEMU_EXT_KEY_EVENT = 0;
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Thread thread = null;
@ -118,7 +122,8 @@ namespace DotNetVnc
RAW_ENCODING,
CURSOR_PSEUDO_ENCODING,
DESKTOP_SIZE_PSEUDO_ENCODING,
XENCENTER_ENCODING
XENCENTER_ENCODING,
QEMU_EXT_KEY_ENCODING
};
private readonly IVNCGraphicsClient client;
@ -134,6 +139,7 @@ namespace DotNetVnc
private int height;
private bool incremental;
private bool qemu_ext_key_encoding = false;
private PixelFormat pixelFormat;
private PixelFormat pixelFormatCursor;
@ -468,13 +474,30 @@ namespace DotNetVnc
this.stream.writeInt32(key);
}
private void writeQemuExtKey(int command, bool down, int key, int sym)
{
this.stream.writeInt8(command);
this.stream.writeInt8(QEMU_EXT_KEY_EVENT);
this.stream.writePadding(1);
this.stream.writeFlag(down);
this.stream.writeInt32(sym);
this.stream.writeInt32(key);
}
public void keyScanEvent(bool down, int key, int sym)
{
lock (this.writeLock)
{
try
{
writeKey(KEY_SCAN_EVENT, down, key);
if (qemu_ext_key_encoding)
{
writeQemuExtKey(QEMU_MSG, down, key, sym);
}
else
{
writeKey(KEY_SCAN_EVENT, down, key);
}
this.stream.Flush();
}
catch (IOException e)