VIR_KEYCODE_SET_XT_KBD = 6,
VIR_KEYCODE_SET_USB = 7,
VIR_KEYCODE_SET_WIN32 = 8,
+ VIR_KEYCODE_SET_RFB = 9,
VIR_KEYCODE_SET_LAST,
} virKeycodeSet;
virCheckFlags(0, -1);
- /* translate the keycode to XT_KBD for qemu driver */
- if (codeset != VIR_KEYCODE_SET_XT_KBD) {
+ /* translate the keycode to RFB for qemu driver */
+ if (codeset != VIR_KEYCODE_SET_RFB) {
int i;
int keycode;
for (i = 0; i < nkeycodes; i++) {
- keycode = virKeycodeValueTranslate(codeset, VIR_KEYCODE_SET_XT_KBD,
+ keycode = virKeycodeValueTranslate(codeset, VIR_KEYCODE_SET_RFB,
keycodes[i]);
if (keycode < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot translate keycode %u of %s codeset to xt_kbd keycode"),
+ _("cannot translate keycode %u of %s codeset to rfb keycode"),
keycodes[i],
virKeycodeSetTypeToString(codeset));
return -1;
import re
namecolums = (0,2,10)
+xtkbdkey_index = 8
def quotestring(str):
if str[0] != '"':
for line in sys.stdin.xreadlines():
a = re.match("([^,]*)," * 13 + "([^,]*)$", line[0:-1]).groups()
b = ""
+ rfbkey = 0
for i in namecolums:
b = b + (a[i] and quotestring(a[i]) or 'NULL') + ','
for i in [ x for x in range(12) if not x in namecolums ]:
b = b + (a[i] or '0') + ','
+ if i == xtkbdkey_index:
+ # RFB keycodes are XT kbd keycodes with a slightly
+ # different encoding of 0xe0 scan codes. RFB uses
+ # the high bit of the first byte, instead of the low
+ # bit of the second byte.
+ rfbkey = int(a[i] or '0')
+ rfbkey = (rfbkey & 0x100) >> 1 | (rfbkey & 0x7f)
+
+ # Append RFB keycode as the last column
+ b = b + str(rfbkey)
print " { " + b + "},"
print '};'
unsigned short xt_kbd;
unsigned short usb;
unsigned short win32;
+ unsigned short rfb;
};
#define VIRT_KEY_INTERNAL
offsetof(struct keycode, usb),
[VIR_KEYCODE_SET_WIN32] =
offsetof(struct keycode, win32),
+ [VIR_KEYCODE_SET_RFB] =
+ offsetof(struct keycode, rfb),
};
+verify(ARRAY_CARDINALITY(codeOffset) == VIR_KEYCODE_SET_LAST);
VIR_ENUM_IMPL(virKeycodeSet, VIR_KEYCODE_SET_LAST,
"linux",
"xt_kbd",
"usb",
"win32",
+ "rfb",
);
static int __virKeycodeValueFromString(unsigned int name_offset,