| 153 | } |
| 154 | |
| 155 | void contextMenuCtrl() { |
| 156 | if (!cur_ctx) |
| 157 | return; |
| 158 | |
| 159 | if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) { |
| 160 | if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { |
| 161 | int i; |
| 162 | for (i = cur_ctx->n_entries - 1; i >= 0; i--) { |
| 163 | if (cur_ctx->entries[i].visibility == CTX_VISIBLE) { |
| 164 | if (i < cur_ctx->sel) { |
| 165 | cur_ctx->sel = i; |
| 166 | break; |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) { |
| 172 | if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { |
| 173 | int i; |
| 174 | for (i = 0; i < cur_ctx->n_entries; i++) { |
| 175 | if (cur_ctx->entries[i].visibility == CTX_VISIBLE) { |
| 176 | if (i > cur_ctx->sel) { |
| 177 | if (!(cur_ctx->entries[i].flags & CTX_FLAG_BARRIER) || (hold_count[PAD_DOWN] <= 1 && hold2_count[PAD_LEFT_ANALOG_DOWN] <= 1)) |
| 178 | cur_ctx->sel = i; |
| 179 | break; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // Close |
| 187 | if (pressed_pad[PAD_TRIANGLE]) { |
| 188 | ctx_menu_mode = CONTEXT_MENU_CLOSING; |
| 189 | } |
| 190 | |
| 191 | // Back |
| 192 | if (pressed_pad[PAD_CANCEL] || pressed_pad[PAD_LEFT]) { |
| 193 | if (ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { |
| 194 | ctx_menu_mode = CONTEXT_MENU_MORE_CLOSING; |
| 195 | } else { |
| 196 | ctx_menu_mode = CONTEXT_MENU_CLOSING; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // Handle |
| 201 | if (pressed_pad[PAD_ENTER] || pressed_pad[PAD_RIGHT]) { |
| 202 | if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { |
| 203 | if (cur_ctx->callback) |
| 204 | ctx_menu_mode = cur_ctx->callback(cur_ctx->sel, cur_ctx->context); |
| 205 | } |
| 206 | } |
| 207 | } |
no outgoing calls
no test coverage detected