Remove dead code.
[mplayer/greg.git] / input / input.h
blob69c6d4b959d94cdc32d497f094670ab9af914576
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_INPUT_H
20 #define MPLAYER_INPUT_H
22 #include "m_config.h"
24 // All command IDs
25 typedef enum {
26 MP_CMD_SEEK,
27 MP_CMD_AUDIO_DELAY,
28 MP_CMD_QUIT,
29 MP_CMD_PAUSE,
30 MP_CMD_GRAB_FRAMES, // deprecated: was a no-op command for years
31 MP_CMD_PLAY_TREE_STEP,
32 MP_CMD_PLAY_TREE_UP_STEP,
33 MP_CMD_PLAY_ALT_SRC_STEP,
34 MP_CMD_SUB_DELAY,
35 MP_CMD_OSD,
36 MP_CMD_VOLUME,
37 MP_CMD_MIXER_USEMASTER,
38 MP_CMD_CONTRAST,
39 MP_CMD_BRIGHTNESS,
40 MP_CMD_HUE,
41 MP_CMD_SATURATION,
42 MP_CMD_FRAMEDROPPING,
43 MP_CMD_TV_STEP_CHANNEL,
44 MP_CMD_TV_STEP_NORM,
45 MP_CMD_TV_STEP_CHANNEL_LIST,
46 MP_CMD_VO_FULLSCREEN,
47 MP_CMD_SUB_POS,
48 MP_CMD_DVDNAV,
49 MP_CMD_SCREENSHOT,
50 MP_CMD_PANSCAN,
51 MP_CMD_MUTE,
52 MP_CMD_LOADFILE,
53 MP_CMD_LOADLIST,
54 MP_CMD_VF_CHANGE_RECTANGLE,
55 MP_CMD_GAMMA,
56 MP_CMD_SUB_VISIBILITY,
57 MP_CMD_VOBSUB_LANG, // deprecated: combined with SUB_SELECT
58 MP_CMD_MENU,
59 MP_CMD_SET_MENU,
60 MP_CMD_GET_TIME_LENGTH,
61 MP_CMD_GET_PERCENT_POS,
62 MP_CMD_SUB_STEP,
63 MP_CMD_TV_SET_CHANNEL,
64 MP_CMD_EDL_MARK,
65 MP_CMD_SUB_ALIGNMENT,
66 MP_CMD_TV_LAST_CHANNEL,
67 MP_CMD_OSD_SHOW_TEXT,
68 MP_CMD_TV_SET_FREQ,
69 MP_CMD_TV_SET_NORM,
70 MP_CMD_TV_SET_BRIGHTNESS,
71 MP_CMD_TV_SET_CONTRAST,
72 MP_CMD_TV_SET_HUE,
73 MP_CMD_TV_SET_SATURATION,
74 MP_CMD_GET_VO_FULLSCREEN,
75 MP_CMD_GET_SUB_VISIBILITY,
76 MP_CMD_SUB_FORCED_ONLY,
77 MP_CMD_VO_ONTOP,
78 MP_CMD_SUB_SELECT,
79 MP_CMD_VO_ROOTWIN,
80 MP_CMD_SWITCH_VSYNC,
81 MP_CMD_SWITCH_RATIO,
82 MP_CMD_FRAME_STEP,
83 MP_CMD_SPEED_INCR,
84 MP_CMD_SPEED_MULT,
85 MP_CMD_SPEED_SET,
86 MP_CMD_RUN,
87 MP_CMD_SUB_LOG,
88 MP_CMD_SWITCH_AUDIO,
89 MP_CMD_GET_TIME_POS,
90 MP_CMD_SUB_LOAD,
91 MP_CMD_SUB_REMOVE,
92 MP_CMD_KEYDOWN_EVENTS,
93 MP_CMD_VO_BORDER,
94 MP_CMD_SET_PROPERTY,
95 MP_CMD_GET_PROPERTY,
96 MP_CMD_OSD_SHOW_PROPERTY_TEXT,
97 MP_CMD_OSD_SHOW_PROGRESSION,
98 MP_CMD_SEEK_CHAPTER,
99 MP_CMD_FILE_FILTER,
100 MP_CMD_GET_FILENAME,
101 MP_CMD_GET_VIDEO_CODEC,
102 MP_CMD_GET_VIDEO_BITRATE,
103 MP_CMD_GET_VIDEO_RESOLUTION,
104 MP_CMD_GET_AUDIO_CODEC,
105 MP_CMD_GET_AUDIO_BITRATE,
106 MP_CMD_GET_AUDIO_SAMPLES,
107 MP_CMD_GET_META_TITLE,
108 MP_CMD_GET_META_ARTIST,
109 MP_CMD_GET_META_ALBUM,
110 MP_CMD_GET_META_YEAR,
111 MP_CMD_GET_META_COMMENT,
112 MP_CMD_GET_META_TRACK,
113 MP_CMD_GET_META_GENRE,
114 MP_CMD_RADIO_STEP_CHANNEL,
115 MP_CMD_RADIO_SET_CHANNEL,
116 MP_CMD_RADIO_SET_FREQ,
117 MP_CMD_SET_MOUSE_POS,
118 MP_CMD_STEP_PROPERTY,
119 MP_CMD_RADIO_STEP_FREQ,
120 MP_CMD_TV_STEP_FREQ,
121 MP_CMD_LOOP,
122 MP_CMD_BALANCE,
123 MP_CMD_SUB_SCALE,
124 MP_CMD_TV_TELETEXT_ADD_DEC,
125 MP_CMD_TV_TELETEXT_GO_LINK,
126 MP_CMD_TV_START_SCAN,
127 MP_CMD_SUB_SOURCE,
128 MP_CMD_SUB_FILE,
129 MP_CMD_SUB_VOB,
130 MP_CMD_SUB_DEMUX,
131 MP_CMD_SWITCH_ANGLE,
132 MP_CMD_ASS_USE_MARGINS,
133 MP_CMD_SWITCH_TITLE,
134 MP_CMD_STOP,
136 /// DVDNAV commands
137 MP_CMD_DVDNAV_UP = 1000,
138 MP_CMD_DVDNAV_DOWN,
139 MP_CMD_DVDNAV_LEFT,
140 MP_CMD_DVDNAV_RIGHT,
141 MP_CMD_DVDNAV_MENU,
142 MP_CMD_DVDNAV_SELECT,
143 MP_CMD_DVDNAV_PREVMENU,
144 MP_CMD_DVDNAV_MOUSECLICK,
146 /// GUI commands
147 MP_CMD_GUI_EVENTS = 5000,
148 MP_CMD_GUI_LOADFILE,
149 MP_CMD_GUI_LOADSUBTITLE,
150 MP_CMD_GUI_ABOUT,
151 MP_CMD_GUI_PLAY,
152 MP_CMD_GUI_STOP,
153 MP_CMD_GUI_PLAYLIST,
154 MP_CMD_GUI_PREFERENCES,
155 MP_CMD_GUI_FULLSCREEN,
156 MP_CMD_GUI_SKINBROWSER,
158 /// DVB commands
159 MP_CMD_DVB_SET_CHANNEL = 5101,
161 /// Console commands
162 MP_CMD_CHELP = 7000,
163 MP_CMD_CEXIT,
164 MP_CMD_CHIDE,
166 /// Audio Filter commands
167 MP_CMD_AF_SWITCH,
168 MP_CMD_AF_ADD,
169 MP_CMD_AF_DEL,
170 MP_CMD_AF_CLR,
172 } mp_command_type;
174 // The arg types
175 #define MP_CMD_ARG_INT 0
176 #define MP_CMD_ARG_FLOAT 1
177 #define MP_CMD_ARG_STRING 2
178 #define MP_CMD_ARG_VOID 3
180 #ifndef MP_CMD_MAX_ARGS
181 #define MP_CMD_MAX_ARGS 10
182 #endif
184 // Error codes for the drivers
186 // An error occurred but we can continue
187 #define MP_INPUT_ERROR -1
188 // A fatal error occurred, this driver should be removed
189 #define MP_INPUT_DEAD -2
190 // No input was available
191 #define MP_INPUT_NOTHING -3
192 //! Input will be available if you try again
193 #define MP_INPUT_RETRY -4
195 // For the key's drivers, if possible you can send key up and key down
196 // events. Key up is the default, to send a key down you must use the
197 // OR operator between the key code and MP_KEY_DOWN.
198 #define MP_KEY_DOWN (1<<29)
199 // Use this when the key shouldn't be auto-repeated (like mouse buttons)
200 #define MP_NO_REPEAT_KEY (1<<28)
202 #ifndef MP_MAX_KEY_DOWN
203 #define MP_MAX_KEY_DOWN 32
204 #endif
206 typedef union mp_cmd_arg_value {
207 int i;
208 float f;
209 char* s;
210 void* v;
211 } mp_cmd_arg_value_t;
213 typedef struct mp_cmd_arg {
214 int type;
215 mp_cmd_arg_value_t v;
216 } mp_cmd_arg_t;
218 typedef struct mp_cmd {
219 int id;
220 char* name;
221 int nargs;
222 mp_cmd_arg_t args[MP_CMD_MAX_ARGS];
223 int pausing;
224 } mp_cmd_t;
227 typedef struct mp_cmd_bind {
228 int input[MP_MAX_KEY_DOWN+1];
229 char* cmd;
230 } mp_cmd_bind_t;
232 typedef struct mp_key_name {
233 int key;
234 char* name;
235 } mp_key_name_t;
237 // These typedefs are for the drivers. They are the functions used to retrieve
238 // the next key code or command.
240 // These functions should return the key code or one of the error codes
241 typedef int (*mp_key_func_t)(int fd);
242 // These functions should act like read but they must use our error code (if needed ;-)
243 typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
244 // These are used to close the driver
245 typedef void (*mp_close_func_t)(int fd);
247 // Set this to grab all incoming key codes
248 extern int (*mp_input_key_cb)(int code);
249 // Should return 1 if the command was processed
250 typedef int (*mp_input_cmd_filter)(mp_cmd_t* cmd, int paused, void* ctx);
252 // This function adds a new key driver.
253 // The first arg is a file descriptor (use a negative value if you don't use any fd)
254 // The second arg tells if we use select on the fd to know if something is available.
255 // The third arg is optional. If null a default function wich reads an int from the
256 // fd will be used.
257 // The last arg can be NULL if nothing is needed to close the driver. The close
258 // function can be used
260 mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func);
262 // This removes a cmd driver, you usually don't need to use it.
263 void
264 mp_input_rm_cmd_fd(int fd);
266 // The args are the same as for the key's drivers. If you don't use any valid fd you MUST
267 // give a read_func.
269 mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func);
271 // As for the cmd one you usually don't need this function.
272 void
273 mp_input_rm_key_fd(int fd);
275 int mp_input_add_event_fd(int fd, void (*read_func)(void));
277 void mp_input_rm_event_fd(int fd);
279 /// Get input key from its name.
280 int mp_input_get_key_from_name(const char *name);
282 // This function can be used to put a command in the system again. It's used by libmpdemux
283 // when it performs a blocking operation to resend the command it received to the main
284 // loop.
286 mp_input_queue_cmd(mp_cmd_t* cmd);
288 // This function retrieves the next available command waiting no more than time msec.
289 // If pause is true, the next input will always return a pause command.
290 mp_cmd_t*
291 mp_input_get_cmd(int time, int paused, int peek_only);
293 mp_cmd_t*
294 mp_input_parse_cmd(char* str);
297 * Parse and queue commands separated by '\n'.
298 * @return count of commands new queued.
300 int mp_input_parse_and_queue_cmds(const char *str);
302 /// These filters allow you to process the command before MPlayer.
303 /// If a filter returns a true value mp_input_get_cmd will return NULL.
304 void
305 mp_input_add_cmd_filter(mp_input_cmd_filter, void* ctx);
307 // After getting a command from mp_input_get_cmd you need to free it using this
308 // function
309 void
310 mp_cmd_free(mp_cmd_t* cmd);
312 // This creates a copy of a command (used by the auto repeat stuff).
313 mp_cmd_t*
314 mp_cmd_clone(mp_cmd_t* cmd);
316 // Set current input section
317 void
318 mp_input_set_section(char *name);
320 // Get current input section
321 char*
322 mp_input_get_section(void);
324 // When you create a new driver you should add it in these 2 functions.
325 void
326 mp_input_init(int use_gui);
328 void
329 mp_input_uninit(void);
331 void mp_input_register_options(m_config_t* cfg);
333 // Interruptible usleep: (used by libmpdemux)
335 mp_input_check_interrupt(int time);
337 extern int async_quit_request;
339 #endif /* MPLAYER_INPUT_H */