1 /*****************************************************************************
2 *
3 * mtdev - Multitouch Protocol Translation Library (MIT license)
4 *
5 * Copyright (C) 2010 Henrik Rydberg <rydberg@euromail.se>
6 * Copyright (C) 2010 Canonical Ltd.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 *
27 ****************************************************************************/
28
29 #define MTDEV_NO_LEGACY_API
30 #include <mtdev.h>
31 #include <stdio.h>
32
33 #define MT_ABS_SIZE 12
34 #define MT_SLOT_ABS_EVENTS { \
35 ABS_MT_TOUCH_MAJOR, \
36 ABS_MT_TOUCH_MINOR, \
37 ABS_MT_WIDTH_MAJOR, \
38 ABS_MT_WIDTH_MINOR, \
39 ABS_MT_ORIENTATION, \
40 ABS_MT_POSITION_X, \
41 ABS_MT_POSITION_Y, \
42 ABS_MT_TOOL_TYPE, \
43 ABS_MT_BLOB_ID, \
44 ABS_MT_TRACKING_ID, \
45 ABS_MT_PRESSURE, \
46 ABS_MT_DISTANCE, \
47 }
48
49 static unsigned int cabs2mt[ABS_CNT];
50 static unsigned int cmt2abs[MT_ABS_SIZE];
51
init_caps()52 static void init_caps()
53 {
54 static const int init_abs_map[MT_ABS_SIZE] = MT_SLOT_ABS_EVENTS;
55 int i;
56 for (i = 0; i < MT_ABS_SIZE; i++) {
57 cabs2mt[init_abs_map[i]] = i + 1;
58 cmt2abs[i] = init_abs_map[i];
59 }
60 }
61
newln(int i,int n)62 static inline const char *newln(int i, int n)
63 {
64 return i == n - 1 || i % 8 == 7 ? "\n" : "";
65 }
66
main(int argc,char * argv[])67 int main(int argc, char *argv[])
68 {
69 int i;
70 init_caps();
71 printf("static const unsigned int mtdev_map_abs2mt[ABS_CNT] = {\n");
72 for (i = 0; i < ABS_CNT; i++)
73 printf(" 0x%04x,%s", cabs2mt[i], newln(i, ABS_CNT));
74 printf("};\n\n");
75 printf("static const unsigned int mtdev_map_mt2abs[MT_ABS_SIZE] = {\n");
76 for (i = 0; i < MT_ABS_SIZE; i++)
77 printf(" 0x%04x,%s", cmt2abs[i], newln(i, MT_ABS_SIZE));
78 printf("};\n\n");
79 return 0;
80 }
81