summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mtdev.h5
-rw-r--r--src/caps.c25
2 files changed, 30 insertions, 0 deletions
diff --git a/include/mtdev.h b/include/mtdev.h
index ba682c5..33ea29c 100644
--- a/include/mtdev.h
+++ b/include/mtdev.h
@@ -68,6 +68,11 @@ extern "C" {
68#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ 68#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */
69#endif 69#endif
70 70
71/* includes available in 3.4 */
72#ifndef EVIOCGMTSLOTS
73#define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len)
74#endif
75
71#define MT_ID_NULL (-1) 76#define MT_ID_NULL (-1)
72#define MT_ID_MIN 0 77#define MT_ID_MIN 0
73#define MT_ID_MAX 65535 78#define MT_ID_MAX 65535
diff --git a/src/caps.c b/src/caps.c
index 23f16fc..45c185c 100644
--- a/src/caps.c
+++ b/src/caps.c
@@ -82,6 +82,28 @@ static void default_fuzz(struct mtdev *dev, int code, int sn)
82 abs->fuzz = (abs->maximum - abs->minimum) / sn; 82 abs->fuzz = (abs->maximum - abs->minimum) / sn;
83} 83}
84 84
85int mtdev_set_slots(struct mtdev *dev, int fd)
86{
87 struct { unsigned code; int values[DIM_FINGER]; } req;
88 struct mtdev_state *state = dev->state;
89 int rc, i, s, nslot;
90
91 nslot = mtdev_get_abs_maximum(dev, ABS_MT_SLOT) + 1;
92
93 for (i = 0; i < MT_ABS_SIZE; i++) {
94 req.code = mtdev_mt2abs(i);
95 if (!mtdev_has_mt_event(dev, req.code))
96 continue;
97 SYSCALL(rc = ioctl(fd, EVIOCGMTSLOTS(sizeof(req)), &req));
98 if (rc < 0)
99 return rc;
100 for (s = 0; s < DIM_FINGER && s < nslot; s++)
101 set_sval(&state->data[s], i, req.values[s]);
102 }
103
104 return 0;
105}
106
85int mtdev_configure(struct mtdev *dev, int fd) 107int mtdev_configure(struct mtdev *dev, int fd)
86{ 108{
87 unsigned long absbits[nlongs(ABS_MAX)]; 109 unsigned long absbits[nlongs(ABS_MAX)];
@@ -118,6 +140,9 @@ int mtdev_configure(struct mtdev *dev, int fd)
118 default_fuzz(dev, ABS_MT_WIDTH_MINOR, SN_WIDTH); 140 default_fuzz(dev, ABS_MT_WIDTH_MINOR, SN_WIDTH);
119 default_fuzz(dev, ABS_MT_ORIENTATION, SN_ORIENT); 141 default_fuzz(dev, ABS_MT_ORIENTATION, SN_ORIENT);
120 142
143 if (dev->has_slot)
144 mtdev_set_slots(dev, fd);
145
121 return 0; 146 return 0;
122} 147}
123 148