[libvirt] [PATCH 2/3] util: Add virKeycodeValueIsModifier function
Peter Krempa
pkrempa at redhat.com
Wed Nov 12 09:57:42 UTC 2014
On 11/11/14 15:54, Martin Kletzander wrote:
> This function returns true if the value supplied is a modifier (Ctrl,
> Shift, Alt or Meta).
>
> Signed-off-by: Martin Kletzander <mkletzan at 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;
I've checked those with a random keymap that I found on the internet :)
> +
> + 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
>
ACK,
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141112/9fa0aee9/attachment-0001.sig>
More information about the libvir-list
mailing list