From ed71606e65e697ea6bc9fc78caf2dd4089dc0aeb Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Dec 2013 19:33:45 +0100 Subject: input: rework how input sources are added Until now, there were two functions to add input sources (stuff like stdin input, slave mode, lirc, joystick). Unify them to a single function (mp_input_add_fd()), and make sure the associated callbacks always have a context parameter. Change the lirc and joystick code such that they take store their state in a context struct (probably worthless), and use the new mp_msg replacements (the point of this refactoring). Additionally, get rid of the ugly USE_FD0_CMD_SELECT etc. ifdeffery in the terminal handling code. --- osdep/terminal.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'osdep/terminal.h') diff --git a/osdep/terminal.h b/osdep/terminal.h index fe4d5e32d5..c524adbc2b 100644 --- a/osdep/terminal.h +++ b/osdep/terminal.h @@ -27,6 +27,8 @@ #include #include +struct input_ctx; + /* Screen size. Initialized by load_termcap() and get_screen_size() */ extern int screen_width; extern int screen_height; @@ -37,6 +39,12 @@ extern char * erase_to_end_of_line; /* Global initialization for terminal output. */ int terminal_init(void); +/* Setup ictx to read input commands from stdin (slave mode) */ +void terminal_setup_stdin_cmd_input(struct input_ctx *ictx); + +/* Setup ictx to read keys from the terminal */ +void terminal_setup_getch(struct input_ctx *ictx); + /* Return whether the process has been backgrounded. */ bool terminal_in_background(void); @@ -54,18 +62,4 @@ void getch2_disable(void); /* Enable and disable STDIN line-buffering */ void getch2_poll(void); -/* Read a character or a special key code (see keycodes.h) */ -struct input_ctx; -bool getch2(struct input_ctx *ictx); - -#if defined(__MINGW32__) -// slave cmd function for Windows -int mp_input_slave_cmd_func(int fd,char* dest,int size); -#define USE_FD0_CMD_SELECT 0 -#define MP_INPUT_SLAVE_CMD_FUNC mp_input_slave_cmd_func -#else -#define USE_FD0_CMD_SELECT 1 -#define MP_INPUT_SLAVE_CMD_FUNC NULL -#endif - #endif /* MPLAYER_GETCH2_H */ -- cgit v1.2.3