Mercurial > mplayer.hg
annotate libvo/vo_caca.c @ 35418:cedb0ba2b5c6
Move the code to set guiInfo's Track, Chapter and Angle start values.
Set them before checking whether there is any media opened, because
with no media opened we clear the counters.
author | ib |
---|---|
date | Thu, 29 Nov 2012 14:11:03 +0000 |
parents | 4d92281ea02b |
children | 5d3f93051de9 |
rev | line source |
---|---|
12129 | 1 /* |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
2 * video output driver for libcaca |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
3 * |
12129 | 4 * by Pigeon <pigeon@pigeond.net> |
5 * | |
6 * Some functions/codes/ideas are from x11 and aalib vo | |
7 * | |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
8 * TODO: support draw_alpha? |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
9 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
10 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
11 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
12 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
15 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
16 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
17 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
20 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
21 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
22 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
23 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
12129 | 25 */ |
26 | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 #include <sys/stat.h> | |
30 #include <unistd.h> | |
31 #include <string.h> | |
32 #include <time.h> | |
33 #include <errno.h> | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
34 #include <caca.h> |
12129 | 35 |
36 #include "config.h" | |
37 #include "video_out.h" | |
38 #include "video_out_internal.h" | |
32467 | 39 #include "sub/sub.h" |
12129 | 40 |
41 #include "osdep/keycodes.h" | |
34271 | 42 #include "input/input.h" |
43 #include "input/mouse.h" | |
12129 | 44 #include "mp_msg.h" |
22823
98eaf29b5dee
Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents:
21161
diff
changeset
|
45 #include "mp_fifo.h" |
12129 | 46 |
25216 | 47 static const vo_info_t info = { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
48 "libcaca", |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
49 "caca", |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
50 "Pigeon <pigeon@pigeond.net>", |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
51 "" |
12129 | 52 }; |
53 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
54 const LIBVO_EXTERN(caca) |
12129 | 55 |
56 /* caca stuff */ | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
57 static caca_canvas_t *canvas; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
58 static caca_display_t *display; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
59 static caca_dither_t *dither = NULL; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
60 static const char *dither_antialias = "default"; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
61 static const char *dither_charset = "default"; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
62 static const char *dither_color = "default"; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
63 static const char *dither_algo = "none"; |
12129 | 64 |
65 /* image infos */ | |
66 static int image_format; | |
67 static int image_width; | |
68 static int image_height; | |
69 | |
70 static int screen_w, screen_h; | |
71 | |
72 /* We want 24bpp always for now */ | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
73 static unsigned int bpp = 24; |
12129 | 74 static unsigned int depth = 3; |
75 static unsigned int rmask = 0xff0000; | |
76 static unsigned int gmask = 0x00ff00; | |
77 static unsigned int bmask = 0x0000ff; | |
78 static unsigned int amask = 0; | |
79 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
80 #define MESSAGE_SIZE 512 |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
81 #define MESSAGE_DURATION 5 |
12129 | 82 |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
83 static time_t stoposd = 0; |
12129 | 84 static int showosdmessage = 0; |
85 static char osdmessagetext[MESSAGE_SIZE]; | |
86 static char posbar[MESSAGE_SIZE]; | |
87 | |
88 static int osdx = 0, osdy = 0; | |
89 static int posbary = 2; | |
90 | |
19053
75327b24e06f
marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
16171
diff
changeset
|
91 static void osdmessage(int duration, const char *fmt, ...) |
12129 | 92 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
93 /* for outputting a centered string at the window bottom for a while */ |
12129 | 94 va_list ar; |
95 char m[MESSAGE_SIZE]; | |
96 | |
97 va_start(ar, fmt); | |
98 vsprintf(m, fmt, ar); | |
99 va_end(ar); | |
100 strcpy(osdmessagetext, m); | |
101 | |
102 showosdmessage = 1; | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
103 stoposd = time(NULL) + duration; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
104 osdx = (screen_w - strlen(osdmessagetext)) / 2; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
105 posbar[0] = '\0'; |
12129 | 106 } |
107 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
108 static void osdpercent(int duration, int min, int max, int val, |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
109 const char *desc, const char *unit) |
12129 | 110 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
111 /* prints a bar for setting values */ |
12129 | 112 float step; |
113 int where, i; | |
114 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
115 step = (float)screen_w / (float)(max - min); |
12129 | 116 where = (val - min) * step; |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
117 osdmessage(duration, "%s: %i%s", desc, val, unit); |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
118 posbar[0] = '|'; |
12129 | 119 posbar[screen_w - 1] = '|'; |
120 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
121 for (i = 0; i < screen_w; i++) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
122 if (i == where) |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
123 posbar[i] = '#'; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
124 else |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
125 posbar[i] = '-'; |
12129 | 126 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
127 |
12129 | 128 if (where != 0) |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
129 posbar[0] = '|'; |
12129 | 130 |
131 if (where != (screen_w - 1)) | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
132 posbar[screen_w - 1] = '|'; |
12129 | 133 |
134 posbar[screen_w] = '\0'; | |
135 } | |
136 | |
29212
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
28446
diff
changeset
|
137 static int resize(void) |
12129 | 138 { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
139 screen_w = caca_get_canvas_width(canvas); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
140 screen_h = caca_get_canvas_height(canvas); |
12129 | 141 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
142 caca_free_dither(dither); |
12129 | 143 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
144 dither = caca_create_dither(bpp, image_width, image_height, |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
145 depth * image_width, |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
146 rmask, gmask, bmask, amask); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
147 if (dither == NULL) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
148 mp_msg(MSGT_VO, MSGL_FATAL, "vo_caca: caca_create_dither failed!\n"); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
149 return ENOSYS; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
150 } |
12129 | 151 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
152 /* Default libcaca features */ |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
153 caca_set_dither_antialias(dither, dither_antialias); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
154 caca_set_dither_charset(dither, dither_charset); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
155 caca_set_dither_color(dither, dither_color); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
156 caca_set_dither_algorithm(dither, dither_algo); |
12129 | 157 |
158 return 0; | |
159 } | |
160 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
161 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
162 uint32_t d_height, uint32_t flags, char *title, |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
163 uint32_t format) |
12129 | 164 { |
165 image_height = height; | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
166 image_width = width; |
12129 | 167 image_format = format; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
168 |
12129 | 169 showosdmessage = 0; |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
170 posbar[0] = '\0'; |
12129 | 171 |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
172 return resize(); |
12129 | 173 } |
174 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
175 static int draw_frame(uint8_t *src[]) |
12129 | 176 { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
177 caca_dither_bitmap(canvas, 0, 0, screen_w, screen_h, dither, src[0]); |
12129 | 178 return 0; |
179 } | |
180 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
181 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) |
12129 | 182 { |
183 return 0; | |
184 } | |
185 | |
186 static void flip_page(void) | |
187 { | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
188 if (showosdmessage) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
189 if (time(NULL) >= stoposd) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
190 showosdmessage = 0; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
191 if (*posbar) |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
192 posbar[0] = '\0'; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
193 } else { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
194 caca_put_str(canvas, osdx, osdy, osdmessagetext); |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
195 if (*posbar) |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
196 caca_put_str(canvas, 0, posbary, posbar); |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
197 } |
12129 | 198 } |
199 | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
200 caca_refresh_display(display); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
201 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
202 |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
203 static void set_next_str(const char * const *list, const char **str, |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
204 const char **msg) |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
205 { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
206 int ind; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
207 for (ind = 0; list[ind]; ind += 2) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
208 if (strcmp(list[ind], *str) == 0) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
209 if (list[ind + 2] == NULL) |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
210 ind = -2; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
211 *str = list[ind + 2]; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
212 *msg = list[ind + 3]; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
213 return; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
214 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
215 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
216 |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
217 *str = list[0]; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
218 *msg = list[1]; |
12129 | 219 } |
220 | |
34275
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
221 static const struct mp_keymap keysym_map[] = { |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
222 {CACA_KEY_RETURN, KEY_ENTER}, {CACA_KEY_ESCAPE, KEY_ESC}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
223 {CACA_KEY_UP, KEY_DOWN}, {CACA_KEY_DOWN, KEY_DOWN}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
224 {CACA_KEY_LEFT, KEY_LEFT}, {CACA_KEY_RIGHT, KEY_RIGHT}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
225 {CACA_KEY_PAGEUP, KEY_PAGE_UP}, {CACA_KEY_PAGEDOWN, KEY_PAGE_DOWN}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
226 {CACA_KEY_HOME, KEY_HOME}, {CACA_KEY_END, KEY_END}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
227 {CACA_KEY_INSERT, KEY_INSERT}, {CACA_KEY_DELETE, KEY_DELETE}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
228 {CACA_KEY_BACKSPACE, KEY_BACKSPACE}, {CACA_KEY_TAB, KEY_TAB}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
229 {CACA_KEY_PAUSE, KEY_PAUSE}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
230 {CACA_KEY_F1, KEY_F+1}, {CACA_KEY_F2, KEY_F+2}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
231 {CACA_KEY_F3, KEY_F+3}, {CACA_KEY_F4, KEY_F+4}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
232 {CACA_KEY_F5, KEY_F+5}, {CACA_KEY_F6, KEY_F+6}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
233 {CACA_KEY_F7, KEY_F+7}, {CACA_KEY_F8, KEY_F+8}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
234 {CACA_KEY_F9, KEY_F+9}, {CACA_KEY_F10, KEY_F+10}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
235 {CACA_KEY_F11, KEY_F+11}, {CACA_KEY_F12, KEY_F+12}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
236 {CACA_KEY_F13, KEY_F+13}, {CACA_KEY_F14, KEY_F+14}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
237 {CACA_KEY_F15, KEY_F+15}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
238 {0, 0} |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
239 }; |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
240 |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
241 static void check_events(void) |
12129 | 242 { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
243 caca_event_t cev; |
34273
3e8cb5ef9ac7
caca: process all pending events instead of exactly one per check_events.
reimar
parents:
34272
diff
changeset
|
244 while (caca_get_event(display, CACA_EVENT_ANY, &cev, 0)) { |
12129 | 245 |
34274 | 246 switch (cev.type) { |
247 case CACA_EVENT_RESIZE: | |
248 caca_refresh_display(display); | |
249 resize(); | |
250 break; | |
251 case CACA_EVENT_QUIT: | |
252 mplayer_put_key(KEY_CLOSE_WIN); | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
253 break; |
34274 | 254 case CACA_EVENT_MOUSE_MOTION: |
255 vo_mouse_movement(cev.data.mouse.x, cev.data.mouse.y); | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
256 break; |
34274 | 257 case CACA_EVENT_MOUSE_PRESS: |
258 if (!vo_nomouse_input) | |
259 mplayer_put_key((MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_DOWN); | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
260 break; |
34274 | 261 case CACA_EVENT_MOUSE_RELEASE: |
262 if (!vo_nomouse_input) | |
263 mplayer_put_key(MOUSE_BTN0 + cev.data.mouse.button - 1); | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
264 break; |
34274 | 265 case CACA_EVENT_KEY_PRESS: |
266 { | |
267 int key = cev.data.key.ch; | |
34275
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
268 int mpkey = lookup_keymap_table(keysym_map, key); |
34274 | 269 const char *msg_name; |
270 | |
34275
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
271 if (mpkey) |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
272 mplayer_put_key(mpkey); |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
273 else |
34274 | 274 switch (key) { |
275 case 'd': | |
276 case 'D': | |
277 /* Toggle dithering algorithm */ | |
278 set_next_str(caca_get_dither_algorithm_list(dither), &dither_algo, &msg_name); | |
279 caca_set_dither_algorithm(dither, dither_algo); | |
280 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
281 break; | |
282 | |
283 case 'a': | |
284 case 'A': | |
285 /* Toggle antialiasing method */ | |
286 set_next_str(caca_get_dither_antialias_list(dither), &dither_antialias, &msg_name); | |
287 caca_set_dither_antialias(dither, dither_antialias); | |
288 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
289 break; | |
290 | |
291 case 'h': | |
292 case 'H': | |
293 /* Toggle charset method */ | |
294 set_next_str(caca_get_dither_charset_list(dither), &dither_charset, &msg_name); | |
295 caca_set_dither_charset(dither, dither_charset); | |
296 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
297 break; | |
298 | |
299 case 'c': | |
300 case 'C': | |
301 /* Toggle color method */ | |
302 set_next_str(caca_get_dither_color_list(dither), &dither_color, &msg_name); | |
303 caca_set_dither_color(dither, dither_color); | |
304 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
305 break; | |
306 | |
307 default: | |
308 if (key <= 255) | |
309 mplayer_put_key(key); | |
310 break; | |
311 } | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
312 } |
34274 | 313 } |
34273
3e8cb5ef9ac7
caca: process all pending events instead of exactly one per check_events.
reimar
parents:
34272
diff
changeset
|
314 } |
12129 | 315 } |
316 | |
317 static void uninit(void) | |
318 { | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
319 caca_free_dither(dither); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
320 dither = NULL; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
321 caca_free_display(display); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
322 caca_free_canvas(canvas); |
12129 | 323 } |
324 | |
325 | |
326 static void draw_osd(void) | |
327 { | |
328 if (vo_osd_progbar_type != -1) | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
329 osdpercent(MESSAGE_DURATION, 0, 255, vo_osd_progbar_value, |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
330 sub_osd_names[vo_osd_progbar_type], ""); |
12129 | 331 } |
332 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
333 static int preinit(const char *arg) |
12129 | 334 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
335 if (arg) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
336 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg); |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
337 return ENOSYS; |
12129 | 338 } |
339 | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
340 canvas = caca_create_canvas(0, 0); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
341 if (canvas == NULL) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
342 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to create canvas\n"); |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
343 return ENOSYS; |
12129 | 344 } |
345 | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
346 display = caca_create_display(canvas); |
12129 | 347 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
348 if (display == NULL) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
349 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to create display\n"); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
350 caca_free_canvas(canvas); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
351 return ENOSYS; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
352 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
353 |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
354 caca_set_display_title(display, "MPlayer"); |
12129 | 355 |
356 return 0; | |
357 } | |
358 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
359 static int query_format(uint32_t format) |
12129 | 360 { |
361 if (format == IMGFMT_BGR24) | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
362 return VFCAP_OSD | VFCAP_CSP_SUPPORTED; |
12129 | 363 |
364 return 0; | |
365 } | |
366 | |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
32467
diff
changeset
|
367 static int control(uint32_t request, void *data) |
12129 | 368 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
369 switch (request) { |
12129 | 370 case VOCTRL_QUERY_FORMAT: |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
371 return query_format(*((uint32_t *)data)); |
12129 | 372 default: |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
373 return VO_NOTIMPL; |
12129 | 374 } |
375 } |