Mercurial > libdvdnav.hg
annotate highlight.c @ 67:61c0ee1bbb7a src
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
check_packet.
| author | richwareham |
|---|---|
| date | Thu, 25 Jul 2002 14:51:40 +0000 |
| parents | 2759605b41f6 |
| children | 940b438a9c9f |
| 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 | |
| 28 /* | |
| 29 #define BUTTON_TESTING | |
| 30 */ | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
31 #include <assert.h> |
| 0 | 32 |
| 33 #include <dvdnav.h> | |
| 34 #include "dvdnav_internal.h" | |
| 35 | |
| 36 #include "vm.h" | |
| 37 # | |
| 38 #include <dvdread/nav_types.h> | |
| 39 | |
| 40 #ifdef BUTTON_TESTING | |
| 41 #include <dvdread/nav_print.h> | |
| 42 #endif | |
| 43 | |
| 44 /* Highlighting API calls */ | |
| 45 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
46 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int* button) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
47 if(!this) |
| 0 | 48 return S_ERR; |
| 49 | |
| 50 /* 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
|
51 (*button) = (this->vm->state.HL_BTNN_REG) >> 10; |
| 0 | 52 |
| 53 return S_OK; | |
| 54 } | |
| 55 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
56 btni_t *__get_current_button(dvdnav_t *this) { |
| 0 | 57 int button = 0; |
| 58 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
59 if(dvdnav_get_current_highlight(this, &button) != S_OK) { |
| 0 | 60 printerrf("Unable to get information on current highlight."); |
| 61 return NULL; | |
| 62 } | |
| 63 #ifdef BUTTON_TESTING | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
64 navPrint_PCI(&(this->pci)); |
| 0 | 65 #endif |
| 66 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
67 return &(this->pci.hli.btnit[button-1]); |
| 0 | 68 } |
| 69 | |
| 29 | 70 dvdnav_status_t dvdnav_button_auto_action(dvdnav_t *this) { |
| 71 btni_t *button_ptr; | |
| 72 | |
| 73 if(!this) | |
| 74 return S_ERR; | |
| 75 | |
| 76 if((button_ptr = __get_current_button(this)) == NULL) { | |
| 77 return S_ERR; | |
| 78 } | |
| 79 if (button_ptr->auto_action_mode == 1) { | |
| 80 return S_OK; | |
| 81 } | |
| 82 return S_ERR; | |
| 83 } | |
| 84 | |
| 85 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
86 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this) { |
| 0 | 87 btni_t *button_ptr; |
| 88 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
89 if(!this) |
| 0 | 90 return S_ERR; |
| 91 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
92 if((button_ptr = __get_current_button(this)) == NULL) { |
| 0 | 93 return S_ERR; |
| 94 } | |
| 95 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
96 dvdnav_button_select(this, button_ptr->up); |
| 29 | 97 if (dvdnav_button_auto_action(this) ) { |
| 98 dvdnav_button_activate(this); | |
| 99 } | |
| 100 | |
| 0 | 101 return S_OK; |
| 102 } | |
| 103 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
104 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this) { |
| 0 | 105 btni_t *button_ptr; |
| 106 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
107 if(!this) |
| 0 | 108 return S_ERR; |
| 109 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
110 if((button_ptr = __get_current_button(this)) == NULL) { |
| 0 | 111 return S_ERR; |
| 112 } | |
| 113 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
114 dvdnav_button_select(this, button_ptr->down); |
| 29 | 115 if (dvdnav_button_auto_action(this) ) { |
| 116 dvdnav_button_activate(this); | |
| 117 } | |
| 0 | 118 |
| 119 return S_OK; | |
| 120 } | |
| 121 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
122 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this) { |
| 0 | 123 btni_t *button_ptr; |
| 124 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
125 if(!this) |
| 0 | 126 return S_ERR; |
| 127 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
128 if((button_ptr = __get_current_button(this)) == NULL) { |
| 0 | 129 printerr("Error fetching information on current button."); |
| 130 return S_ERR; | |
| 131 } | |
| 132 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
133 dvdnav_button_select(this, button_ptr->right); |
| 29 | 134 if (dvdnav_button_auto_action(this) ) { |
| 135 dvdnav_button_activate(this); | |
| 136 } | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
137 |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
138 return S_OK; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
139 } |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
140 |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
141 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
142 btni_t *button_ptr; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
143 |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
144 if(!this) |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
145 return S_ERR; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
146 |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
147 if((button_ptr = __get_current_button(this)) == NULL) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
148 return S_ERR; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
149 } |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
150 |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
151 dvdnav_button_select(this, button_ptr->left); |
| 29 | 152 if (dvdnav_button_auto_action(this) ) { |
| 153 dvdnav_button_activate(this); | |
| 154 } | |
| 0 | 155 |
| 156 return S_OK; | |
| 157 } | |
| 158 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
159 dvdnav_status_t dvdnav_get_highlight_area(pci_t* nav_pci , int32_t button, int32_t mode, |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
160 dvdnav_highlight_area_t* highlight) { |
| 0 | 161 btni_t *button_ptr; |
| 31 | 162 #ifdef BUTTON_TESTING |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
163 fprintf(stderr,"Button get_highlight_area %i\n", button); |
| 31 | 164 #endif |
| 0 | 165 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
166 /* Set the highlight SPRM if the passed button was valid*/ |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
167 if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) { |
| 30 | 168 fprintf(stderr,"Unable to select button number %i as it doesn't exist\n", |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
169 button); |
| 0 | 170 return S_ERR; |
| 171 } | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
172 button_ptr = &nav_pci->hli.btnit[button-1]; |
| 0 | 173 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
174 highlight->sx = button_ptr->x_start; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
175 highlight->sy = button_ptr->y_start; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
176 highlight->ex = button_ptr->x_end; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
177 highlight->ey = button_ptr->y_end; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
178 if(button_ptr->btn_coln != 0) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
179 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
|
180 } else { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
181 highlight->palette = 0; |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
182 } |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
183 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
|
184 highlight->buttonN = button; |
| 31 | 185 #ifdef BUTTON_TESTING |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
186 fprintf(stderr,"highlight.c:Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n", |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
187 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
|
188 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
|
189 1, |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
190 button); |
| 31 | 191 #endif |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
192 |
| 0 | 193 return S_OK; |
| 194 } | |
| 195 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
196 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this) { |
| 0 | 197 int button; |
| 26 | 198 btni_t *button_ptr = NULL; |
| 0 | 199 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
200 if(!this) |
| 0 | 201 return S_ERR; |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
202 pthread_mutex_lock(&this->vm_lock); |
| 0 | 203 |
| 204 /* Precisely the same as selecting a button except we want | |
| 205 * a different palette */ | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
206 if(dvdnav_get_current_highlight(this, &button) != S_OK) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
207 pthread_mutex_unlock(&this->vm_lock); |
| 0 | 208 return S_ERR; |
| 209 } | |
| 57 | 210 /* FIXME: dvdnav_button_select should really return a |
| 211 * special case for explicit NO-BUTTONS. | |
| 212 */ | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
213 if(dvdnav_button_select(this, button) != S_OK) { |
| 57 | 214 /* Special code to handle still menus with no buttons. |
| 215 * the navigation is expected to report to the appicatino that a STILL is | |
| 216 * underway. In turn, the application is supposed to report to the user | |
| 217 * that the playback is pause. The user is then expected to undo the pause. | |
| 218 * ie: hit play. At that point, the navigation should release the still and | |
| 219 * go to the next Cell. | |
| 220 * Explanation by Mathieu Lavage <mathieu_lacage@realmagic.fr> | |
| 221 * Code added by jcdutton. | |
| 222 */ | |
| 223 if (this->position_current.still != 0) { | |
| 224 /* In still, but no buttons. */ | |
| 225 vm_get_next_cell(this->vm); | |
| 226 this->position_current.still = 0; | |
| 227 pthread_mutex_unlock(&this->vm_lock); | |
| 228 return S_OK; | |
| 229 } | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
230 pthread_mutex_unlock(&this->vm_lock); |
| 0 | 231 return S_ERR; |
| 232 } | |
| 26 | 233 /* FIXME: The button command should really be passed in the API instead. */ |
| 234 button_ptr = __get_current_button(this); | |
| 0 | 235 /* Finally, make the VM execute the appropriate code and |
| 236 * scedule a jump */ | |
| 31 | 237 #ifdef BUTTON_TESTING |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
3
diff
changeset
|
238 fprintf(stderr, "libdvdnav: Evaluating Button Activation commands.\n"); |
| 31 | 239 #endif |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
240 if(vm_eval_cmd(this->vm, &(button_ptr->cmd)) == 1) { |
| 26 | 241 /* Command caused a jump */ |
| 242 this->vm->hop_channel++; | |
| 243 this->position_current.still = 0; | |
| 0 | 244 } |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
245 pthread_mutex_unlock(&this->vm_lock); |
| 0 | 246 return S_OK; |
| 247 } | |
| 248 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
249 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, int button) { |
| 0 | 250 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
251 if(!this) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
252 printerrf("Unable to select button number %i as this state bad", |
| 0 | 253 button); |
| 254 return S_ERR; | |
| 255 } | |
| 256 | |
| 31 | 257 #ifdef BUTTON_TESTING |
| 258 fprintf(stderr,"libdvdnav: Button select %i\n", button); | |
| 259 #endif | |
| 0 | 260 |
| 261 /* Set the highlight SPRM if the passed button was valid*/ | |
| 57 | 262 /* FIXME: this->pci should be provided by the application. */ |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
263 if((button <= 0) || (button > this->pci.hli.hl_gi.btn_ns)) { |
| 0 | 264 printerrf("Unable to select button number %i as it doesn't exist", |
| 265 button); | |
| 266 return S_ERR; | |
| 267 } | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
268 this->vm->state.HL_BTNN_REG = (button << 10); |
| 0 | 269 |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
270 this->hli_state = 1; /* Selected */ |
| 0 | 271 |
|
64
2759605b41f6
We need to update the button info when moving around in menus.
mroi
parents:
57
diff
changeset
|
272 this->position_current.button = -1; /* Force Highligh change */ |
| 0 | 273 |
| 274 return S_OK; | |
| 275 } | |
| 276 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
277 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, |
| 0 | 278 int button) { |
| 279 /* A trivial function */ | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
280 if(dvdnav_button_select(this, button) != S_ERR) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
281 return dvdnav_button_activate(this); |
| 0 | 282 } |
| 283 | |
| 284 /* Should never get here without an error */ | |
| 285 return S_ERR; | |
| 286 } | |
| 287 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
288 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, int x, int y) { |
| 0 | 289 int button, cur_button; |
| 290 | |
| 291 /* FIXME: At the moment, the case of no button matchin (x,y) is | |
| 292 * silently ignored, is this OK? */ | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
293 if(!this) |
| 0 | 294 return S_ERR; |
| 295 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
296 if(dvdnav_get_current_highlight(this, &cur_button) != S_OK) { |
| 0 | 297 return S_ERR; |
| 298 } | |
| 299 | |
| 300 /* Loop through each button */ | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
301 for(button=1; button <= this->pci.hli.hl_gi.btn_ns; button++) { |
| 0 | 302 btni_t *button_ptr = NULL; |
| 303 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
304 button_ptr = &(this->pci.hli.btnit[button-1]); |
| 0 | 305 if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) && |
| 306 (y >= button_ptr->y_start) && (y <= button_ptr->y_end)) { | |
| 307 /* As an efficiency measure, only re-select the button | |
| 308 * if it is different to the previously selected one. */ | |
| 309 if(button != cur_button) { | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
310 dvdnav_button_select(this, button); |
| 0 | 311 } |
| 312 } | |
| 313 } | |
| 314 | |
| 315 return S_OK; | |
| 316 } | |
| 317 | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
318 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, int x, int y) { |
| 0 | 319 /* A trivial function */ |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
320 if(dvdnav_mouse_select(this, x,y) != S_ERR) { |
|
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
321 return dvdnav_button_activate(this); |
| 0 | 322 } |
| 323 | |
| 324 /* Should never get here without an error */ | |
| 325 return S_ERR; | |
| 326 } | |
| 327 |
