Add virKeynameFromKeycode for later xen/libxl sendkey usage. Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx> --- src/libvirt_private.syms | 1 + src/util/virkeycode.c | 17 +++++++++++++++++ src/util/virkeycode.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6df2784..087b75f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1540,6 +1540,7 @@ virKeycodeSetTypeFromString; virKeycodeSetTypeToString; virKeycodeValueFromString; virKeycodeValueTranslate; +virKeynameFromKeycode; # util/virkeyfile.h diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c index 7880a0a..c6b3b36 100644 --- a/src/util/virkeycode.c +++ b/src/util/virkeycode.c @@ -124,3 +124,20 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset, return -1; } + +const char * +virKeynameFromKeycode(virKeycodeSet codeset, int keycode) +{ + size_t i; + + for (i = 0; i < VIR_KEYMAP_ENTRY_MAX; i++) { + if (!virKeymapNames[codeset] || + !virKeymapValues[codeset]) + continue; + + if (virKeymapValues[codeset][i] == keycode) + return virKeymapNames[codeset][i]; + } + + return NULL; +} diff --git a/src/util/virkeycode.h b/src/util/virkeycode.h index 6947cfe..aefb1c9 100644 --- a/src/util/virkeycode.h +++ b/src/util/virkeycode.h @@ -29,5 +29,6 @@ int virKeycodeValueFromString(virKeycodeSet codeset, const char *keyname); int virKeycodeValueTranslate(virKeycodeSet from_codeset, virKeycodeSet to_offset, int key_value); +const char *virKeynameFromKeycode(virKeycodeSet codeset, int keycode); #endif -- 1.8.4.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list