summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAlexander Levin <al.le@rockbox.org>2010-04-10 19:43:47 +0000
committerAlexander Levin <al.le@rockbox.org>2010-04-10 19:43:47 +0000
commit31959e78d02894bd357a4db3a2092275dc791f19 (patch)
tree453db6c1cdf743d7b505da6fd8a49c38b2e592a9 /apps
parente3379ed812f72aea187edc4da2c9922c2493f152 (diff)
downloadrockbox-31959e78d02894bd357a4db3a2092275dc791f19.tar.gz
rockbox-31959e78d02894bd357a4db3a2092275dc791f19.zip
Use better names for hotkey related constants; add somecomments (FS#11191)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25570 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/onplay.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index 61bfe66957..0959cdf514 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1199,22 +1199,12 @@ static bool open_with(void)
1199extern const struct menu_item_ex *selected_menu_item; 1199extern const struct menu_item_ex *selected_menu_item;
1200extern bool hotkey_settable_menu; 1200extern bool hotkey_settable_menu;
1201 1201
1202#define HOT_MASK 0x0FF 1202#define HOTKEY_ACTION_MASK 0x0FF /* Mask to apply to get the action (enum) */
1203#define HOT_WPS 0x100 1203#define HOTKEY_CTX_WPS 0x100 /* Mask to apply to check whether it's for WPS */
1204#define HOT_TREE 0x200 1204#define HOTKEY_CTX_TREE 0x200 /* Mask to apply to check whether it's for the tree */
1205
1206struct hotkey_assignment {
1207 int item;
1208 struct menu_func func;
1209 int return_code;
1210 const struct menu_item_ex *menu_addr;
1211 int lang_id;
1212};
1213
1214#define HOTKEY_FUNC(func, param) {{(void *)func}, param}
1215 1205
1216/* Any desired hotkey functions go here... */ 1206/* Any desired hotkey functions go here... */
1217enum hotkey_settings { 1207enum hotkey_action {
1218 HOTKEY_OFF = 0, 1208 HOTKEY_OFF = 0,
1219 HOTKEY_VIEW_PLAYLIST = 1, 1209 HOTKEY_VIEW_PLAYLIST = 1,
1220 HOTKEY_SHOW_TRACK_INFO, 1210 HOTKEY_SHOW_TRACK_INFO,
@@ -1224,35 +1214,45 @@ enum hotkey_settings {
1224 HOTKEY_INSERT, 1214 HOTKEY_INSERT,
1225}; 1215};
1226 1216
1217struct hotkey_assignment {
1218 int item; /* Bit or'd hotkey_action and HOTKEY_CTX_x */
1219 struct menu_func func; /* Function to run if this entry is selcted */
1220 int return_code; /* What to return afer the function is run */
1221 const struct menu_item_ex *menu_addr;
1222 int lang_id; /* How to present the item to the user */
1223};
1224
1225#define HOTKEY_FUNC(func, param) {{(void *)func}, param}
1226
1227/* ... and here. Order is not important. */ 1227/* ... and here. Order is not important. */
1228static struct hotkey_assignment hotkey_items[] = { 1228static struct hotkey_assignment hotkey_items[] = {
1229 { HOTKEY_VIEW_PLAYLIST | HOT_WPS, 1229 { HOTKEY_VIEW_PLAYLIST | HOTKEY_CTX_WPS,
1230 HOTKEY_FUNC(NULL, NULL), 1230 HOTKEY_FUNC(NULL, NULL),
1231 ONPLAY_PLAYLIST, &view_cur_playlist, 1231 ONPLAY_PLAYLIST, &view_cur_playlist,
1232 LANG_VIEW_DYNAMIC_PLAYLIST }, 1232 LANG_VIEW_DYNAMIC_PLAYLIST },
1233 { HOTKEY_SHOW_TRACK_INFO| HOT_WPS, 1233 { HOTKEY_SHOW_TRACK_INFO| HOTKEY_CTX_WPS,
1234 HOTKEY_FUNC(browse_id3, NULL), 1234 HOTKEY_FUNC(browse_id3, NULL),
1235 ONPLAY_RELOAD_DIR, &browse_id3_item, 1235 ONPLAY_RELOAD_DIR, &browse_id3_item,
1236 LANG_MENU_SHOW_ID3_INFO }, 1236 LANG_MENU_SHOW_ID3_INFO },
1237#ifdef HAVE_PITCHSCREEN 1237#ifdef HAVE_PITCHSCREEN
1238 { HOTKEY_PITCHSCREEN | HOT_WPS, 1238 { HOTKEY_PITCHSCREEN | HOTKEY_CTX_WPS,
1239 HOTKEY_FUNC(gui_syncpitchscreen_run, NULL), 1239 HOTKEY_FUNC(gui_syncpitchscreen_run, NULL),
1240 ONPLAY_RELOAD_DIR, &pitch_screen_item, 1240 ONPLAY_RELOAD_DIR, &pitch_screen_item,
1241 LANG_PITCH }, 1241 LANG_PITCH },
1242#endif 1242#endif
1243 { HOTKEY_OPEN_WITH | HOT_WPS | HOT_TREE, 1243 { HOTKEY_OPEN_WITH | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE,
1244 HOTKEY_FUNC(open_with, NULL), 1244 HOTKEY_FUNC(open_with, NULL),
1245 ONPLAY_RELOAD_DIR, &list_viewers_item, 1245 ONPLAY_RELOAD_DIR, &list_viewers_item,
1246 LANG_ONPLAY_OPEN_WITH }, 1246 LANG_ONPLAY_OPEN_WITH },
1247 { HOTKEY_DELETE | HOT_WPS | HOT_TREE, 1247 { HOTKEY_DELETE | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE,
1248 HOTKEY_FUNC(delete_item, NULL), 1248 HOTKEY_FUNC(delete_item, NULL),
1249 ONPLAY_RELOAD_DIR, &delete_file_item, 1249 ONPLAY_RELOAD_DIR, &delete_file_item,
1250 LANG_DELETE }, 1250 LANG_DELETE },
1251 { HOTKEY_DELETE | HOT_TREE, 1251 { HOTKEY_DELETE | HOTKEY_CTX_TREE,
1252 HOTKEY_FUNC(delete_item, NULL), 1252 HOTKEY_FUNC(delete_item, NULL),
1253 ONPLAY_RELOAD_DIR, &delete_dir_item, 1253 ONPLAY_RELOAD_DIR, &delete_dir_item,
1254 LANG_DELETE }, 1254 LANG_DELETE },
1255 { HOTKEY_INSERT | HOT_TREE, 1255 { HOTKEY_INSERT | HOTKEY_CTX_TREE,
1256 HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT), 1256 HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT),
1257 ONPLAY_START_PLAY, &i_pl_item, 1257 ONPLAY_START_PLAY, &i_pl_item,
1258 LANG_INSERT }, 1258 LANG_INSERT },
@@ -1266,7 +1266,7 @@ int get_hotkey_desc_id(int hk_func)
1266 int i; 1266 int i;
1267 for (i = 0; i < num_hotkey_items; i++) 1267 for (i = 0; i < num_hotkey_items; i++)
1268 { 1268 {
1269 if ((hotkey_items[i].item & HOT_MASK) == hk_func) 1269 if ((hotkey_items[i].item & HOTKEY_ACTION_MASK) == hk_func)
1270 return hotkey_items[i].lang_id; 1270 return hotkey_items[i].lang_id;
1271 } 1271 }
1272 1272
@@ -1278,7 +1278,7 @@ static int execute_hotkey(bool is_wps)
1278{ 1278{
1279 int i; 1279 int i;
1280 struct hotkey_assignment *this_item; 1280 struct hotkey_assignment *this_item;
1281 const int context = is_wps ? HOT_WPS : HOT_TREE; 1281 const int context = is_wps ? HOTKEY_CTX_WPS : HOTKEY_CTX_TREE;
1282 const int this_hotkey = (is_wps ? global_settings.hotkey_wps : 1282 const int this_hotkey = (is_wps ? global_settings.hotkey_wps :
1283 global_settings.hotkey_tree); 1283 global_settings.hotkey_tree);
1284 1284
@@ -1286,8 +1286,8 @@ static int execute_hotkey(bool is_wps)
1286 for (i = 0; i < num_hotkey_items; i++) 1286 for (i = 0; i < num_hotkey_items; i++)
1287 { 1287 {
1288 this_item = &hotkey_items[i]; 1288 this_item = &hotkey_items[i];
1289 if ((this_item->item & context) && 1289 if ((this_item->item & context) &&
1290 ((this_item->item & HOT_MASK) == this_hotkey)) 1290 ((this_item->item & HOTKEY_ACTION_MASK) == this_hotkey))
1291 { 1291 {
1292 /* run the associated function (with optional param), if any */ 1292 /* run the associated function (with optional param), if any */
1293 const struct menu_func func = this_item->func; 1293 const struct menu_func func = this_item->func;
@@ -1313,7 +1313,7 @@ static void set_hotkey(bool is_wps)
1313{ 1313{
1314 int i; 1314 int i;
1315 struct hotkey_assignment *this_item; 1315 struct hotkey_assignment *this_item;
1316 const int context = is_wps ? HOT_WPS : HOT_TREE; 1316 const int context = is_wps ? HOTKEY_CTX_WPS : HOTKEY_CTX_TREE;
1317 int *hk_func = is_wps ? &global_settings.hotkey_wps : 1317 int *hk_func = is_wps ? &global_settings.hotkey_wps :
1318 &global_settings.hotkey_tree; 1318 &global_settings.hotkey_tree;
1319 int this_hk, 1319 int this_hk,
@@ -1324,10 +1324,10 @@ static void set_hotkey(bool is_wps)
1324 for (i = 0; i < num_hotkey_items; i++) 1324 for (i = 0; i < num_hotkey_items; i++)
1325 { 1325 {
1326 this_item = &hotkey_items[i]; 1326 this_item = &hotkey_items[i];
1327 if ((this_item->item & context) && 1327 if ((this_item->item & context) &&
1328 (this_item->menu_addr == selected_menu_item)) 1328 (this_item->menu_addr == selected_menu_item))
1329 { 1329 {
1330 this_hk = this_item->item & HOT_MASK; 1330 this_hk = this_item->item & HOTKEY_ACTION_MASK;
1331 this_id = P2ID((selected_menu_item->callback_and_desc)->desc); 1331 this_id = P2ID((selected_menu_item->callback_and_desc)->desc);
1332 match_found = true; 1332 match_found = true;
1333 break; 1333 break;