diff options
-rw-r--r-- | apps/onplay.c | 57 | ||||
-rw-r--r-- | apps/onplay.h | 2 |
2 files changed, 25 insertions, 34 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index c9ec565a0c..fc236fc854 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -1195,15 +1195,11 @@ static bool open_with(void) | |||
1195 | return list_viewers(); | 1195 | return list_viewers(); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | #define HOTKEY_ACTION_MASK 0x0FF /* Mask to apply to get the action (enum) */ | ||
1199 | #define HOTKEY_CTX_WPS 0x100 /* Mask to apply to check whether it's for WPS */ | ||
1200 | #define HOTKEY_CTX_TREE 0x200 /* Mask to apply to check whether it's for the tree */ | ||
1201 | |||
1202 | struct hotkey_assignment { | 1198 | struct hotkey_assignment { |
1203 | int item; /* Bit or'd hotkey_action and HOTKEY_CTX_x */ | 1199 | int action; /* hotkey_action */ |
1200 | int lang_id; /* Language ID */ | ||
1204 | struct menu_func func; /* Function to run if this entry is selected */ | 1201 | struct menu_func func; /* Function to run if this entry is selected */ |
1205 | int return_code; /* What to return after the function is run */ | 1202 | int return_code; /* What to return after the function is run */ |
1206 | int lang_id; /* Language ID */ | ||
1207 | }; | 1203 | }; |
1208 | 1204 | ||
1209 | #define HOTKEY_FUNC(func, param) {{(void *)func}, param} | 1205 | #define HOTKEY_FUNC(func, param) {{(void *)func}, param} |
@@ -1212,61 +1208,56 @@ struct hotkey_assignment { | |||
1212 | and in the settings menu in settings_list.c. The order here | 1208 | and in the settings menu in settings_list.c. The order here |
1213 | is not important. */ | 1209 | is not important. */ |
1214 | static struct hotkey_assignment hotkey_items[] = { | 1210 | static struct hotkey_assignment hotkey_items[] = { |
1215 | { HOTKEY_VIEW_PLAYLIST | HOTKEY_CTX_WPS, | 1211 | { HOTKEY_VIEW_PLAYLIST, LANG_VIEW_DYNAMIC_PLAYLIST, |
1216 | HOTKEY_FUNC(NULL, NULL), | 1212 | HOTKEY_FUNC(NULL, NULL), |
1217 | ONPLAY_PLAYLIST, LANG_VIEW_DYNAMIC_PLAYLIST }, | 1213 | ONPLAY_PLAYLIST }, |
1218 | { HOTKEY_SHOW_TRACK_INFO| HOTKEY_CTX_WPS, | 1214 | { HOTKEY_SHOW_TRACK_INFO, LANG_MENU_SHOW_ID3_INFO, |
1219 | HOTKEY_FUNC(browse_id3, NULL), | 1215 | HOTKEY_FUNC(browse_id3, NULL), |
1220 | ONPLAY_RELOAD_DIR, LANG_MENU_SHOW_ID3_INFO }, | 1216 | ONPLAY_RELOAD_DIR }, |
1221 | #ifdef HAVE_PITCHSCREEN | 1217 | #ifdef HAVE_PITCHSCREEN |
1222 | { HOTKEY_PITCHSCREEN | HOTKEY_CTX_WPS, | 1218 | { HOTKEY_PITCHSCREEN, LANG_PITCH, |
1223 | HOTKEY_FUNC(gui_syncpitchscreen_run, NULL), | 1219 | HOTKEY_FUNC(gui_syncpitchscreen_run, NULL), |
1224 | ONPLAY_RELOAD_DIR, LANG_PITCH }, | 1220 | ONPLAY_RELOAD_DIR }, |
1225 | #endif | 1221 | #endif |
1226 | { HOTKEY_OPEN_WITH | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE, | 1222 | { HOTKEY_OPEN_WITH, LANG_ONPLAY_OPEN_WITH, |
1227 | HOTKEY_FUNC(open_with, NULL), | 1223 | HOTKEY_FUNC(open_with, NULL), |
1228 | ONPLAY_RELOAD_DIR, LANG_ONPLAY_OPEN_WITH }, | 1224 | ONPLAY_RELOAD_DIR }, |
1229 | { HOTKEY_DELETE | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE, | 1225 | { HOTKEY_DELETE, LANG_DELETE, |
1230 | HOTKEY_FUNC(delete_item, NULL), | 1226 | HOTKEY_FUNC(delete_item, NULL), |
1231 | ONPLAY_RELOAD_DIR, LANG_DELETE }, | 1227 | ONPLAY_RELOAD_DIR }, |
1232 | { HOTKEY_DELETE | HOTKEY_CTX_TREE, | 1228 | { HOTKEY_INSERT, LANG_INSERT, |
1233 | HOTKEY_FUNC(delete_item, NULL), | ||
1234 | ONPLAY_RELOAD_DIR, LANG_DELETE }, | ||
1235 | { HOTKEY_INSERT | HOTKEY_CTX_TREE, | ||
1236 | HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT), | 1229 | HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT), |
1237 | ONPLAY_START_PLAY, LANG_INSERT }, | 1230 | ONPLAY_START_PLAY }, |
1238 | }; | 1231 | }; |
1239 | 1232 | ||
1240 | static const int num_hotkey_items = sizeof(hotkey_items) / sizeof(hotkey_items[0]); | 1233 | static const int num_hotkey_items = sizeof(hotkey_items) / sizeof(hotkey_items[0]); |
1241 | 1234 | ||
1242 | /* Return the language ID for the input function */ | 1235 | /* Return the language ID for this action */ |
1243 | int get_hotkey_lang_id(int hk_func) | 1236 | int get_hotkey_lang_id(int action) |
1244 | { | 1237 | { |
1245 | int i; | 1238 | int i = num_hotkey_items; |
1246 | for (i = 0; i < num_hotkey_items; i++) | 1239 | while (i--) |
1247 | { | 1240 | { |
1248 | if ((hotkey_items[i].item & HOTKEY_ACTION_MASK) == hk_func) | 1241 | if (hotkey_items[i].action == action) |
1249 | return hotkey_items[i].lang_id; | 1242 | return hotkey_items[i].lang_id; |
1250 | } | 1243 | } |
1251 | 1244 | ||
1252 | return LANG_OFF; | 1245 | return LANG_OFF; |
1253 | } | 1246 | } |
1254 | 1247 | ||
1255 | /* Execute the hotkey function, if listed for this screen */ | 1248 | /* Execute the hotkey function, if listed */ |
1256 | static int execute_hotkey(bool is_wps) | 1249 | static int execute_hotkey(bool is_wps) |
1257 | { | 1250 | { |
1258 | int i; | 1251 | int i = num_hotkey_items; |
1259 | struct hotkey_assignment *this_item; | 1252 | struct hotkey_assignment *this_item; |
1260 | const int context = is_wps ? HOTKEY_CTX_WPS : HOTKEY_CTX_TREE; | 1253 | const int action = (is_wps ? global_settings.hotkey_wps : |
1261 | const int this_hotkey = (is_wps ? global_settings.hotkey_wps : | ||
1262 | global_settings.hotkey_tree); | 1254 | global_settings.hotkey_tree); |
1263 | 1255 | ||
1264 | /* search assignment struct for a match for the hotkey setting */ | 1256 | /* search assignment struct for a match for the hotkey setting */ |
1265 | for (i = 0; i < num_hotkey_items; i++) | 1257 | while (i--) |
1266 | { | 1258 | { |
1267 | this_item = &hotkey_items[i]; | 1259 | this_item = &hotkey_items[i]; |
1268 | if ((this_item->item & context) && | 1260 | if (this_item->action == action) |
1269 | ((this_item->item & HOTKEY_ACTION_MASK) == this_hotkey)) | ||
1270 | { | 1261 | { |
1271 | /* run the associated function (with optional param), if any */ | 1262 | /* run the associated function (with optional param), if any */ |
1272 | const struct menu_func func = this_item->func; | 1263 | const struct menu_func func = this_item->func; |
diff --git a/apps/onplay.h b/apps/onplay.h index 161366ecc2..a489b09cce 100644 --- a/apps/onplay.h +++ b/apps/onplay.h | |||
@@ -32,7 +32,7 @@ enum { | |||
32 | }; | 32 | }; |
33 | 33 | ||
34 | #ifdef HAVE_HOTKEY | 34 | #ifdef HAVE_HOTKEY |
35 | int get_hotkey_lang_id(int hk_func); | 35 | int get_hotkey_lang_id(int action); |
36 | 36 | ||
37 | enum hotkey_action { | 37 | enum hotkey_action { |
38 | HOTKEY_OFF = 0, | 38 | HOTKEY_OFF = 0, |