From 016cc05381163b01f441e584e52b02809053e7b3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 5 Jun 2013 16:30:00 +1000 Subject: [PATCH] Add the remaining ev bits Signed-off-by: Peter Hutterer --- libevdev/libevdev-int.h | 6 ++++++ libevdev/libevdev-util.h | 10 ++++++++++ libevdev/libevdev.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h index b16e5c2..e51df22 100644 --- a/libevdev/libevdev-int.h +++ b/libevdev/libevdev-int.h @@ -66,11 +66,17 @@ struct libevdev { unsigned long rel_bits[NLONGS(REL_CNT)]; unsigned long abs_bits[NLONGS(ABS_CNT)]; unsigned long led_bits[NLONGS(LED_CNT)]; + unsigned long msc_bits[NLONGS(MSC_CNT)]; + unsigned long sw_bits[NLONGS(SW_CNT)]; + unsigned long rep_bits[NLONGS(REP_CNT)]; /* convenience, always 1 */ + unsigned long ff_bits[NLONGS(FF_CNT)]; + unsigned long snd_bits[NLONGS(SND_CNT)]; unsigned long key_values[NLONGS(KEY_CNT)]; struct input_absinfo abs_info[ABS_CNT]; unsigned int mt_slot_vals[MAX_SLOTS][ABS_MT_CNT]; int num_slots; /**< valid slots in mt_slot_vals */ int current_slot; + int rep_values[2]; int need_sync; int grabbed; diff --git a/libevdev/libevdev-util.h b/libevdev/libevdev-util.h index 2c4128d..6c79404 100644 --- a/libevdev/libevdev-util.h +++ b/libevdev/libevdev-util.h @@ -70,6 +70,11 @@ type_to_mask_const(const struct libevdev *dev, unsigned int type, const unsigned max_mask(REL, rel); max_mask(KEY, key); max_mask(LED, led); + max_mask(MSC, msc); + max_mask(SW, sw); + max_mask(FF, ff); + max_mask(REP, rep); + max_mask(SND, snd); default: max = -1; break; @@ -88,6 +93,11 @@ type_to_mask(struct libevdev *dev, unsigned int type, unsigned long **mask) max_mask(REL, rel); max_mask(KEY, key); max_mask(LED, led); + max_mask(MSC, msc); + max_mask(SW, sw); + max_mask(FF, ff); + max_mask(REP, rep); + max_mask(SND, snd); default: max = -1; break; diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index 7e292f6..2dbc6c1 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -209,6 +209,31 @@ libevdev_set_fd(struct libevdev* dev, int fd) if (rc < 0) goto out; + rc = ioctl(fd, EVIOCGBIT(EV_SW, sizeof(dev->sw_bits)), dev->sw_bits); + if (rc < 0) + goto out; + + rc = ioctl(fd, EVIOCGBIT(EV_MSC, sizeof(dev->msc_bits)), dev->msc_bits); + if (rc < 0) + goto out; + + rc = ioctl(fd, EVIOCGBIT(EV_FF, sizeof(dev->ff_bits)), dev->ff_bits); + if (rc < 0) + goto out; + + rc = ioctl(fd, EVIOCGBIT(EV_SND, sizeof(dev->snd_bits)), dev->snd_bits); + if (rc < 0) + goto out; + + /* rep is a special case, always set it to 1 for both values if EV_REP is set */ + if (bit_is_set(dev->bits, EV_REP)) { + for (i = 0; i < REP_MAX; i++) + set_bit(dev->rep_bits, i); + rc = ioctl(fd, EVIOCGREP, dev->rep_values); + if (rc < 0) + goto out; + } + for (i = ABS_X; i <= ABS_MAX; i++) { if (bit_is_set(dev->abs_bits, i)) { struct input_absinfo abs_info;