Mercurial > libdvdnav.hg
annotate highlight.c @ 387:4e28052eb201 src
A variable assignment is missing a lock around it.
All other accesses are locked.
Patch by Erik Hovland %erik!hovland dot org*
| author | rathann |
|---|---|
| date | Sun, 31 Aug 2008 18:13:23 +0000 |
| parents | 579a3538d284 |
| children | 90ca650854e0 |
| 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> |
| 278 | 29 #include <inttypes.h> |
|
288
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
30 #include <stdlib.h> |
|
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
31 #include <stdio.h> |
|
294
2146ff691bcd
include limits.h; it was included in the previous dvdnav_internal.h and without it players segfault
nicodvb
parents:
290
diff
changeset
|
32 #include <limits.h> |
|
288
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
33 #include <string.h> |
| 290 | 34 #include <sys/time.h> |
| 386 | 35 #include <dvdread/nav_types.h> |
|
285
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
36 #include "dvd_types.h" |
|
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
37 #include "remap.h" |
|
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
38 #include "vm/decoder.h" |
|
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
39 #include "vm/vm.h" |
|
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
40 #include "vm/vmcmd.h" |
| 0 | 41 #include "dvdnav_internal.h" |
|
285
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
42 #include "dvdnav.h" |
| 0 | 43 |
| 114 | 44 /* |
| 45 #define BUTTON_TESTING | |
| 46 */ | |
| 47 | |
| 0 | 48 #ifdef BUTTON_TESTING |
| 114 | 49 |
| 169 | 50 #include "nav_print.h" |
|
86
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 static void print_time(dvd_time_t *dtime) { |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
53 const char *rate; |
| 114 | 54 |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
55 assert((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
56 assert((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
57 assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
58 assert((dtime->frame_u&0xf) < 0xa); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
59 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
60 fprintf(MSG_OUT,"%02x:%02x:%02x.%02x", |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
61 dtime->hour, |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
62 dtime->minute, |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
63 dtime->second, |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
64 dtime->frame_u & 0x3f); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
65 switch((dtime->frame_u & 0xc0) >> 6) { |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
66 case 1: |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
67 rate = "25.00"; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
68 break; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
69 case 3: |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
70 rate = "29.97"; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
71 break; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
72 default: |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
73 rate = "(please send a bug report)"; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
74 break; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
75 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
76 fprintf(MSG_OUT," @ %s fps", rate); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
77 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
78 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
79 static void nav_print_PCI_GI(pci_gi_t *pci_gi) { |
| 196 | 80 int32_t i; |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
81 |
| 114 | 82 fprintf(MSG_OUT,"libdvdnav: pci_gi:\n"); |
| 83 fprintf(MSG_OUT,"libdvdnav: nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); | |
| 84 fprintf(MSG_OUT,"libdvdnav: vobu_cat 0x%04x\n", pci_gi->vobu_cat); | |
| 85 fprintf(MSG_OUT,"libdvdnav: vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); | |
| 86 fprintf(MSG_OUT,"libdvdnav: vobu_s_ptm 0x%08x\n", pci_gi->vobu_s_ptm); | |
| 87 fprintf(MSG_OUT,"libdvdnav: vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm); | |
| 88 fprintf(MSG_OUT,"libdvdnav: vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm); | |
| 89 fprintf(MSG_OUT,"libdvdnav: e_eltm "); | |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
90 print_time(&pci_gi->e_eltm); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
91 fprintf(MSG_OUT,"\n"); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
92 |
| 114 | 93 fprintf(MSG_OUT,"libdvdnav: vobu_isrc \""); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
94 for(i = 0; i < 32; i++) { |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
95 char c = pci_gi->vobu_isrc[i]; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
96 if((c >= ' ') && (c <= '~')) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
97 fprintf(MSG_OUT,"%c", c); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
98 else |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
99 fprintf(MSG_OUT,"."); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
100 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
101 fprintf(MSG_OUT,"\"\n"); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
102 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
103 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
104 static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { |
| 196 | 105 int32_t i, j = 0; |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
106 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
107 for(i = 0; i < 9; i++) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
108 j |= nsml_agli->nsml_agl_dsta[i]; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
109 if(j == 0) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
110 return; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
111 |
| 114 | 112 fprintf(MSG_OUT,"libdvdnav: nsml_agli:\n"); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
113 for(i = 0; i < 9; i++) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
114 if(nsml_agli->nsml_agl_dsta[i]) |
| 114 | 115 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
|
116 nsml_agli->nsml_agl_dsta[i]); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
117 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
118 |
| 196 | 119 static void nav_print_HL_GI(hl_gi_t *hl_gi, int32_t *btngr_ns, int32_t *btn_ns) { |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
120 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
121 if((hl_gi->hli_ss & 0x03) == 0) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
122 return; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
123 |
| 114 | 124 fprintf(MSG_OUT,"libdvdnav: hl_gi:\n"); |
| 125 fprintf(MSG_OUT,"libdvdnav: hli_ss 0x%01x\n", hl_gi->hli_ss & 0x03); | |
| 126 fprintf(MSG_OUT,"libdvdnav: hli_s_ptm 0x%08x\n", hl_gi->hli_s_ptm); | |
| 127 fprintf(MSG_OUT,"libdvdnav: hli_e_ptm 0x%08x\n", hl_gi->hli_e_ptm); | |
| 128 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
|
129 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
130 *btngr_ns = hl_gi->btngr_ns; |
| 114 | 131 fprintf(MSG_OUT,"libdvdnav: btngr_ns %d\n", hl_gi->btngr_ns); |
| 132 fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty 0x%02x\n", 1, hl_gi->btngr1_dsp_ty); | |
| 133 fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty 0x%02x\n", 2, hl_gi->btngr2_dsp_ty); | |
| 134 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
|
135 |
| 114 | 136 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
|
137 *btn_ns = hl_gi->btn_ns; |
| 114 | 138 fprintf(MSG_OUT,"libdvdnav: btn_ns %d\n", hl_gi->btn_ns); |
| 139 fprintf(MSG_OUT,"libdvdnav: nsl_btn_ns %d\n", hl_gi->nsl_btn_ns); | |
| 140 fprintf(MSG_OUT,"libdvdnav: fosl_btnn %d\n", hl_gi->fosl_btnn); | |
| 141 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
|
142 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
143 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
144 static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { |
| 196 | 145 int32_t i, j; |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
146 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
147 j = 0; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
148 for(i = 0; i < 6; i++) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
149 j |= btn_colit->btn_coli[i/2][i&1]; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
150 if(j == 0) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
151 return; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
152 |
| 114 | 153 fprintf(MSG_OUT,"libdvdnav: btn_colit:\n"); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
154 for(i = 0; i < 3; i++) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
155 for(j = 0; j < 2; j++) |
| 114 | 156 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
|
157 i, (j == 0) ? "sl" : "ac", |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
158 btn_colit->btn_coli[i][j]); |
|
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 |
| 196 | 161 static void nav_print_BTNIT(btni_t *btni_table, int32_t btngr_ns, int32_t btn_ns) { |
| 162 int32_t i, j, k; | |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
163 |
| 114 | 164 fprintf(MSG_OUT,"libdvdnav: btnit:\n"); |
| 165 fprintf(MSG_OUT,"libdvdnav: btngr_ns: %i\n", btngr_ns); | |
| 166 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
|
167 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
168 if(btngr_ns == 0) |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
169 return; |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
170 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
171 for(i = 0; i < btngr_ns; i++) { |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
172 for(j = 0; j < (36 / btngr_ns); j++) { |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
173 if(j < btn_ns) { |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
174 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
|
175 |
| 114 | 176 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
|
177 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
|
178 btni->btn_coln, btni->auto_action_mode); |
| 114 | 179 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
|
180 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
|
181 |
| 114 | 182 fprintf(MSG_OUT,"libdvdnav: up %d, ", btni->up); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
183 fprintf(MSG_OUT,"down %d, ", btni->down); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
184 fprintf(MSG_OUT,"left %d, ", btni->left); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
185 fprintf(MSG_OUT,"right %d\n", btni->right); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
186 for(k = 0; k < 8; k++) { |
| 114 | 187 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
|
188 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
189 fprintf(MSG_OUT, "| "); |
| 166 | 190 #ifdef TRACE |
| 153 | 191 vm_print_mnemonic(&btni->cmd); |
| 166 | 192 #endif |
| 114 | 193 fprintf(MSG_OUT, "\n"); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
194 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
195 } |
|
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 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
199 static void nav_print_HLI(hli_t *hli) { |
| 196 | 200 int32_t btngr_ns = 0, btn_ns = 0; |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
201 |
| 114 | 202 fprintf(MSG_OUT,"libdvdnav: hli:\n"); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
203 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
|
204 nav_print_BTN_COLIT(&hli->btn_colit); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
205 nav_print_BTNIT(hli->btnit, btngr_ns, btn_ns); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
206 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
207 |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
208 void nav_print_PCI(pci_t *pci) { |
| 114 | 209 fprintf(MSG_OUT,"libdvdnav: pci packet:\n"); |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
210 nav_print_PCI_GI(&pci->pci_gi); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
211 nav_print_NSML_AGLI(&pci->nsml_agli); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
212 nav_print_HLI(&pci->hli); |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
213 } |
|
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
214 |
| 114 | 215 #endif |
|
86
129ac4af16a4
Improve debugging output to help with debugging button activations.
jcdutton
parents:
76
diff
changeset
|
216 |
| 0 | 217 |
| 218 /* Highlighting API calls */ | |
| 219 | |
| 196 | 220 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int32_t *button) { |
| 0 | 221 /* Simply return the appropriate value based on the SPRM */ |
|
205
ba43bdbb07e8
Update to allow events sent to the gui to tell it whether we are in a button or not.
jcdutton
parents:
197
diff
changeset
|
222 if(((*button) = this->position_current.button) == -1) |
|
ba43bdbb07e8
Update to allow events sent to the gui to tell it whether we are in a button or not.
jcdutton
parents:
197
diff
changeset
|
223 (*button) = this->vm->state.HL_BTNN_REG >> 10; |
| 0 | 224 |
| 193 | 225 return DVDNAV_STATUS_OK; |
| 0 | 226 } |
| 227 | |
| 114 | 228 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { |
| 196 | 229 int32_t button = 0; |
| 0 | 230 |
| 166 | 231 if(!pci->hli.hl_gi.hli_ss) { |
| 232 printerr("Not in a menu."); | |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
233 return NULL; |
| 166 | 234 } |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
235 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
|
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
236 printerr("This NAV has already been left."); |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
237 return NULL; |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
238 } |
| 117 | 239 |
| 240 button = this->vm->state.HL_BTNN_REG >> 10; | |
| 0 | 241 #ifdef BUTTON_TESTING |
| 166 | 242 nav_print_PCI(pci); |
| 0 | 243 #endif |
| 244 | |
| 98 | 245 return &(pci->hli.btnit[button-1]); |
| 0 | 246 } |
| 247 | |
| 114 | 248 static dvdnav_status_t button_auto_action(dvdnav_t *this, pci_t *pci) { |
| 249 if (get_current_button(this, pci)->auto_action_mode) | |
| 250 return dvdnav_button_activate(this, pci); | |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
251 return DVDNAV_STATUS_OK; |
| 29 | 252 } |
| 253 | |
| 98 | 254 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) { |
| 0 | 255 btni_t *button_ptr; |
| 256 | |
| 114 | 257 if(!(button_ptr = get_current_button(this, pci))) |
| 193 | 258 return DVDNAV_STATUS_ERR; |
| 114 | 259 |
| 98 | 260 dvdnav_button_select(this, pci, button_ptr->up); |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
261 return button_auto_action(this, pci); |
| 0 | 262 } |
| 263 | |
| 98 | 264 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) { |
| 0 | 265 btni_t *button_ptr; |
| 266 | |
| 114 | 267 if(!(button_ptr = get_current_button(this, pci))) |
| 193 | 268 return DVDNAV_STATUS_ERR; |
| 114 | 269 |
| 98 | 270 dvdnav_button_select(this, pci, button_ptr->down); |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
271 return button_auto_action(this, pci); |
| 0 | 272 } |
| 273 | |
| 98 | 274 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) { |
| 0 | 275 btni_t *button_ptr; |
| 276 | |
| 114 | 277 if(!(button_ptr = get_current_button(this, pci))) |
| 193 | 278 return DVDNAV_STATUS_ERR; |
| 114 | 279 |
| 98 | 280 dvdnav_button_select(this, pci, button_ptr->right); |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
281 return button_auto_action(this, pci); |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
282 } |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
283 |
| 98 | 284 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
|
285 btni_t *button_ptr; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
286 |
| 114 | 287 if(!(button_ptr = get_current_button(this, pci))) |
| 193 | 288 return DVDNAV_STATUS_ERR; |
| 114 | 289 |
| 98 | 290 dvdnav_button_select(this, pci, button_ptr->left); |
|
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
196
diff
changeset
|
291 return button_auto_action(this, pci); |
| 0 | 292 } |
| 293 | |
| 114 | 294 dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode, |
| 295 dvdnav_highlight_area_t *highlight) { | |
| 0 | 296 btni_t *button_ptr; |
| 114 | 297 |
| 31 | 298 #ifdef BUTTON_TESTING |
| 76 | 299 fprintf(MSG_OUT, "libdvdnav: Button get_highlight_area %i\n", button); |
| 31 | 300 #endif |
| 166 | 301 |
| 302 if(!nav_pci->hli.hl_gi.hli_ss) | |
| 193 | 303 return DVDNAV_STATUS_ERR; |
| 114 | 304 if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) |
| 193 | 305 return DVDNAV_STATUS_ERR; |
| 114 | 306 |
| 166 | 307 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
308 button_ptr = &nav_pci->hli.btnit[button-1]; |
| 0 | 309 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
310 highlight->sx = button_ptr->x_start; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
311 highlight->sy = button_ptr->y_start; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
312 highlight->ex = button_ptr->x_end; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
313 highlight->ey = button_ptr->y_end; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
314 if(button_ptr->btn_coln != 0) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
315 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
|
316 } else { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
317 highlight->palette = 0; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
318 } |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
319 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
|
320 highlight->buttonN = button; |
| 31 | 321 #ifdef BUTTON_TESTING |
| 114 | 322 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
|
323 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
|
324 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
|
325 1, |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
326 button); |
| 31 | 327 #endif |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
328 |
| 193 | 329 return DVDNAV_STATUS_OK; |
| 0 | 330 } |
| 331 | |
| 98 | 332 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { |
| 196 | 333 int32_t button; |
| 26 | 334 btni_t *button_ptr = NULL; |
| 114 | 335 |
| 166 | 336 if(!pci->hli.hl_gi.hli_ss) { |
| 337 printerr("Not in a menu."); | |
| 193 | 338 return DVDNAV_STATUS_ERR; |
| 166 | 339 } |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
340 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
|
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
341 printerr("This NAV has already been left."); |
| 193 | 342 return DVDNAV_STATUS_ERR; |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
343 } |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
344 pthread_mutex_lock(&this->vm_lock); |
| 0 | 345 |
| 117 | 346 button = this->vm->state.HL_BTNN_REG >> 10; |
| 114 | 347 |
| 348 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { | |
| 57 | 349 /* Special code to handle still menus with no buttons. |
| 166 | 350 * The navigation is expected to report to the application that a STILL is |
| 57 | 351 * underway. In turn, the application is supposed to report to the user |
| 166 | 352 * that the playback is paused. The user is then expected to undo the pause, |
| 57 | 353 * ie: hit play. At that point, the navigation should release the still and |
| 354 * go to the next Cell. | |
| 166 | 355 * Explanation by Mathieu Lacage <mathieu_lacage@realmagic.fr> |
| 57 | 356 * Code added by jcdutton. |
| 357 */ | |
| 358 if (this->position_current.still != 0) { | |
| 359 /* In still, but no buttons. */ | |
| 360 vm_get_next_cell(this->vm); | |
| 361 this->position_current.still = 0; | |
| 116 | 362 this->sync_wait = 0; |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
363 this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn; |
| 57 | 364 pthread_mutex_unlock(&this->vm_lock); |
| 114 | 365 /* clear error message */ |
| 366 printerr(""); | |
| 193 | 367 return DVDNAV_STATUS_OK; |
| 57 | 368 } |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
369 pthread_mutex_unlock(&this->vm_lock); |
| 193 | 370 return DVDNAV_STATUS_ERR; |
| 0 | 371 } |
| 114 | 372 |
| 373 button_ptr = get_current_button(this, pci); | |
| 374 /* Finally, make the VM execute the appropriate code and probably | |
| 0 | 375 * scedule a jump */ |
| 31 | 376 #ifdef BUTTON_TESTING |
| 76 | 377 fprintf(MSG_OUT, "libdvdnav: Evaluating Button Activation commands.\n"); |
| 31 | 378 #endif |
| 114 | 379 if(vm_exec_cmd(this->vm, &(button_ptr->cmd)) == 1) { |
| 26 | 380 /* Command caused a jump */ |
| 381 this->vm->hop_channel++; | |
| 382 this->position_current.still = 0; | |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
383 this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn; |
| 0 | 384 } |
| 114 | 385 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
386 pthread_mutex_unlock(&this->vm_lock); |
| 193 | 387 return DVDNAV_STATUS_OK; |
| 0 | 388 } |
| 389 | |
|
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
390 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
|
391 { |
| 114 | 392 pthread_mutex_lock(&this->vm_lock); |
| 393 /* 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
|
394 * schedule a jump */ |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
395 #ifdef BUTTON_TESTING |
| 114 | 396 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
|
397 #endif |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
398 if(button > 0) { |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
399 this->vm->state.HL_BTNN_REG = (button << 10); |
| 114 | 400 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
|
401 /* Command caused a jump */ |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
402 this->vm->hop_channel++; |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
403 } |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
404 } |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
405 /* 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
|
406 this->position_current.still = 0; |
| 116 | 407 this->sync_wait = 0; |
|
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
408 pthread_mutex_unlock(&this->vm_lock); |
| 193 | 409 return DVDNAV_STATUS_OK; |
|
91
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
410 } |
|
df9712507b30
Add a new API function, to allow for more flexible menu button control.
jcdutton
parents:
86
diff
changeset
|
411 |
| 196 | 412 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) { |
| 166 | 413 if(!pci->hli.hl_gi.hli_ss) { |
| 414 printerr("Not in a menu."); | |
| 193 | 415 return DVDNAV_STATUS_ERR; |
| 166 | 416 } |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
417 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
|
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
418 printerr("This NAV has already been left."); |
| 193 | 419 return DVDNAV_STATUS_ERR; |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
420 } |
| 0 | 421 |
| 31 | 422 #ifdef BUTTON_TESTING |
| 76 | 423 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); |
| 31 | 424 #endif |
| 0 | 425 |
| 98 | 426 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { |
| 114 | 427 printerr("Button does not exist."); |
| 193 | 428 return DVDNAV_STATUS_ERR; |
| 0 | 429 } |
| 114 | 430 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
431 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
|
432 this->position_current.button = -1; /* Force Highligh change */ |
| 0 | 433 |
| 193 | 434 return DVDNAV_STATUS_OK; |
| 0 | 435 } |
| 436 | |
| 98 | 437 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, |
| 196 | 438 int32_t button) { |
| 0 | 439 /* A trivial function */ |
| 193 | 440 if(dvdnav_button_select(this, pci, button) != DVDNAV_STATUS_ERR) |
| 98 | 441 return dvdnav_button_activate(this, pci); |
| 193 | 442 return DVDNAV_STATUS_ERR; |
| 0 | 443 } |
| 444 | |
| 196 | 445 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int32_t x, int32_t y) { |
| 446 int32_t button, cur_button; | |
| 447 int32_t best,dist,d; | |
| 448 int32_t mx,my,dx,dy; | |
| 69 | 449 |
| 166 | 450 if(!pci->hli.hl_gi.hli_ss) { |
| 451 printerr("Not in a menu."); | |
| 193 | 452 return DVDNAV_STATUS_ERR; |
| 166 | 453 } |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
454 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
|
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
455 printerr("This NAV has already been left."); |
| 193 | 456 return DVDNAV_STATUS_ERR; |
|
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
169
diff
changeset
|
457 } |
| 0 | 458 |
| 117 | 459 cur_button = this->vm->state.HL_BTNN_REG >> 10; |
| 114 | 460 |
| 461 best = 0; | |
| 69 | 462 dist = 0x08000000; /* >> than (720*720)+(567*567); */ |
| 463 | |
| 114 | 464 /* Loop through all buttons */ |
| 465 for(button = 1; button <= pci->hli.hl_gi.btn_ns; button++) { | |
|
227
10af49ee5118
Fix a bug. We pass pci_t as a function param, so why bother looking at an
jcdutton
parents:
205
diff
changeset
|
466 btni_t *button_ptr = &(pci->hli.btnit[button-1]); |
|
10af49ee5118
Fix a bug. We pass pci_t as a function param, so why bother looking at an
jcdutton
parents:
205
diff
changeset
|
467 |
| 0 | 468 if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) && |
| 469 (y >= button_ptr->y_start) && (y <= button_ptr->y_end)) { | |
| 69 | 470 mx = (button_ptr->x_start + button_ptr->x_end)/2; |
| 114 | 471 my = (button_ptr->y_start + button_ptr->y_end)/2; |
| 69 | 472 dx = mx - x; |
| 473 dy = my - y; | |
| 474 d = (dx*dx) + (dy*dy); | |
| 475 /* If the mouse is within the button and the mouse is closer | |
| 476 * to the center of this button then it is the best choice. */ | |
| 477 if(d < dist) { | |
| 114 | 478 dist = d; |
| 479 best = button; | |
| 0 | 480 } |
| 481 } | |
| 482 } | |
| 114 | 483 /* As an efficiency measure, only re-select the button |
| 484 * if it is different to the previously selected one. */ | |
| 485 if (best != 0 && best != cur_button) | |
| 486 dvdnav_button_select(this, pci, best); | |
| 487 | |
| 193 | 488 /* return DVDNAV_STATUS_OK only if we actually found a matching button */ |
| 489 return best ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; | |
| 0 | 490 } |
| 491 | |
| 196 | 492 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int32_t x, int32_t y) { |
| 0 | 493 /* A trivial function */ |
| 193 | 494 if(dvdnav_mouse_select(this, pci, x,y) != DVDNAV_STATUS_ERR) |
| 98 | 495 return dvdnav_button_activate(this, pci); |
| 193 | 496 return DVDNAV_STATUS_ERR; |
| 0 | 497 } |
