virkeycode: Allow ANSI_A

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>
This commit is contained in:
Michal Privoznik committed 2013-12-24 17:36:47 +01:00
1 parent aa4619337c
commit 72ffbd1bf3
3 files changed
+7 -7

No files matched your search

+3 -3
View 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;
}