1 /***************************************************************************
3 * Multitouch protocol X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 * Copyright (C) 2009,2010 Nokia Corporation
7 * Adaptation to libmtdev and Linux multi-touch-protocol B (slotted)
8 * Copyright (C) 2010 Intel Corporation
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 **************************************************************************/
27 #include <linux/input.h>
33 void hw_init(struct mtev_hw_state *hw)
36 memset(hw, 0, sizeof(struct mtev_hw_state));
37 for (i = 0; i < HW_MAX_SLOTS; i++)
38 hw->slot[i].tracking_id = INVALID_TRACKING_ID;
41 bool hw_read(struct mtev_hw_state *hw, const struct input_event* ev)
43 // xf86Msg(X_INFO, "event: %d %d %d\n", ev->type, ev->code, ev->value);
52 xf86Msg(X_ERROR, "libmtdev sent SYN_MT_REPORT");
58 if (ev->code == ABS_MT_SLOT) {
59 if (ev->value >= HW_MAX_SLOTS) {
60 xf86Msg(X_ERROR, "Slot usage (%d) exceeds limit of %d", ev->value, HW_MAX_SLOTS);
61 hw->current_slot = INVALID_SLOT;
63 hw->current_slot = ev->value;
67 if (hw->current_slot == INVALID_SLOT)
71 case ABS_MT_POSITION_X:
72 hw->slot[hw->current_slot].position_x = ev->value;
74 case ABS_MT_POSITION_Y:
75 hw->slot[hw->current_slot].position_y = ev->value;
77 case ABS_MT_TOUCH_MAJOR:
78 hw->slot[hw->current_slot].touch_major = ev->value;
80 case ABS_MT_TOUCH_MINOR:
81 hw->slot[hw->current_slot].touch_minor = ev->value;
83 case ABS_MT_WIDTH_MAJOR:
84 hw->slot[hw->current_slot].width_major = ev->value;
86 case ABS_MT_WIDTH_MINOR:
87 hw->slot[hw->current_slot].width_minor = ev->value;
89 case ABS_MT_ORIENTATION:
90 hw->slot[hw->current_slot].orientation = ev->value;
93 hw->slot[hw->current_slot].pressure = ev->value;
95 case ABS_MT_TRACKING_ID:
96 if (ev->value == -1) /* Slot contact has been released */
97 hw->slot[hw->current_slot].tracking_id = INVALID_TRACKING_ID;
99 hw->slot[hw->current_slot].tracking_id = hw->current_slot;//ev->value;