summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-15 19:40:34 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:28:08 +0200
commit4583da1ad81b59b2a8cd2ae51c32b1bc8d32f1c4 (patch)
tree5041c40ec1d899aa135a3030413b919b2dad0384
parentff88de5cd38b5b51bad0e63d373d66745f1f8d31 (diff)
refactor: Generate code for ABS_MT mapping
Use the kernel-provided list MT_SLOT_ABS_EVENTS to generate code mappings between ABS_MT space and MT space. This patch adds the program mapgen that does the mapping, and adds two include files generated with it. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--Makefile1
-rw-r--r--include/abs2mt.h39
-rw-r--r--include/mtbit.h14
-rw-r--r--mtdev/mapgen.c69
4 files changed, 123 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index f364845..1ed5758 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@ o_src = hwstate mtstate memory mtouch gestures
16o_driver= multitouch 16o_driver= multitouch
17 17
18TARGETS += match/test 18TARGETS += match/test
19TARGETS += mtdev/mapgen
19TARGETS += src/test 20TARGETS += src/test
20 21
21OBJECTS = $(addsuffix .o,\ 22OBJECTS = $(addsuffix .o,\
diff --git a/include/abs2mt.h b/include/abs2mt.h
new file mode 100644
index 0000000..6021d8d
--- /dev/null
+++ b/include/abs2mt.h
@@ -0,0 +1,39 @@
1/* generated by mapgen - do not edit */
2
3#ifndef ABS2MT_H
4#define ABS2MT_H
5
6#include "common.h"
7
8static const unsigned int map_abs2mt[ABS_CNT] = {
9 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
10 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
11 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
12 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
13 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
14 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
15 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
16 0x0009, 0x000a, 0x000b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
17};
18
19static const unsigned int map_mt2abs[MT_ABS_SIZE] = {
20 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
21 0x0038, 0x0039, 0x003a,
22};
23
24static inline int has_abs2mt(unsigned int code)
25{
26 return map_abs2mt[code];
27}
28
29static inline unsigned int abs2mt(unsigned int code)
30{
31 return map_abs2mt[code] - 1;
32}
33
34static inline unsigned int mt2abs(unsigned int mtcode)
35{
36 return map_mt2abs[mtcode];
37}
38
39#endif
diff --git a/include/mtbit.h b/include/mtbit.h
new file mode 100644
index 0000000..2c4dacb
--- /dev/null
+++ b/include/mtbit.h
@@ -0,0 +1,14 @@
1/* generated by mapgen - do not edit */
2
3#ifndef MTBIT_H
4#define MTBIT_H
5
6#define BIT_TRACKING_ID 9
7#define BIT_POSITION_X 5
8#define BIT_POSITION_Y 6
9#define BIT_TOUCH_MAJOR 0
10#define BIT_TOUCH_MINOR 1
11#define BIT_WIDTH_MAJOR 2
12#define BIT_WIDTH_MINOR 3
13
14#endif
diff --git a/mtdev/mapgen.c b/mtdev/mapgen.c
new file mode 100644
index 0000000..efb3524
--- /dev/null
+++ b/mtdev/mapgen.c
@@ -0,0 +1,69 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#include <common.h>
23#include <fcntl.h>
24#include <xbypass.h>
25
26#define BIT_DEF(name) \
27 printf("#define BIT_"#name" %d\n", \
28 cabs2mt[ABS_MT_##name] - 1)
29
30static unsigned int cabs2mt[ABS_CNT];
31static unsigned int cmt2abs[MT_ABS_SIZE];
32
33void init_caps()
34{
35 static const int init_abs_map[MT_ABS_SIZE] = MT_SLOT_ABS_EVENTS;
36 int i;
37 for (i = 0; i < MT_ABS_SIZE; i++) {
38 cabs2mt[init_abs_map[i]] = i + 1;
39 cmt2abs[i] = init_abs_map[i];
40 }
41}
42
43static inline const char *newln(int i, int n)
44{
45 return i == n - 1 || i % 8 == 7 ? "\n" : "";
46}
47
48int main(int argc, char *argv[])
49{
50 int i;
51 init_caps();
52 printf("static const unsigned int map_abs2mt[ABS_CNT] = {\n");
53 for (i = 0; i < ABS_CNT; i++)
54 printf(" 0x%04x,%s", cabs2mt[i], newln(i, ABS_CNT));
55 printf("};\n\n");
56 printf("static const unsigned int map_mt2abs[MT_ABS_SIZE] = {\n");
57 for (i = 0; i < MT_ABS_SIZE; i++)
58 printf(" 0x%04x,%s", cmt2abs[i], newln(i, MT_ABS_SIZE));
59 printf("};\n\n");
60 BIT_DEF(TRACKING_ID);
61 BIT_DEF(POSITION_X);
62 BIT_DEF(POSITION_Y);
63 BIT_DEF(TOUCH_MAJOR);
64 BIT_DEF(TOUCH_MINOR);
65 BIT_DEF(WIDTH_MAJOR);
66 BIT_DEF(WIDTH_MINOR);
67 printf("\n");
68 return 0;
69}