From a773c79d6d767ddfe574ad513ab0276bdd13a717 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 6 Nov 2008 14:03:42 +0100 Subject: Driver stages in place - should one support multiple device instances by moving the private alloc to init/close? Signed-off-by: Henrik Rydberg --- src/hwdata.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/hwdata.c (limited to 'src/hwdata.c') diff --git a/src/hwdata.c b/src/hwdata.c new file mode 100644 index 0000000..212e860 --- /dev/null +++ b/src/hwdata.c @@ -0,0 +1,90 @@ +#include "hwdata.h" +#include + +/******************************************************/ + +static int parse_event(struct HWData *hw) +{ + const struct input_event *ev = hw->event + hw->at++; + bool on = ev->value != 0; + switch (ev->type) { + case EV_SYN: + switch (ev->code) { + case SYN_REPORT: + return 0; + } + break; + case EV_KEY: + switch (ev->code) { + case BTN_LEFT: + hw->left = on; + break; + case BTN_MIDDLE: + hw->middle = on; + break; + case BTN_RIGHT: + hw->right = on; + break; + case BTN_MT_REPORT_PACKET: + if (on) + hw->nfinger = 0; + break; + case BTN_MT_REPORT_FINGER: + if (!on && hw->nfinger < DIM_FINGER) + hw->nfinger++; + break; + } + break; + case EV_ABS: + switch (ev->code) { + case ABS_MT_TOUCH_MAJOR: + hw->finger[hw->nfinger].touch_major = ev->value; + break; + case ABS_MT_TOUCH_MINOR: + hw->finger[hw->nfinger].touch_minor = ev->value; + break; + case ABS_MT_WIDTH_MAJOR: + hw->finger[hw->nfinger].width_major = ev->value; + break; + case ABS_MT_WIDTH_MINOR: + hw->finger[hw->nfinger].width_minor = ev->value; + break; + case ABS_MT_ORIENTATION: + hw->finger[hw->nfinger].orientation = ev->value; + break; + case ABS_MT_POSITION_X: + hw->finger[hw->nfinger].position_x = ev->value; + break; + case ABS_MT_POSITION_Y: + hw->finger[hw->nfinger].position_y = ev->value; + break; + } + break; + } + return -EAGAIN; +} + +/******************************************************/ + +int read_hwdata(struct HWData *hw, int fd) +{ + int n; + do { + while (hw->at < hw->nev) + if (!parse_event(hw)) + return 0; + n = read(fd, hw->event, sizeof(hw->event)); + hw->at = 0; + hw->nev = n / sizeof(struct input_event); + xf86Msg(X_INFO, "multitouch: read: %d %d\n", n, hw->nev); + } while (n > 0); + return -EIO; +}; + +/******************************************************/ + +void output_hwdata(const struct HWData *hw) +{ +} + +/******************************************************/ -- cgit v1.2.3