diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-17 18:12:58 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-06-17 18:12:58 +0200 |
| commit | 66e5de9eaefc33ffa6af3617f9ec7a50f10af50d (patch) | |
| tree | 66535311e0b9c422b30341237fd596fb9ebbdd75 /test/mtdev-mapgen.c | |
Initial load of mtdev project
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'test/mtdev-mapgen.c')
| -rw-r--r-- | test/mtdev-mapgen.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/mtdev-mapgen.c b/test/mtdev-mapgen.c new file mode 100644 index 0000000..823ce96 --- /dev/null +++ b/test/mtdev-mapgen.c | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * mtdev - MT device event converter (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 | #include <mtdev-mapping.h> | ||
| 30 | #include <stdio.h> | ||
| 31 | |||
| 32 | #define BIT_DEF(name) \ | ||
| 33 | printf("#define MTDEV_"#name"\t%d\n", \ | ||
| 34 | cabs2mt[ABS_MT_##name] - 1) | ||
| 35 | |||
| 36 | static unsigned int cabs2mt[ABS_CNT]; | ||
| 37 | static unsigned int cmt2abs[MT_ABS_SIZE]; | ||
| 38 | |||
| 39 | void init_caps() | ||
| 40 | { | ||
| 41 | static const int init_abs_map[MT_ABS_SIZE] = MT_SLOT_ABS_EVENTS; | ||
| 42 | int i; | ||
| 43 | for (i = 0; i < MT_ABS_SIZE; i++) { | ||
| 44 | cabs2mt[init_abs_map[i]] = i + 1; | ||
| 45 | cmt2abs[i] = init_abs_map[i]; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline const char *newln(int i, int n) | ||
| 50 | { | ||
| 51 | return i == n - 1 || i % 8 == 7 ? "\n" : ""; | ||
| 52 | } | ||
| 53 | |||
| 54 | int main(int argc, char *argv[]) | ||
| 55 | { | ||
| 56 | int i; | ||
| 57 | init_caps(); | ||
| 58 | printf("static const unsigned int mtdev_map_abs2mt[ABS_CNT] = {\n"); | ||
| 59 | for (i = 0; i < ABS_CNT; i++) | ||
| 60 | printf(" 0x%04x,%s", cabs2mt[i], newln(i, ABS_CNT)); | ||
| 61 | printf("};\n\n"); | ||
| 62 | printf("static const unsigned int mtdev_map_mt2abs[MT_ABS_SIZE] = {\n"); | ||
| 63 | for (i = 0; i < MT_ABS_SIZE; i++) | ||
| 64 | printf(" 0x%04x,%s", cmt2abs[i], newln(i, MT_ABS_SIZE)); | ||
| 65 | printf("};\n\n"); | ||
| 66 | BIT_DEF(TRACKING_ID); | ||
| 67 | BIT_DEF(POSITION_X); | ||
| 68 | BIT_DEF(POSITION_Y); | ||
| 69 | BIT_DEF(TOUCH_MAJOR); | ||
| 70 | BIT_DEF(TOUCH_MINOR); | ||
| 71 | BIT_DEF(WIDTH_MAJOR); | ||
| 72 | BIT_DEF(WIDTH_MINOR); | ||
| 73 | BIT_DEF(ORIENTATION); | ||
| 74 | printf("\n"); | ||
| 75 | return 0; | ||
| 76 | } | ||
