Re: [PATCH 2/3] util: Add virKeycodeValueIsModifier function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]