diff options
Diffstat (limited to 'src/input/libdvdnav/highlight.c')
-rw-r--r-- | src/input/libdvdnav/highlight.c | 164 |
1 files changed, 84 insertions, 80 deletions
diff --git a/src/input/libdvdnav/highlight.c b/src/input/libdvdnav/highlight.c index 671fac135..47de16097 100644 --- a/src/input/libdvdnav/highlight.c +++ b/src/input/libdvdnav/highlight.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: highlight.c,v 1.13 2003/04/29 15:58:30 jcdutton Exp $ + * $Id: highlight.c,v 1.14 2003/05/11 13:44:05 jcdutton Exp $ * */ @@ -65,7 +65,7 @@ static void print_time(dvd_time_t *dtime) { } static void nav_print_PCI_GI(pci_gi_t *pci_gi) { - int i; + int32_t i; fprintf(MSG_OUT,"libdvdnav: pci_gi:\n"); fprintf(MSG_OUT,"libdvdnav: nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); @@ -90,7 +90,7 @@ static void nav_print_PCI_GI(pci_gi_t *pci_gi) { } static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { - int i, j = 0; + int32_t i, j = 0; for(i = 0; i < 9; i++) j |= nsml_agli->nsml_agl_dsta[i]; @@ -104,7 +104,7 @@ static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { nsml_agli->nsml_agl_dsta[i]); } -static void nav_print_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { +static void nav_print_HL_GI(hl_gi_t *hl_gi, int32_t *btngr_ns, int32_t *btn_ns) { if((hl_gi->hli_ss & 0x03) == 0) return; @@ -130,7 +130,7 @@ static void nav_print_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { } static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { - int i, j; + int32_t i, j; j = 0; for(i = 0; i < 6; i++) @@ -146,8 +146,8 @@ static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { btn_colit->btn_coli[i][j]); } -static void nav_print_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { - int i, j, k; +static void nav_print_BTNIT(btni_t *btni_table, int32_t btngr_ns, int32_t btn_ns) { + int32_t i, j, k; fprintf(MSG_OUT,"libdvdnav: btnit:\n"); fprintf(MSG_OUT,"libdvdnav: btngr_ns: %i\n", btngr_ns); @@ -185,7 +185,7 @@ static void nav_print_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { } static void nav_print_HLI(hli_t *hli) { - int btngr_ns = 0, btn_ns = 0; + int32_t btngr_ns = 0, btn_ns = 0; fprintf(MSG_OUT,"libdvdnav: hli:\n"); nav_print_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns); @@ -205,30 +205,36 @@ void nav_print_PCI(pci_t *pci) { /* Highlighting API calls */ -dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int *button) { +dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int32_t *button) { - if(!this) { + if(!this || !button) { printerr("Passed a NULL pointer."); - return S_ERR; + return DVDNAV_STATUS_ERR; } /* Simply return the appropriate value based on the SPRM */ (*button) = this->position_current.button; - return S_OK; + return DVDNAV_STATUS_OK; } static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { - int button = 0; + int32_t button = 0; - if(!this) { + if(!this || !pci) { printerr("Passed a NULL pointer."); - return S_ERR; + return DVDNAV_STATUS_ERR; } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); - return S_ERR; + return DVDNAV_STATUS_ERR; } +#if 0 /* This causes some DVDs to fail to activate buttons. */ + if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { + printerr("This NAV has already been left."); + return DVDNAV_STATUS_ERR; + } +#endif button = this->vm->state.HL_BTNN_REG >> 10; #ifdef BUTTON_TESTING @@ -246,69 +252,49 @@ static dvdnav_status_t button_auto_action(dvdnav_t *this, pci_t *pci) { dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - if(!this) { - printerr("Passed a NULL pointer."); - return S_ERR; - } - if(!(button_ptr = get_current_button(this, pci))) - return S_ERR; + return DVDNAV_STATUS_ERR; dvdnav_button_select(this, pci, button_ptr->up); button_auto_action(this, pci); - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - if(!this) { - printerr("Passed a NULL pointer."); - return S_ERR; - } - if(!(button_ptr = get_current_button(this, pci))) - return S_ERR; + return DVDNAV_STATUS_ERR; dvdnav_button_select(this, pci, button_ptr->down); button_auto_action(this, pci); - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - if(!this) { - printerr("Passed a NULL pointer."); - return S_ERR; - } - if(!(button_ptr = get_current_button(this, pci))) - return S_ERR; + return DVDNAV_STATUS_ERR; dvdnav_button_select(this, pci, button_ptr->right); button_auto_action(this, pci); - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - if(!this) { - printerr("Passed a NULL pointer."); - return S_ERR; - } - if(!(button_ptr = get_current_button(this, pci))) - return S_ERR; + return DVDNAV_STATUS_ERR; dvdnav_button_select(this, pci, button_ptr->left); button_auto_action(this, pci); - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode, @@ -320,9 +306,9 @@ dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32 #endif if(!nav_pci->hli.hl_gi.hli_ss) - return S_ERR; + return DVDNAV_STATUS_ERR; if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) - return S_ERR; + return DVDNAV_STATUS_ERR; button_ptr = &nav_pci->hli.btnit[button-1]; @@ -346,22 +332,27 @@ dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32 button); #endif - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { - int button; + int32_t button; btni_t *button_ptr = NULL; - if(!this) { + if(!this || !pci) { printerr("Passed a NULL pointer."); - return S_ERR; + return DVDNAV_STATUS_ERR; } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); - return S_ERR; + return DVDNAV_STATUS_ERR; } - +#if 0 /* This causes some DVDs to fail to activate buttons. */ + if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { + printerr("This NAV has already been left."); + return DVDNAV_STATUS_ERR; + } +#endif pthread_mutex_lock(&this->vm_lock); button = this->vm->state.HL_BTNN_REG >> 10; @@ -381,13 +372,14 @@ dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { vm_get_next_cell(this->vm); this->position_current.still = 0; this->sync_wait = 0; + this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn; pthread_mutex_unlock(&this->vm_lock); /* clear error message */ printerr(""); - return S_OK; + return DVDNAV_STATUS_OK; } pthread_mutex_unlock(&this->vm_lock); - return S_ERR; + return DVDNAV_STATUS_ERR; } button_ptr = get_current_button(this, pci); @@ -400,17 +392,18 @@ dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { /* Command caused a jump */ this->vm->hop_channel++; this->position_current.still = 0; + this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn; } pthread_mutex_unlock(&this->vm_lock); - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd) { - if(!this) { + if(!this || !cmd) { printerr("Passed a NULL pointer."); - return S_ERR; + return DVDNAV_STATUS_ERR; } pthread_mutex_lock(&this->vm_lock); @@ -430,19 +423,25 @@ dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cm this->position_current.still = 0; this->sync_wait = 0; pthread_mutex_unlock(&this->vm_lock); - return S_OK; + return DVDNAV_STATUS_OK; } -dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) { +dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) { - if(!this) { + if(!this || !pci) { printerr("Passed a NULL pointer."); - return S_ERR; + return DVDNAV_STATUS_ERR; } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); - return S_ERR; + return DVDNAV_STATUS_ERR; } +#if 0 /* This causes some DVDs to fail to activate buttons. */ + if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { + printerr("This NAV has already been left."); + return DVDNAV_STATUS_ERR; + } +#endif #ifdef BUTTON_TESTING fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); @@ -450,36 +449,42 @@ dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) { if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { printerr("Button does not exist."); - return S_ERR; + return DVDNAV_STATUS_ERR; } this->vm->state.HL_BTNN_REG = (button << 10); this->position_current.button = -1; /* Force Highligh change */ - return S_OK; + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, - int button) { + int32_t button) { /* A trivial function */ - if(dvdnav_button_select(this, pci, button) != S_ERR) + if(dvdnav_button_select(this, pci, button) != DVDNAV_STATUS_ERR) return dvdnav_button_activate(this, pci); - return S_ERR; + return DVDNAV_STATUS_ERR; } -dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) { - int button, cur_button; - int best,dist,d; - int mx,my,dx,dy; +dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int32_t x, int32_t y) { + int32_t button, cur_button; + int32_t best,dist,d; + int32_t mx,my,dx,dy; - if(!this) { + if(!this || !pci) { printerr("Passed a NULL pointer."); - return S_ERR; + return DVDNAV_STATUS_ERR; } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); - return S_ERR; + return DVDNAV_STATUS_ERR; + } +#if 0 /* This causes some DVDs to fail to activate buttons. */ + if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { + printerr("This NAV has already been left."); + return DVDNAV_STATUS_ERR; } +#endif cur_button = this->vm->state.HL_BTNN_REG >> 10; @@ -505,19 +510,18 @@ dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) { } } } - /* As an efficiency measure, only re-select the button * if it is different to the previously selected one. */ if (best != 0 && best != cur_button) dvdnav_button_select(this, pci, best); - /* return S_OK only if we actually found a matching button */ - return best ? S_OK : S_ERR; + /* return DVDNAV_STATUS_OK only if we actually found a matching button */ + return best ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; } -dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int x, int y) { +dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int32_t x, int32_t y) { /* A trivial function */ - if(dvdnav_mouse_select(this, pci, x,y) != S_ERR) + if(dvdnav_mouse_select(this, pci, x,y) != DVDNAV_STATUS_ERR) return dvdnav_button_activate(this, pci); - return S_ERR; + return DVDNAV_STATUS_ERR; } |