1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-20 18:28:01 +00:00

input: remove classic LIRC support

It's much easier to configure remotes as X11 input devices.
This commit is contained in:
wm4 2015-03-24 15:53:36 +01:00
parent d5318e5e09
commit 1e659a9f0f
11 changed files with 8 additions and 203 deletions

View File

@ -32,8 +32,10 @@ INTERACTIVE CONTROL
=================== ===================
mpv has a fully configurable, command-driven control layer which allows you mpv has a fully configurable, command-driven control layer which allows you
to control mpv using keyboard, mouse, joystick or remote control (with to control mpv using keyboard, mouse, joystick or remote control (there is no
LIRC). See the ``--input-`` options for ways to customize it. LIRC support - configure remotes as input devices instead).
See the ``--input-`` options for ways to customize it.
Keyboard Control Keyboard Control
---------------- ----------------

View File

@ -2364,13 +2364,6 @@ Input
``--input-js-dev`` ``--input-js-dev``
Specifies the joystick device to use (default: ``/dev/input/js0``). Specifies the joystick device to use (default: ``/dev/input/js0``).
``--input-lirc``, ``--no-input-lirc``
Enable/disable LIRC support. Enabled by default.
``--input-lirc-conf=<filename>``
(LIRC only)
Specifies a configuration file for LIRC (default: ``~/.lircrc``).
``--input-media-keys=<yes|no>`` ``--input-media-keys=<yes|no>``
(OS X only) (OS X only)
Enable/disable media keys support. Enabled by default (except for libmpv). Enable/disable media keys support. Enabled by default (except for libmpv).
@ -2951,7 +2944,7 @@ TV
Use _ for spaces in names (or play with quoting ;-) ). The channel Use _ for spaces in names (or play with quoting ;-) ). The channel
names will then be written using OSD, and the slave commands names will then be written using OSD, and the slave commands
``tv_step_channel``, ``tv_set_channel`` and ``tv_last_channel`` ``tv_step_channel``, ``tv_set_channel`` and ``tv_last_channel``
will be usable for a remote control (see LIRC). Not compatible with will be usable for a remote control. Not compatible with
the ``frequency`` parameter. the ``frequency`` parameter.
.. note:: .. note::

View File

@ -46,6 +46,9 @@ Input
* Allow customizing whether a key binding for seeking shows the video time, the * Allow customizing whether a key binding for seeking shows the video time, the
OSD bar, or nothing (see the `Input Command Prefixes`_ section). OSD bar, or nothing (see the `Input Command Prefixes`_ section).
* Support mapping multiple commands to one key. * Support mapping multiple commands to one key.
* Classic LIRC support was removed. Install remotes as input devices instead.
This way they will send X11 key events to the mpv window, which can be bound
using the normal ``input.conf``.
Audio Audio
~~~~~ ~~~~~
@ -227,7 +230,6 @@ Command Line Switches
``-idx`` ``--index`` ``-idx`` ``--index``
``-lavdopts ...`` ``--vd-lavc-...`` ``-lavdopts ...`` ``--vd-lavc-...``
``-lavfdopts`` ``--demuxer-lavf-...`` ``-lavfdopts`` ``--demuxer-lavf-...``
``-lircconf`` ``--input-lirc-conf``
``-loop 0`` ``--loop=inf`` ``-loop 0`` ``--loop=inf``
``-mixer-channel`` AO suboptions (``alsa``, ``oss``) ``-mixer-channel`` AO suboptions (``alsa``, ``oss``)
``-mixer`` AO suboptions (``alsa``, ``oss``) ``-mixer`` AO suboptions (``alsa``, ``oss``)

View File

@ -165,9 +165,6 @@ struct input_opts {
int ar_rate; int ar_rate;
char *js_dev; char *js_dev;
int use_joystick; int use_joystick;
int use_lirc;
char *lirc_configfile;
int use_lircc;
int use_alt_gr; int use_alt_gr;
int use_appleremote; int use_appleremote;
int use_media_keys; int use_media_keys;
@ -190,15 +187,11 @@ const struct m_sub_options input_config = {
OPT_FLAG("test", test, CONF_GLOBAL), OPT_FLAG("test", test, CONF_GLOBAL),
OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000), OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000),
OPT_FLAG("joystick", use_joystick, CONF_GLOBAL), OPT_FLAG("joystick", use_joystick, CONF_GLOBAL),
OPT_FLAG("lirc", use_lirc, CONF_GLOBAL),
OPT_FLAG("right-alt-gr", use_alt_gr, CONF_GLOBAL), OPT_FLAG("right-alt-gr", use_alt_gr, CONF_GLOBAL),
OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000), OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000),
OPT_FLAG("cursor", enable_mouse_movements, CONF_GLOBAL), OPT_FLAG("cursor", enable_mouse_movements, CONF_GLOBAL),
OPT_FLAG("vo-keyboard", vo_key_input, CONF_GLOBAL), OPT_FLAG("vo-keyboard", vo_key_input, CONF_GLOBAL),
OPT_FLAG("x11-keyboard", vo_key_input, CONF_GLOBAL), // old alias OPT_FLAG("x11-keyboard", vo_key_input, CONF_GLOBAL), // old alias
#if HAVE_LIRC
OPT_STRING("lirc-conf", lirc_configfile, CONF_GLOBAL),
#endif
#if HAVE_COCOA #if HAVE_COCOA
OPT_FLAG("appleremote", use_appleremote, CONF_GLOBAL), OPT_FLAG("appleremote", use_appleremote, CONF_GLOBAL),
OPT_FLAG("media-keys", use_media_keys, CONF_GLOBAL), OPT_FLAG("media-keys", use_media_keys, CONF_GLOBAL),
@ -212,7 +205,6 @@ const struct m_sub_options input_config = {
.doubleclick_time = 300, .doubleclick_time = 300,
.ar_delay = 200, .ar_delay = 200,
.ar_rate = 40, .ar_rate = 40,
.use_lirc = 1,
.use_alt_gr = 1, .use_alt_gr = 1,
.enable_mouse_movements = 1, .enable_mouse_movements = 1,
#if HAVE_COCOA #if HAVE_COCOA
@ -1257,11 +1249,6 @@ void mp_input_load(struct input_ctx *ictx)
mp_input_joystick_add(ictx, input_conf->js_dev); mp_input_joystick_add(ictx, input_conf->js_dev);
#endif #endif
#if HAVE_LIRC
if (input_conf->use_lirc)
mp_input_lirc_add(ictx, input_conf->lirc_configfile);
#endif
if (input_conf->use_alt_gr) { if (input_conf->use_alt_gr) {
ictx->using_alt_gr = true; ictx->using_alt_gr = true;
} }

View File

@ -258,7 +258,6 @@ void mp_input_set_repeat_info(struct input_ctx *ictx, int rate, int delay);
void mp_input_pipe_add(struct input_ctx *ictx, const char *filename); void mp_input_pipe_add(struct input_ctx *ictx, const char *filename);
void mp_input_joystick_add(struct input_ctx *ictx, char *dev); void mp_input_joystick_add(struct input_ctx *ictx, char *dev);
void mp_input_lirc_add(struct input_ctx *ictx, char *lirc_configfile);
struct mp_ipc_ctx; struct mp_ipc_ctx;
struct mp_client_api; struct mp_client_api;

View File

@ -1,167 +0,0 @@
/*
* 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.
*/
#include <lirc/lirc_client.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <poll.h>
#include "common/common.h"
#include "common/msg.h"
#include "input.h"
struct ctx {
struct mp_log *log;
struct lirc_config *lirc_config;
char* cmd_buf;
int fd;
};
static struct ctx *mp_input_lirc_init(struct input_ctx *ictx, struct mp_log *log,
char *lirc_configfile)
{
int lirc_sock;
int mode;
mp_verbose(log,"Setting up LIRC support...\n");
if((lirc_sock=lirc_init("mpv",0))==-1){
mp_verbose(log,"Failed to open LIRC support. You will not be able to use your remote control.\n");
return NULL;
}
mode = fcntl(lirc_sock, F_GETFL);
if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
mp_err(log, "setting non-blocking mode failed: %s\n", mp_strerror(errno));
lirc_deinit();
return NULL;
}
struct lirc_config *lirc_config = NULL;
if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
mp_err(log, "Failed to read LIRC config file %s.\n",
lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
lirc_deinit();
return NULL;
}
struct ctx *ctx = talloc_ptrtype(NULL, ctx);
*ctx = (struct ctx){
.log = log,
.lirc_config = lirc_config,
.fd = lirc_sock,
};
return ctx;
}
static int mp_input_lirc_read(void *pctx,int fd,char* dest, int s) {
int r,cl = 0;
char *code = NULL,*c = NULL;
struct ctx *ctx = pctx;
// We have something in the buffer return it
if(ctx->cmd_buf != NULL) {
int l = strlen(ctx->cmd_buf), w = l > s ? s : l;
memcpy(dest,ctx->cmd_buf,w);
l -= w;
if(l > 0)
memmove(ctx->cmd_buf,&ctx->cmd_buf[w],l+1);
else {
free(ctx->cmd_buf);
ctx->cmd_buf = NULL;
}
return w;
}
// Nothing in the buffer, poll the lirc fd
if(lirc_nextcode(&code) != 0) {
MP_ERR(ctx, "Lirc error.\n");
return -1;
}
if(!code) return 0;
// We put all cmds in a single buffer separated by \n
while((r = lirc_code2char(ctx->lirc_config,code,&c))==0 && c!=NULL) {
int l = strlen(c);
if(l <= 0)
continue;
ctx->cmd_buf = realloc(ctx->cmd_buf,cl+l+2);
memcpy(&ctx->cmd_buf[cl],c,l);
cl += l+1;
ctx->cmd_buf[cl-1] = '\n';
ctx->cmd_buf[cl] = '\0';
}
free(code);
if(r < 0)
return -1;
else if(ctx->cmd_buf) // return the first command in the buffer
return mp_input_lirc_read(ctx,fd,dest,s);
else
return 0;
}
static int mp_input_lirc_close(void *pctx,int fd)
{
struct ctx *ctx = pctx;
free(ctx->cmd_buf);
lirc_freeconfig(ctx->lirc_config);
lirc_deinit();
close(fd);
talloc_free(ctx);
return 0;
}
static void read_lirc_thread(struct mp_input_src *src, void *param)
{
int wakeup_fd = mp_input_src_get_wakeup_fd(src);
struct ctx *ctx = mp_input_lirc_init(src->input_ctx, src->log, param);
if (!ctx)
return;
mp_input_src_init_done(src);
while (1) {
struct pollfd fds[2] = {
{ .fd = ctx->fd, .events = POLLIN },
{ .fd = wakeup_fd, .events = POLLIN },
};
poll(fds, 2, -1);
if (!(fds[0].revents & POLLIN))
break;
char buffer[128];
int r = mp_input_lirc_read(ctx, ctx->fd, buffer, sizeof(buffer));
if (r < 0)
break;
mp_input_src_feed_cmd_text(src, buffer, r);
}
mp_input_lirc_close(ctx, ctx->fd);
}
void mp_input_lirc_add(struct input_ctx *ictx, char *lirc_configfile)
{
mp_input_add_thread_src(ictx, (void *)lirc_configfile, read_lirc_thread);
}

View File

@ -164,7 +164,6 @@ options_state_machine() {
opt_yes_no _libguess "libguess" opt_yes_no _libguess "libguess"
opt_yes_no _termios "termios database for key codes" opt_yes_no _termios "termios database for key codes"
opt_yes_no _iconv "iconv for encoding conversion" opt_yes_no _iconv "iconv for encoding conversion"
opt_yes_no _lirc "LIRC (remote control) support"
opt_yes_no _joystick "joystick support" no opt_yes_no _joystick "joystick support" no
opt_yes_no _vm "X video mode extensions" opt_yes_no _vm "X video mode extensions"
opt_yes_no _dvb "DVB input" opt_yes_no _dvb "DVB input"
@ -841,8 +840,6 @@ check_trivial "VapourSynth core" $_vapoursynth_core VAPOURSYNTH_CORE
check_trivial "joystick" $_joystick JOYSTICK check_trivial "joystick" $_joystick JOYSTICK
check_statement_libs "lirc" $_lirc LIRC lirc/lirc_client.h "" -llirc_client
check_trivial "encoding" $_encoding ENCODING check_trivial "encoding" $_encoding ENCODING
# needs dlopen on unix # needs dlopen on unix

View File

@ -74,7 +74,6 @@ SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c \
SOURCES-$(JACK) += audio/out/ao_jack.c SOURCES-$(JACK) += audio/out/ao_jack.c
SOURCES-$(JOYSTICK) += input/joystick.c SOURCES-$(JOYSTICK) += input/joystick.c
SOURCES-$(LIRC) += input/lirc.c
SOURCES-$(OPENAL) += audio/out/ao_openal.c SOURCES-$(OPENAL) += audio/out/ao_openal.c
SOURCES-$(OSS_AUDIO) += audio/out/ao_oss.c SOURCES-$(OSS_AUDIO) += audio/out/ao_oss.c
SOURCES-$(PULSE) += audio/out/ao_pulse.c SOURCES-$(PULSE) += audio/out/ao_pulse.c

View File

@ -604,7 +604,6 @@ const m_option_t mp_opts[] = {
OPT_REMOVED("identify", "use TOOLS/mpv_identify.sh"), OPT_REMOVED("identify", "use TOOLS/mpv_identify.sh"),
OPT_REMOVED("lavdopts", "use --vd-lavc-..."), OPT_REMOVED("lavdopts", "use --vd-lavc-..."),
OPT_REMOVED("lavfdopts", "use --demuxer-lavf-..."), OPT_REMOVED("lavfdopts", "use --demuxer-lavf-..."),
OPT_REPLACED("lircconf", "input-lirc-conf"),
OPT_REPLACED("lua", "script"), OPT_REPLACED("lua", "script"),
OPT_REPLACED("lua-opts", "script-opts"), OPT_REPLACED("lua-opts", "script-opts"),
OPT_REMOVED("mixer-channel", "use AO suboptions (alsa, oss)"), OPT_REMOVED("mixer-channel", "use AO suboptions (alsa, oss)"),
@ -647,7 +646,6 @@ const m_option_t mp_opts[] = {
OPT_REMOVED("xy", "use --autofit"), OPT_REMOVED("xy", "use --autofit"),
OPT_REMOVED("zoom", "Inverse available as ``--video-unscaled"), OPT_REMOVED("zoom", "Inverse available as ``--video-unscaled"),
OPT_REPLACED("media-keys", "input-media-keys"), OPT_REPLACED("media-keys", "input-media-keys"),
OPT_REPLACED("lirc", "input-lirc"),
OPT_REPLACED("right-alt-gr", "input-right-alt-gr"), OPT_REPLACED("right-alt-gr", "input-right-alt-gr"),
OPT_REPLACED("autosub", "sub-auto"), OPT_REPLACED("autosub", "sub-auto"),
OPT_REPLACED("autosub-match", "sub-auto"), OPT_REPLACED("autosub-match", "sub-auto"),

View File

@ -313,10 +313,6 @@ iconv support use --disable-iconv.",
'desc' : 'joystick', 'desc' : 'joystick',
'func': check_cc(header_name='linux/joystick.h'), 'func': check_cc(header_name='linux/joystick.h'),
'default': 'disable' 'default': 'disable'
}, {
'name' : '--lirc',
'desc' : 'lirc',
'func': check_cc(header_name='lirc/lirc_client.h', lib='lirc_client'),
}, { }, {
'name': '--libbluray', 'name': '--libbluray',
'desc': 'Bluray support', 'desc': 'Bluray support',

View File

@ -185,7 +185,6 @@ def build(ctx):
( "input/keycodes.c" ), ( "input/keycodes.c" ),
( "input/pipe-win32.c", "waio" ), ( "input/pipe-win32.c", "waio" ),
( "input/joystick.c", "joystick" ), ( "input/joystick.c", "joystick" ),
( "input/lirc.c", "lirc" ),
## Misc ## Misc
( "misc/bstr.c" ), ( "misc/bstr.c" ),