Jonathan Gordon | 5b5a626 | 2008-04-15 10:35:11 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Jonathan Gordon | 970cfee | 2008-04-15 11:00:38 +0000 | [diff] [blame] | 8 | * $Id$ |
Jonathan Gordon | 5b5a626 | 2008-04-15 10:35:11 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2006 Jonathan Gordon |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Jonathan Gordon | 5b5a626 | 2008-04-15 10:35:11 +0000 | [diff] [blame] | 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 | /* Button Code Definitions for touchpad targets */ |
| 23 | #include <stdio.h> |
| 24 | #include <string.h> |
| 25 | #include <stdlib.h> |
| 26 | |
| 27 | #include "config.h" |
| 28 | #include "action.h" |
| 29 | #include "button.h" |
| 30 | #include "settings.h" |
| 31 | |
| 32 | const struct button_mapping* target_get_context_mapping(int context); |
| 33 | /* How this file is used: |
| 34 | get_context_mapping() at the bottom of the file is called by action.c as usual. |
| 35 | if the context is for the remote control its then passed straight to |
| 36 | target_get_context_mapping(). |
| 37 | These tables are only used for the touchpad buttons, so at the end of each |
| 38 | CONTEXT_CUSTOM2 is OR'ed with the context and then sent to target_get_context_mapping() |
| 39 | (NOTE: CONTEXT_CUSTOM2 will be stripped before being sent to make it easier.) |
| 40 | In the target keymap, remember to |CONTEXT_CUSTOM2 in the LAST_ITEM_IN_LIST__NEXTLIST() macro |
| 41 | to speed it up a tiny bit... if you dont it will go through these tables first before going |
| 42 | back to the target file. |
| 43 | */ |
| 44 | |
| 45 | |
| 46 | /* touchpad "buttons" |
| 47 | screen is split into a 3x3 grid for buttons... |
| 48 | BUTTON_TOPLEFT BUTTON_TOPMIDDLE BUTTON_TOPRIGHT |
| 49 | BUTTON_MIDLEFT BUTTON_CENTER BUTTON_MIDRIGHT |
| 50 | BUTTON_BOTTOMLEFT BUTTON_BOTTOMMIDDLE BUTTON_BOTTOMRIGHT |
| 51 | */ |
| 52 | |
| 53 | static const struct button_mapping button_context_standard[] = { |
| 54 | { ACTION_STD_PREV, BUTTON_TOPMIDDLE, BUTTON_NONE }, |
| 55 | { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 56 | { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, |
| 57 | { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 58 | |
| 59 | { ACTION_STD_OK, BUTTON_CENTER|BUTTON_REL, BUTTON_CENTER }, |
| 60 | { ACTION_STD_OK, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_MIDRIGHT }, |
| 61 | { ACTION_STD_OK, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_MIDRIGHT }, |
| 62 | |
| 63 | { ACTION_STD_MENU, BUTTON_TOPLEFT, BUTTON_NONE }, |
| 64 | { ACTION_STD_QUICKSCREEN, BUTTON_TOPLEFT|BUTTON_REPEAT, BUTTON_NONE }, |
| 65 | { ACTION_STD_CONTEXT, BUTTON_CENTER|BUTTON_REPEAT, BUTTON_CENTER }, |
| 66 | { ACTION_STD_CANCEL, BUTTON_MIDLEFT, BUTTON_NONE }, |
| 67 | { ACTION_STD_CANCEL, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, |
| 68 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_STD) |
| 69 | }; /* button_context_standard */ |
| 70 | |
| 71 | static const struct button_mapping button_context_wps[] = { |
Rob Purchase | fcb7d61 | 2008-06-22 19:19:48 +0000 | [diff] [blame] | 72 | |
| 73 | { ACTION_WPS_SKIPNEXT, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_MIDRIGHT }, |
| 74 | { ACTION_WPS_SKIPPREV, BUTTON_MIDLEFT|BUTTON_REL, BUTTON_MIDLEFT }, |
| 75 | |
| 76 | { ACTION_WPS_SEEKBACK, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, |
| 77 | { ACTION_WPS_SEEKFWD, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_NONE }, |
| 78 | { ACTION_WPS_STOPSEEK, BUTTON_MIDLEFT|BUTTON_REL, BUTTON_MIDLEFT|BUTTON_REPEAT }, |
| 79 | { ACTION_WPS_STOPSEEK, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_MIDRIGHT|BUTTON_REPEAT }, |
| 80 | |
Rob Purchase | 0494157 | 2008-06-27 12:34:23 +0000 | [diff] [blame] | 81 | { ACTION_WPS_CONTEXT, BUTTON_CENTER|BUTTON_REPEAT, BUTTON_CENTER }, |
| 82 | { ACTION_WPS_QUICKSCREEN, BUTTON_TOPRIGHT|BUTTON_REPEAT, BUTTON_TOPRIGHT }, |
Jonathan Gordon | 5b5a626 | 2008-04-15 10:35:11 +0000 | [diff] [blame] | 83 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_WPS) |
| 84 | }; /* button_context_wps */ |
| 85 | |
| 86 | static const struct button_mapping button_context_list[] = { |
| 87 | #if 0 |
| 88 | /* this is all to show how the poor-mans-gestures can be used... */ |
| 89 | { ACTION_LISTTREE_PGUP, BUTTON_TOPRIGHT, BUTTON_NONE}, |
| 90 | { ACTION_LISTTREE_PGUP, BUTTON_TOPRIGHT|BUTTON_REPEAT, BUTTON_TOPRIGHT}, |
| 91 | { ACTION_STD_NEXTREPEAT, BUTTON_CENTER, BUTTON_TOPMIDDLE}, |
| 92 | { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE, BUTTON_CENTER}, |
| 93 | { ACTION_NONE, BUTTON_TOPMIDDLE, BUTTON_NONE }, |
| 94 | { ACTION_NONE, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, |
| 95 | { ACTION_STD_PREV, BUTTON_TOPMIDDLE|BUTTON_REL, BUTTON_NONE }, |
| 96 | { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE|BUTTON_REL, BUTTON_NONE }, |
| 97 | { ACTION_LISTTREE_PGDOWN, BUTTON_BOTTOMRIGHT, BUTTON_NONE}, |
| 98 | { ACTION_LISTTREE_PGDOWN, BUTTON_BOTTOMRIGHT|BUTTON_REPEAT, BUTTON_BOTTOMRIGHT}, |
| 99 | { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE, BUTTON_CENTER}, |
| 100 | { ACTION_STD_PREVREPEAT, BUTTON_CENTER, BUTTON_BOTTOMMIDDLE}, |
| 101 | #endif |
| 102 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_LIST) |
| 103 | }; /* button_context_list */ |
| 104 | |
| 105 | static const struct button_mapping button_context_tree[] = { |
| 106 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM2|CONTEXT_TREE) |
| 107 | }; /* button_context_tree */ |
| 108 | |
| 109 | static const struct button_mapping button_context_listtree_scroll_with_combo[] = { |
| 110 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_TREE), |
| 111 | }; |
| 112 | |
| 113 | static const struct button_mapping button_context_listtree_scroll_without_combo[] = { |
| 114 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_TREE), |
| 115 | }; |
| 116 | |
| 117 | static const struct button_mapping button_context_settings[] = { |
| 118 | { ACTION_SETTINGS_INC, BUTTON_TOPMIDDLE, BUTTON_NONE }, |
| 119 | { ACTION_SETTINGS_INCREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 120 | { ACTION_SETTINGS_DEC, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, |
| 121 | { ACTION_SETTINGS_DECREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 122 | { ACTION_STD_OK, BUTTON_CENTER, BUTTON_NONE }, |
| 123 | { ACTION_STD_CANCEL, BUTTON_MIDLEFT, BUTTON_NONE }, |
| 124 | |
| 125 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS) |
| 126 | }; /* button_context_settings */ |
| 127 | |
| 128 | static const struct button_mapping button_context_settings_right_is_inc[] = { |
| 129 | { ACTION_STD_PREV, BUTTON_TOPMIDDLE, BUTTON_NONE }, |
| 130 | { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 131 | { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, |
| 132 | { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 133 | { ACTION_SETTINGS_INC, BUTTON_MIDRIGHT, BUTTON_NONE }, |
| 134 | { ACTION_SETTINGS_INCREPEAT, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_NONE }, |
| 135 | { ACTION_SETTINGS_DEC, BUTTON_MIDLEFT, BUTTON_NONE }, |
| 136 | { ACTION_SETTINGS_DECREPEAT, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, |
| 137 | { ACTION_STD_OK, BUTTON_CENTER, BUTTON_NONE }, |
| 138 | { ACTION_STD_CANCEL, BUTTON_TOPLEFT, BUTTON_NONE }, |
| 139 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_SETTINGS) |
| 140 | }; /* button_context_settingsgraphical */ |
| 141 | |
| 142 | static const struct button_mapping button_context_yesno[] = { |
| 143 | { ACTION_YESNO_ACCEPT, BUTTON_MIDLEFT, BUTTON_NONE }, |
| 144 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_YESNOSCREEN) |
| 145 | }; /* button_context_settings_yesno */ |
| 146 | |
| 147 | static const struct button_mapping button_context_colorchooser[] = { |
| 148 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_COLOURCHOOSER), |
| 149 | }; /* button_context_colorchooser */ |
| 150 | |
| 151 | static const struct button_mapping button_context_eq[] = { |
| 152 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_EQ), |
| 153 | }; /* button_context_eq */ |
| 154 | |
| 155 | /* Bookmark Screen */ |
| 156 | static const struct button_mapping button_context_bmark[] = { |
| 157 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_BOOKMARKSCREEN), |
| 158 | }; /* button_context_bmark */ |
| 159 | |
| 160 | static const struct button_mapping button_context_time[] = { |
| 161 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_TIME), |
| 162 | }; /* button_context_time */ |
| 163 | |
| 164 | static const struct button_mapping button_context_quickscreen[] = { |
| 165 | |
Rob Purchase | 0494157 | 2008-06-27 12:34:23 +0000 | [diff] [blame] | 166 | { ACTION_STD_CANCEL, BUTTON_CENTER|BUTTON_REL, BUTTON_NONE }, |
| 167 | { ACTION_QS_DOWNINV, BUTTON_TOPMIDDLE|BUTTON_REL, BUTTON_NONE }, |
| 168 | { ACTION_QS_DOWNINV, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 169 | { ACTION_QS_DOWN, BUTTON_BOTTOMMIDDLE|BUTTON_REL, BUTTON_NONE }, |
| 170 | { ACTION_QS_DOWN, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 171 | { ACTION_QS_LEFT, BUTTON_MIDLEFT|BUTTON_REL, BUTTON_NONE }, |
| 172 | { ACTION_QS_LEFT, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, |
| 173 | { ACTION_QS_RIGHT, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_NONE }, |
| 174 | { ACTION_QS_RIGHT, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_NONE }, |
Jonathan Gordon | 5b5a626 | 2008-04-15 10:35:11 +0000 | [diff] [blame] | 175 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_QUICKSCREEN) |
| 176 | }; /* button_context_quickscreen */ |
| 177 | |
| 178 | static const struct button_mapping button_context_pitchscreen[] = { |
| 179 | |
Rob Purchase | 0494157 | 2008-06-27 12:34:23 +0000 | [diff] [blame] | 180 | { ACTION_PS_INC_SMALL, BUTTON_TOPMIDDLE, BUTTON_NONE }, |
| 181 | { ACTION_PS_INC_BIG, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 182 | { ACTION_PS_DEC_SMALL, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, |
| 183 | { ACTION_PS_DEC_BIG, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, |
| 184 | { ACTION_PS_NUDGE_LEFT, BUTTON_MIDLEFT, BUTTON_NONE }, |
| 185 | { ACTION_PS_NUDGE_LEFTOFF, BUTTON_MIDLEFT|BUTTON_REL, BUTTON_NONE }, |
| 186 | { ACTION_PS_NUDGE_RIGHT, BUTTON_MIDRIGHT, BUTTON_NONE }, |
| 187 | { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_NONE }, |
| 188 | { ACTION_PS_TOGGLE_MODE, BUTTON_BOTTOMRIGHT, BUTTON_NONE }, |
| 189 | { ACTION_PS_RESET, BUTTON_CENTER, BUTTON_NONE }, |
| 190 | { ACTION_PS_EXIT, BUTTON_TOPLEFT, BUTTON_NONE }, |
Jonathan Gordon | 5b5a626 | 2008-04-15 10:35:11 +0000 | [diff] [blame] | 191 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_PITCHSCREEN) |
| 192 | }; /* button_context_pitchcreen */ |
| 193 | |
| 194 | static const struct button_mapping button_context_keyboard[] = { |
| 195 | |
| 196 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_KEYBOARD) |
| 197 | }; /* button_context_keyboard */ |
| 198 | |
| 199 | const struct button_mapping* get_context_mapping(int context) |
| 200 | { |
| 201 | if ((context&CONTEXT_REMOTE) || (context&CONTEXT_CUSTOM2)) |
| 202 | return target_get_context_mapping(context&(~CONTEXT_CUSTOM2)); |
| 203 | |
| 204 | switch (context) |
| 205 | { |
| 206 | case CONTEXT_STD: |
| 207 | return button_context_standard; |
| 208 | case CONTEXT_WPS: |
| 209 | return button_context_wps; |
| 210 | |
| 211 | case CONTEXT_LIST: |
| 212 | return button_context_list; |
| 213 | case CONTEXT_MAINMENU: |
| 214 | case CONTEXT_TREE: |
| 215 | if (global_settings.hold_lr_for_scroll_in_list) |
| 216 | return button_context_listtree_scroll_without_combo; |
| 217 | else |
| 218 | return button_context_listtree_scroll_with_combo; |
| 219 | case CONTEXT_CUSTOM|CONTEXT_TREE: |
| 220 | return button_context_tree; |
| 221 | |
| 222 | case CONTEXT_SETTINGS: |
| 223 | return button_context_settings; |
| 224 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: |
| 225 | return button_context_settings_right_is_inc; |
| 226 | |
| 227 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
| 228 | return button_context_colorchooser; |
| 229 | case CONTEXT_SETTINGS_EQ: |
| 230 | return button_context_eq; |
| 231 | |
| 232 | case CONTEXT_SETTINGS_TIME: |
| 233 | return button_context_time; |
| 234 | |
| 235 | case CONTEXT_YESNOSCREEN: |
| 236 | return button_context_yesno; |
| 237 | case CONTEXT_BOOKMARKSCREEN: |
| 238 | return button_context_bmark; |
| 239 | case CONTEXT_QUICKSCREEN: |
| 240 | return button_context_quickscreen; |
| 241 | case CONTEXT_PITCHSCREEN: |
| 242 | return button_context_pitchscreen; |
| 243 | case CONTEXT_KEYBOARD: |
| 244 | return button_context_keyboard; |
| 245 | } |
| 246 | return button_context_standard; |
| 247 | } |