1 #ifndef MPLAYER_INPUT_H
2 #define MPLAYER_INPUT_H
6 #define MP_CMD_AUDIO_DELAY 1
9 // #define MP_CMD_GRAB_FRAMES 4 // was a no-op command for years
10 #define MP_CMD_PLAY_TREE_STEP 5
11 #define MP_CMD_PLAY_TREE_UP_STEP 6
12 #define MP_CMD_PLAY_ALT_SRC_STEP 7
13 #define MP_CMD_SUB_DELAY 8
15 #define MP_CMD_VOLUME 10
16 #define MP_CMD_MIXER_USEMASTER 11
17 #define MP_CMD_CONTRAST 12
18 #define MP_CMD_BRIGHTNESS 13
20 #define MP_CMD_SATURATION 15
21 #define MP_CMD_FRAMEDROPPING 16
22 #define MP_CMD_TV_STEP_CHANNEL 17
23 #define MP_CMD_TV_STEP_NORM 18
24 #define MP_CMD_TV_STEP_CHANNEL_LIST 19
25 #define MP_CMD_VO_FULLSCREEN 20
26 #define MP_CMD_SUB_POS 21
27 #define MP_CMD_DVDNAV 22
28 #define MP_CMD_SCREENSHOT 23
29 #define MP_CMD_PANSCAN 24
30 #define MP_CMD_MUTE 25
31 #define MP_CMD_LOADFILE 26
32 #define MP_CMD_LOADLIST 27
33 #define MP_CMD_VF_CHANGE_RECTANGLE 28
34 #define MP_CMD_GAMMA 29
35 #define MP_CMD_SUB_VISIBILITY 30
36 // #define MP_CMD_VOBSUB_LANG 31 // combined with SUB_SELECT
37 #define MP_CMD_MENU 32
38 #define MP_CMD_SET_MENU 33
39 #define MP_CMD_GET_TIME_LENGTH 34
40 #define MP_CMD_GET_PERCENT_POS 35
41 #define MP_CMD_SUB_STEP 36
42 #define MP_CMD_TV_SET_CHANNEL 37
43 #define MP_CMD_EDL_MARK 38
44 #define MP_CMD_SUB_ALIGNMENT 39
45 #define MP_CMD_TV_LAST_CHANNEL 40
46 #define MP_CMD_OSD_SHOW_TEXT 41
47 #define MP_CMD_TV_SET_FREQ 42
48 #define MP_CMD_TV_SET_NORM 43
49 #define MP_CMD_TV_SET_BRIGHTNESS 44
50 #define MP_CMD_TV_SET_CONTRAST 45
51 #define MP_CMD_TV_SET_HUE 46
52 #define MP_CMD_TV_SET_SATURATION 47
53 #define MP_CMD_GET_VO_FULLSCREEN 48
54 #define MP_CMD_GET_SUB_VISIBILITY 49
55 #define MP_CMD_SUB_FORCED_ONLY 50
56 #define MP_CMD_VO_ONTOP 51
57 #define MP_CMD_SUB_SELECT 52
58 #define MP_CMD_VO_ROOTWIN 53
59 #define MP_CMD_SWITCH_VSYNC 54
60 #define MP_CMD_SWITCH_RATIO 55
61 #define MP_CMD_FRAME_STEP 56
62 #define MP_CMD_SPEED_INCR 57
63 #define MP_CMD_SPEED_MULT 58
64 #define MP_CMD_SPEED_SET 59
66 #define MP_CMD_SUB_LOG 61
67 #define MP_CMD_SWITCH_AUDIO 62
68 #define MP_CMD_GET_TIME_POS 63
69 #define MP_CMD_SUB_LOAD 64
70 #define MP_CMD_SUB_REMOVE 65
71 #define MP_CMD_KEYDOWN_EVENTS 66
72 #define MP_CMD_VO_BORDER 67
73 #define MP_CMD_SET_PROPERTY 68
74 #define MP_CMD_GET_PROPERTY 69
75 #define MP_CMD_OSD_SHOW_PROPERTY_TEXT 70
76 #define MP_CMD_SEEK_CHAPTER 71
77 #define MP_CMD_FILE_FILTER 72
78 #define MP_CMD_GET_FILENAME 73
79 #define MP_CMD_GET_VIDEO_CODEC 74
80 #define MP_CMD_GET_VIDEO_BITRATE 75
81 #define MP_CMD_GET_VIDEO_RESOLUTION 76
82 #define MP_CMD_GET_AUDIO_CODEC 77
83 #define MP_CMD_GET_AUDIO_BITRATE 78
84 #define MP_CMD_GET_AUDIO_SAMPLES 79
85 #define MP_CMD_GET_META_TITLE 80
86 #define MP_CMD_GET_META_ARTIST 81
87 #define MP_CMD_GET_META_ALBUM 82
88 #define MP_CMD_GET_META_YEAR 83
89 #define MP_CMD_GET_META_COMMENT 84
90 #define MP_CMD_GET_META_TRACK 85
91 #define MP_CMD_GET_META_GENRE 86
92 #define MP_CMD_RADIO_STEP_CHANNEL 87
93 #define MP_CMD_RADIO_SET_CHANNEL 88
94 #define MP_CMD_RADIO_SET_FREQ 89
95 #define MP_CMD_SET_MOUSE_POS 90
96 #define MP_CMD_STEP_PROPERTY 91
97 #define MP_CMD_RADIO_STEP_FREQ 92
98 #define MP_CMD_TV_STEP_FREQ 93
99 #define MP_CMD_LOOP 94
100 #define MP_CMD_BALANCE 96
101 #define MP_CMD_SUB_SCALE 97
102 #define MP_CMD_TV_TELETEXT_ADD_DEC 98
103 #define MP_CMD_TV_TELETEXT_GO_LINK 99
104 #define MP_CMD_TV_START_SCAN 100
105 #define MP_CMD_SUB_SOURCE 101
106 #define MP_CMD_SUB_FILE 102
107 #define MP_CMD_SUB_VOB 103
108 #define MP_CMD_SUB_DEMUX 104
109 #define MP_CMD_SWITCH_ANGLE 105
110 #define MP_CMD_ASS_USE_MARGINS 106
111 #define MP_CMD_SWITCH_TITLE 107
112 #define MP_CMD_STOP 108
114 #define MP_CMD_GUI_EVENTS 5000
115 #define MP_CMD_GUI_LOADFILE 5001
116 #define MP_CMD_GUI_LOADSUBTITLE 5002
117 #define MP_CMD_GUI_ABOUT 5003
118 #define MP_CMD_GUI_PLAY 5004
119 #define MP_CMD_GUI_STOP 5005
120 #define MP_CMD_GUI_PLAYLIST 5006
121 #define MP_CMD_GUI_PREFERENCES 5007
122 #define MP_CMD_GUI_FULLSCREEN 5008
123 #define MP_CMD_GUI_SKINBROWSER 5009
125 #ifdef HAS_DVBIN_SUPPORT
126 #define MP_CMD_DVB_SET_CHANNEL 5101
129 #define MP_CMD_DVDNAV_UP 1
130 #define MP_CMD_DVDNAV_DOWN 2
131 #define MP_CMD_DVDNAV_LEFT 3
132 #define MP_CMD_DVDNAV_RIGHT 4
133 #define MP_CMD_DVDNAV_MENU 5
134 #define MP_CMD_DVDNAV_SELECT 6
135 #define MP_CMD_DVDNAV_PREVMENU 7
136 #define MP_CMD_DVDNAV_MOUSECLICK 8
139 #define MP_CMD_CHELP 7000
140 #define MP_CMD_CEXIT 7001
141 #define MP_CMD_CHIDE 7002
144 #define MP_CMD_ARG_INT 0
145 #define MP_CMD_ARG_FLOAT 1
146 #define MP_CMD_ARG_STRING 2
147 #define MP_CMD_ARG_VOID 3
149 #ifndef MP_CMD_MAX_ARGS
150 #define MP_CMD_MAX_ARGS 10
153 // Error codes for the drivers
155 // An error occurred but we can continue
156 #define MP_INPUT_ERROR -1
157 // A fatal error occurred, this driver should be removed
158 #define MP_INPUT_DEAD -2
159 // No input was available
160 #define MP_INPUT_NOTHING -3
161 //! Input will be available if you try again
162 #define MP_INPUT_RETRY -4
164 // For the key's drivers, if possible you can send key up and key down
165 // events. Key up is the default, to send a key down you must use the
166 // OR operator between the key code and MP_KEY_DOWN.
167 #define MP_KEY_DOWN (1<<29)
168 // Use this when the key shouldn't be auto-repeated (like mouse buttons)
169 #define MP_NO_REPEAT_KEY (1<<28)
171 #ifndef MP_MAX_KEY_DOWN
172 #define MP_MAX_KEY_DOWN 32
177 typedef union mp_cmd_arg_value
{
182 } mp_cmd_arg_value_t
;
184 typedef struct mp_cmd_arg
{
186 mp_cmd_arg_value_t v
;
189 typedef struct mp_cmd
{
193 mp_cmd_arg_t args
[MP_CMD_MAX_ARGS
];
198 // These typedefs are for the drivers. They are the functions used to retrieve
199 // the next key code or command.
201 // These functions should return the key code or one of the error codes
202 typedef int (*mp_key_func_t
)(void *ctx
, int fd
);
203 // These functions should act like read but they must use our error code (if needed ;-)
204 typedef int (*mp_cmd_func_t
)(int fd
,char* dest
,int size
);
205 // These are used to close the driver
206 typedef void (*mp_close_func_t
)(int fd
);
208 // Set this to grab all incoming key codes
209 extern int (*mp_input_key_cb
)(int code
);
210 // Should return 1 if the command was processed
211 typedef int (*mp_input_cmd_filter
)(mp_cmd_t
* cmd
, int paused
, void* ctx
);
213 // This function adds a new key driver.
214 // The first arg is a file descriptor (use a negative value if you don't use any fd)
215 // The second arg tells if we use select on the fd to know if something is available.
216 // The third arg is optional. If null a default function wich reads an int from the
218 // The last arg can be NULL if nothing is needed to close the driver. The close
219 // function can be used
220 int mp_input_add_cmd_fd(struct input_ctx
*ictx
, int fd
, int select
,
221 mp_cmd_func_t read_func
, mp_close_func_t close_func
);
223 // This removes a cmd driver, you usually don't need to use it.
224 void mp_input_rm_cmd_fd(struct input_ctx
*ictx
, int fd
);
226 // The args are the same as for the key's drivers. If you don't use any valid fd you MUST
228 int mp_input_add_key_fd(struct input_ctx
*ictx
, int fd
, int select
,
229 mp_key_func_t read_func
, mp_close_func_t close_func
,
232 // As for the cmd one you usually don't need this function.
233 void mp_input_rm_key_fd(struct input_ctx
*ictx
, int fd
);
235 /// Get input key from its name.
236 int mp_input_get_key_from_name(const char *name
);
238 // This function can be used to put a command in the system again. It's used by libmpdemux
239 // when it performs a blocking operation to resend the command it received to the main
241 int mp_input_queue_cmd(struct input_ctx
*ictx
, mp_cmd_t
* cmd
);
243 // This function retrieves the next available command waiting no more than time msec.
244 // If pause is true, the next input will always return a pause command.
246 mp_input_get_cmd(struct input_ctx
*ictx
, int time
, int paused
, int peek_only
);
249 mp_input_parse_cmd(char* str
);
252 * Parse and queue commands separated by '\n'.
253 * @return count of commands new queued.
255 int mp_input_parse_and_queue_cmds(struct input_ctx
*ictx
, const char *str
);
257 /// These filters allow you to process the command before MPlayer.
258 /// If a filter returns a true value mp_input_get_cmd will return NULL.
260 mp_input_add_cmd_filter(mp_input_cmd_filter
, void* ctx
);
262 // After getting a command from mp_input_get_cmd you need to free it using this
265 mp_cmd_free(mp_cmd_t
* cmd
);
267 // This creates a copy of a command (used by the auto repeat stuff).
269 mp_cmd_clone(mp_cmd_t
* cmd
);
271 // Set current input section
272 void mp_input_set_section(struct input_ctx
*ictx
, char *name
);
274 // Get current input section
275 char *mp_input_get_section(struct input_ctx
*ictx
);
277 // When you create a new driver you should add it in these 2 functions.
279 struct input_ctx
*mp_input_init(struct input_conf
*input_conf
, int use_gui
);
281 void mp_input_uninit(struct input_ctx
*ictx
);
283 // Interruptible usleep: (used by libmpdemux)
285 mp_input_check_interrupt(struct input_ctx
*ictx
, int time
);
287 extern int async_quit_request
;
289 #endif /* MPLAYER_INPUT_H */