diff options
Diffstat (limited to 'apps/plugins/lib/touchscreen.c')
-rw-r--r-- | apps/plugins/lib/touchscreen.c | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/apps/plugins/lib/touchscreen.c b/apps/plugins/lib/touchscreen.c deleted file mode 100644 index 5b7517349a..0000000000 --- a/apps/plugins/lib/touchscreen.c +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "plugin.h" | ||
23 | |||
24 | #ifdef HAVE_TOUCHSCREEN | ||
25 | |||
26 | #include "touchscreen.h" | ||
27 | |||
28 | unsigned int touchscreen_map(struct ts_mappings *map, int x, int y) | ||
29 | { | ||
30 | int i; | ||
31 | for(i=0; i < map->amount; i++) | ||
32 | { | ||
33 | #define _MAP(x) (map->mappings[x]) | ||
34 | if(x > _MAP(i).tl_x && x < (_MAP(i).tl_x+_MAP(i).width) | ||
35 | && y > _MAP(i).tl_y && y < (_MAP(i).tl_y+_MAP(i).height)) | ||
36 | return i; | ||
37 | } | ||
38 | |||
39 | return -1; | ||
40 | } | ||
41 | |||
42 | unsigned int touchscreen_map_raster(struct ts_raster *map, int x, int y, struct ts_raster_result *result) | ||
43 | { | ||
44 | int res1_x, res2_x, res1_y, res2_y; | ||
45 | |||
46 | if((x - map->tl_x) < 0 || | ||
47 | (x - map->tl_x) > map->width) | ||
48 | return -1; | ||
49 | res1_x = (x - map->tl_x)/(map->raster_width); | ||
50 | res2_x = (x - map->tl_x)%(map->raster_width); | ||
51 | |||
52 | if((y - map->tl_y) < 0 || | ||
53 | (y - map->tl_y) > map->height) | ||
54 | return -1; | ||
55 | res1_y = (y - map->tl_y)/(map->raster_height); | ||
56 | res2_y = (y - map->tl_y)%(map->raster_height); | ||
57 | |||
58 | if(res2_x == 0 || res2_y == 0) /* pen hit a raster boundary */ | ||
59 | return -2; | ||
60 | else | ||
61 | { | ||
62 | (*result).x = res1_x; | ||
63 | (*result).y = res1_y; | ||
64 | return 1; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | struct ts_raster_button_result touchscreen_raster_map_button(struct ts_raster_button_mapping *map, int x, int y, int button) | ||
69 | { | ||
70 | struct ts_raster_button_result ret = {0, {0, 0}, {0, 0}}; | ||
71 | struct ts_raster_result tmp; | ||
72 | |||
73 | ret.action = TS_ACTION_NONE; | ||
74 | if(touchscreen_map_raster(map->raster, x, y, &tmp) != 1) | ||
75 | return ret; | ||
76 | |||
77 | #define NOT_HANDLED (ret.action == TS_ACTION_NONE) | ||
78 | if((button == BUTTON_REPEAT) && (map->_prev_btn_state != BUTTON_REPEAT) && map->drag_drop_enable) | ||
79 | { | ||
80 | map->_prev_x = tmp.x; | ||
81 | map->_prev_y = tmp.y; | ||
82 | } | ||
83 | if((button == BUTTON_REL) && (map->_prev_btn_state == BUTTON_REPEAT) && map->drag_drop_enable) | ||
84 | { | ||
85 | ret.action = TS_ACTION_DRAG_DROP; | ||
86 | ret.from.x = map->_prev_x; | ||
87 | ret.from.y = map->_prev_y; | ||
88 | ret.to.x = tmp.x; | ||
89 | ret.to.y = tmp.y; | ||
90 | } | ||
91 | if((button == BUTTON_REL) && map->double_click_enable && NOT_HANDLED) | ||
92 | { | ||
93 | if(map->_prev_x == tmp.x && map->_prev_y == tmp.y) | ||
94 | { | ||
95 | ret.action = TS_ACTION_DOUBLE_CLICK; | ||
96 | ret.from.x = ret.to.x = tmp.x; | ||
97 | ret.from.y = ret.to.y = tmp.y; | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | map->_prev_x = tmp.x; | ||
102 | map->_prev_y = tmp.y; | ||
103 | } | ||
104 | } | ||
105 | if((button & BUTTON_REL || button & BUTTON_REPEAT) && map->two_d_movement_enable && NOT_HANDLED) | ||
106 | { | ||
107 | if((map->two_d_from.x == tmp.x) ^ (map->two_d_from.y == tmp.y)) | ||
108 | { | ||
109 | ret.action = TS_ACTION_TWO_D_MOVEMENT; | ||
110 | ret.from.x = map->two_d_from.x; | ||
111 | ret.from.y = map->two_d_from.y; | ||
112 | ret.to.x = map->two_d_from.x + (map->two_d_from.x == tmp.x ? 0 : (tmp.x > map->two_d_from.x ? 1 : -1)); | ||
113 | ret.to.y = map->two_d_from.y + (map->two_d_from.y == tmp.y ? 0 : (tmp.y > map->two_d_from.y ? 1 : -1)); | ||
114 | } | ||
115 | else | ||
116 | ret.action = TS_ACTION_NONE; | ||
117 | } | ||
118 | if(map->click_enable && (button & BUTTON_REL) && NOT_HANDLED) | ||
119 | { | ||
120 | ret.action = TS_ACTION_CLICK; | ||
121 | ret.from.x = ret.to.x = tmp.x; | ||
122 | ret.from.y = ret.to.y = tmp.y; | ||
123 | } | ||
124 | if(map->move_progress_enable && NOT_HANDLED) | ||
125 | { | ||
126 | ret.action = TS_ACTION_MOVE; | ||
127 | ret.from.x = ret.to.x = tmp.x; | ||
128 | ret.from.y = ret.to.y = tmp.y; | ||
129 | } | ||
130 | |||
131 | map->_prev_btn_state = button; | ||
132 | return ret; | ||
133 | } | ||
134 | |||
135 | #endif /* HAVE_TOUCHSCREEN */ | ||