annotate highlight.c @ 26:794d2e16a4d4 src

Removed un-needed variables. General Clean up.
author jcdutton
date Tue, 23 Apr 2002 12:55:40 +0000
parents 3c1df0cb3aee
children c3c8b98d7e95
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 */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
31 #include <assert.h>
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
32
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
33 #include <dvdnav.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
34 #include "dvdnav_internal.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
35
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
36 #include "vm.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
37 #
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
38 #include <dvdread/nav_types.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
39
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
40 #ifdef BUTTON_TESTING
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
41 #include <dvdread/nav_print.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
42 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
43
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
44 /* Highlighting API calls */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
48 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
49
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
52
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
53 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
54 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
55
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
56 pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
57 if (!this ) assert(0);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
58 return &this->pci;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
59 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
60
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
61 btni_t *__get_current_button(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
62 int button = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
63
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
64 if(dvdnav_get_current_highlight(this, &button) != S_OK) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
65 printerrf("Unable to get information on current highlight.");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
66 return NULL;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
67 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
68 #ifdef BUTTON_TESTING
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
69 navPrint_PCI(&(this->pci));
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
70 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
71
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
72 return &(this->pci.hli.btnit[button-1]);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
73 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
74
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
75 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
76 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
77
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
78 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
79 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
80
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
81 if((button_ptr = __get_current_button(this)) == NULL) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
82 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
83 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
84
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
85 dvdnav_button_select(this, button_ptr->up);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
86
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
87 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
88 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
89
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
90 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
91 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
92
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
93 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
94 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
95
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
96 if((button_ptr = __get_current_button(this)) == NULL) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
97 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
98 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
99
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
100 dvdnav_button_select(this, button_ptr->down);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
101
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
102 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
103 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
104
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
105 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
106 btni_t *button_ptr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
107
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
108 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
109 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
110
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
111 if((button_ptr = __get_current_button(this)) == NULL) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
112 printerr("Error fetching information on current button.");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
113 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
114 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
115
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
116 dvdnav_button_select(this, button_ptr->right);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
117
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
118 return S_OK;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
119 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
120
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
121 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
122 btni_t *button_ptr;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
123
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
124 if(!this)
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
125 return S_ERR;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
126
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
127 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
128 return S_ERR;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
129 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
130
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
131 dvdnav_button_select(this, button_ptr->left);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
132
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
133 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
134 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
135
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
136 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
137 dvdnav_highlight_area_t* highlight) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
138 btni_t *button_ptr;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
139 fprintf(stderr,"Button get_highlight_area %i\n", button);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
140
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
141 /* 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
142 if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
143 fprintf(stderr,"Unable to select button number %i as it doesn't exist",
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
144 button);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
145 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
146 }
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
147 button_ptr = &nav_pci->hli.btnit[button-1];
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
148
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
149 highlight->sx = button_ptr->x_start;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
150 highlight->sy = button_ptr->y_start;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
151 highlight->ex = button_ptr->x_end;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
152 highlight->ey = button_ptr->y_end;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
153 if(button_ptr->btn_coln != 0) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
154 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
155 } else {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
156 highlight->palette = 0;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
157 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
158 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
159 highlight->buttonN = button;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
160 //#ifdef BUTTON_TESTING
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
161 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
162 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
163 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
164 1,
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
165 button);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
166 //#endif
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
167
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
168 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
169 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
170
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
171 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
172 int button;
26
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 22
diff changeset
173 btni_t *button_ptr = NULL;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
174
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
175 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
176 return S_ERR;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
177 pthread_mutex_lock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
178
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
179 /* Precisely the same as selecting a button except we want
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
180 * a different palette */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
181 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
182 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
183 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
184 }
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
185 if(dvdnav_button_select(this, button) != S_OK) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
186 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
187 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
188 }
26
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 22
diff changeset
189 /* FIXME: The button command should really be passed in the API instead. */
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 22
diff changeset
190 button_ptr = __get_current_button(this);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
191 /* Finally, make the VM execute the appropriate code and
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
192 * scedule a jump */
10
6f0fb88d1463 Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents: 3
diff changeset
193 fprintf(stderr, "libdvdnav: Evaluating Button Activation commands.\n");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
194 if(vm_eval_cmd(this->vm, &(button_ptr->cmd)) == 1) {
26
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 22
diff changeset
195 /* Command caused a jump */
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 22
diff changeset
196 this->vm->hop_channel++;
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 22
diff changeset
197 this->position_current.still = 0;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
198 }
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
199 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
200 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
201 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
202
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
203 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, int button) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
204
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
205 if(!this) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
206 printerrf("Unable to select button number %i as this state bad",
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
207 button);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
208 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
209 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
210
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
211 fprintf(stderr,"Button select %i\n", button);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
212
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
213 /* Set the highlight SPRM if the passed button was valid*/
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
214 if((button <= 0) || (button > this->pci.hli.hl_gi.btn_ns)) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
215 printerrf("Unable to select button number %i as it doesn't exist",
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
216 button);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
217 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
218 }
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
219 this->vm->state.HL_BTNN_REG = (button << 10);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
220
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
221 this->hli_state = 1; /* Selected */
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
222
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
223 // this->position_current.button = -1; /* Force Highligh change */
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
224
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
225 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
226 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
227
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
228 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this,
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
229 int button) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
230 /* A trivial function */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
231 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
232 return dvdnav_button_activate(this);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
233 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
234
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
235 /* Should never get here without an error */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
236 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
237 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
238
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
239 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, int x, int y) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
240 int button, cur_button;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
241
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
242 /* FIXME: At the moment, the case of no button matchin (x,y) is
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
243 * silently ignored, is this OK? */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
244 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
245 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
246
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
247 if(dvdnav_get_current_highlight(this, &cur_button) != S_OK) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
248 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
249 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
250
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
251 /* Loop through each button */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
252 for(button=1; button <= this->pci.hli.hl_gi.btn_ns; button++) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
253 btni_t *button_ptr = NULL;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
254
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
255 button_ptr = &(this->pci.hli.btnit[button-1]);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
256 if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) &&
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
257 (y >= button_ptr->y_start) && (y <= button_ptr->y_end)) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
258 /* As an efficiency measure, only re-select the button
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
259 * if it is different to the previously selected one. */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
260 if(button != cur_button) {
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
261 dvdnav_button_select(this, button);
0
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
266 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
267 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
268
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
269 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, int x, int y) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
270 /* A trivial function */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 10
diff changeset
271 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
272 return dvdnav_button_activate(this);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
273 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
274
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
275 /* Should never get here without an error */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
276 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
277 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
278