diff options
Diffstat (limited to 'apps/keymaps/keymap-touchpad.c')
-rw-r--r-- | apps/keymaps/keymap-touchpad.c | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/apps/keymaps/keymap-touchpad.c b/apps/keymaps/keymap-touchpad.c new file mode 100644 index 0000000000..48f1103cd3 --- /dev/null +++ b/apps/keymaps/keymap-touchpad.c | |||
@@ -0,0 +1,214 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: keymap-mr500.c 16056 2008-01-11 21:48:01Z roolku $ | ||
9 | * | ||
10 | * Copyright (C) 2006 Jonathan Gordon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | /* Button Code Definitions for touchpad targets */ | ||
21 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <stdlib.h> | ||
24 | |||
25 | #include "config.h" | ||
26 | #include "action.h" | ||
27 | #include "button.h" | ||
28 | #include "settings.h" | ||
29 | |||
30 | const struct button_mapping* target_get_context_mapping(int context); | ||
31 | /* How this file is used: | ||
32 | get_context_mapping() at the bottom of the file is called by action.c as usual. | ||
33 | if the context is for the remote control its then passed straight to | ||
34 | target_get_context_mapping(). | ||
35 | These tables are only used for the touchpad buttons, so at the end of each | ||
36 | CONTEXT_CUSTOM2 is OR'ed with the context and then sent to target_get_context_mapping() | ||
37 | (NOTE: CONTEXT_CUSTOM2 will be stripped before being sent to make it easier.) | ||
38 | In the target keymap, remember to |CONTEXT_CUSTOM2 in the LAST_ITEM_IN_LIST__NEXTLIST() macro | ||
39 | to speed it up a tiny bit... if you dont it will go through these tables first before going | ||
40 | back to the target file. | ||
41 | */ | ||
42 | |||
43 | |||
44 | /* touchpad "buttons" | ||
45 | screen is split into a 3x3 grid for buttons... | ||
46 | BUTTON_TOPLEFT BUTTON_TOPMIDDLE BUTTON_TOPRIGHT | ||
47 | BUTTON_MIDLEFT BUTTON_CENTER BUTTON_MIDRIGHT | ||
48 | BUTTON_BOTTOMLEFT BUTTON_BOTTOMMIDDLE BUTTON_BOTTOMRIGHT | ||
49 | */ | ||
50 | |||
51 | static const struct button_mapping button_context_standard[] = { | ||
52 | { ACTION_STD_PREV, BUTTON_TOPMIDDLE, BUTTON_NONE }, | ||
53 | { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, | ||
54 | { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, | ||
55 | { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, | ||
56 | |||
57 | { ACTION_STD_OK, BUTTON_CENTER|BUTTON_REL, BUTTON_CENTER }, | ||
58 | { ACTION_STD_OK, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_MIDRIGHT }, | ||
59 | { ACTION_STD_OK, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_MIDRIGHT }, | ||
60 | |||
61 | { ACTION_STD_MENU, BUTTON_TOPLEFT, BUTTON_NONE }, | ||
62 | { ACTION_STD_QUICKSCREEN, BUTTON_TOPLEFT|BUTTON_REPEAT, BUTTON_NONE }, | ||
63 | { ACTION_STD_CONTEXT, BUTTON_CENTER|BUTTON_REPEAT, BUTTON_CENTER }, | ||
64 | { ACTION_STD_CANCEL, BUTTON_MIDLEFT, BUTTON_NONE }, | ||
65 | { ACTION_STD_CANCEL, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, | ||
66 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_STD) | ||
67 | }; /* button_context_standard */ | ||
68 | |||
69 | static const struct button_mapping button_context_wps[] = { | ||
70 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_WPS) | ||
71 | }; /* button_context_wps */ | ||
72 | |||
73 | static const struct button_mapping button_context_list[] = { | ||
74 | #if 0 | ||
75 | /* this is all to show how the poor-mans-gestures can be used... */ | ||
76 | { ACTION_LISTTREE_PGUP, BUTTON_TOPRIGHT, BUTTON_NONE}, | ||
77 | { ACTION_LISTTREE_PGUP, BUTTON_TOPRIGHT|BUTTON_REPEAT, BUTTON_TOPRIGHT}, | ||
78 | { ACTION_STD_NEXTREPEAT, BUTTON_CENTER, BUTTON_TOPMIDDLE}, | ||
79 | { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE, BUTTON_CENTER}, | ||
80 | { ACTION_NONE, BUTTON_TOPMIDDLE, BUTTON_NONE }, | ||
81 | { ACTION_NONE, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, | ||
82 | { ACTION_STD_PREV, BUTTON_TOPMIDDLE|BUTTON_REL, BUTTON_NONE }, | ||
83 | { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE|BUTTON_REL, BUTTON_NONE }, | ||
84 | { ACTION_LISTTREE_PGDOWN, BUTTON_BOTTOMRIGHT, BUTTON_NONE}, | ||
85 | { ACTION_LISTTREE_PGDOWN, BUTTON_BOTTOMRIGHT|BUTTON_REPEAT, BUTTON_BOTTOMRIGHT}, | ||
86 | { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE, BUTTON_CENTER}, | ||
87 | { ACTION_STD_PREVREPEAT, BUTTON_CENTER, BUTTON_BOTTOMMIDDLE}, | ||
88 | #endif | ||
89 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_LIST) | ||
90 | }; /* button_context_list */ | ||
91 | |||
92 | static const struct button_mapping button_context_tree[] = { | ||
93 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM2|CONTEXT_TREE) | ||
94 | }; /* button_context_tree */ | ||
95 | |||
96 | static const struct button_mapping button_context_listtree_scroll_with_combo[] = { | ||
97 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_TREE), | ||
98 | }; | ||
99 | |||
100 | static const struct button_mapping button_context_listtree_scroll_without_combo[] = { | ||
101 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_TREE), | ||
102 | }; | ||
103 | |||
104 | static const struct button_mapping button_context_settings[] = { | ||
105 | { ACTION_SETTINGS_INC, BUTTON_TOPMIDDLE, BUTTON_NONE }, | ||
106 | { ACTION_SETTINGS_INCREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, | ||
107 | { ACTION_SETTINGS_DEC, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, | ||
108 | { ACTION_SETTINGS_DECREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, | ||
109 | { ACTION_STD_OK, BUTTON_CENTER, BUTTON_NONE }, | ||
110 | { ACTION_STD_CANCEL, BUTTON_MIDLEFT, BUTTON_NONE }, | ||
111 | |||
112 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS) | ||
113 | }; /* button_context_settings */ | ||
114 | |||
115 | static const struct button_mapping button_context_settings_right_is_inc[] = { | ||
116 | { ACTION_STD_PREV, BUTTON_TOPMIDDLE, BUTTON_NONE }, | ||
117 | { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, | ||
118 | { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, | ||
119 | { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, | ||
120 | { ACTION_SETTINGS_INC, BUTTON_MIDRIGHT, BUTTON_NONE }, | ||
121 | { ACTION_SETTINGS_INCREPEAT, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_NONE }, | ||
122 | { ACTION_SETTINGS_DEC, BUTTON_MIDLEFT, BUTTON_NONE }, | ||
123 | { ACTION_SETTINGS_DECREPEAT, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, | ||
124 | { ACTION_STD_OK, BUTTON_CENTER, BUTTON_NONE }, | ||
125 | { ACTION_STD_CANCEL, BUTTON_TOPLEFT, BUTTON_NONE }, | ||
126 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_SETTINGS) | ||
127 | }; /* button_context_settingsgraphical */ | ||
128 | |||
129 | static const struct button_mapping button_context_yesno[] = { | ||
130 | { ACTION_YESNO_ACCEPT, BUTTON_MIDLEFT, BUTTON_NONE }, | ||
131 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_YESNOSCREEN) | ||
132 | }; /* button_context_settings_yesno */ | ||
133 | |||
134 | static const struct button_mapping button_context_colorchooser[] = { | ||
135 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_COLOURCHOOSER), | ||
136 | }; /* button_context_colorchooser */ | ||
137 | |||
138 | static const struct button_mapping button_context_eq[] = { | ||
139 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_EQ), | ||
140 | }; /* button_context_eq */ | ||
141 | |||
142 | /* Bookmark Screen */ | ||
143 | static const struct button_mapping button_context_bmark[] = { | ||
144 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_BOOKMARKSCREEN), | ||
145 | }; /* button_context_bmark */ | ||
146 | |||
147 | static const struct button_mapping button_context_time[] = { | ||
148 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_TIME), | ||
149 | }; /* button_context_time */ | ||
150 | |||
151 | static const struct button_mapping button_context_quickscreen[] = { | ||
152 | |||
153 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_QUICKSCREEN) | ||
154 | }; /* button_context_quickscreen */ | ||
155 | |||
156 | static const struct button_mapping button_context_pitchscreen[] = { | ||
157 | |||
158 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_PITCHSCREEN) | ||
159 | }; /* button_context_pitchcreen */ | ||
160 | |||
161 | static const struct button_mapping button_context_keyboard[] = { | ||
162 | |||
163 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_KEYBOARD) | ||
164 | }; /* button_context_keyboard */ | ||
165 | |||
166 | const struct button_mapping* get_context_mapping(int context) | ||
167 | { | ||
168 | if ((context&CONTEXT_REMOTE) || (context&CONTEXT_CUSTOM2)) | ||
169 | return target_get_context_mapping(context&(~CONTEXT_CUSTOM2)); | ||
170 | |||
171 | switch (context) | ||
172 | { | ||
173 | case CONTEXT_STD: | ||
174 | return button_context_standard; | ||
175 | case CONTEXT_WPS: | ||
176 | return button_context_wps; | ||
177 | |||
178 | case CONTEXT_LIST: | ||
179 | return button_context_list; | ||
180 | case CONTEXT_MAINMENU: | ||
181 | case CONTEXT_TREE: | ||
182 | if (global_settings.hold_lr_for_scroll_in_list) | ||
183 | return button_context_listtree_scroll_without_combo; | ||
184 | else | ||
185 | return button_context_listtree_scroll_with_combo; | ||
186 | case CONTEXT_CUSTOM|CONTEXT_TREE: | ||
187 | return button_context_tree; | ||
188 | |||
189 | case CONTEXT_SETTINGS: | ||
190 | return button_context_settings; | ||
191 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: | ||
192 | return button_context_settings_right_is_inc; | ||
193 | |||
194 | case CONTEXT_SETTINGS_COLOURCHOOSER: | ||
195 | return button_context_colorchooser; | ||
196 | case CONTEXT_SETTINGS_EQ: | ||
197 | return button_context_eq; | ||
198 | |||
199 | case CONTEXT_SETTINGS_TIME: | ||
200 | return button_context_time; | ||
201 | |||
202 | case CONTEXT_YESNOSCREEN: | ||
203 | return button_context_yesno; | ||
204 | case CONTEXT_BOOKMARKSCREEN: | ||
205 | return button_context_bmark; | ||
206 | case CONTEXT_QUICKSCREEN: | ||
207 | return button_context_quickscreen; | ||
208 | case CONTEXT_PITCHSCREEN: | ||
209 | return button_context_pitchscreen; | ||
210 | case CONTEXT_KEYBOARD: | ||
211 | return button_context_keyboard; | ||
212 | } | ||
213 | return button_context_standard; | ||
214 | } | ||