comparison highlight.c @ 197:a20a5976a207 src

last_cmd_nav_lbn has to be initialized with an invalid value, so that the first test to filter double commands will always fail, but 0 is not invalid here! * use SRI_END_OF_CELL and reenable double command filter * fix return values of get_current_button() * use return value of button_auto_action()
author mroi
date Mon, 12 May 2003 19:43:11 +0000
parents b751f0790ac6
children ba43bdbb07e8
comparison
equal deleted inserted replaced
196:b751f0790ac6 197:a20a5976a207
221 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { 221 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) {
222 int32_t button = 0; 222 int32_t button = 0;
223 223
224 if(!this || !pci) { 224 if(!this || !pci) {
225 printerr("Passed a NULL pointer."); 225 printerr("Passed a NULL pointer.");
226 return DVDNAV_STATUS_ERR; 226 return NULL;
227 } 227 }
228 if(!pci->hli.hl_gi.hli_ss) { 228 if(!pci->hli.hl_gi.hli_ss) {
229 printerr("Not in a menu."); 229 printerr("Not in a menu.");
230 return DVDNAV_STATUS_ERR; 230 return NULL;
231 } 231 }
232 #if 0 /* This causes some DVDs to fail to activate buttons. */
233 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { 232 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
234 printerr("This NAV has already been left."); 233 printerr("This NAV has already been left.");
235 return DVDNAV_STATUS_ERR; 234 return NULL;
236 } 235 }
237 #endif
238 236
239 button = this->vm->state.HL_BTNN_REG >> 10; 237 button = this->vm->state.HL_BTNN_REG >> 10;
240 #ifdef BUTTON_TESTING 238 #ifdef BUTTON_TESTING
241 nav_print_PCI(pci); 239 nav_print_PCI(pci);
242 #endif 240 #endif
245 } 243 }
246 244
247 static dvdnav_status_t button_auto_action(dvdnav_t *this, pci_t *pci) { 245 static dvdnav_status_t button_auto_action(dvdnav_t *this, pci_t *pci) {
248 if (get_current_button(this, pci)->auto_action_mode) 246 if (get_current_button(this, pci)->auto_action_mode)
249 return dvdnav_button_activate(this, pci); 247 return dvdnav_button_activate(this, pci);
248 return DVDNAV_STATUS_OK;
250 } 249 }
251 250
252 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) { 251 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) {
253 btni_t *button_ptr; 252 btni_t *button_ptr;
254 253
255 if(!(button_ptr = get_current_button(this, pci))) 254 if(!(button_ptr = get_current_button(this, pci)))
256 return DVDNAV_STATUS_ERR; 255 return DVDNAV_STATUS_ERR;
257 256
258 dvdnav_button_select(this, pci, button_ptr->up); 257 dvdnav_button_select(this, pci, button_ptr->up);
259 button_auto_action(this, pci); 258 return button_auto_action(this, pci);
260
261 return DVDNAV_STATUS_OK;
262 } 259 }
263 260
264 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) { 261 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) {
265 btni_t *button_ptr; 262 btni_t *button_ptr;
266 263
267 if(!(button_ptr = get_current_button(this, pci))) 264 if(!(button_ptr = get_current_button(this, pci)))
268 return DVDNAV_STATUS_ERR; 265 return DVDNAV_STATUS_ERR;
269 266
270 dvdnav_button_select(this, pci, button_ptr->down); 267 dvdnav_button_select(this, pci, button_ptr->down);
271 button_auto_action(this, pci); 268 return button_auto_action(this, pci);
272
273 return DVDNAV_STATUS_OK;
274 } 269 }
275 270
276 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) { 271 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) {
277 btni_t *button_ptr; 272 btni_t *button_ptr;
278 273
279 if(!(button_ptr = get_current_button(this, pci))) 274 if(!(button_ptr = get_current_button(this, pci)))
280 return DVDNAV_STATUS_ERR; 275 return DVDNAV_STATUS_ERR;
281 276
282 dvdnav_button_select(this, pci, button_ptr->right); 277 dvdnav_button_select(this, pci, button_ptr->right);
283 button_auto_action(this, pci); 278 return button_auto_action(this, pci);
284
285 return DVDNAV_STATUS_OK;
286 } 279 }
287 280
288 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) { 281 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) {
289 btni_t *button_ptr; 282 btni_t *button_ptr;
290 283
291 if(!(button_ptr = get_current_button(this, pci))) 284 if(!(button_ptr = get_current_button(this, pci)))
292 return DVDNAV_STATUS_ERR; 285 return DVDNAV_STATUS_ERR;
293 286
294 dvdnav_button_select(this, pci, button_ptr->left); 287 dvdnav_button_select(this, pci, button_ptr->left);
295 button_auto_action(this, pci); 288 return button_auto_action(this, pci);
296
297 return DVDNAV_STATUS_OK;
298 } 289 }
299 290
300 dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode, 291 dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode,
301 dvdnav_highlight_area_t *highlight) { 292 dvdnav_highlight_area_t *highlight) {
302 btni_t *button_ptr; 293 btni_t *button_ptr;
345 } 336 }
346 if(!pci->hli.hl_gi.hli_ss) { 337 if(!pci->hli.hl_gi.hli_ss) {
347 printerr("Not in a menu."); 338 printerr("Not in a menu.");
348 return DVDNAV_STATUS_ERR; 339 return DVDNAV_STATUS_ERR;
349 } 340 }
350 #if 0 /* This causes some DVDs to fail to activate buttons. */
351 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { 341 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
352 printerr("This NAV has already been left."); 342 printerr("This NAV has already been left.");
353 return DVDNAV_STATUS_ERR; 343 return DVDNAV_STATUS_ERR;
354 } 344 }
355 #endif
356 pthread_mutex_lock(&this->vm_lock); 345 pthread_mutex_lock(&this->vm_lock);
357 346
358 button = this->vm->state.HL_BTNN_REG >> 10; 347 button = this->vm->state.HL_BTNN_REG >> 10;
359 348
360 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { 349 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) {
434 } 423 }
435 if(!pci->hli.hl_gi.hli_ss) { 424 if(!pci->hli.hl_gi.hli_ss) {
436 printerr("Not in a menu."); 425 printerr("Not in a menu.");
437 return DVDNAV_STATUS_ERR; 426 return DVDNAV_STATUS_ERR;
438 } 427 }
439 #if 0 /* This causes some DVDs to fail to activate buttons. */
440 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { 428 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
441 printerr("This NAV has already been left."); 429 printerr("This NAV has already been left.");
442 return DVDNAV_STATUS_ERR; 430 return DVDNAV_STATUS_ERR;
443 } 431 }
444 #endif
445 432
446 #ifdef BUTTON_TESTING 433 #ifdef BUTTON_TESTING
447 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); 434 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button);
448 #endif 435 #endif
449 436
477 } 464 }
478 if(!pci->hli.hl_gi.hli_ss) { 465 if(!pci->hli.hl_gi.hli_ss) {
479 printerr("Not in a menu."); 466 printerr("Not in a menu.");
480 return DVDNAV_STATUS_ERR; 467 return DVDNAV_STATUS_ERR;
481 } 468 }
482 #if 0 /* This causes some DVDs to fail to activate buttons. */
483 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { 469 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
484 printerr("This NAV has already been left."); 470 printerr("This NAV has already been left.");
485 return DVDNAV_STATUS_ERR; 471 return DVDNAV_STATUS_ERR;
486 } 472 }
487 #endif
488 473
489 cur_button = this->vm->state.HL_BTNN_REG >> 10; 474 cur_button = this->vm->state.HL_BTNN_REG >> 10;
490 475
491 best = 0; 476 best = 0;
492 dist = 0x08000000; /* >> than (720*720)+(567*567); */ 477 dist = 0x08000000; /* >> than (720*720)+(567*567); */