imx233: add touchscreen driver
[maemo-rb.git] / apps / keymaps / keymap-hm801.c
blobb69656a3f175f1b6d18aaf17f91f5beb942879d6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 Andrew Ryabinin
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 /* Button Code Definitions for HiFiMAN HM-801 reference design target */
24 #include "config.h"
25 #include "action.h"
26 #include "button.h"
27 #include "settings.h"
29 /*
30 * The format of the list is as follows
31 * { Action Code, Button code, Prereq button code }
32 * if there's no need to check the previous button's value, use BUTTON_NONE
33 * Insert LAST_ITEM_IN_LIST at the end of each mapping
35 static const struct button_mapping button_context_standard[] = {
36 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
37 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
38 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
39 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
41 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
42 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
43 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
44 { ACTION_STD_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
45 { ACTION_STD_MENU, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
47 LAST_ITEM_IN_LIST
48 }; /* button_context_standard */
50 static const struct button_mapping button_context_wps[] = {
51 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
52 { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
53 { ACTION_WPS_PLAY, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
54 { ACTION_WPS_STOP, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
56 { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV },
57 { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
58 { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT },
59 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
60 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
61 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
63 { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT},
64 { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
65 { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT },
66 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT},
67 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
68 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
70 { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_POWER|BUTTON_PREV, BUTTON_POWER },
71 { ACTION_WPS_ABSETA_PREVDIR, BUTTON_POWER|BUTTON_NEXT, BUTTON_POWER },
72 { ACTION_WPS_ABRESET, BUTTON_POWER|BUTTON_UP, BUTTON_POWER },
74 { ACTION_WPS_BROWSE, BUTTON_UP|BUTTON_REL, BUTTON_UP },
75 { ACTION_WPS_CONTEXT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP },
76 { ACTION_WPS_MENU, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
77 { ACTION_WPS_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN },
78 { ACTION_WPS_PITCHSCREEN, BUTTON_POWER|BUTTON_LEFT, BUTTON_POWER },
79 { ACTION_WPS_ID3SCREEN, BUTTON_POWER|BUTTON_RIGHT, BUTTON_POWER },
80 { ACTION_WPS_LIST_BOOKMARKS, BUTTON_POWER|BUTTON_SELECT, BUTTON_POWER },
81 { ACTION_WPS_CREATE_BOOKMARK, BUTTON_POWER|BUTTON_DOWN, BUTTON_POWER },
82 { ACTION_WPS_VIEW_PLAYLIST, BUTTON_POWER|BUTTON_PLAY, BUTTON_POWER },
84 LAST_ITEM_IN_LIST
85 }; /* button_context_wps */
87 /** Bookmark Screen **/
88 static const struct button_mapping button_context_bmark[] = {
89 { ACTION_BMS_DELETE, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
91 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
92 }; /* button_context_settings_bmark */
95 /** Keyboard **/
96 static const struct button_mapping button_context_keyboard[] = {
97 { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
98 { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
99 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
100 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
101 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
102 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
103 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
104 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
106 { ACTION_KBD_CURSOR_LEFT, BUTTON_PREV, BUTTON_NONE },
107 { ACTION_KBD_CURSOR_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
108 { ACTION_KBD_CURSOR_RIGHT, BUTTON_NEXT, BUTTON_NONE },
109 { ACTION_KBD_CURSOR_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
111 { ACTION_KBD_BACKSPACE, BUTTON_PLAY, BUTTON_NONE },
113 { ACTION_KBD_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT},
114 { ACTION_KBD_DONE, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT},
115 { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_NONE },
117 LAST_ITEM_IN_LIST
118 }; /* button_context_keyboard */
120 /** Pitchscreen **/
121 static const struct button_mapping button_context_pitchscreen[] = {
122 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
123 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
124 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
125 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
126 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
127 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
128 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
129 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
130 { ACTION_PS_TOGGLE_MODE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
131 { ACTION_PS_RESET, BUTTON_SELECT|BUTTON_REPEAT,BUTTON_SELECT },
132 { ACTION_PS_EXIT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
133 { ACTION_PS_SLOWER, BUTTON_PREV, BUTTON_NONE },
134 { ACTION_PS_FASTER, BUTTON_NEXT, BUTTON_NONE },
136 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
137 }; /* button_context_pitchscreen */
139 /** Quickscreen **/
140 static const struct button_mapping button_context_quickscreen[] = {
141 { ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE },
142 { ACTION_QS_TOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
143 { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE },
144 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
145 { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE },
146 { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
147 { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
148 { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
149 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
151 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
152 }; /* button_context_quickscreen */
154 /** Settings - General Mappings **/
155 static const struct button_mapping button_context_settings[] = {
156 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
157 { ACTION_SETTINGS_RESET, BUTTON_SELECT, BUTTON_NONE },
158 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
159 { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
160 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
161 { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
162 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
163 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
164 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
165 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
167 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
168 }; /* button_context_settings */
170 /** Settings - Using Sliders **/
171 static const struct button_mapping button_context_settings_r_is_inc[] = {
172 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
173 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
174 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
175 { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
177 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
179 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
180 }; /* button_context_settings_r_is_inc */
182 /** Tree **/
183 static const struct button_mapping button_context_tree[] = {
184 { ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
185 { ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
186 { ACTION_TREE_HOTKEY, BUTTON_NEXT, BUTTON_NONE },
188 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
189 }; /* button_context_tree */
191 static const struct button_mapping button_context_tree_scroll_lr[] = {
192 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
193 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
194 { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
195 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
196 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
197 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
199 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
200 }; /* button_context_tree_scroll_lr */
202 /** Yes/No Screen **/
203 static const struct button_mapping button_context_yesnoscreen[] = {
204 { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE },
205 LAST_ITEM_IN_LIST
206 }; /* button_context_settings_yesnoscreen */
208 /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
209 const struct button_mapping* get_context_mapping(int context)
211 switch (context)
213 /* anything that uses button_context_standard */
214 case CONTEXT_LIST:
215 case CONTEXT_STD:
216 default:
217 return button_context_standard;
219 /* contexts with special mapping */
220 case CONTEXT_BOOKMARKSCREEN:
221 return button_context_bmark;
223 case CONTEXT_KEYBOARD:
224 case CONTEXT_MORSE_INPUT:
225 return button_context_keyboard;
227 case CONTEXT_PITCHSCREEN:
228 return button_context_pitchscreen;
230 case CONTEXT_QUICKSCREEN:
231 return button_context_quickscreen;
233 case CONTEXT_SETTINGS:
234 case CONTEXT_SETTINGS_TIME:
235 return button_context_settings;
237 case CONTEXT_SETTINGS_COLOURCHOOSER:
238 case CONTEXT_SETTINGS_EQ:
239 case CONTEXT_SETTINGS_RECTRIGGER:
240 return button_context_settings_r_is_inc;
242 case CONTEXT_TREE:
243 case CONTEXT_MAINMENU:
244 if (global_settings.hold_lr_for_scroll_in_list)
245 return button_context_tree_scroll_lr;
246 /* else fall through to CONTEXT_TREE|CONTEXT_CUSTOM */
247 case CONTEXT_TREE|CONTEXT_CUSTOM:
248 return button_context_tree;
250 case CONTEXT_WPS:
251 return button_context_wps;
253 case CONTEXT_YESNOSCREEN:
254 return button_context_yesnoscreen;