sync mga_vid.h to revision 265 from the mga_vid repo
[mplayer/glamo.git] / input / input.h
blobe6381b3e3447481d67a71c79922a38b265a21c56
1 #ifndef MPLAYER_INPUT_H
2 #define MPLAYER_INPUT_H
4 // All command IDs
5 #define MP_CMD_SEEK 0
6 #define MP_CMD_AUDIO_DELAY 1
7 #define MP_CMD_QUIT 2
8 #define MP_CMD_PAUSE 3
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
14 #define MP_CMD_OSD 9
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
19 #define MP_CMD_HUE 14
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
65 #define MP_CMD_RUN 60
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
113 #define MP_CMD_GUI_EVENTS 5000
114 #define MP_CMD_GUI_LOADFILE 5001
115 #define MP_CMD_GUI_LOADSUBTITLE 5002
116 #define MP_CMD_GUI_ABOUT 5003
117 #define MP_CMD_GUI_PLAY 5004
118 #define MP_CMD_GUI_STOP 5005
119 #define MP_CMD_GUI_PLAYLIST 5006
120 #define MP_CMD_GUI_PREFERENCES 5007
121 #define MP_CMD_GUI_FULLSCREEN 5008
122 #define MP_CMD_GUI_SKINBROWSER 5009
124 #ifdef HAS_DVBIN_SUPPORT
125 #define MP_CMD_DVB_SET_CHANNEL 5101
126 #endif
128 #define MP_CMD_DVDNAV_UP 1
129 #define MP_CMD_DVDNAV_DOWN 2
130 #define MP_CMD_DVDNAV_LEFT 3
131 #define MP_CMD_DVDNAV_RIGHT 4
132 #define MP_CMD_DVDNAV_MENU 5
133 #define MP_CMD_DVDNAV_SELECT 6
134 #define MP_CMD_DVDNAV_PREVMENU 7
135 #define MP_CMD_DVDNAV_MOUSECLICK 8
137 /// Console commands
138 #define MP_CMD_CHELP 7000
139 #define MP_CMD_CEXIT 7001
140 #define MP_CMD_CHIDE 7002
142 // The arg types
143 #define MP_CMD_ARG_INT 0
144 #define MP_CMD_ARG_FLOAT 1
145 #define MP_CMD_ARG_STRING 2
146 #define MP_CMD_ARG_VOID 3
148 #ifndef MP_CMD_MAX_ARGS
149 #define MP_CMD_MAX_ARGS 10
150 #endif
152 // Error codes for the drivers
154 // An error occurred but we can continue
155 #define MP_INPUT_ERROR -1
156 // A fatal error occurred, this driver should be removed
157 #define MP_INPUT_DEAD -2
158 // No input was available
159 #define MP_INPUT_NOTHING -3
160 //! Input will be available if you try again
161 #define MP_INPUT_RETRY -4
163 // For the key's drivers, if possible you can send key up and key down
164 // events. Key up is the default, to send a key down you must use the
165 // OR operator between the key code and MP_KEY_DOWN.
166 #define MP_KEY_DOWN (1<<29)
167 // Use this when the key shouldn't be auto-repeated (like mouse buttons)
168 #define MP_NO_REPEAT_KEY (1<<28)
170 #ifndef MP_MAX_KEY_DOWN
171 #define MP_MAX_KEY_DOWN 32
172 #endif
174 typedef union mp_cmd_arg_value {
175 int i;
176 float f;
177 char* s;
178 void* v;
179 } mp_cmd_arg_value_t;
181 typedef struct mp_cmd_arg {
182 int type;
183 mp_cmd_arg_value_t v;
184 } mp_cmd_arg_t;
186 typedef struct mp_cmd {
187 int id;
188 char* name;
189 int nargs;
190 mp_cmd_arg_t args[MP_CMD_MAX_ARGS];
191 int pausing;
192 } mp_cmd_t;
195 typedef struct mp_cmd_bind {
196 int input[MP_MAX_KEY_DOWN+1];
197 char* cmd;
198 } mp_cmd_bind_t;
200 typedef struct mp_key_name {
201 int key;
202 char* name;
203 } mp_key_name_t;
205 // These typedefs are for the drivers. They are the functions used to retrieve
206 // the next key code or command.
208 // These functions should return the key code or one of the error codes
209 typedef int (*mp_key_func_t)(int fd);
210 // These functions should act like read but they must use our error code (if needed ;-)
211 typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
212 // These are used to close the driver
213 typedef void (*mp_close_func_t)(int fd);
215 // Set this to grab all incoming key codes
216 extern int (*mp_input_key_cb)(int code);
217 // Should return 1 if the command was processed
218 typedef int (*mp_input_cmd_filter)(mp_cmd_t* cmd, int paused, void* ctx);
220 // This function adds a new key driver.
221 // The first arg is a file descriptor (use a negative value if you don't use any fd)
222 // The second arg tells if we use select on the fd to know if something is available.
223 // The third arg is optional. If null a default function wich reads an int from the
224 // fd will be used.
225 // The last arg can be NULL if nothing is needed to close the driver. The close
226 // function can be used
228 mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func);
230 // This removes a cmd driver, you usually don't need to use it.
231 void
232 mp_input_rm_cmd_fd(int fd);
234 // The args are the same as for the key's drivers. If you don't use any valid fd you MUST
235 // give a read_func.
237 mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func);
239 // As for the cmd one you usually don't need this function.
240 void
241 mp_input_rm_key_fd(int fd);
243 int mp_input_add_event_fd(int fd, void (*read_func)(void));
245 void mp_input_rm_event_fd(int fd);
247 /// Get input key from its name.
248 int mp_input_get_key_from_name(const char *name);
250 // This function can be used to put a command in the system again. It's used by libmpdemux
251 // when it performs a blocking operation to resend the command it received to the main
252 // loop.
254 mp_input_queue_cmd(mp_cmd_t* cmd);
256 // This function retrieves the next available command waiting no more than time msec.
257 // If pause is true, the next input will always return a pause command.
258 mp_cmd_t*
259 mp_input_get_cmd(int time, int paused, int peek_only);
261 mp_cmd_t*
262 mp_input_parse_cmd(char* str);
265 * Parse and queue commands separated by '\n'.
266 * @return count of commands new queued.
268 int mp_input_parse_and_queue_cmds(const char *str);
270 /// These filters allow you to process the command before MPlayer.
271 /// If a filter returns a true value mp_input_get_cmd will return NULL.
272 void
273 mp_input_add_cmd_filter(mp_input_cmd_filter, void* ctx);
275 // After getting a command from mp_input_get_cmd you need to free it using this
276 // function
277 void
278 mp_cmd_free(mp_cmd_t* cmd);
280 // This creates a copy of a command (used by the auto repeat stuff).
281 mp_cmd_t*
282 mp_cmd_clone(mp_cmd_t* cmd);
284 // Set current input section
285 void
286 mp_input_set_section(char *name);
288 // Get current input section
289 char*
290 mp_input_get_section(void);
292 // When you create a new driver you should add it in these 2 functions.
293 void
294 mp_input_init(int use_gui);
296 void
297 mp_input_uninit(void);
299 // Interruptible usleep: (used by libmpdemux)
301 mp_input_check_interrupt(int time);
303 extern int async_quit_request;
305 #endif /* MPLAYER_INPUT_H */