mapping single-key input devices to buttons

Johannes Berg johannes at sipsolutions.net
Sat Apr 29 00:50:38 PDT 2006


On Sat, 2006-04-29 at 00:25 +0200, Johannes Berg wrote:
 
> -#define test_bit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8)))
> +/* we must use this kernel-compatible implementation */
> +#define BITS_PER_LONG (sizeof(long) * 8)
> +#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
> +#define OFF(x)  ((x)%BITS_PER_LONG)
> +#define BIT(x)  (1UL<<OFF(x))
> +#define LONG(x) ((x)/BITS_PER_LONG)
> +#define test_bit(bit, array)    ((array[LONG(bit)] >> OFF(bit)) & 1)

Come to think of it, the original was of course correct on little-endian
platforms due to byte ordering. Grr! Sometimes I feel like a
second-class citizen...

johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 793 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/hal/attachments/20060429/c77ca424/attachment-0001.pgp


More information about the hal mailing list