diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-15 20:24:14 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-06-16 02:28:08 +0200 |
| commit | 78085b21f2dc7b1d49a0c54ab56b567fc195d440 (patch) | |
| tree | 3ae649c25b380114ce2eaa5463350fb9b29ee78c | |
| parent | 4583da1ad81b59b2a8cd2ae51c32b1bc8d32f1c4 (diff) | |
refactor: Simplify capabilities
Use the generated abs2mt mapping to simplify the MT device
capabilities.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | driver/multitouch.c | 8 | ||||
| -rw-r--r-- | include/mtdev-caps.h | 23 | ||||
| -rw-r--r-- | include/mtstate.h | 3 | ||||
| -rw-r--r-- | mtdev/caps.c | 104 | ||||
| -rw-r--r-- | src/hwstate.c | 18 | ||||
| -rw-r--r-- | src/memory.c | 10 | ||||
| -rw-r--r-- | src/mtstate.c | 12 |
7 files changed, 85 insertions, 93 deletions
diff --git a/driver/multitouch.c b/driver/multitouch.c index 7e275b3..ee5242f 100644 --- a/driver/multitouch.c +++ b/driver/multitouch.c | |||
| @@ -141,16 +141,16 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local) | |||
| 141 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 | 141 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 |
| 142 | axes_labels[0], | 142 | axes_labels[0], |
| 143 | #endif | 143 | #endif |
| 144 | mt->caps.abs_position_x.minimum, | 144 | mt->caps.abs[BIT_POSITION_X].minimum, |
| 145 | mt->caps.abs_position_x.maximum, | 145 | mt->caps.abs[BIT_POSITION_X].maximum, |
| 146 | 1, 0, 1); | 146 | 1, 0, 1); |
| 147 | xf86InitValuatorDefaults(dev, 0); | 147 | xf86InitValuatorDefaults(dev, 0); |
| 148 | xf86InitValuatorAxisStruct(dev, 1, | 148 | xf86InitValuatorAxisStruct(dev, 1, |
| 149 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 | 149 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 |
| 150 | axes_labels[1], | 150 | axes_labels[1], |
| 151 | #endif | 151 | #endif |
| 152 | mt->caps.abs_position_y.minimum, | 152 | mt->caps.abs[BIT_POSITION_Y].minimum, |
| 153 | mt->caps.abs_position_y.maximum, | 153 | mt->caps.abs[BIT_POSITION_Y].maximum, |
| 154 | 1, 0, 1); | 154 | 1, 0, 1); |
| 155 | xf86InitValuatorDefaults(dev, 1); | 155 | xf86InitValuatorDefaults(dev, 1); |
| 156 | 156 | ||
diff --git a/include/mtdev-caps.h b/include/mtdev-caps.h index 8f88404..4460eca 100644 --- a/include/mtdev-caps.h +++ b/include/mtdev-caps.h | |||
| @@ -23,25 +23,18 @@ | |||
| 23 | #define MTDEV_CAPS_H | 23 | #define MTDEV_CAPS_H |
| 24 | 24 | ||
| 25 | #include "common.h" | 25 | #include "common.h" |
| 26 | #include "abs2mt.h" | ||
| 27 | #include "mtbit.h" | ||
| 26 | 28 | ||
| 27 | struct Capabilities { | 29 | struct Capabilities { |
| 28 | struct input_id devid; | 30 | struct input_id devid; |
| 29 | char devname[32]; | 31 | char devname[32]; |
| 30 | int has_left, has_middle; | 32 | int has_left, has_middle, has_right; |
| 31 | int has_right, has_mtdata, has_ibt; | 33 | int has_mtdata, has_ibt; |
| 32 | int has_touch_major, has_touch_minor; | 34 | int has_slot, nullid; |
| 33 | int has_width_major, has_width_minor; | 35 | int has_abs[MT_ABS_SIZE]; |
| 34 | int has_orientation, has_dummy; | 36 | struct input_absinfo slot; |
| 35 | int has_position_x, has_position_y; | 37 | struct input_absinfo abs[MT_ABS_SIZE]; |
| 36 | struct input_absinfo abs_touch_major; | ||
| 37 | struct input_absinfo abs_touch_minor; | ||
| 38 | struct input_absinfo abs_width_major; | ||
| 39 | struct input_absinfo abs_width_minor; | ||
| 40 | struct input_absinfo abs_orientation; | ||
| 41 | struct input_absinfo abs_position_x; | ||
| 42 | struct input_absinfo abs_position_y; | ||
| 43 | int xfuzz, yfuzz, wfuzz; | ||
| 44 | int yclick; | ||
| 45 | }; | 38 | }; |
| 46 | 39 | ||
| 47 | int read_capabilities(struct Capabilities *cap, int fd); | 40 | int read_capabilities(struct Capabilities *cap, int fd); |
diff --git a/include/mtstate.h b/include/mtstate.h index ac0b18d..b5f5dd1 100644 --- a/include/mtstate.h +++ b/include/mtstate.h | |||
| @@ -54,8 +54,7 @@ static inline int center_dist2(const struct MTFinger *a, | |||
| 54 | 54 | ||
| 55 | static inline int center_maxdist2(const struct Capabilities *caps) | 55 | static inline int center_maxdist2(const struct Capabilities *caps) |
| 56 | { | 56 | { |
| 57 | return dist2(caps->abs_position_x.maximum - get_cap_xmid(caps), | 57 | return dist2(get_cap_xsize(caps) / 2, get_cap_ysize(caps) / 2); |
| 58 | caps->abs_position_y.maximum - get_cap_ymid(caps)); | ||
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | #endif | 60 | #endif |
diff --git a/mtdev/caps.c b/mtdev/caps.c index 51e7f5b..069816e 100644 --- a/mtdev/caps.c +++ b/mtdev/caps.c | |||
| @@ -19,17 +19,17 @@ | |||
| 19 | * | 19 | * |
| 20 | **************************************************************************/ | 20 | **************************************************************************/ |
| 21 | 21 | ||
| 22 | #include <mtdev-caps.h> | 22 | #include "mtdev-caps.h" |
| 23 | #include "mtbit.h" | ||
| 23 | 24 | ||
| 24 | #define SETABS(c, x, map, key, fd) \ | 25 | #define SETABS(c, x, map, key, fd) \ |
| 25 | (c->has_##x = getbit(map, key) && getabs(&c->abs_##x, key, fd)) | 26 | (c->has_##x = getbit(map, key) && getabs(&c->x, key, fd)) |
| 26 | 27 | ||
| 27 | #define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "") | 28 | #define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "") |
| 28 | 29 | ||
| 29 | #define CLICK_AREA(c) ((c->has_ibt ? 0.20 : 0.00) * get_cap_ysize(c)) | ||
| 30 | |||
| 31 | static const int SN_COORD = 250; /* coordinate signal-to-noise ratio */ | 30 | static const int SN_COORD = 250; /* coordinate signal-to-noise ratio */ |
| 32 | static const int SN_WIDTH = 100; /* width signal-to-noise ratio */ | 31 | static const int SN_WIDTH = 100; /* width signal-to-noise ratio */ |
| 32 | static const int SN_ORIENT = 10; /* orientation signal-to-noise ratio */ | ||
| 33 | 33 | ||
| 34 | static const int bits_per_long = 8 * sizeof(long); | 34 | static const int bits_per_long = 8 * sizeof(long); |
| 35 | 35 | ||
| @@ -50,6 +50,11 @@ static int getabs(struct input_absinfo *abs, int key, int fd) | |||
| 50 | return rc >= 0; | 50 | return rc >= 0; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | static int has_mt_data(const struct Capabilities *cap) | ||
| 54 | { | ||
| 55 | return cap->has_abs[BIT_POSITION_X] && cap->has_abs[BIT_POSITION_Y]; | ||
| 56 | } | ||
| 57 | |||
| 53 | static int has_integrated_button(const struct Capabilities *cap) | 58 | static int has_integrated_button(const struct Capabilities *cap) |
| 54 | { | 59 | { |
| 55 | static const int bcm5974_vmask_ibt = 1; | 60 | static const int bcm5974_vmask_ibt = 1; |
| @@ -58,12 +63,20 @@ static int has_integrated_button(const struct Capabilities *cap) | |||
| 58 | return cap->devid.version & bcm5974_vmask_ibt; | 63 | return cap->devid.version & bcm5974_vmask_ibt; |
| 59 | } | 64 | } |
| 60 | 65 | ||
| 66 | static void default_fuzz(struct Capabilities *cap, unsigned int code, int sn) | ||
| 67 | { | ||
| 68 | int bit = abs2mt(code); | ||
| 69 | if (cap->has_abs[bit] && cap->abs[bit].fuzz == 0) | ||
| 70 | cap->abs[bit].fuzz = | ||
| 71 | (cap->abs[bit].maximum - cap->abs[bit].minimum) / sn; | ||
| 72 | } | ||
| 73 | |||
| 61 | int read_capabilities(struct Capabilities *cap, int fd) | 74 | int read_capabilities(struct Capabilities *cap, int fd) |
| 62 | { | 75 | { |
| 63 | unsigned long evbits[nlongs(EV_MAX)]; | 76 | unsigned long evbits[nlongs(EV_MAX)]; |
| 64 | unsigned long absbits[nlongs(ABS_MAX)]; | 77 | unsigned long absbits[nlongs(ABS_MAX)]; |
| 65 | unsigned long keybits[nlongs(KEY_MAX)]; | 78 | unsigned long keybits[nlongs(KEY_MAX)]; |
| 66 | int rc; | 79 | int rc, i; |
| 67 | 80 | ||
| 68 | memset(cap, 0, sizeof(struct Capabilities)); | 81 | memset(cap, 0, sizeof(struct Capabilities)); |
| 69 | 82 | ||
| @@ -87,95 +100,76 @@ int read_capabilities(struct Capabilities *cap, int fd) | |||
| 87 | cap->has_middle = getbit(keybits, BTN_MIDDLE); | 100 | cap->has_middle = getbit(keybits, BTN_MIDDLE); |
| 88 | cap->has_right = getbit(keybits, BTN_RIGHT); | 101 | cap->has_right = getbit(keybits, BTN_RIGHT); |
| 89 | 102 | ||
| 90 | SETABS(cap, touch_major, absbits, ABS_MT_TOUCH_MAJOR, fd); | 103 | SETABS(cap, slot, absbits, ABS_MT_SLOT, fd); |
| 91 | SETABS(cap, touch_minor, absbits, ABS_MT_TOUCH_MINOR, fd); | 104 | for (i = 0; i < MT_ABS_SIZE; i++) |
| 92 | SETABS(cap, width_major, absbits, ABS_MT_WIDTH_MAJOR, fd); | 105 | SETABS(cap, abs[i], absbits, mt2abs(i), fd); |
| 93 | SETABS(cap, width_minor, absbits, ABS_MT_WIDTH_MINOR, fd); | ||
| 94 | SETABS(cap, orientation, absbits, ABS_MT_ORIENTATION, fd); | ||
| 95 | SETABS(cap, position_x, absbits, ABS_MT_POSITION_X, fd); | ||
| 96 | SETABS(cap, position_y, absbits, ABS_MT_POSITION_Y, fd); | ||
| 97 | 106 | ||
| 98 | cap->has_mtdata = cap->has_position_x && cap->has_position_y; | 107 | cap->has_mtdata = has_mt_data(cap); |
| 99 | cap->has_ibt = has_integrated_button(cap); | 108 | cap->has_ibt = has_integrated_button(cap); |
| 100 | 109 | ||
| 101 | cap->xfuzz = cap->abs_position_x.fuzz; | 110 | if (cap->has_abs[BIT_TRACKING_ID]) |
| 102 | cap->yfuzz = cap->abs_position_y.fuzz; | 111 | cap->nullid = cap->abs[BIT_TRACKING_ID].minimum - 1; |
| 103 | if (cap->xfuzz <= 0 || cap->yfuzz <= 0) { | ||
| 104 | cap->xfuzz = get_cap_xsize(cap) / SN_COORD; | ||
| 105 | cap->yfuzz = get_cap_ysize(cap) / SN_COORD; | ||
| 106 | } | ||
| 107 | cap->wfuzz = cap->abs_touch_major.fuzz; | ||
| 108 | if (cap->wfuzz <= 0) | ||
| 109 | cap->wfuzz = get_cap_wsize(cap) / SN_WIDTH; | ||
| 110 | 112 | ||
| 111 | cap->yclick = cap->abs_position_y.maximum - CLICK_AREA(cap); | 113 | default_fuzz(cap, ABS_MT_POSITION_X, SN_COORD); |
| 114 | default_fuzz(cap, ABS_MT_POSITION_Y, SN_COORD); | ||
| 115 | default_fuzz(cap, ABS_MT_TOUCH_MAJOR, SN_WIDTH); | ||
| 116 | default_fuzz(cap, ABS_MT_TOUCH_MINOR, SN_WIDTH); | ||
| 117 | default_fuzz(cap, ABS_MT_WIDTH_MAJOR, SN_WIDTH); | ||
| 118 | default_fuzz(cap, ABS_MT_WIDTH_MINOR, SN_WIDTH); | ||
| 119 | default_fuzz(cap, ABS_MT_ORIENTATION, SN_ORIENT); | ||
| 112 | 120 | ||
| 113 | return 0; | 121 | return 0; |
| 114 | } | 122 | } |
| 115 | 123 | ||
| 116 | int get_cap_xsize(const struct Capabilities *cap) | 124 | int get_cap_xsize(const struct Capabilities *cap) |
| 117 | { | 125 | { |
| 118 | return cap->abs_position_x.maximum - cap->abs_position_x.minimum; | 126 | const struct input_absinfo *x = &cap->abs[BIT_POSITION_X]; |
| 127 | return x->maximum - x->minimum; | ||
| 119 | } | 128 | } |
| 120 | 129 | ||
| 121 | int get_cap_ysize(const struct Capabilities *cap) | 130 | int get_cap_ysize(const struct Capabilities *cap) |
| 122 | { | 131 | { |
| 123 | return cap->abs_position_y.maximum - cap->abs_position_y.minimum; | 132 | const struct input_absinfo *y = &cap->abs[BIT_POSITION_Y]; |
| 133 | return y->maximum - y->minimum; | ||
| 124 | } | 134 | } |
| 125 | 135 | ||
| 126 | int get_cap_wsize(const struct Capabilities *cap) | 136 | int get_cap_wsize(const struct Capabilities *cap) |
| 127 | { | 137 | { |
| 128 | return cap->abs_touch_major.maximum - cap->abs_touch_major.minimum; | 138 | const struct input_absinfo *w = &cap->abs[BIT_TOUCH_MAJOR]; |
| 139 | return w->maximum - w->minimum; | ||
| 129 | } | 140 | } |
| 130 | 141 | ||
| 131 | int get_cap_xmid(const struct Capabilities *cap) | 142 | int get_cap_xmid(const struct Capabilities *cap) |
| 132 | { | 143 | { |
| 133 | return (cap->abs_position_x.maximum + cap->abs_position_x.minimum) >> 1; | 144 | const struct input_absinfo *x = &cap->abs[BIT_POSITION_X]; |
| 145 | return (x->maximum + x->minimum) >> 1; | ||
| 134 | } | 146 | } |
| 135 | 147 | ||
| 136 | int get_cap_ymid(const struct Capabilities *cap) | 148 | int get_cap_ymid(const struct Capabilities *cap) |
| 137 | { | 149 | { |
| 138 | return (cap->abs_position_y.maximum + cap->abs_position_y.minimum) >> 1; | 150 | const struct input_absinfo *y = &cap->abs[BIT_POSITION_Y]; |
| 151 | return (y->maximum + y->minimum) >> 1; | ||
| 139 | } | 152 | } |
| 140 | 153 | ||
| 141 | void output_capabilities(const struct Capabilities *cap) | 154 | void output_capabilities(const struct Capabilities *cap) |
| 142 | { | 155 | { |
| 143 | char line[1024]; | 156 | char line[1024]; |
| 157 | int i; | ||
| 144 | memset(line, 0, sizeof(line)); | 158 | memset(line, 0, sizeof(line)); |
| 145 | ADDCAP(line, cap, left); | 159 | ADDCAP(line, cap, left); |
| 146 | ADDCAP(line, cap, middle); | 160 | ADDCAP(line, cap, middle); |
| 147 | ADDCAP(line, cap, right); | 161 | ADDCAP(line, cap, right); |
| 148 | ADDCAP(line, cap, mtdata); | 162 | ADDCAP(line, cap, mtdata); |
| 149 | ADDCAP(line, cap, ibt); | 163 | ADDCAP(line, cap, ibt); |
| 150 | ADDCAP(line, cap, touch_major); | ||
| 151 | ADDCAP(line, cap, touch_minor); | ||
| 152 | ADDCAP(line, cap, width_major); | ||
| 153 | ADDCAP(line, cap, width_minor); | ||
| 154 | ADDCAP(line, cap, orientation); | ||
| 155 | ADDCAP(line, cap, position_x); | ||
| 156 | ADDCAP(line, cap, position_y); | ||
| 157 | xf86Msg(X_INFO, "multitouch: devname: %s\n", cap->devname); | 164 | xf86Msg(X_INFO, "multitouch: devname: %s\n", cap->devname); |
| 158 | xf86Msg(X_INFO, "multitouch: devid: %x %x %x\n", | 165 | xf86Msg(X_INFO, "multitouch: devid: %x %x %x\n", |
| 159 | cap->devid.vendor, cap->devid.product, cap->devid.version); | 166 | cap->devid.vendor, cap->devid.product, cap->devid.version); |
| 160 | xf86Msg(X_INFO, "multitouch: caps:%s\n", line); | 167 | xf86Msg(X_INFO, "multitouch: caps:%s\n", line); |
| 161 | if (cap->has_touch_major) | 168 | for (i = 0; i < MT_ABS_SIZE; i++) { |
| 162 | xf86Msg(X_INFO, "multitouch: touch: %d %d\n", | 169 | if (cap->has_abs[i]) |
| 163 | cap->abs_touch_major.minimum, | 170 | xf86Msg(X_INFO, "multitouch: %d: min: %d max: %d\n", |
| 164 | cap->abs_touch_major.maximum); | 171 | i, |
| 165 | if (cap->has_width_major) | 172 | cap->abs[i].minimum, |
| 166 | xf86Msg(X_INFO, "multitouch: width: %d %d\n", | 173 | cap->abs[i].maximum); |
| 167 | cap->abs_width_major.minimum, | 174 | } |
| 168 | cap->abs_width_major.maximum); | ||
| 169 | if (cap->has_orientation) | ||
| 170 | xf86Msg(X_INFO, "multitouch: orientation: %d %d\n", | ||
| 171 | cap->abs_orientation.minimum, | ||
| 172 | cap->abs_orientation.maximum); | ||
| 173 | if (cap->has_position_x) | ||
| 174 | xf86Msg(X_INFO, "multitouch: position_x: %d %d\n", | ||
| 175 | cap->abs_position_x.minimum, | ||
| 176 | cap->abs_position_x.maximum); | ||
| 177 | if (cap->has_position_y) | ||
| 178 | xf86Msg(X_INFO, "multitouch: position_y: %d %d\n", | ||
| 179 | cap->abs_position_y.minimum, | ||
| 180 | cap->abs_position_y.maximum); | ||
| 181 | } | 175 | } |
diff --git a/src/hwstate.c b/src/hwstate.c index 81f4b8b..032351c 100644 --- a/src/hwstate.c +++ b/src/hwstate.c | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | #include "hwstate.h" | 22 | #include "hwstate.h" |
| 23 | 23 | ||
| 24 | #define NOTOUCH(hw, c) ((hw)->touch_major == 0 && (c)->has_touch_major) | 24 | #define NOTOUCH(hw, c) ((hw)->touch_major == 0 && (c)->has_abs[BIT_TOUCH_MAJOR]) |
| 25 | 25 | ||
| 26 | void init_hwstate(struct HWState *s) | 26 | void init_hwstate(struct HWState *s) |
| 27 | { | 27 | { |
| @@ -49,12 +49,12 @@ static void set_finger(struct FingerState *fs, | |||
| 49 | const struct FingerData *hw, int id, | 49 | const struct FingerData *hw, int id, |
| 50 | const struct Capabilities *caps) | 50 | const struct Capabilities *caps) |
| 51 | { | 51 | { |
| 52 | int x = defuzz(hw->position_x, fs->hw.position_x, caps->xfuzz); | 52 | int x = defuzz(hw->position_x, fs->hw.position_x, caps->abs[BIT_POSITION_X].fuzz); |
| 53 | int y = defuzz(hw->position_y, fs->hw.position_y, caps->yfuzz); | 53 | int y = defuzz(hw->position_y, fs->hw.position_y, caps->abs[BIT_POSITION_Y].fuzz); |
| 54 | int tj = defuzz(hw->touch_major, fs->hw.touch_major, caps->wfuzz); | 54 | int tj = defuzz(hw->touch_major, fs->hw.touch_major, caps->abs[BIT_TOUCH_MAJOR].fuzz); |
| 55 | int tn = defuzz(hw->touch_minor, fs->hw.touch_minor, caps->wfuzz); | 55 | int tn = defuzz(hw->touch_minor, fs->hw.touch_minor, caps->abs[BIT_TOUCH_MAJOR].fuzz); |
| 56 | int wj = defuzz(hw->width_major, fs->hw.width_major, caps->wfuzz); | 56 | int wj = defuzz(hw->width_major, fs->hw.width_major, caps->abs[BIT_TOUCH_MAJOR].fuzz); |
| 57 | int wn = defuzz(hw->width_minor, fs->hw.width_minor, caps->wfuzz); | 57 | int wn = defuzz(hw->width_minor, fs->hw.width_minor, caps->abs[BIT_TOUCH_MAJOR].fuzz); |
| 58 | fs->id = id; | 58 | fs->id = id; |
| 59 | fs->hw = *hw; | 59 | fs->hw = *hw; |
| 60 | fs->hw.position_x = x; | 60 | fs->hw.position_x = x; |
| @@ -65,9 +65,9 @@ static void set_finger(struct FingerState *fs, | |||
| 65 | } | 65 | } |
| 66 | fs->hw.width_major = wj; | 66 | fs->hw.width_major = wj; |
| 67 | fs->hw.width_minor = wn; | 67 | fs->hw.width_minor = wn; |
| 68 | if (!caps->has_touch_minor) | 68 | if (!caps->has_abs[BIT_TOUCH_MINOR]) |
| 69 | fs->hw.touch_minor = hw->touch_major; | 69 | fs->hw.touch_minor = hw->touch_major; |
| 70 | if (!caps->has_width_minor) | 70 | if (!caps->has_abs[BIT_WIDTH_MINOR]) |
| 71 | fs->hw.width_minor = hw->width_major; | 71 | fs->hw.width_minor = hw->width_major; |
| 72 | } | 72 | } |
| 73 | 73 | ||
diff --git a/src/memory.c b/src/memory.c index 9084502..39621da 100644 --- a/src/memory.c +++ b/src/memory.c | |||
| @@ -21,6 +21,9 @@ | |||
| 21 | 21 | ||
| 22 | #include "memory.h" | 22 | #include "memory.h" |
| 23 | 23 | ||
| 24 | /* click area definition */ | ||
| 25 | #define CLICK_AREA(c) ((c->has_ibt ? 0.20 : 0.00) * get_cap_ysize(c)) | ||
| 26 | |||
| 24 | /* fraction of max movement threshold */ | 27 | /* fraction of max movement threshold */ |
| 25 | #define DELTA_CUT(x) (0.5 * (x)) | 28 | #define DELTA_CUT(x) (0.5 * (x)) |
| 26 | 29 | ||
| @@ -88,11 +91,12 @@ static void update_pointers(struct Memory *m, | |||
| 88 | const struct Capabilities *caps) | 91 | const struct Capabilities *caps) |
| 89 | { | 92 | { |
| 90 | const struct MTFinger *f = state->finger; | 93 | const struct MTFinger *f = state->finger; |
| 94 | int yclick = caps->abs[BIT_POSITION_Y].maximum - CLICK_AREA(caps); | ||
| 91 | int i; | 95 | int i; |
| 92 | 96 | ||
| 93 | if (state->nfinger < 2) { | 97 | if (state->nfinger < 2) { |
| 94 | m->pointing = m->fingers; | 98 | m->pointing = m->fingers; |
| 95 | m->ybar = caps->abs_position_y.maximum; | 99 | m->ybar = caps->abs[BIT_POSITION_Y].maximum; |
| 96 | return; | 100 | return; |
| 97 | } | 101 | } |
| 98 | 102 | ||
| @@ -107,9 +111,9 @@ static void update_pointers(struct Memory *m, | |||
| 107 | } | 111 | } |
| 108 | 112 | ||
| 109 | m->pointing = 0; | 113 | m->pointing = 0; |
| 110 | m->ybar = caps->yclick; | 114 | m->ybar = yclick; |
| 111 | foreach_bit(i, m->fingers) { | 115 | foreach_bit(i, m->fingers) { |
| 112 | if (f[i].hw.position_y > caps->yclick) | 116 | if (f[i].hw.position_y > yclick) |
| 113 | continue; | 117 | continue; |
| 114 | if (!m->pointing || f[i].hw.position_y > m->ybar) | 118 | if (!m->pointing || f[i].hw.position_y > m->ybar) |
| 115 | m->ybar = f[i].hw.position_y; | 119 | m->ybar = f[i].hw.position_y; |
diff --git a/src/mtstate.c b/src/mtstate.c index 1e2eeef..2403765 100644 --- a/src/mtstate.c +++ b/src/mtstate.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include "mtstate.h" | 22 | #include "mtstate.h" |
| 23 | 23 | ||
| 24 | #define TOUCH_WIDTH(hw) (0.05 * hw->width_major) | 24 | #define TOUCH_WIDTH(hw) (0.05 * hw->width_major) |
| 25 | #define TOUCH_SCALE(caps) (0.05 * caps->abs_touch_major.maximum) | 25 | #define TOUCH_SCALE(caps) (0.05 * caps->abs[BIT_TOUCH_MAJOR].maximum) |
| 26 | 26 | ||
| 27 | #define THUMB_TOUCH(hw) (1.2 * hw->touch_minor) | 27 | #define THUMB_TOUCH(hw) (1.2 * hw->touch_minor) |
| 28 | #define THUMB_WIDTH_TOUCH(hw) (3 * hw->touch_major) | 28 | #define THUMB_WIDTH_TOUCH(hw) (3 * hw->touch_major) |
| @@ -37,9 +37,9 @@ void init_mtstate(struct MTState *s) | |||
| 37 | static int touching_finger(const struct FingerData *hw, | 37 | static int touching_finger(const struct FingerData *hw, |
| 38 | const struct Capabilities *caps) | 38 | const struct Capabilities *caps) |
| 39 | { | 39 | { |
| 40 | if (caps->has_touch_major && caps->has_width_major) | 40 | if (caps->has_abs[BIT_TOUCH_MAJOR] && caps->has_abs[BIT_WIDTH_MAJOR]) |
| 41 | return hw->touch_major > TOUCH_WIDTH(hw); | 41 | return hw->touch_major > TOUCH_WIDTH(hw); |
| 42 | if (caps->has_touch_major) | 42 | if (caps->has_abs[BIT_TOUCH_MAJOR]) |
| 43 | return hw->touch_major > TOUCH_SCALE(caps); | 43 | return hw->touch_major > TOUCH_SCALE(caps); |
| 44 | return 1; | 44 | return 1; |
| 45 | } | 45 | } |
| @@ -55,8 +55,10 @@ static int touching_finger(const struct FingerData *hw, | |||
| 55 | static int thumb_finger(const struct FingerData *hw, | 55 | static int thumb_finger(const struct FingerData *hw, |
| 56 | const struct Capabilities *caps) | 56 | const struct Capabilities *caps) |
| 57 | { | 57 | { |
| 58 | if (!caps->has_touch_major || !caps->has_touch_minor || | 58 | if (!caps->has_abs[BIT_TOUCH_MAJOR] || |
| 59 | !caps->has_width_major || !caps->has_width_minor) | 59 | !caps->has_abs[BIT_TOUCH_MINOR] || |
| 60 | !caps->has_abs[BIT_WIDTH_MAJOR] || | ||
| 61 | !caps->has_abs[BIT_WIDTH_MINOR]) | ||
| 60 | return 0; | 62 | return 0; |
| 61 | return hw->touch_major > THUMB_TOUCH(hw) && | 63 | return hw->touch_major > THUMB_TOUCH(hw) && |
| 62 | hw->width_major > THUMB_WIDTH_TOUCH(hw) && | 64 | hw->width_major > THUMB_WIDTH_TOUCH(hw) && |
