summaryrefslogtreecommitdiffstats
path: root/osdep/terminal.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 19:33:45 +0100
committerwm4 <wm4@nowhere>2013-12-21 20:50:13 +0100
commited71606e65e697ea6bc9fc78caf2dd4089dc0aeb (patch)
treed3b80546a8e40c821ee7575c236d813021b8b7c8 /osdep/terminal.h
parentdadf3a9a46d31a101aeaa1256b0d6f914eb32f1e (diff)
downloadmpv-ed71606e65e697ea6bc9fc78caf2dd4089dc0aeb.tar.bz2
mpv-ed71606e65e697ea6bc9fc78caf2dd4089dc0aeb.tar.xz
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.
Diffstat (limited to 'osdep/terminal.h')
-rw-r--r--osdep/terminal.h22
1 files changed, 8 insertions, 14 deletions
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 <stdbool.h>
#include <stdio.h>
+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 */