diff options
author | Arnaud Patard <rtp@mageia.org> | 2011-03-18 21:28:23 +0000 |
---|---|---|
committer | Arnaud Patard <rtp@mageia.org> | 2011-03-18 21:28:23 +0000 |
commit | 9200953d1de496b673fa4a7ec8e0e05cf7cb3363 (patch) | |
tree | c2730cd4433035feeddb3c00a6cfd5cf9e282c93 /perl-install/c | |
parent | f5add924a408f14c2d49f0d969e58b0732eab777 (diff) | |
download | drakx-backup-do-not-use-9200953d1de496b673fa4a7ec8e0e05cf7cb3363.tar drakx-backup-do-not-use-9200953d1de496b673fa4a7ec8e0e05cf7cb3363.tar.gz drakx-backup-do-not-use-9200953d1de496b673fa4a7ec8e0e05cf7cb3363.tar.bz2 drakx-backup-do-not-use-9200953d1de496b673fa4a7ec8e0e05cf7cb3363.tar.xz drakx-backup-do-not-use-9200953d1de496b673fa4a7ec8e0e05cf7cb3363.zip |
- use EVIOCGBIT ioctl instead of trying to parse key field from
/proc/bus/input/devices to avoid issues on 64bit kernel with 32bit userspace
Diffstat (limited to 'perl-install/c')
-rwxr-xr-x | perl-install/c/stuff.xs.pl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index cd2c6bf03..b2c4c2512 100755 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -36,6 +36,7 @@ print ' #include <net/route.h> #include <netinet/in.h> #include <linux/sockios.h> +#include <linux/input.h> // for ethtool structs: typedef unsigned long long u64; @@ -485,7 +486,40 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) } } +#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) +void +EVIocGBitKey (char *file) + PPCODE: + int fd; + int i; + long bitmask[NBITS(KEY_MAX)]; + + fd = open (file, O_RDONLY); + if (fd < 0) { + perror("Cannot open /dev/input/eventX"); + return; + } + + if (ioctl (fd, EVIOCGBIT(EV_KEY, sizeof (bitmask)), bitmask) < 0) { + perror ("ioctl EVIOCGBIT failed"); + close (fd); + return; + } + + for (i = NBITS(KEY_MAX) - 1; i > 0; i--) + if (bitmask[i]) + break; + + for (; i >= 0; i--) { + EXTEND(sp, 1); + PUSHs(sv_2mortal(newSViv(bitmask[i]))); + } char * kernel_version() |