Permalink
Browse files

Use the right highlight area in DVD menus when 'wide' is not the firs…

…t in the list.

Signed-off-by: Stuart Morgan <smorgan@mythtv.org>

Fixes #11291
  • Loading branch information...
1 parent 9497ba1 commit 1eaecea6dd38db0c20b94f8ecb549b4c29491297 Richard committed with stuartm Dec 14, 2012
@@ -57,6 +57,17 @@ typedef struct {
uint32_t buttonN;
} dvdnav_highlight_area_t;
+/*
+ * Button groups to identify the correct highlight areas
+ * (see dvdnav_get_highlight_area_with_group())
+ */
+typedef enum {
+ DVD_BTN_GRP_Normal = 0x00,
+ DVD_BTN_GRP_Wide = 0x01,
+ DVD_BTN_GRP_Letterbox = 0x02,
+ DVD_BTN_GRP_PanScan = 0x04
+} DVDBtnGrp_t;
+
/* the following types are currently unused */
@@ -481,6 +481,13 @@ dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32
dvdnav_highlight_area_t *highlight);
/*
+ * Get the area associated with a certain button in the given
+ * button group.
+ */
+dvdnav_status_t dvdnav_get_highlight_area_from_group(pci_t *nav_pci, DVDBtnGrp_t group,
+ int32_t button, int32_t mode, dvdnav_highlight_area_t *highlight);
+
+/*
* Move button highlight around as suggested by function name (e.g. with arrow keys).
*/
dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *self, pci_t *pci);
@@ -325,6 +325,66 @@ dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32
return DVDNAV_STATUS_OK;
}
+dvdnav_status_t dvdnav_get_highlight_area_from_group(pci_t *nav_pci, DVDBtnGrp_t group,
+ int32_t button, int32_t mode, dvdnav_highlight_area_t *highlight) {
+ btni_t *button_ptr;
+ unsigned int mask = (unsigned int)group;
+ int grpstart;
+ int maxbtns;
+
+#ifdef BUTTON_TESTING
+ fprintf(MSG_OUT, "libdvdnav: Button dvdnav_get_highlight_area_from_group %i,%i\n", button, group);
+#endif
+
+ if(!nav_pci->hli.hl_gi.hli_ss)
+ return DVDNAV_STATUS_ERR;
+ if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns) || (nav_pci->hli.hl_gi.btngr_ns <= 0))
+ return DVDNAV_STATUS_ERR;
+
+ if(group == DVD_BTN_GRP_Normal) {
+ mask = 0xFFFFFFFF;
+ }
+
+ /* 36 buttons in total are spread over the number
+ * of button groups. Find out how many buttons we
+ * have in each group
+ */
+ maxbtns = (36 / nav_pci->hli.hl_gi.btngr_ns);
+
+ if((nav_pci->hli.hl_gi.btngr1_dsp_ty & mask) == group) {
+ grpstart = 0;
+ } else if((nav_pci->hli.hl_gi.btngr_ns > 1) && ((nav_pci->hli.hl_gi.btngr2_dsp_ty & mask) == group)) {
+ grpstart = maxbtns;
+ } else if((nav_pci->hli.hl_gi.btngr_ns > 2) && ((nav_pci->hli.hl_gi.btngr3_dsp_ty & mask) == group)) {
+ grpstart = maxbtns * 2;
+ } else {
+ grpstart = 0;
+ }
+
+ button_ptr = &nav_pci->hli.btnit[grpstart+button-1];
+
+ highlight->sx = button_ptr->x_start;
+ highlight->sy = button_ptr->y_start;
+ highlight->ex = button_ptr->x_end;
+ highlight->ey = button_ptr->y_end;
+ if(button_ptr->btn_coln != 0) {
+ highlight->palette = nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode];
+ } else {
+ highlight->palette = 0;
+ }
+ highlight->pts = nav_pci->hli.hl_gi.hli_s_ptm;
+ highlight->buttonN = button;
+#ifdef BUTTON_TESTING
+ fprintf(MSG_OUT, "libdvdnav: highlight: Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u, groupmask = %i\n",
+ button_ptr->x_start, button_ptr->y_start,
+ button_ptr->x_end, button_ptr->y_end,
+ 1, group,
+ button);
+#endif
+
+ return DVDNAV_STATUS_OK;
+}
+
dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) {
int32_t button;
btni_t *button_ptr = NULL;
@@ -1430,7 +1430,7 @@ bool DVDRingBuffer::DVDButtonUpdate(bool b_mode)
dvdnav_highlight_area_t hl;
dvdnav_get_current_highlight(m_dvdnav, &button);
pci = dvdnav_get_current_nav_pci(m_dvdnav);
- dvdRet = dvdnav_get_highlight_area(pci, button, b_mode, &hl);
+ dvdRet = dvdnav_get_highlight_area_from_group(pci, DVD_BTN_GRP_Wide, button, b_mode, &hl);
if (dvdRet == DVDNAV_STATUS_ERR)
return false;

0 comments on commit 1eaecea

Please sign in to comment.