comparison highlight.c @ 191:dbea22936623 src

when a command has been issued to leave a menu, filter all further commands for this menu
author mroi
date Tue, 06 May 2003 14:11:44 +0000
parents 90b1f6f0520e
children b80dff4bef76
comparison
equal deleted inserted replaced
190:c575bd95911d 191:dbea22936623
205 205
206 /* Highlighting API calls */ 206 /* Highlighting API calls */
207 207
208 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int *button) { 208 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int *button) {
209 209
210 if(!this) { 210 if(!this || !button) {
211 printerr("Passed a NULL pointer."); 211 printerr("Passed a NULL pointer.");
212 return S_ERR; 212 return S_ERR;
213 } 213 }
214 214
215 /* Simply return the appropriate value based on the SPRM */ 215 /* Simply return the appropriate value based on the SPRM */
219 } 219 }
220 220
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 int button = 0; 222 int button = 0;
223 223
224 if(!this) { 224 if(!this || !pci) {
225 printerr("Passed a NULL pointer."); 225 printerr("Passed a NULL pointer.");
226 return S_ERR; 226 return S_ERR;
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 S_ERR;
231 }
232 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
233 printerr("This NAV has already been left.");
230 return S_ERR; 234 return S_ERR;
231 } 235 }
232 236
233 button = this->vm->state.HL_BTNN_REG >> 10; 237 button = this->vm->state.HL_BTNN_REG >> 10;
234 #ifdef BUTTON_TESTING 238 #ifdef BUTTON_TESTING
244 } 248 }
245 249
246 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) { 250 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) {
247 btni_t *button_ptr; 251 btni_t *button_ptr;
248 252
249 if(!this) {
250 printerr("Passed a NULL pointer.");
251 return S_ERR;
252 }
253
254 if(!(button_ptr = get_current_button(this, pci))) 253 if(!(button_ptr = get_current_button(this, pci)))
255 return S_ERR; 254 return S_ERR;
256 255
257 dvdnav_button_select(this, pci, button_ptr->up); 256 dvdnav_button_select(this, pci, button_ptr->up);
258 button_auto_action(this, pci); 257 button_auto_action(this, pci);
261 } 260 }
262 261
263 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) { 262 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) {
264 btni_t *button_ptr; 263 btni_t *button_ptr;
265 264
266 if(!this) {
267 printerr("Passed a NULL pointer.");
268 return S_ERR;
269 }
270
271 if(!(button_ptr = get_current_button(this, pci))) 265 if(!(button_ptr = get_current_button(this, pci)))
272 return S_ERR; 266 return S_ERR;
273 267
274 dvdnav_button_select(this, pci, button_ptr->down); 268 dvdnav_button_select(this, pci, button_ptr->down);
275 button_auto_action(this, pci); 269 button_auto_action(this, pci);
278 } 272 }
279 273
280 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) { 274 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) {
281 btni_t *button_ptr; 275 btni_t *button_ptr;
282 276
283 if(!this) {
284 printerr("Passed a NULL pointer.");
285 return S_ERR;
286 }
287
288 if(!(button_ptr = get_current_button(this, pci))) 277 if(!(button_ptr = get_current_button(this, pci)))
289 return S_ERR; 278 return S_ERR;
290 279
291 dvdnav_button_select(this, pci, button_ptr->right); 280 dvdnav_button_select(this, pci, button_ptr->right);
292 button_auto_action(this, pci); 281 button_auto_action(this, pci);
295 } 284 }
296 285
297 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) { 286 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) {
298 btni_t *button_ptr; 287 btni_t *button_ptr;
299 288
300 if(!this) {
301 printerr("Passed a NULL pointer.");
302 return S_ERR;
303 }
304
305 if(!(button_ptr = get_current_button(this, pci))) 289 if(!(button_ptr = get_current_button(this, pci)))
306 return S_ERR; 290 return S_ERR;
307 291
308 dvdnav_button_select(this, pci, button_ptr->left); 292 dvdnav_button_select(this, pci, button_ptr->left);
309 button_auto_action(this, pci); 293 button_auto_action(this, pci);
351 335
352 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { 336 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) {
353 int button; 337 int button;
354 btni_t *button_ptr = NULL; 338 btni_t *button_ptr = NULL;
355 339
356 if(!this) { 340 if(!this || !pci) {
357 printerr("Passed a NULL pointer."); 341 printerr("Passed a NULL pointer.");
358 return S_ERR; 342 return S_ERR;
359 } 343 }
360 if(!pci->hli.hl_gi.hli_ss) { 344 if(!pci->hli.hl_gi.hli_ss) {
361 printerr("Not in a menu."); 345 printerr("Not in a menu.");
346 return S_ERR;
347 }
348 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
349 printerr("This NAV has already been left.");
362 return S_ERR; 350 return S_ERR;
363 } 351 }
364 352
365 pthread_mutex_lock(&this->vm_lock); 353 pthread_mutex_lock(&this->vm_lock);
366 354
379 if (this->position_current.still != 0) { 367 if (this->position_current.still != 0) {
380 /* In still, but no buttons. */ 368 /* In still, but no buttons. */
381 vm_get_next_cell(this->vm); 369 vm_get_next_cell(this->vm);
382 this->position_current.still = 0; 370 this->position_current.still = 0;
383 this->sync_wait = 0; 371 this->sync_wait = 0;
372 this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn;
384 pthread_mutex_unlock(&this->vm_lock); 373 pthread_mutex_unlock(&this->vm_lock);
385 /* clear error message */ 374 /* clear error message */
386 printerr(""); 375 printerr("");
387 return S_OK; 376 return S_OK;
388 } 377 }
398 #endif 387 #endif
399 if(vm_exec_cmd(this->vm, &(button_ptr->cmd)) == 1) { 388 if(vm_exec_cmd(this->vm, &(button_ptr->cmd)) == 1) {
400 /* Command caused a jump */ 389 /* Command caused a jump */
401 this->vm->hop_channel++; 390 this->vm->hop_channel++;
402 this->position_current.still = 0; 391 this->position_current.still = 0;
392 this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn;
403 } 393 }
404 394
405 pthread_mutex_unlock(&this->vm_lock); 395 pthread_mutex_unlock(&this->vm_lock);
406 return S_OK; 396 return S_OK;
407 } 397 }
408 398
409 dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd) 399 dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd)
410 { 400 {
411 if(!this) { 401 if(!this || !cmd) {
412 printerr("Passed a NULL pointer."); 402 printerr("Passed a NULL pointer.");
413 return S_ERR; 403 return S_ERR;
414 } 404 }
415 405
416 pthread_mutex_lock(&this->vm_lock); 406 pthread_mutex_lock(&this->vm_lock);
433 return S_OK; 423 return S_OK;
434 } 424 }
435 425
436 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) { 426 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) {
437 427
438 if(!this) { 428 if(!this || !pci) {
439 printerr("Passed a NULL pointer."); 429 printerr("Passed a NULL pointer.");
440 return S_ERR; 430 return S_ERR;
441 } 431 }
442 if(!pci->hli.hl_gi.hli_ss) { 432 if(!pci->hli.hl_gi.hli_ss) {
443 printerr("Not in a menu."); 433 printerr("Not in a menu.");
434 return S_ERR;
435 }
436 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
437 printerr("This NAV has already been left.");
444 return S_ERR; 438 return S_ERR;
445 } 439 }
446 440
447 #ifdef BUTTON_TESTING 441 #ifdef BUTTON_TESTING
448 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); 442 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button);
470 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) { 464 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) {
471 int button, cur_button; 465 int button, cur_button;
472 int best,dist,d; 466 int best,dist,d;
473 int mx,my,dx,dy; 467 int mx,my,dx,dy;
474 468
475 if(!this) { 469 if(!this || !pci) {
476 printerr("Passed a NULL pointer."); 470 printerr("Passed a NULL pointer.");
477 return S_ERR; 471 return S_ERR;
478 } 472 }
479 if(!pci->hli.hl_gi.hli_ss) { 473 if(!pci->hli.hl_gi.hli_ss) {
480 printerr("Not in a menu."); 474 printerr("Not in a menu.");
475 return S_ERR;
476 }
477 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
478 printerr("This NAV has already been left.");
481 return S_ERR; 479 return S_ERR;
482 } 480 }
483 481
484 cur_button = this->vm->state.HL_BTNN_REG >> 10; 482 cur_button = this->vm->state.HL_BTNN_REG >> 10;
485 483