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
28 MP_CMD_GRAB_FRAMES
, // deprecated: was a no-op command for years
29 MP_CMD_PLAY_TREE_STEP
,
30 MP_CMD_PLAY_TREE_UP_STEP
,
31 MP_CMD_PLAY_ALT_SRC_STEP
,
35 MP_CMD_MIXER_USEMASTER
,
41 MP_CMD_TV_STEP_CHANNEL
,
43 MP_CMD_TV_STEP_CHANNEL_LIST
,
52 MP_CMD_VF_CHANGE_RECTANGLE
,
54 MP_CMD_SUB_VISIBILITY
,
55 MP_CMD_VOBSUB_LANG
, // deprecated: combined with SUB_SELECT
58 MP_CMD_GET_TIME_LENGTH
,
59 MP_CMD_GET_PERCENT_POS
,
61 MP_CMD_TV_SET_CHANNEL
,
64 MP_CMD_TV_LAST_CHANNEL
,
68 MP_CMD_TV_SET_BRIGHTNESS
,
69 MP_CMD_TV_SET_CONTRAST
,
71 MP_CMD_TV_SET_SATURATION
,
72 MP_CMD_GET_VO_FULLSCREEN
,
73 MP_CMD_GET_SUB_VISIBILITY
,
74 MP_CMD_SUB_FORCED_ONLY
,
90 MP_CMD_KEYDOWN_EVENTS
,
93 MP_CMD_SET_PROPERTY_OSD
,
95 MP_CMD_OSD_SHOW_PROPERTY_TEXT
,
99 MP_CMD_GET_VIDEO_CODEC
,
100 MP_CMD_GET_VIDEO_BITRATE
,
101 MP_CMD_GET_VIDEO_RESOLUTION
,
102 MP_CMD_GET_AUDIO_CODEC
,
103 MP_CMD_GET_AUDIO_BITRATE
,
104 MP_CMD_GET_AUDIO_SAMPLES
,
105 MP_CMD_GET_META_TITLE
,
106 MP_CMD_GET_META_ARTIST
,
107 MP_CMD_GET_META_ALBUM
,
108 MP_CMD_GET_META_YEAR
,
109 MP_CMD_GET_META_COMMENT
,
110 MP_CMD_GET_META_TRACK
,
111 MP_CMD_GET_META_GENRE
,
112 MP_CMD_RADIO_STEP_CHANNEL
,
113 MP_CMD_RADIO_SET_CHANNEL
,
114 MP_CMD_RADIO_SET_FREQ
,
115 MP_CMD_SET_MOUSE_POS
,
116 MP_CMD_STEP_PROPERTY
,
117 MP_CMD_STEP_PROPERTY_OSD
,
118 MP_CMD_RADIO_STEP_FREQ
,
123 MP_CMD_TV_TELETEXT_ADD_DEC
,
124 MP_CMD_TV_TELETEXT_GO_LINK
,
125 MP_CMD_TV_START_SCAN
,
131 MP_CMD_ASS_USE_MARGINS
,
136 MP_CMD_DVDNAV_UP
= 1000,
141 MP_CMD_DVDNAV_SELECT
,
142 MP_CMD_DVDNAV_PREVMENU
,
143 MP_CMD_DVDNAV_MOUSECLICK
,
146 MP_CMD_DVB_SET_CHANNEL
= 5101,
155 #define MP_CMD_ARG_INT 0
156 #define MP_CMD_ARG_FLOAT 1
157 #define MP_CMD_ARG_STRING 2
158 #define MP_CMD_ARG_VOID 3
160 #ifndef MP_CMD_MAX_ARGS
161 #define MP_CMD_MAX_ARGS 10
164 // Error codes for the drivers
166 // An error occurred but we can continue
167 #define MP_INPUT_ERROR -1
168 // A fatal error occurred, this driver should be removed
169 #define MP_INPUT_DEAD -2
170 // No input was available
171 #define MP_INPUT_NOTHING -3
172 //! Input will be available if you try again
173 #define MP_INPUT_RETRY -4
175 // For the key's drivers, if possible you can send key up and key down
176 // events. Key up is the default, to send a key down you must use the
177 // OR operator between the key code and MP_KEY_DOWN.
178 #define MP_KEY_DOWN (1<<29)
179 // Use this when the key shouldn't be auto-repeated (like mouse buttons)
180 #define MP_NO_REPEAT_KEY (1<<28)
182 #ifndef MP_MAX_KEY_DOWN
183 #define MP_MAX_KEY_DOWN 32
188 typedef union mp_cmd_arg_value
{
193 } mp_cmd_arg_value_t
;
195 typedef struct mp_cmd_arg
{
197 mp_cmd_arg_value_t v
;
200 typedef struct mp_cmd
{
204 mp_cmd_arg_t args
[MP_CMD_MAX_ARGS
];
209 // These typedefs are for the drivers. They are the functions used to retrieve
210 // the next key code or command.
212 // These functions should return the key code or one of the error codes
213 typedef int (*mp_key_func_t
)(void *ctx
, int fd
);
214 // These functions should act like read but they must use our error code (if needed ;-)
215 typedef int (*mp_cmd_func_t
)(int fd
,char* dest
,int size
);
216 // These are used to close the driver
217 typedef void (*mp_close_func_t
)(int fd
);
219 // Set this to grab all incoming key codes
220 extern int (*mp_input_key_cb
)(int code
);
221 // Should return 1 if the command was processed
222 typedef int (*mp_input_cmd_filter
)(mp_cmd_t
* cmd
, int paused
, void* ctx
);
224 // This function adds a new key driver.
225 // The first arg is a file descriptor (use a negative value if you don't use any fd)
226 // The second arg tells if we use select on the fd to know if something is available.
227 // The third arg is optional. If null a default function wich reads an int from the
229 // The last arg can be NULL if nothing is needed to close the driver. The close
230 // function can be used
231 int mp_input_add_cmd_fd(struct input_ctx
*ictx
, int fd
, int select
,
232 mp_cmd_func_t read_func
, mp_close_func_t close_func
);
234 // This removes a cmd driver, you usually don't need to use it.
235 void mp_input_rm_cmd_fd(struct input_ctx
*ictx
, int fd
);
237 // The args are the same as for the key's drivers. If you don't use any valid fd you MUST
239 int mp_input_add_key_fd(struct input_ctx
*ictx
, int fd
, int select
,
240 mp_key_func_t read_func
, mp_close_func_t close_func
,
243 // As for the cmd one you usually don't need this function.
244 void mp_input_rm_key_fd(struct input_ctx
*ictx
, int fd
);
246 /// Get input key from its name.
247 int mp_input_get_key_from_name(const char *name
);
249 // This function can be used to put a command in the system again. It's used by libmpdemux
250 // when it performs a blocking operation to resend the command it received to the main
252 int mp_input_queue_cmd(struct input_ctx
*ictx
, mp_cmd_t
* cmd
);
254 // This function retrieves the next available command waiting no more than time msec.
255 // If pause is true, the next input will always return a pause command.
257 mp_input_get_cmd(struct input_ctx
*ictx
, int time
, int paused
, int peek_only
);
260 mp_input_parse_cmd(char* str
);
263 * Parse and queue commands separated by '\n'.
264 * @return count of commands new queued.
266 int mp_input_parse_and_queue_cmds(struct input_ctx
*ictx
, const char *str
);
268 /// These filters allow you to process the command before MPlayer.
269 /// If a filter returns a true value mp_input_get_cmd will return NULL.
271 mp_input_add_cmd_filter(mp_input_cmd_filter
, void* ctx
);
273 // After getting a command from mp_input_get_cmd you need to free it using this
276 mp_cmd_free(mp_cmd_t
* cmd
);
278 // This creates a copy of a command (used by the auto repeat stuff).
280 mp_cmd_clone(mp_cmd_t
* cmd
);
282 // Set current input section
283 void mp_input_set_section(struct input_ctx
*ictx
, char *name
);
285 // Get current input section
286 char *mp_input_get_section(struct input_ctx
*ictx
);
288 // When you create a new driver you should add it in these 2 functions.
290 struct input_ctx
*mp_input_init(struct input_conf
*input_conf
);
292 void mp_input_uninit(struct input_ctx
*ictx
);
295 void mp_input_register_options(struct m_config
*cfg
);
297 // Interruptible usleep: (used by libmpdemux)
299 mp_input_check_interrupt(struct input_ctx
*ictx
, int time
);
301 extern int async_quit_request
;
303 #endif /* MPLAYER_INPUT_H */