]> xenbits.xensource.com Git - libvirt.git/commitdiff
virkeycode: Allow ANSI_A
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 19 Dec 2013 15:40:16 +0000 (16:40 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Dec 2013 16:36:47 +0000 (17:36 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1044806

Currently, sending the ANSI_A keycode from os_x codepage doesn't work as
it has a special value of 0x0. Our internal code handles that no
different to other not defined keycodes. Hence, in order to allow it we
must change all the undefined keycodes from 0 to -1 and adapt some code
too.

  # virsh send-key guestname --codeset os_x ANSI_A
  error: invalid keycode: 'ANSI_A'

  # virsh send-key guestname --codeset os_x ANSI_B
  # virsh send-key guestname --codeset os_x ANSI_C

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virkeycode-mapgen.py
src/util/virkeycode.c
tools/virsh-domain.c

index 22b21b4753198c0ed10dac1d5af712c3b20eac2b..8360bfe52548cc9d5b57729b189859554442d14a 100755 (executable)
@@ -86,12 +86,12 @@ for i in range(len(cols)):
     if isname:
         print "const char *virKeymapNames_" + name + "[] = {"
     else:
-        print "unsigned short virKeymapValues_" + name + "[] = {"
+        print "int virKeymapValues_" + name + "[] = {"
 
     for entry in keycodes:
         if isname:
             print "  " + quotestring(entry[i] or "NULL") + ","
         else:
-            print "  " + (entry[i] or "0") + ","
+            print "  " + (entry[i] or "-1") + ","
 
     print "};\n"
index 50594d658082acc115d52c2f318eb2665636deed..7880a0aba2c0b436af675834febea8a39b162c46 100644 (file)
@@ -50,7 +50,7 @@ static const char **virKeymapNames[] = {
 };
 verify(ARRAY_CARDINALITY(virKeymapNames) == VIR_KEYCODE_SET_LAST);
 
-static unsigned short *virKeymapValues[] = {
+static int *virKeymapValues[] = {
     [VIR_KEYCODE_SET_LINUX] =
       virKeymapValues_linux,
     [VIR_KEYCODE_SET_XT] =
@@ -113,7 +113,7 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset,
 {
     size_t i;
 
-    if (key_value <= 0)
+    if (key_value < 0)
         return -1;
 
 
index 760dca598c8fd02b13d3cdab1f7df20da60e95f4..3aabd26af1d3348a06ea659a79c109a6c7782283 100644 (file)
@@ -7049,7 +7049,7 @@ vshKeyCodeGetInt(const char *key_name)
 {
     unsigned int val;
 
-    if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff || !val)
+    if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff)
         return -1;
     return val;
 }
@@ -7090,8 +7090,8 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
         }
 
-        if ((keycode = vshKeyCodeGetInt(opt->data)) <= 0) {
-            if ((keycode = virKeycodeValueFromString(codeset, opt->data)) <= 0) {
+        if ((keycode = vshKeyCodeGetInt(opt->data)) < 0) {
+            if ((keycode = virKeycodeValueFromString(codeset, opt->data)) < 0) {
                 vshError(ctl, _("invalid keycode: '%s'"), opt->data);
                 goto cleanup;
             }