Mercurial > libdvdnav.hg
annotate highlight.c @ 114:b6834e6359cf src
big libdvdnav cleanup, quoting the ChangeLog:
* some bugfixes
* code cleanup
* build process polishing
* more sensible event order in get_next_block to ensure useful event delivery
* VOBU level resume
* fixed: seeking in a multiangle feature briefly showed the wrong angle
author | mroi |
---|---|
date | Thu, 20 Feb 2003 15:32:21 +0000 |
parents | 457f35f43ba6 |
children | 4d711d0518e9 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
28 #include <assert.h> |
0 | 29 |
30 #include "dvdnav_internal.h" | |
31 | |
32 #include "vm.h" | |
33 #include <dvdread/nav_types.h> | |
34 | |
114 | 35 /* |
36 #define BUTTON_TESTING | |
37 */ | |
38 | |
0 | 39 #ifdef BUTTON_TESTING |
114 | 40 |
0 | 41 #include <dvdread/nav_print.h> |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
42 #include "vmcmd.h" |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
43 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
44 static void print_time(dvd_time_t *dtime) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
45 const char *rate; |
114 | 46 |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
47 assert((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
48 assert((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
49 assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
50 assert((dtime->frame_u&0xf) < 0xa); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
51 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
52 fprintf(MSG_OUT,"%02x:%02x:%02x.%02x", |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
53 dtime->hour, |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
54 dtime->minute, |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
55 dtime->second, |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
56 dtime->frame_u & 0x3f); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
57 switch((dtime->frame_u & 0xc0) >> 6) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
58 case 1: |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
59 rate = "25.00"; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
60 break; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
61 case 3: |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
62 rate = "29.97"; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
63 break; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
64 default: |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
65 rate = "(please send a bug report)"; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
66 break; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
67 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
68 fprintf(MSG_OUT," @ %s fps", rate); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
69 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
70 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
71 static void nav_print_PCI_GI(pci_gi_t *pci_gi) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
72 int i; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
73 |
114 | 74 fprintf(MSG_OUT,"libdvdnav: pci_gi:\n"); |
75 fprintf(MSG_OUT,"libdvdnav: nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); | |
76 fprintf(MSG_OUT,"libdvdnav: vobu_cat 0x%04x\n", pci_gi->vobu_cat); | |
77 fprintf(MSG_OUT,"libdvdnav: vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); | |
78 fprintf(MSG_OUT,"libdvdnav: vobu_s_ptm 0x%08x\n", pci_gi->vobu_s_ptm); | |
79 fprintf(MSG_OUT,"libdvdnav: vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm); | |
80 fprintf(MSG_OUT,"libdvdnav: vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm); | |
81 fprintf(MSG_OUT,"libdvdnav: e_eltm "); | |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
82 print_time(&pci_gi->e_eltm); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
83 fprintf(MSG_OUT,"\n"); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
84 |
114 | 85 fprintf(MSG_OUT,"libdvdnav: vobu_isrc \""); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
86 for(i = 0; i < 32; i++) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
87 char c = pci_gi->vobu_isrc[i]; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
88 if((c >= ' ') && (c <= '~')) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
89 fprintf(MSG_OUT,"%c", c); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
90 else |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
91 fprintf(MSG_OUT,"."); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
92 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
93 fprintf(MSG_OUT,"\"\n"); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
94 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
95 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
96 static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
97 int i, j = 0; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
98 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
99 for(i = 0; i < 9; i++) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
100 j |= nsml_agli->nsml_agl_dsta[i]; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
101 if(j == 0) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
102 return; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
103 |
114 | 104 fprintf(MSG_OUT,"libdvdnav: nsml_agli:\n"); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
105 for(i = 0; i < 9; i++) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
106 if(nsml_agli->nsml_agl_dsta[i]) |
114 | 107 fprintf(MSG_OUT,"libdvdnav: nsml_agl_c%d_dsta 0x%08x\n", i + 1, |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
108 nsml_agli->nsml_agl_dsta[i]); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
109 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
110 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
111 static void nav_print_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
112 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
113 if((hl_gi->hli_ss & 0x03) == 0) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
114 return; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
115 |
114 | 116 fprintf(MSG_OUT,"libdvdnav: hl_gi:\n"); |
117 fprintf(MSG_OUT,"libdvdnav: hli_ss 0x%01x\n", hl_gi->hli_ss & 0x03); | |
118 fprintf(MSG_OUT,"libdvdnav: hli_s_ptm 0x%08x\n", hl_gi->hli_s_ptm); | |
119 fprintf(MSG_OUT,"libdvdnav: hli_e_ptm 0x%08x\n", hl_gi->hli_e_ptm); | |
120 fprintf(MSG_OUT,"libdvdnav: btn_se_e_ptm 0x%08x\n", hl_gi->btn_se_e_ptm); | |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
121 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
122 *btngr_ns = hl_gi->btngr_ns; |
114 | 123 fprintf(MSG_OUT,"libdvdnav: btngr_ns %d\n", hl_gi->btngr_ns); |
124 fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty 0x%02x\n", 1, hl_gi->btngr1_dsp_ty); | |
125 fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty 0x%02x\n", 2, hl_gi->btngr2_dsp_ty); | |
126 fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty 0x%02x\n", 3, hl_gi->btngr3_dsp_ty); | |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
127 |
114 | 128 fprintf(MSG_OUT,"libdvdnav: btn_ofn %d\n", hl_gi->btn_ofn); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
129 *btn_ns = hl_gi->btn_ns; |
114 | 130 fprintf(MSG_OUT,"libdvdnav: btn_ns %d\n", hl_gi->btn_ns); |
131 fprintf(MSG_OUT,"libdvdnav: nsl_btn_ns %d\n", hl_gi->nsl_btn_ns); | |
132 fprintf(MSG_OUT,"libdvdnav: fosl_btnn %d\n", hl_gi->fosl_btnn); | |
133 fprintf(MSG_OUT,"libdvdnav: foac_btnn %d\n", hl_gi->foac_btnn); | |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
134 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
135 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
136 static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
137 int i, j; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
138 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
139 j = 0; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
140 for(i = 0; i < 6; i++) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
141 j |= btn_colit->btn_coli[i/2][i&1]; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
142 if(j == 0) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
143 return; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
144 |
114 | 145 fprintf(MSG_OUT,"libdvdnav: btn_colit:\n"); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
146 for(i = 0; i < 3; i++) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
147 for(j = 0; j < 2; j++) |
114 | 148 fprintf(MSG_OUT,"libdvdnav: btn_cqoli %d %s_coli: %08x\n", |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
149 i, (j == 0) ? "sl" : "ac", |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
150 btn_colit->btn_coli[i][j]); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
151 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
152 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
153 static void nav_print_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
154 int i, j, k; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
155 |
114 | 156 fprintf(MSG_OUT,"libdvdnav: btnit:\n"); |
157 fprintf(MSG_OUT,"libdvdnav: btngr_ns: %i\n", btngr_ns); | |
158 fprintf(MSG_OUT,"libdvdnav: btn_ns: %i\n", btn_ns); | |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
159 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
160 if(btngr_ns == 0) |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
161 return; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
162 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
163 for(i = 0; i < btngr_ns; i++) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
164 for(j = 0; j < (36 / btngr_ns); j++) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
165 if(j < btn_ns) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
166 btni_t *btni = &btni_table[(36 / btngr_ns) * i + j]; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
167 |
114 | 168 fprintf(MSG_OUT,"libdvdnav: group %d btni %d: ", i+1, j+1); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
169 fprintf(MSG_OUT,"btn_coln %d, auto_action_mode %d\n", |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
170 btni->btn_coln, btni->auto_action_mode); |
114 | 171 fprintf(MSG_OUT,"libdvdnav: coords (%d, %d) .. (%d, %d)\n", |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
172 btni->x_start, btni->y_start, btni->x_end, btni->y_end); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
173 |
114 | 174 fprintf(MSG_OUT,"libdvdnav: up %d, ", btni->up); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
175 fprintf(MSG_OUT,"down %d, ", btni->down); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
176 fprintf(MSG_OUT,"left %d, ", btni->left); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
177 fprintf(MSG_OUT,"right %d\n", btni->right); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
178 for(k = 0; k < 8; k++) { |
114 | 179 fprintf(MSG_OUT, "libdvdnav: %02x ", btni->cmd.bytes[k]); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
180 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
181 fprintf(MSG_OUT, "| "); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
182 vmPrint_mnemonic(&btni->cmd); |
114 | 183 fprintf(MSG_OUT, "\n"); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
184 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
185 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
186 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
187 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
188 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
189 static void nav_print_HLI(hli_t *hli) { |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
190 int btngr_ns = 0, btn_ns = 0; |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
191 |
114 | 192 fprintf(MSG_OUT,"libdvdnav: hli:\n"); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
193 nav_print_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
194 nav_print_BTN_COLIT(&hli->btn_colit); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
195 nav_print_BTNIT(hli->btnit, btngr_ns, btn_ns); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
196 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
197 |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
198 void nav_print_PCI(pci_t *pci) { |
114 | 199 fprintf(MSG_OUT,"libdvdnav: pci packet:\n"); |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
200 nav_print_PCI_GI(&pci->pci_gi); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
201 nav_print_NSML_AGLI(&pci->nsml_agli); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
202 nav_print_HLI(&pci->hli); |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
203 } |
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
204 |
114 | 205 #endif |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
206 |
0 | 207 |
208 /* Highlighting API calls */ | |
209 | |
114 | 210 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int *button) { |
211 | |
212 if(!this) { | |
213 printerr("Passed a NULL pointer."); | |
214 return S_ERR; | |
215 } | |
0 | 216 |
217 /* Simply return the appropriate value based on the SPRM */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
218 (*button) = (this->vm->state.HL_BTNN_REG) >> 10; |
0 | 219 |
220 return S_OK; | |
221 } | |
222 | |
114 | 223 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { |
0 | 224 int button = 0; |
225 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
226 if(dvdnav_get_current_highlight(this, &button) != S_OK) { |
76 | 227 printerr("Unable to get information on current highlight."); |
0 | 228 return NULL; |
229 } | |
230 #ifdef BUTTON_TESTING | |
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
231 nav_print_PCI(&(this->pci)); |
0 | 232 #endif |
233 | |
98 | 234 return &(pci->hli.btnit[button-1]); |
0 | 235 } |
236 | |
114 | 237 static dvdnav_status_t button_auto_action(dvdnav_t *this, pci_t *pci) { |
238 if (get_current_button(this, pci)->auto_action_mode) | |
239 return dvdnav_button_activate(this, pci); | |
29 | 240 } |
241 | |
98 | 242 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) { |
0 | 243 btni_t *button_ptr; |
244 | |
114 | 245 if(!this) { |
246 printerr("Passed a NULL pointer."); | |
0 | 247 return S_ERR; |
248 } | |
249 | |
114 | 250 if(!(button_ptr = get_current_button(this, pci))) |
251 return S_ERR; | |
252 | |
98 | 253 dvdnav_button_select(this, pci, button_ptr->up); |
114 | 254 button_auto_action(this, pci); |
29 | 255 |
0 | 256 return S_OK; |
257 } | |
258 | |
98 | 259 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) { |
0 | 260 btni_t *button_ptr; |
261 | |
114 | 262 if(!this) { |
263 printerr("Passed a NULL pointer."); | |
0 | 264 return S_ERR; |
265 } | |
266 | |
114 | 267 if(!(button_ptr = get_current_button(this, pci))) |
268 return S_ERR; | |
269 | |
98 | 270 dvdnav_button_select(this, pci, button_ptr->down); |
114 | 271 button_auto_action(this, pci); |
0 | 272 |
273 return S_OK; | |
274 } | |
275 | |
98 | 276 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) { |
0 | 277 btni_t *button_ptr; |
278 | |
114 | 279 if(!this) { |
280 printerr("Passed a NULL pointer."); | |
0 | 281 return S_ERR; |
282 } | |
283 | |
114 | 284 if(!(button_ptr = get_current_button(this, pci))) |
285 return S_ERR; | |
286 | |
98 | 287 dvdnav_button_select(this, pci, button_ptr->right); |
114 | 288 button_auto_action(this, pci); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
289 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
290 return S_OK; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
291 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
292 |
98 | 293 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
294 btni_t *button_ptr; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
295 |
114 | 296 if(!this) { |
297 printerr("Passed a NULL pointer."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
298 return S_ERR; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
299 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
300 |
114 | 301 if(!(button_ptr = get_current_button(this, pci))) |
302 return S_ERR; | |
303 | |
98 | 304 dvdnav_button_select(this, pci, button_ptr->left); |
114 | 305 button_auto_action(this, pci); |
0 | 306 |
307 return S_OK; | |
308 } | |
309 | |
114 | 310 dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode, |
311 dvdnav_highlight_area_t *highlight) { | |
0 | 312 btni_t *button_ptr; |
114 | 313 |
31 | 314 #ifdef BUTTON_TESTING |
76 | 315 fprintf(MSG_OUT, "libdvdnav: Button get_highlight_area %i\n", button); |
31 | 316 #endif |
0 | 317 |
114 | 318 if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) |
0 | 319 return S_ERR; |
114 | 320 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
321 button_ptr = &nav_pci->hli.btnit[button-1]; |
0 | 322 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
323 highlight->sx = button_ptr->x_start; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
324 highlight->sy = button_ptr->y_start; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
325 highlight->ex = button_ptr->x_end; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
326 highlight->ey = button_ptr->y_end; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
327 if(button_ptr->btn_coln != 0) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
328 highlight->palette = nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode]; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
329 } else { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
330 highlight->palette = 0; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
331 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
332 highlight->pts = nav_pci->hli.hl_gi.hli_s_ptm; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
333 highlight->buttonN = button; |
31 | 334 #ifdef BUTTON_TESTING |
114 | 335 fprintf(MSG_OUT, "libdvdnav: highlight: Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n", |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
336 button_ptr->x_start, button_ptr->y_start, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
337 button_ptr->x_end, button_ptr->y_end, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
338 1, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
339 button); |
31 | 340 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
341 |
0 | 342 return S_OK; |
343 } | |
344 | |
98 | 345 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { |
0 | 346 int button; |
26 | 347 btni_t *button_ptr = NULL; |
114 | 348 |
349 if(!this) { | |
350 printerr("Passed a NULL pointer."); | |
351 return S_ERR; | |
352 } | |
353 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
354 pthread_mutex_lock(&this->vm_lock); |
0 | 355 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
356 if(dvdnav_get_current_highlight(this, &button) != S_OK) { |
114 | 357 pthread_mutex_unlock(&this->vm_lock); |
0 | 358 return S_ERR; |
359 } | |
114 | 360 |
361 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { | |
57 | 362 /* Special code to handle still menus with no buttons. |
363 * the navigation is expected to report to the appicatino that a STILL is | |
364 * underway. In turn, the application is supposed to report to the user | |
365 * that the playback is pause. The user is then expected to undo the pause. | |
366 * ie: hit play. At that point, the navigation should release the still and | |
367 * go to the next Cell. | |
368 * Explanation by Mathieu Lavage <mathieu_lacage@realmagic.fr> | |
369 * Code added by jcdutton. | |
370 */ | |
371 if (this->position_current.still != 0) { | |
372 /* In still, but no buttons. */ | |
373 vm_get_next_cell(this->vm); | |
374 this->position_current.still = 0; | |
375 pthread_mutex_unlock(&this->vm_lock); | |
114 | 376 /* clear error message */ |
377 printerr(""); | |
57 | 378 return S_OK; |
379 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
380 pthread_mutex_unlock(&this->vm_lock); |
0 | 381 return S_ERR; |
382 } | |
114 | 383 |
384 button_ptr = get_current_button(this, pci); | |
385 /* Finally, make the VM execute the appropriate code and probably | |
0 | 386 * scedule a jump */ |
31 | 387 #ifdef BUTTON_TESTING |
76 | 388 fprintf(MSG_OUT, "libdvdnav: Evaluating Button Activation commands.\n"); |
31 | 389 #endif |
114 | 390 if(vm_exec_cmd(this->vm, &(button_ptr->cmd)) == 1) { |
26 | 391 /* Command caused a jump */ |
392 this->vm->hop_channel++; | |
393 this->position_current.still = 0; | |
0 | 394 } |
114 | 395 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
396 pthread_mutex_unlock(&this->vm_lock); |
0 | 397 return S_OK; |
398 } | |
399 | |
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
400 dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd) |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
401 { |
114 | 402 if(!this) { |
403 printerr("Passed a NULL pointer."); | |
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
404 return S_ERR; |
114 | 405 } |
406 | |
407 pthread_mutex_lock(&this->vm_lock); | |
408 /* make the VM execute the appropriate code and probably | |
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
409 * schedule a jump */ |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
410 #ifdef BUTTON_TESTING |
114 | 411 fprintf(MSG_OUT, "libdvdnav: dvdnav_button_activate_cmd: Evaluating Button Activation commands.\n"); |
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
412 #endif |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
413 if(button > 0) { |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
414 this->vm->state.HL_BTNN_REG = (button << 10); |
114 | 415 if(vm_exec_cmd(this->vm, cmd) == 1) { |
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
416 /* Command caused a jump */ |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
417 this->vm->hop_channel++; |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
418 } |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
419 } |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
420 /* Always remove still, because some still menus have no buttons. */ |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
421 this->position_current.still = 0; |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
422 pthread_mutex_unlock(&this->vm_lock); |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
423 return S_OK; |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
424 } |
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
425 |
98 | 426 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) { |
0 | 427 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
428 if(!this) { |
114 | 429 printerr("Passed a NULL pointer."); |
430 return S_ERR; | |
0 | 431 } |
432 | |
31 | 433 #ifdef BUTTON_TESTING |
76 | 434 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); |
31 | 435 #endif |
0 | 436 |
98 | 437 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { |
114 | 438 printerr("Button does not exist."); |
0 | 439 return S_ERR; |
440 } | |
114 | 441 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
442 this->vm->state.HL_BTNN_REG = (button << 10); |
64
2759605b41f6
We need to update the button info when moving around in menus.
mroi
parents:
57
diff
changeset
|
443 this->position_current.button = -1; /* Force Highligh change */ |
0 | 444 |
445 return S_OK; | |
446 } | |
447 | |
98 | 448 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, |
0 | 449 int button) { |
450 /* A trivial function */ | |
114 | 451 if(dvdnav_button_select(this, pci, button) != S_ERR) |
98 | 452 return dvdnav_button_activate(this, pci); |
0 | 453 return S_ERR; |
454 } | |
455 | |
98 | 456 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) { |
0 | 457 int button, cur_button; |
69 | 458 uint32_t best,dist; |
459 int mx,my,dx,dy,d; | |
460 | |
114 | 461 if(!this) { |
462 printerr("Passed a NULL pointer."); | |
0 | 463 return S_ERR; |
464 } | |
465 | |
114 | 466 if(dvdnav_get_current_highlight(this, &cur_button) != S_OK) |
467 return S_ERR; | |
468 | |
469 best = 0; | |
69 | 470 dist = 0x08000000; /* >> than (720*720)+(567*567); */ |
471 | |
114 | 472 /* Loop through all buttons */ |
473 for(button = 1; button <= pci->hli.hl_gi.btn_ns; button++) { | |
474 btni_t *button_ptr = &(this->pci.hli.btnit[button-1]); | |
475 | |
0 | 476 if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) && |
477 (y >= button_ptr->y_start) && (y <= button_ptr->y_end)) { | |
69 | 478 mx = (button_ptr->x_start + button_ptr->x_end)/2; |
114 | 479 my = (button_ptr->y_start + button_ptr->y_end)/2; |
69 | 480 dx = mx - x; |
481 dy = my - y; | |
482 d = (dx*dx) + (dy*dy); | |
483 /* If the mouse is within the button and the mouse is closer | |
484 * to the center of this button then it is the best choice. */ | |
485 if(d < dist) { | |
114 | 486 dist = d; |
487 best = button; | |
0 | 488 } |
489 } | |
490 } | |
114 | 491 |
492 /* As an efficiency measure, only re-select the button | |
493 * if it is different to the previously selected one. */ | |
494 if (best != 0 && best != cur_button) | |
495 dvdnav_button_select(this, pci, best); | |
496 | |
497 /* return S_OK only if we actually found a matching button */ | |
498 return best ? S_OK : S_ERR; | |
0 | 499 } |
500 | |
98 | 501 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int x, int y) { |
0 | 502 /* A trivial function */ |
114 | 503 if(dvdnav_mouse_select(this, pci, x,y) != S_ERR) |
98 | 504 return dvdnav_button_activate(this, pci); |
0 | 505 return S_ERR; |
506 } |