This function returns true if the value supplied is a modifier (Ctrl,
Shift, Alt or Meta).
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virkeycode.c | 21 +++++++++++++++++++++
src/util/virkeycode.h | 2 ++
3 files changed, 24 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b8f35e8..5c3de01 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1530,6 +1530,7 @@ virJSONValueToString;
virKeycodeSetTypeFromString;
virKeycodeSetTypeToString;
virKeycodeValueFromString;
+virKeycodeValueIsModifier;
virKeycodeValueTranslate;
diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
index 7880a0a..7705ffd 100644
--- a/src/util/virkeycode.c
+++ b/src/util/virkeycode.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2014 Red Hat, Inc.
* Copyright (c) 2011 Lai Jiangshan
*
* This library is free software; you can redistribute it and/or
@@ -124,3 +125,23 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset,
return -1;
}
+
+
+bool
+virKeycodeValueIsModifier(unsigned int key_value)
+{
+ switch (key_value) {
+ case 29: /* Left Control */
+ case 157: /* Right Control */
+ case 42: /* Left Shift */
+ case 54: /* Right Shift */
+ case 56: /* Left Alt */
+ case 184: /* Right Alt */
+ case 219: /* Left Meta */
+ case 220: /* Right Meta */
+ return true;
+
+ default:
+ return false;
+ }
+}
diff --git a/src/util/virkeycode.h b/src/util/virkeycode.h
index 6947cfe..d04a2a4 100644
--- a/src/util/virkeycode.h
+++ b/src/util/virkeycode.h
@@ -1,6 +1,7 @@
/*
* virkeycode.h: keycodes definitions and declarations
*
+ * Copyright (C) 2014 Red Hat, Inc.
* Copyright (c) 2011 Lai Jiangshan
*
* This library is free software; you can redistribute it and/or
@@ -29,5 +30,6 @@ int virKeycodeValueFromString(virKeycodeSet codeset, const char
*keyname);
int virKeycodeValueTranslate(virKeycodeSet from_codeset,
virKeycodeSet to_offset,
int key_value);
+bool virKeycodeValueIsModifier(unsigned int key_value);
#endif
--
2.1.3