changeset 98:457f35f43ba6 src

Improved DVD menu selection. The application using libdvdnav has to supply the nav_pci info. The nav_pci info in libdvdnav is not parsed correctly, and is also not insync with the display.
author jcdutton
date Wed, 18 Sep 2002 04:21:45 +0000
parents c1dff1899bda
children c5e47a98c883
files dvdnav.h highlight.c
diffstat 2 files changed, 47 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.h	Tue Sep 17 11:00:25 2002 +0000
+++ b/dvdnav.h	Wed Sep 18 04:21:45 2002 +0000
@@ -534,31 +534,31 @@
  * 
  * \param self Pointer to dvdnav_t associated with this operation.
  */
-dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *self);
+dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *self, pci_t *pci);
 /**
  * Move button highlight around as suggested by function name (e.g. with arrow keys).
  * 
  * \param self Pointer to dvdnav_t associated with this operation.
  */
-dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *self);
+dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *self, pci_t *pci);
 /**
  * Move button highlight around as suggested by function name (e.g. with arrow keys).
  * 
  * \param self Pointer to dvdnav_t associated with this operation.
  */
-dvdnav_status_t dvdnav_right_button_select(dvdnav_t *self);
+dvdnav_status_t dvdnav_right_button_select(dvdnav_t *self, pci_t *pci);
 /**
  * Move button highlight around as suggested by function name (e.g. with arrow keys).
  * 
  * \param self Pointer to dvdnav_t associated with this operation.
  */
-dvdnav_status_t dvdnav_left_button_select(dvdnav_t *self);
+dvdnav_status_t dvdnav_left_button_select(dvdnav_t *self, pci_t *pci);
 
 /**
  * Activate (press) the currently highlighted button.
  * \param self Pointer to dvdnav_t associated with this operation.
  */
-dvdnav_status_t dvdnav_button_activate(dvdnav_t *self);
+dvdnav_status_t dvdnav_button_activate(dvdnav_t *self, pci_t *pci);
 
 /**
  * Highlight a specific button.
@@ -566,7 +566,7 @@
  * \param self Pointer to dvdnav_t associated with this operation.
  * \param button 1..39 -- Button number to activate.
  */
-dvdnav_status_t dvdnav_button_select(dvdnav_t *self, int button);
+dvdnav_status_t dvdnav_button_select(dvdnav_t *self, pci_t *pci, int button);
 
 /**
  * Activate (press) specified button.
@@ -574,7 +574,7 @@
  * \param self Pointer to dvdnav_t associated with this operation.
  * \param button 1..39 -- Button number to activate.
  */
-dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *self, int button);
+dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *self, pci_t *pci, int button);
 
 /**
  * Activate (press) a button and execute specified command.
@@ -591,7 +591,7 @@
  * \param x X co-ordinate in image.
  * \param y Y xo-ordinate in image.
  */
-dvdnav_status_t dvdnav_mouse_select(dvdnav_t *self, int x, int y);
+dvdnav_status_t dvdnav_mouse_select(dvdnav_t *self, pci_t *pci, int x, int y);
 
 /**
  * Activate (press) button at specified co-ordinates.
@@ -600,7 +600,7 @@
  * \param x X co-ordinate in image.
  * \param y Y xo-ordinate in image.
  */
-dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *self, int x, int y);
+dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *self, pci_t *pci, int x, int y);
 
 /**
  * @}
--- a/highlight.c	Tue Sep 17 11:00:25 2002 +0000
+++ b/highlight.c	Wed Sep 18 04:21:45 2002 +0000
@@ -217,7 +217,7 @@
   return S_OK;
 }
 
-btni_t *__get_current_button(dvdnav_t *this) {
+btni_t *__get_current_button(dvdnav_t *this, pci_t *pci) {
   int button = 0;
 
   if(dvdnav_get_current_highlight(this, &button) != S_OK) {
@@ -228,16 +228,16 @@
   nav_print_PCI(&(this->pci));
 #endif
   
-  return &(this->pci.hli.btnit[button-1]);
+  return &(pci->hli.btnit[button-1]);
 }
 
-dvdnav_status_t dvdnav_button_auto_action(dvdnav_t *this) {
+dvdnav_status_t dvdnav_button_auto_action(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
   if(!this)
    return S_ERR;
 
-  if((button_ptr = __get_current_button(this)) == NULL) {
+  if((button_ptr = __get_current_button(this, pci)) == NULL) {
     return S_ERR;
   }
   if (button_ptr->auto_action_mode == 1) {
@@ -247,74 +247,74 @@
 }
 
 
-dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this) {
+dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
   if(!this)
    return S_ERR;
 
-  if((button_ptr = __get_current_button(this)) == NULL) {
+  if((button_ptr = __get_current_button(this, pci)) == NULL) {
     return S_ERR;
   }
 
-  dvdnav_button_select(this, button_ptr->up);
-  if (dvdnav_button_auto_action(this) ) {
-    dvdnav_button_activate(this);
+  dvdnav_button_select(this, pci, button_ptr->up);
+  if (dvdnav_button_auto_action(this, pci) ) {
+    dvdnav_button_activate(this, pci);
   }
  
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this) {
+dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
   if(!this)
    return S_ERR;
 
-  if((button_ptr = __get_current_button(this)) == NULL) {
+  if((button_ptr = __get_current_button(this, pci)) == NULL) {
     return S_ERR;
   }
 
-  dvdnav_button_select(this, button_ptr->down);
-  if (dvdnav_button_auto_action(this) ) {
-    dvdnav_button_activate(this);
+  dvdnav_button_select(this, pci, button_ptr->down);
+  if (dvdnav_button_auto_action(this, pci) ) {
+    dvdnav_button_activate(this, pci);
   }
   
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this) {
+dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
   if(!this)
    return S_ERR;
 
-  if((button_ptr = __get_current_button(this)) == NULL) {
+  if((button_ptr = __get_current_button(this, pci)) == NULL) {
     printerr("Error fetching information on current button.");
     return S_ERR;
   }
 
-  dvdnav_button_select(this, button_ptr->right);
-  if (dvdnav_button_auto_action(this) ) {
-    dvdnav_button_activate(this);
+  dvdnav_button_select(this, pci, button_ptr->right);
+  if (dvdnav_button_auto_action(this, pci) ) {
+    dvdnav_button_activate(this, pci);
   }
   
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this) {
+dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
   if(!this)
    return S_ERR;
 
-  if((button_ptr = __get_current_button(this)) == NULL) {
+  if((button_ptr = __get_current_button(this, pci)) == NULL) {
     return S_ERR;
   }
 
-  dvdnav_button_select(this, button_ptr->left);
-  if (dvdnav_button_auto_action(this) ) {
-    dvdnav_button_activate(this);
+  dvdnav_button_select(this, pci, button_ptr->left);
+  if (dvdnav_button_auto_action(this, pci) ) {
+    dvdnav_button_activate(this, pci);
   }
   
   return S_OK;
@@ -357,7 +357,7 @@
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_button_activate(dvdnav_t *this) {
+dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) {
   int button;
   btni_t *button_ptr = NULL;
   
@@ -374,7 +374,7 @@
 /* FIXME: dvdnav_button_select should really return a
  * special case for explicit NO-BUTTONS.
  */
-  if(dvdnav_button_select(this, button) != S_OK) {
+  if(dvdnav_button_select(this, pci, button) != S_OK) {
     /* Special code to handle still menus with no buttons.
      * the navigation is expected to report to the appicatino that a STILL is
      * underway. In turn, the application is supposed to report to the user
@@ -395,7 +395,7 @@
     return S_ERR;
   }
   /* FIXME: The button command should really be passed in the API instead. */ 
-  button_ptr = __get_current_button(this);
+  button_ptr = __get_current_button(this, pci);
   /* Finally, make the VM execute the appropriate code and
    * scedule a jump */
 #ifdef BUTTON_TESTING
@@ -435,7 +435,7 @@
   return S_OK;
 }  
 
-dvdnav_status_t dvdnav_button_select(dvdnav_t *this, int button) {
+dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) {
   
   if(!this) {
    printerrf("Unable to select button number %i as this state bad",
@@ -449,7 +449,7 @@
   
   /* Set the highlight SPRM if the passed button was valid*/
   /* FIXME: this->pci should be provided by the application. */
-  if((button <= 0) || (button > this->pci.hli.hl_gi.btn_ns)) {
+  if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) {
     printerrf("Unable to select button number %i as it doesn't exist",
 	      button);
     return S_ERR;
@@ -463,18 +463,18 @@
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, 
+dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, 
 						  int button) {
   /* A trivial function */
-  if(dvdnav_button_select(this, button) != S_ERR) {
-    return dvdnav_button_activate(this);
+  if(dvdnav_button_select(this, pci, button) != S_ERR) {
+    return dvdnav_button_activate(this, pci);
   }
   
   /* Should never get here without an error */
   return S_ERR;
 }
 
-dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, int x, int y) {
+dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) {
   int button, cur_button;
   uint32_t best,dist;
   int mx,my,dx,dy,d;
@@ -492,7 +492,7 @@
   dist = 0x08000000; /* >> than  (720*720)+(567*567); */
   
   /* Loop through each button */
-  for(button=1; button <= this->pci.hli.hl_gi.btn_ns; button++) {
+  for(button=1; button <= pci->hli.hl_gi.btn_ns; button++) {
     btni_t *button_ptr = NULL;
     button_ptr = &(this->pci.hli.btnit[button-1]);
     if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) &&
@@ -514,17 +514,17 @@
     /* As an efficiency measure, only re-select the button
      * if it is different to the previously selected one. */
     if(best != cur_button) {
-      dvdnav_button_select(this, best);
+      dvdnav_button_select(this, pci, best);
     }
   }
   
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, int x, int y) {
+dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int x, int y) {
   /* A trivial function */
-  if(dvdnav_mouse_select(this, x,y) != S_ERR) {
-    return dvdnav_button_activate(this);
+  if(dvdnav_mouse_select(this, pci, x,y) != S_ERR) {
+    return dvdnav_button_activate(this, pci);
   }
   
   /* Should never get here without an error */