Mercurial > mplayer.hg
annotate libvo/vo_caca.c @ 37058:a6b7e61e4af1
Disable system DPI scaling on Windows.
We scale the video just fine (or rather, better)
ourselves.
The GUI might be in trouble here though, since it
does not want its video to be scaled by the OS but
it also isn't DPI aware either...
author | reimar |
---|---|
date | Sat, 19 Apr 2014 08:30:17 +0000 |
parents | 5d3f93051de9 |
children |
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" | |
36517 | 38 #define NO_DRAW_SLICE |
12129 | 39 #include "video_out_internal.h" |
32467 | 40 #include "sub/sub.h" |
12129 | 41 |
42 #include "osdep/keycodes.h" | |
34271 | 43 #include "input/input.h" |
44 #include "input/mouse.h" | |
12129 | 45 #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
|
46 #include "mp_fifo.h" |
12129 | 47 |
25216 | 48 static const vo_info_t info = { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
49 "libcaca", |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
50 "caca", |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
51 "Pigeon <pigeon@pigeond.net>", |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
52 "" |
12129 | 53 }; |
54 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
55 const LIBVO_EXTERN(caca) |
12129 | 56 |
57 /* caca stuff */ | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
58 static caca_canvas_t *canvas; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
59 static caca_display_t *display; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 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
|
64 static const char *dither_algo = "none"; |
12129 | 65 |
66 /* image infos */ | |
67 static int image_format; | |
68 static int image_width; | |
69 static int image_height; | |
70 | |
71 static int screen_w, screen_h; | |
72 | |
73 /* We want 24bpp always for now */ | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
74 static unsigned int bpp = 24; |
12129 | 75 static unsigned int depth = 3; |
76 static unsigned int rmask = 0xff0000; | |
77 static unsigned int gmask = 0x00ff00; | |
78 static unsigned int bmask = 0x0000ff; | |
79 static unsigned int amask = 0; | |
80 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
81 #define MESSAGE_SIZE 512 |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
82 #define MESSAGE_DURATION 5 |
12129 | 83 |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
84 static time_t stoposd = 0; |
12129 | 85 static int showosdmessage = 0; |
86 static char osdmessagetext[MESSAGE_SIZE]; | |
87 static char posbar[MESSAGE_SIZE]; | |
88 | |
89 static int osdx = 0, osdy = 0; | |
90 static int posbary = 2; | |
91 | |
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
|
92 static void osdmessage(int duration, const char *fmt, ...) |
12129 | 93 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
94 /* for outputting a centered string at the window bottom for a while */ |
12129 | 95 va_list ar; |
96 char m[MESSAGE_SIZE]; | |
97 | |
98 va_start(ar, fmt); | |
99 vsprintf(m, fmt, ar); | |
100 va_end(ar); | |
101 strcpy(osdmessagetext, m); | |
102 | |
103 showosdmessage = 1; | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
104 stoposd = time(NULL) + duration; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
105 osdx = (screen_w - strlen(osdmessagetext)) / 2; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
106 posbar[0] = '\0'; |
12129 | 107 } |
108 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
109 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
|
110 const char *desc, const char *unit) |
12129 | 111 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
112 /* prints a bar for setting values */ |
12129 | 113 float step; |
114 int where, i; | |
115 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
116 step = (float)screen_w / (float)(max - min); |
12129 | 117 where = (val - min) * step; |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
118 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
|
119 posbar[0] = '|'; |
12129 | 120 posbar[screen_w - 1] = '|'; |
121 | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
122 for (i = 0; i < screen_w; i++) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
123 if (i == where) |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
124 posbar[i] = '#'; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
125 else |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
126 posbar[i] = '-'; |
12129 | 127 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
128 |
12129 | 129 if (where != 0) |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
130 posbar[0] = '|'; |
12129 | 131 |
132 if (where != (screen_w - 1)) | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
133 posbar[screen_w - 1] = '|'; |
12129 | 134 |
135 posbar[screen_w] = '\0'; | |
136 } | |
137 | |
29212
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
28446
diff
changeset
|
138 static int resize(void) |
12129 | 139 { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
140 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
|
141 screen_h = caca_get_canvas_height(canvas); |
12129 | 142 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
143 caca_free_dither(dither); |
12129 | 144 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
145 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
|
146 depth * image_width, |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
147 rmask, gmask, bmask, amask); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
148 if (dither == NULL) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
149 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
|
150 return ENOSYS; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
151 } |
12129 | 152 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
153 /* Default libcaca features */ |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 caca_set_dither_algorithm(dither, dither_algo); |
12129 | 158 |
159 return 0; | |
160 } | |
161 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
162 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
|
163 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
|
164 uint32_t format) |
12129 | 165 { |
166 image_height = height; | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
167 image_width = width; |
12129 | 168 image_format = format; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
169 |
12129 | 170 showosdmessage = 0; |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
171 posbar[0] = '\0'; |
12129 | 172 |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
173 return resize(); |
12129 | 174 } |
175 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
176 static int draw_frame(uint8_t *src[]) |
12129 | 177 { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
178 caca_dither_bitmap(canvas, 0, 0, screen_w, screen_h, dither, src[0]); |
12129 | 179 return 0; |
180 } | |
181 | |
182 static void flip_page(void) | |
183 { | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
184 if (showosdmessage) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
185 if (time(NULL) >= stoposd) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
186 showosdmessage = 0; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
187 if (*posbar) |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
188 posbar[0] = '\0'; |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
189 } else { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
190 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
|
191 if (*posbar) |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
192 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
|
193 } |
12129 | 194 } |
195 | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
196 caca_refresh_display(display); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
197 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
198 |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
199 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
|
200 const char **msg) |
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 int ind; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
203 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
|
204 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
|
205 if (list[ind + 2] == NULL) |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
206 ind = -2; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
207 *str = list[ind + 2]; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
208 *msg = list[ind + 3]; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
209 return; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
210 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
211 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
212 |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
213 *str = list[0]; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
214 *msg = list[1]; |
12129 | 215 } |
216 | |
34275
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
217 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
|
218 {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
|
219 {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
|
220 {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
|
221 {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
|
222 {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
|
223 {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
|
224 {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
|
225 {CACA_KEY_PAUSE, KEY_PAUSE}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
226 {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
|
227 {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
|
228 {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
|
229 {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
|
230 {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
|
231 {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
|
232 {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
|
233 {CACA_KEY_F15, KEY_F+15}, |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
234 {0, 0} |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
235 }; |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
236 |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
237 static void check_events(void) |
12129 | 238 { |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
239 caca_event_t cev; |
34273
3e8cb5ef9ac7
caca: process all pending events instead of exactly one per check_events.
reimar
parents:
34272
diff
changeset
|
240 while (caca_get_event(display, CACA_EVENT_ANY, &cev, 0)) { |
12129 | 241 |
34274 | 242 switch (cev.type) { |
243 case CACA_EVENT_RESIZE: | |
244 caca_refresh_display(display); | |
245 resize(); | |
246 break; | |
247 case CACA_EVENT_QUIT: | |
248 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
|
249 break; |
34274 | 250 case CACA_EVENT_MOUSE_MOTION: |
251 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
|
252 break; |
34274 | 253 case CACA_EVENT_MOUSE_PRESS: |
254 if (!vo_nomouse_input) | |
255 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
|
256 break; |
34274 | 257 case CACA_EVENT_MOUSE_RELEASE: |
258 if (!vo_nomouse_input) | |
259 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
|
260 break; |
34274 | 261 case CACA_EVENT_KEY_PRESS: |
262 { | |
263 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
|
264 int mpkey = lookup_keymap_table(keysym_map, key); |
34274 | 265 const char *msg_name; |
266 | |
34275
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
267 if (mpkey) |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
268 mplayer_put_key(mpkey); |
4d92281ea02b
Use lookup_keymap_table instead of a large number of switch cases.
reimar
parents:
34274
diff
changeset
|
269 else |
34274 | 270 switch (key) { |
271 case 'd': | |
272 case 'D': | |
273 /* Toggle dithering algorithm */ | |
274 set_next_str(caca_get_dither_algorithm_list(dither), &dither_algo, &msg_name); | |
275 caca_set_dither_algorithm(dither, dither_algo); | |
276 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
277 break; | |
278 | |
279 case 'a': | |
280 case 'A': | |
281 /* Toggle antialiasing method */ | |
282 set_next_str(caca_get_dither_antialias_list(dither), &dither_antialias, &msg_name); | |
283 caca_set_dither_antialias(dither, dither_antialias); | |
284 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
285 break; | |
286 | |
287 case 'h': | |
288 case 'H': | |
289 /* Toggle charset method */ | |
290 set_next_str(caca_get_dither_charset_list(dither), &dither_charset, &msg_name); | |
291 caca_set_dither_charset(dither, dither_charset); | |
292 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
293 break; | |
294 | |
295 case 'c': | |
296 case 'C': | |
297 /* Toggle color method */ | |
298 set_next_str(caca_get_dither_color_list(dither), &dither_color, &msg_name); | |
299 caca_set_dither_color(dither, dither_color); | |
300 osdmessage(MESSAGE_DURATION, "Using %s", msg_name); | |
301 break; | |
302 | |
303 default: | |
304 if (key <= 255) | |
305 mplayer_put_key(key); | |
306 break; | |
307 } | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
308 } |
34274 | 309 } |
34273
3e8cb5ef9ac7
caca: process all pending events instead of exactly one per check_events.
reimar
parents:
34272
diff
changeset
|
310 } |
12129 | 311 } |
312 | |
313 static void uninit(void) | |
314 { | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
315 caca_free_dither(dither); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
316 dither = NULL; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
317 caca_free_display(display); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
318 caca_free_canvas(canvas); |
12129 | 319 } |
320 | |
321 | |
322 static void draw_osd(void) | |
323 { | |
324 if (vo_osd_progbar_type != -1) | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
325 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
|
326 sub_osd_names[vo_osd_progbar_type], ""); |
12129 | 327 } |
328 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
329 static int preinit(const char *arg) |
12129 | 330 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
331 if (arg) { |
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
332 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
|
333 return ENOSYS; |
12129 | 334 } |
335 | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
336 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
|
337 if (canvas == NULL) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
338 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
|
339 return ENOSYS; |
12129 | 340 } |
341 | |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
342 display = caca_create_display(canvas); |
12129 | 343 |
34250
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
344 if (display == NULL) { |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
345 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
|
346 caca_free_canvas(canvas); |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
347 return ENOSYS; |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
348 } |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
349 |
94905e65a560
vo_caca: Port to libcaca 1.x API, which is widespread enough nowadays.
diego
parents:
34249
diff
changeset
|
350 caca_set_display_title(display, "MPlayer"); |
12129 | 351 |
352 return 0; | |
353 } | |
354 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
355 static int query_format(uint32_t format) |
12129 | 356 { |
357 if (format == IMGFMT_BGR24) | |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
358 return VFCAP_OSD | VFCAP_CSP_SUPPORTED; |
12129 | 359 |
360 return 0; | |
361 } | |
362 | |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
32467
diff
changeset
|
363 static int control(uint32_t request, void *data) |
12129 | 364 { |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
365 switch (request) { |
12129 | 366 case VOCTRL_QUERY_FORMAT: |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
367 return query_format(*((uint32_t *)data)); |
12129 | 368 default: |
34249
edee96cf6d71
vo_caca: reformat and prettyprint as K&R, shorten some lines
diego
parents:
33305
diff
changeset
|
369 return VO_NOTIMPL; |
12129 | 370 } |
371 } |