summaryrefslogtreecommitdiffstats
path: root/input/input.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 23:15:32 +0100
committerwm4 <wm4@nowhere>2013-12-21 23:15:32 +0100
commit0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2 (patch)
treeb70f214f8c3fc802d6d6edbf8395273c854ac0fd /input/input.h
parenta4fe95b0d8d339ba5afbdb5346ad8fd367a4a1c1 (diff)
parent245e5b844177e9ad9a9c07eff5efab7c3fccdebc (diff)
downloadmpv-0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2.tar.bz2
mpv-0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2.tar.xz
Merge branch 'msg_refactor'
This branch changes mp_msg() so that it doesn't require global context. The changes are pretty violent.
Diffstat (limited to 'input/input.h')
-rw-r--r--input/input.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/input/input.h b/input/input.h
index 62892dc15a..3a1d3f6116 100644
--- a/input/input.h
+++ b/input/input.h
@@ -171,25 +171,26 @@ typedef struct mp_cmd {
bool mp_input_is_abort_cmd(int cmd_id);
/* Add a new command input source.
- * "fd" is a file descriptor (use a negative value if you don't use any fd)
+ * "fd" is a file descriptor (use -1 if you don't use any fd)
* "select" tells whether to use select() on the fd to determine when to
* try reading.
- * "read_func" is optional. If NULL a default function which reads data
- * directly from the fd will be used. It must return either text data
- * or one of the MP_INPUT error codes above.
+ * "read_cmd_func" is optional. It must return either text data or one of the
+ * MP_INPUT error codes above. For return values >= 0, it behaves like UNIX
+ * read() and returns the number of bytes copied to the dest buffer.
+ * "read_key_func" is optional. It returns either key codes (ASCII, keycodes.h),
+ * or MP_INPUT error codes.
* "close_func" will be called when closing. Can be NULL. Its return value
* is ignored (it's only there to allow using standard close() as the func).
+ * "ctx" is for free use, and is passed to the callbacks.
*/
-int mp_input_add_cmd_fd(struct input_ctx *ictx, int fd, int select,
- int read_func(int fd, char *dest, int size),
- int close_func(int fd));
+int mp_input_add_fd(struct input_ctx *ictx, int fd, int select,
+ int read_cmd_func(void *ctx, int fd, char *dest, int size),
+ int read_key_func(void *ctx, int fd),
+ int close_func(void *ctx, int fd), void *ctx);
-/* The args are similar to the cmd version above, except you must give
- * a read_func, and it should return key codes (ASCII plus keycodes.h).
+/* Can be passed as read_func for above function in order to read() from the FD.
*/
-int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
- int read_func(void *ctx, int fd),
- int close_func(int fd), void *ctx);
+int input_default_read_cmd(void *ctx, int fd, char *buf, int l);
// Process keyboard input. code is a key code from keycodes.h, possibly
// with modifiers applied. MP_INPUT_RELEASE_ALL is also a valid value.