annotate highlight.c @ 3:328eadb3f37e src

Added initial example programs directory and make sure all debug/error output goes to stderr.
author richwareham
date Mon, 01 Apr 2002 18:56:28 +0000
parents 3ddf0eaece51
children 6f0fb88d1463
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1 /*
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
3 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
4 * This file is part of libdvdnav, a DVD navigation library.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
5 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
6 * libdvdnav is free software; you can redistribute it and/or modify
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
9 * (at your option) any later version.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
10 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
11 * libdvdnav is distributed in the hope that it will be useful,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
14 * GNU General Public License for more details.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
15 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
19 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
20 * $Id$
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
21 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
22 */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
23
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
25 #include "config.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
26 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
27
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
28 /*
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
29 #define BUTTON_TESTING
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
30 */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
31
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
32 #include <dvdnav.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
33 #include "dvdnav_internal.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
34
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
35 #include "vm.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
36 #
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
37 #include <dvdread/nav_types.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
38
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
39 #ifdef BUTTON_TESTING
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
40 #include <dvdread/nav_print.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
41 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
42
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
43 /* Highlighting API calls */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
44
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
45 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *self, int* button) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
46 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
47 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
48
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
49 /* Simply return the appropriate value based on the SPRM */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
50 (*button) = (self->vm->state.HL_BTNN_REG) >> 10;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
51
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
52 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
53 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
54
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
55 btni_t *__get_current_button(dvdnav_t *self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
56 int button = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
57
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
58 if(dvdnav_get_current_highlight(self, &button) != S_OK) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
59 printerrf("Unable to get information on current highlight.");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
60 return NULL;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
61 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
62 #ifdef BUTTON_TESTING
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
63 navPrint_PCI(&(self->pci));
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
64 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
65
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
66 return &(self->pci.hli.btnit[button-1]);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
67 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
68
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
69 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
70 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
71
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
72 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
73 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
74
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
75 if((button_ptr = __get_current_button(self)) == NULL) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
76 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
77 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
78
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
79 dvdnav_button_select(self, button_ptr->up);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
80
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
81 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
82 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
83
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
84 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
85 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
86
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
87 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
88 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
89
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
90 if((button_ptr = __get_current_button(self)) == NULL) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
91 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
92 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
93
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
94 dvdnav_button_select(self, button_ptr->down);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
95
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
96 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
97 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
98
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
99 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
100 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
101
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
102 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
103 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
104
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
105 if((button_ptr = __get_current_button(self)) == NULL) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
106 printerr("Error fetching information on current button.");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
107 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
108 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
109
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
110 dvdnav_button_select(self, button_ptr->right);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
111
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
112 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
113 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
114
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
115 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
116 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
117
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
118 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
119 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
120
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
121 if((button_ptr = __get_current_button(self)) == NULL) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
122 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
123 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
124
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
125 dvdnav_button_select(self, button_ptr->left);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
126
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
127 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
128 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
129
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
130 dvdnav_status_t dvdnav_button_activate(dvdnav_t *self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
131 int button;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
132 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
133
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
134 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
135 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
136 pthread_mutex_lock(&self->vm_lock);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
137
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
138 /* Precisely the same as selecting a button except we want
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
139 * a different palette */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
140 if(dvdnav_get_current_highlight(self, &button) != S_OK) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
141 pthread_mutex_unlock(&self->vm_lock);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
142 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
143 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
144 if(dvdnav_button_select(self, button) != S_OK) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
145 pthread_mutex_unlock(&self->vm_lock);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
146 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
147 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
148
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
149 /* Now get the current button's info */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
150 if((button_ptr = __get_current_button(self)) == NULL) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
151 printerr("Error fetching information on current button.");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
152 pthread_mutex_unlock(&self->vm_lock);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
153 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
154 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
155
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
156 /* And set the palette */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
157 if(button_ptr->btn_coln != 0) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
158 self->hli_clut =
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
159 self->pci.hli.btn_colit.btn_coli[button_ptr->btn_coln-1][1];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
160 } else {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
161 self->hli_clut = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
162 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
163
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
164 /* Finally, make the VM execute the appropriate code and
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
165 * scedule a jump */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
166
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
167 if(vm_eval_cmd(self->vm, &(button_ptr->cmd)) == 1) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
168 /* Cammand caused a jump */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
169 dvdnav_do_post_jump(self);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
170 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
171
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
172 pthread_mutex_unlock(&self->vm_lock);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
173 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
174 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
175
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
176 dvdnav_status_t dvdnav_button_select(dvdnav_t *self, int button) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
177 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
178
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
179 if(!self) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
180 printerrf("Unable to select button number %i as self state bad",
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
181 button);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
182 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
183 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
184
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
185 fprintf(stderr,"Button select %i\n", button);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
186
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
187 /* Set the highlight SPRM if the passed button was valid*/
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
188 if((button <= 0) || (button > self->pci.hli.hl_gi.btn_ns)) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
189 printerrf("Unable to select button number %i as it doesn't exist",
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
190 button);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
191 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
192 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
193 self->vm->state.HL_BTNN_REG = (button << 10);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
194
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
195 /* Now get the current button's info */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
196 if((button_ptr = __get_current_button(self)) == NULL) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
197 printerr("Error fetching information on current button.");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
198 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
199 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
200
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
201 self->hli_bbox[0] = button_ptr->x_start;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
202 self->hli_bbox[1] = button_ptr->y_start;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
203 self->hli_bbox[2] = button_ptr->x_end;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
204 self->hli_bbox[3] = button_ptr->y_end;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
205 self->hli_state = 1; /* Selected */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
206
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
207 if(button_ptr->btn_coln != 0) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
208 self->hli_clut =
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
209 self->pci.hli.btn_colit.btn_coli[button_ptr->btn_coln-1][0];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
210 } else {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
211 self->hli_clut = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
212 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
213 self->hli_pts = self->pci.hli.hl_gi.hli_s_ptm;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
214 self->hli_buttonN = button;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
215 self->highlight_changed = 1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
216 #ifdef BUTTON_TESTING
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
217 fprintf(stderr,"highlight.c:Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n",
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
218 button_ptr->x_start, button_ptr->y_start,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
219 button_ptr->x_end, button_ptr->y_end,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
220 1,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
221 button);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
222 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
223
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
224 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
225 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
226
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
227 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *self,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
228 int button) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
229 /* A trivial function */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
230 if(dvdnav_button_select(self, button) != S_ERR) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
231 return dvdnav_button_activate(self);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
232 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
233
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
234 /* Should never get here without an error */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
235 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
236 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
237
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
238 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *self, int x, int y) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
239 int button, cur_button;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
240
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
241 /* FIXME: At the moment, the case of no button matchin (x,y) is
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
242 * silently ignored, is this OK? */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
243 if(!self)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
244 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
245
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
246 if(dvdnav_get_current_highlight(self, &cur_button) != S_OK) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
247 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
248 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
249
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
250 /* Loop through each button */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
251 for(button=1; button <= self->pci.hli.hl_gi.btn_ns; button++) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
252 btni_t *button_ptr = NULL;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
253
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
254 button_ptr = &(self->pci.hli.btnit[button-1]);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
255 if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) &&
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
256 (y >= button_ptr->y_start) && (y <= button_ptr->y_end)) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
257 /* As an efficiency measure, only re-select the button
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
258 * if it is different to the previously selected one. */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
259 if(button != cur_button) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
260 dvdnav_button_select(self, button);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
261 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
262 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
263 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
264
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
265 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
266 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
267
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
268 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *self, int x, int y) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
269 /* A trivial function */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
270 if(dvdnav_mouse_select(self, x,y) != S_ERR) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
271 return dvdnav_button_activate(self);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
272 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
273
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
274 /* Should never get here without an error */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
275 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
276 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
277