diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2012-02-07 14:45:11 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-02-11 07:46:05 +1000 |
commit | 5cb5bb573491058c35bbaac5c4c4fceea4626f57 (patch) | |
tree | 059ebd47c5f49b97d03df2e634283e953ad21f2e /src/synproto.c | |
parent | 0df994b3d80006d2fb114226d8b488e98d0e03d4 (diff) |
Add touch valuator mask to hw state structure
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/synproto.c')
-rw-r--r-- | src/synproto.c | 91 |
1 files changed, 89 insertions, 2 deletions
diff --git a/src/synproto.c b/src/synproto.c index 9f042b5..49d333d 100644 --- a/src/synproto.c +++ b/src/synproto.c @@ -28,16 +28,82 @@ #include "synproto.h" +#include "synaptics.h" +#include "synapticsstr.h" + +#ifdef HAVE_MULTITOUCH +static int +HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv) +{ + int num_vals; + int i = 0; + + hw->num_mt_mask = priv->num_slots; + hw->mt_mask = malloc(hw->num_mt_mask * sizeof(ValuatorMask *)); + if (!hw->mt_mask) + goto fail; + + num_vals = 2; /* x and y */ + num_vals += 2; /* scroll axes */ + num_vals += priv->num_mt_axes; + + for (; i < hw->num_mt_mask; i++) + { + hw->mt_mask[i] = valuator_mask_new(num_vals); + if (!hw->mt_mask[i]) + goto fail; + } + + hw->slot_state = calloc(hw->num_mt_mask, sizeof(enum SynapticsSlotState)); + if (!hw->slot_state) + goto fail; + + return Success; + +fail: + for (i--; i >= 0; i--) + valuator_mask_free(&hw->mt_mask[i]); + free(hw->mt_mask); + hw->mt_mask = NULL; + return BadAlloc; +} +#endif struct SynapticsHwState * SynapticsHwStateAlloc(SynapticsPrivate *priv) { - return calloc(1, sizeof(struct SynapticsHwState)); + struct SynapticsHwState *hw; + + hw = calloc(1, sizeof(struct SynapticsHwState)); + if (!hw) + return NULL; + +#ifdef HAVE_MULTITOUCH + if (HwStateAllocTouch(hw, priv) != Success) + { + free(hw); + return NULL; + } +#endif + + return hw; } void SynapticsHwStateFree(struct SynapticsHwState **hw) { +#ifdef HAVE_MULTITOUCH + int i; + + if (!*hw) + return; + + free((*hw)->slot_state); + for (i = 0; i < (*hw)->num_mt_mask; i++) + valuator_mask_free(&(*hw)->mt_mask[i]); + free((*hw)->mt_mask); +#endif + free(*hw); *hw = NULL; } @@ -46,5 +112,26 @@ void SynapticsCopyHwState(struct SynapticsHwState *dst, const struct SynapticsHwState *src) { - *dst = *src; +#ifdef HAVE_MULTITOUCH + int i; +#endif + + dst->millis = src->millis; + dst->x = src->x; + dst->y = src->y; + dst->z = src->z; + dst->numFingers = src->numFingers; + dst->fingerWidth = src->fingerWidth; + dst->left = src->left; + dst->right = src->right; + dst->up = src->up; + dst->down = src->down; + memcpy(dst->multi, src->multi, sizeof(dst->multi)); + dst->middle = src->middle; +#ifdef HAVE_MULTITOUCH + for (i = 0; i < dst->num_mt_mask && i < src->num_mt_mask; i++) + valuator_mask_copy(dst->mt_mask[i], src->mt_mask[i]); + memcpy(dst->slot_state, src->slot_state, + dst->num_mt_mask * sizeof(enum SynapticsSlotState)); +#endif } |