2008-12-13 18:28:00 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_INPUT_H
|
|
|
|
#define MPLAYER_INPUT_H
|
2008-01-01 21:35:58 +00:00
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// All command IDs
|
2008-06-18 17:18:49 +00:00
|
|
|
typedef enum {
|
|
|
|
MP_CMD_SEEK,
|
|
|
|
MP_CMD_AUDIO_DELAY,
|
|
|
|
MP_CMD_QUIT,
|
|
|
|
MP_CMD_PAUSE,
|
|
|
|
MP_CMD_GRAB_FRAMES, // deprecated: was a no-op command for years
|
|
|
|
MP_CMD_PLAY_TREE_STEP,
|
|
|
|
MP_CMD_PLAY_TREE_UP_STEP,
|
|
|
|
MP_CMD_PLAY_ALT_SRC_STEP,
|
|
|
|
MP_CMD_SUB_DELAY,
|
|
|
|
MP_CMD_OSD,
|
|
|
|
MP_CMD_VOLUME,
|
|
|
|
MP_CMD_MIXER_USEMASTER,
|
|
|
|
MP_CMD_CONTRAST,
|
|
|
|
MP_CMD_BRIGHTNESS,
|
|
|
|
MP_CMD_HUE,
|
|
|
|
MP_CMD_SATURATION,
|
|
|
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
|
|
|
MP_CMD_STEP_PROPERTY,
|
|
|
|
MP_CMD_RADIO_STEP_FREQ,
|
|
|
|
MP_CMD_TV_STEP_FREQ,
|
|
|
|
MP_CMD_LOOP,
|
|
|
|
MP_CMD_BALANCE,
|
|
|
|
MP_CMD_SUB_SCALE,
|
|
|
|
MP_CMD_TV_TELETEXT_ADD_DEC,
|
|
|
|
MP_CMD_TV_TELETEXT_GO_LINK,
|
|
|
|
MP_CMD_TV_START_SCAN,
|
|
|
|
MP_CMD_SUB_SOURCE,
|
|
|
|
MP_CMD_SUB_FILE,
|
|
|
|
MP_CMD_SUB_VOB,
|
|
|
|
MP_CMD_SUB_DEMUX,
|
|
|
|
MP_CMD_SWITCH_ANGLE,
|
|
|
|
MP_CMD_ASS_USE_MARGINS,
|
|
|
|
MP_CMD_SWITCH_TITLE,
|
|
|
|
MP_CMD_STOP,
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2008-06-19 18:51:42 +00:00
|
|
|
/// DVDNAV commands
|
|
|
|
MP_CMD_DVDNAV_UP = 1000,
|
|
|
|
MP_CMD_DVDNAV_DOWN,
|
|
|
|
MP_CMD_DVDNAV_LEFT,
|
|
|
|
MP_CMD_DVDNAV_RIGHT,
|
|
|
|
MP_CMD_DVDNAV_MENU,
|
|
|
|
MP_CMD_DVDNAV_SELECT,
|
|
|
|
MP_CMD_DVDNAV_PREVMENU,
|
|
|
|
MP_CMD_DVDNAV_MOUSECLICK,
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2008-06-18 17:18:49 +00:00
|
|
|
/// GUI commands
|
|
|
|
MP_CMD_GUI_EVENTS = 5000,
|
|
|
|
MP_CMD_GUI_LOADFILE,
|
|
|
|
MP_CMD_GUI_LOADSUBTITLE,
|
|
|
|
MP_CMD_GUI_ABOUT,
|
|
|
|
MP_CMD_GUI_PLAY,
|
|
|
|
MP_CMD_GUI_STOP,
|
|
|
|
MP_CMD_GUI_PLAYLIST,
|
|
|
|
MP_CMD_GUI_PREFERENCES,
|
|
|
|
MP_CMD_GUI_FULLSCREEN,
|
|
|
|
MP_CMD_GUI_SKINBROWSER,
|
2002-02-25 13:14:27 +00:00
|
|
|
|
2008-06-18 17:18:49 +00:00
|
|
|
/// DVB commands
|
|
|
|
MP_CMD_DVB_SET_CHANNEL = 5101,
|
|
|
|
|
|
|
|
/// Console commands
|
|
|
|
MP_CMD_CHELP = 7000,
|
|
|
|
MP_CMD_CEXIT,
|
|
|
|
MP_CMD_CHIDE,
|
|
|
|
} mp_command_type;
|
2003-08-11 14:32:53 +00:00
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// The arg types
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_CMD_ARG_INT 0
|
|
|
|
#define MP_CMD_ARG_FLOAT 1
|
|
|
|
#define MP_CMD_ARG_STRING 2
|
2002-04-03 17:58:17 +00:00
|
|
|
#define MP_CMD_ARG_VOID 3
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2002-03-19 13:29:28 +00:00
|
|
|
#ifndef MP_CMD_MAX_ARGS
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_CMD_MAX_ARGS 10
|
2002-03-19 13:29:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Error codes for the drivers
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2003-12-24 22:00:51 +00:00
|
|
|
// An error occurred but we can continue
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_INPUT_ERROR -1
|
2003-12-24 22:00:51 +00:00
|
|
|
// A fatal error occurred, this driver should be removed
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_INPUT_DEAD -2
|
2003-09-14 17:52:59 +00:00
|
|
|
// No input was available
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_INPUT_NOTHING -3
|
2005-06-27 08:16:23 +00:00
|
|
|
//! Input will be available if you try again
|
|
|
|
#define MP_INPUT_RETRY -4
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// For the key's drivers, if possible you can send key up and key down
|
2009-05-13 02:58:57 +00:00
|
|
|
// events. Key up is the default, to send a key down you must use the
|
2004-10-13 23:38:11 +00:00
|
|
|
// OR operator between the key code and MP_KEY_DOWN.
|
2002-02-11 11:42:08 +00:00
|
|
|
#define MP_KEY_DOWN (1<<29)
|
2002-03-19 13:29:28 +00:00
|
|
|
// Use this when the key shouldn't be auto-repeated (like mouse buttons)
|
2002-02-11 11:42:08 +00:00
|
|
|
#define MP_NO_REPEAT_KEY (1<<28)
|
2002-02-08 18:10:56 +00:00
|
|
|
|
|
|
|
#ifndef MP_MAX_KEY_DOWN
|
|
|
|
#define MP_MAX_KEY_DOWN 32
|
|
|
|
#endif
|
|
|
|
|
2002-01-30 12:46:03 +00:00
|
|
|
typedef union mp_cmd_arg_value {
|
|
|
|
int i;
|
|
|
|
float f;
|
|
|
|
char* s;
|
2002-04-03 17:58:17 +00:00
|
|
|
void* v;
|
2002-01-30 12:46:03 +00:00
|
|
|
} mp_cmd_arg_value_t;
|
|
|
|
|
|
|
|
typedef struct mp_cmd_arg {
|
|
|
|
int type;
|
|
|
|
mp_cmd_arg_value_t v;
|
|
|
|
} mp_cmd_arg_t;
|
|
|
|
|
|
|
|
typedef struct mp_cmd {
|
|
|
|
int id;
|
|
|
|
char* name;
|
|
|
|
int nargs;
|
|
|
|
mp_cmd_arg_t args[MP_CMD_MAX_ARGS];
|
2004-11-20 10:51:13 +00:00
|
|
|
int pausing;
|
2002-01-30 12:46:03 +00:00
|
|
|
} mp_cmd_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct mp_cmd_bind {
|
2002-02-08 18:10:56 +00:00
|
|
|
int input[MP_MAX_KEY_DOWN+1];
|
2002-01-30 12:46:03 +00:00
|
|
|
char* cmd;
|
|
|
|
} mp_cmd_bind_t;
|
|
|
|
|
2002-02-08 18:10:56 +00:00
|
|
|
typedef struct mp_key_name {
|
|
|
|
int key;
|
|
|
|
char* name;
|
|
|
|
} mp_key_name_t;
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// These typedefs are for the drivers. They are the functions used to retrieve
|
2002-03-19 13:29:28 +00:00
|
|
|
// the next key code or command.
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// These functions should return the key code or one of the error codes
|
2002-01-30 12:46:03 +00:00
|
|
|
typedef int (*mp_key_func_t)(int fd);
|
2002-10-25 16:06:25 +00:00
|
|
|
// These functions should act like read but they must use our error code (if needed ;-)
|
2002-01-30 12:46:03 +00:00
|
|
|
typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
|
2002-03-19 13:29:28 +00:00
|
|
|
// These are used to close the driver
|
2002-01-30 12:46:03 +00:00
|
|
|
typedef void (*mp_close_func_t)(int fd);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// Set this to grab all incoming key codes
|
2008-12-04 15:07:15 +00:00
|
|
|
extern int (*mp_input_key_cb)(int code);
|
2002-11-14 23:41:44 +00:00
|
|
|
// Should return 1 if the command was processed
|
|
|
|
typedef int (*mp_input_cmd_filter)(mp_cmd_t* cmd, int paused, void* ctx);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// This function adds a new key driver.
|
2002-03-19 13:29:28 +00:00
|
|
|
// The first arg is a file descriptor (use a negative value if you don't use any fd)
|
2003-09-14 17:52:59 +00:00
|
|
|
// The second arg tells if we use select on the fd to know if something is available.
|
|
|
|
// The third arg is optional. If null a default function wich reads an int from the
|
2002-03-19 13:29:28 +00:00
|
|
|
// fd will be used.
|
|
|
|
// The last arg can be NULL if nothing is needed to close the driver. The close
|
|
|
|
// function can be used
|
2002-01-30 12:46:03 +00:00
|
|
|
int
|
|
|
|
mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// This removes a cmd driver, you usually don't need to use it.
|
2002-01-30 12:46:03 +00:00
|
|
|
void
|
|
|
|
mp_input_rm_cmd_fd(int fd);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// The args are the same as for the key's drivers. If you don't use any valid fd you MUST
|
2002-03-19 13:29:28 +00:00
|
|
|
// give a read_func.
|
2002-01-30 12:46:03 +00:00
|
|
|
int
|
|
|
|
mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// As for the cmd one you usually don't need this function.
|
2002-01-30 12:46:03 +00:00
|
|
|
void
|
|
|
|
mp_input_rm_key_fd(int fd);
|
|
|
|
|
2007-08-25 04:28:14 +00:00
|
|
|
int mp_input_add_event_fd(int fd, void (*read_func)(void));
|
|
|
|
|
|
|
|
void mp_input_rm_event_fd(int fd);
|
|
|
|
|
2007-12-04 10:42:59 +00:00
|
|
|
/// Get input key from its name.
|
|
|
|
int mp_input_get_key_from_name(const char *name);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// This function can be used to put a command in the system again. It's used by libmpdemux
|
|
|
|
// when it performs a blocking operation to resend the command it received to the main
|
2002-03-19 13:29:28 +00:00
|
|
|
// loop.
|
2002-02-23 21:13:35 +00:00
|
|
|
int
|
|
|
|
mp_input_queue_cmd(mp_cmd_t* cmd);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// This function retrieves the next available command waiting no more than time msec.
|
2002-03-19 13:29:28 +00:00
|
|
|
// If pause is true, the next input will always return a pause command.
|
2002-01-30 12:46:03 +00:00
|
|
|
mp_cmd_t*
|
2004-10-10 17:39:07 +00:00
|
|
|
mp_input_get_cmd(int time, int paused, int peek_only);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2002-11-14 23:41:44 +00:00
|
|
|
mp_cmd_t*
|
|
|
|
mp_input_parse_cmd(char* str);
|
|
|
|
|
2007-12-11 08:03:47 +00:00
|
|
|
/**
|
|
|
|
* Parse and queue commands separated by '\n'.
|
|
|
|
* @return count of commands new queued.
|
|
|
|
*/
|
|
|
|
int mp_input_parse_and_queue_cmds(const char *str);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
/// These filters allow you to process the command before MPlayer.
|
|
|
|
/// If a filter returns a true value mp_input_get_cmd will return NULL.
|
2002-11-14 23:41:44 +00:00
|
|
|
void
|
|
|
|
mp_input_add_cmd_filter(mp_input_cmd_filter, void* ctx);
|
|
|
|
|
2002-03-19 13:29:28 +00:00
|
|
|
// After getting a command from mp_input_get_cmd you need to free it using this
|
|
|
|
// function
|
2002-01-30 12:46:03 +00:00
|
|
|
void
|
|
|
|
mp_cmd_free(mp_cmd_t* cmd);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// This creates a copy of a command (used by the auto repeat stuff).
|
2002-02-11 11:42:08 +00:00
|
|
|
mp_cmd_t*
|
|
|
|
mp_cmd_clone(mp_cmd_t* cmd);
|
|
|
|
|
2007-06-07 18:06:53 +00:00
|
|
|
// Set current input section
|
|
|
|
void
|
|
|
|
mp_input_set_section(char *name);
|
|
|
|
|
|
|
|
// Get current input section
|
|
|
|
char*
|
|
|
|
mp_input_get_section(void);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// When you create a new driver you should add it in these 2 functions.
|
2002-01-30 12:46:03 +00:00
|
|
|
void
|
2006-03-18 18:13:22 +00:00
|
|
|
mp_input_init(int use_gui);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2002-01-31 09:37:12 +00:00
|
|
|
void
|
|
|
|
mp_input_uninit(void);
|
2002-10-23 14:46:20 +00:00
|
|
|
|
|
|
|
// Interruptible usleep: (used by libmpdemux)
|
|
|
|
int
|
|
|
|
mp_input_check_interrupt(int time);
|
|
|
|
|
2008-01-08 21:40:44 +00:00
|
|
|
extern int async_quit_request;
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_INPUT_H */
|