summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-15 20:24:14 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:28:08 +0200
commit78085b21f2dc7b1d49a0c54ab56b567fc195d440 (patch)
tree3ae649c25b380114ce2eaa5463350fb9b29ee78c /src
parent4583da1ad81b59b2a8cd2ae51c32b1bc8d32f1c4 (diff)
refactor: Simplify capabilities
Use the generated abs2mt mapping to simplify the MT device capabilities. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/hwstate.c18
-rw-r--r--src/memory.c10
-rw-r--r--src/mtstate.c12
3 files changed, 23 insertions, 17 deletions
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 @@
#include "hwstate.h"
-#define NOTOUCH(hw, c) ((hw)->touch_major == 0 && (c)->has_touch_major)
+#define NOTOUCH(hw, c) ((hw)->touch_major == 0 && (c)->has_abs[BIT_TOUCH_MAJOR])
void init_hwstate(struct HWState *s)
{
@@ -49,12 +49,12 @@ static void set_finger(struct FingerState *fs,
const struct FingerData *hw, int id,
const struct Capabilities *caps)
{
- int x = defuzz(hw->position_x, fs->hw.position_x, caps->xfuzz);
- int y = defuzz(hw->position_y, fs->hw.position_y, caps->yfuzz);
- int tj = defuzz(hw->touch_major, fs->hw.touch_major, caps->wfuzz);
- int tn = defuzz(hw->touch_minor, fs->hw.touch_minor, caps->wfuzz);
- int wj = defuzz(hw->width_major, fs->hw.width_major, caps->wfuzz);
- int wn = defuzz(hw->width_minor, fs->hw.width_minor, caps->wfuzz);
+ int x = defuzz(hw->position_x, fs->hw.position_x, caps->abs[BIT_POSITION_X].fuzz);
+ int y = defuzz(hw->position_y, fs->hw.position_y, caps->abs[BIT_POSITION_Y].fuzz);
+ int tj = defuzz(hw->touch_major, fs->hw.touch_major, caps->abs[BIT_TOUCH_MAJOR].fuzz);
+ int tn = defuzz(hw->touch_minor, fs->hw.touch_minor, caps->abs[BIT_TOUCH_MAJOR].fuzz);
+ int wj = defuzz(hw->width_major, fs->hw.width_major, caps->abs[BIT_TOUCH_MAJOR].fuzz);
+ int wn = defuzz(hw->width_minor, fs->hw.width_minor, caps->abs[BIT_TOUCH_MAJOR].fuzz);
fs->id = id;
fs->hw = *hw;
fs->hw.position_x = x;
@@ -65,9 +65,9 @@ static void set_finger(struct FingerState *fs,
}
fs->hw.width_major = wj;
fs->hw.width_minor = wn;
- if (!caps->has_touch_minor)
+ if (!caps->has_abs[BIT_TOUCH_MINOR])
fs->hw.touch_minor = hw->touch_major;
- if (!caps->has_width_minor)
+ if (!caps->has_abs[BIT_WIDTH_MINOR])
fs->hw.width_minor = hw->width_major;
}
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 @@
#include "memory.h"
+/* click area definition */
+#define CLICK_AREA(c) ((c->has_ibt ? 0.20 : 0.00) * get_cap_ysize(c))
+
/* fraction of max movement threshold */
#define DELTA_CUT(x) (0.5 * (x))
@@ -88,11 +91,12 @@ static void update_pointers(struct Memory *m,
const struct Capabilities *caps)
{
const struct MTFinger *f = state->finger;
+ int yclick = caps->abs[BIT_POSITION_Y].maximum - CLICK_AREA(caps);
int i;
if (state->nfinger < 2) {
m->pointing = m->fingers;
- m->ybar = caps->abs_position_y.maximum;
+ m->ybar = caps->abs[BIT_POSITION_Y].maximum;
return;
}
@@ -107,9 +111,9 @@ static void update_pointers(struct Memory *m,
}
m->pointing = 0;
- m->ybar = caps->yclick;
+ m->ybar = yclick;
foreach_bit(i, m->fingers) {
- if (f[i].hw.position_y > caps->yclick)
+ if (f[i].hw.position_y > yclick)
continue;
if (!m->pointing || f[i].hw.position_y > m->ybar)
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 @@
#include "mtstate.h"
#define TOUCH_WIDTH(hw) (0.05 * hw->width_major)
-#define TOUCH_SCALE(caps) (0.05 * caps->abs_touch_major.maximum)
+#define TOUCH_SCALE(caps) (0.05 * caps->abs[BIT_TOUCH_MAJOR].maximum)
#define THUMB_TOUCH(hw) (1.2 * hw->touch_minor)
#define THUMB_WIDTH_TOUCH(hw) (3 * hw->touch_major)
@@ -37,9 +37,9 @@ void init_mtstate(struct MTState *s)
static int touching_finger(const struct FingerData *hw,
const struct Capabilities *caps)
{
- if (caps->has_touch_major && caps->has_width_major)
+ if (caps->has_abs[BIT_TOUCH_MAJOR] && caps->has_abs[BIT_WIDTH_MAJOR])
return hw->touch_major > TOUCH_WIDTH(hw);
- if (caps->has_touch_major)
+ if (caps->has_abs[BIT_TOUCH_MAJOR])
return hw->touch_major > TOUCH_SCALE(caps);
return 1;
}
@@ -55,8 +55,10 @@ static int touching_finger(const struct FingerData *hw,
static int thumb_finger(const struct FingerData *hw,
const struct Capabilities *caps)
{
- if (!caps->has_touch_major || !caps->has_touch_minor ||
- !caps->has_width_major || !caps->has_width_minor)
+ if (!caps->has_abs[BIT_TOUCH_MAJOR] ||
+ !caps->has_abs[BIT_TOUCH_MINOR] ||
+ !caps->has_abs[BIT_WIDTH_MAJOR] ||
+ !caps->has_abs[BIT_WIDTH_MINOR])
return 0;
return hw->touch_major > THUMB_TOUCH(hw) &&
hw->width_major > THUMB_WIDTH_TOUCH(hw) &&