From 5423c418c257bca03b44db285797b0a82fb72f84 Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 16 May 2008 09:42:28 +0000 Subject: cosmetics: Remove useless parentheses from return statements. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26791 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/joystick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'input') diff --git a/input/joystick.c b/input/joystick.c index ec3720548d..f646235ce4 100644 --- a/input/joystick.c +++ b/input/joystick.c @@ -120,9 +120,9 @@ int mp_input_joystick_read(int fd) { btns &= ~(1 << ev.number); btns |= (ev.value << ev.number); if(ev.value == 1) - return ((JOY_BTN0+ev.number) | MP_KEY_DOWN); + return (JOY_BTN0 + ev.number) | MP_KEY_DOWN; else - return (JOY_BTN0+ev.number); + return JOY_BTN0 + ev.number; } else if(ev.type & JS_EVENT_AXIS) { if(ev.value < -JOY_AXIS_DELTA && axis[ev.number] != -1) { axis[ev.number] = -1; -- cgit v1.2.3 From dc6d14fb1b20e86cc24c6fbe5ce239566e5d588e Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 18 May 2008 11:53:00 +0000 Subject: Add support for AppleIR Remote as an input under Linux systems. This requires Linux 2.6 with evdev and appleir drivers. The keymapping is done to mimics the one that was done for MacOSX. WARNING: Most distributions do not seems to bother and only let root access to the device. Modify udev rules accordingly if you want regular user to be able to use the remote. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26795 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/appleir.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ input/ar.h | 5 ++ input/input.c | 12 +++++ 3 files changed, 168 insertions(+) create mode 100644 input/appleir.c (limited to 'input') diff --git a/input/appleir.c b/input/appleir.c new file mode 100644 index 0000000000..a3ec66e8cb --- /dev/null +++ b/input/appleir.c @@ -0,0 +1,151 @@ +/* + * Linux Apple IR Remote input interface + * + * Copyright (C) 2008 Benjamin Zores + * + * 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 "config.h" + +#include "ar.h" +#include "input.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "mp_msg.h" +#include "help_mp.h" + +#define EVDEV_MAX_EVENTS 32 + +/* ripped from AppleIR driver */ +#define USB_VENDOR_APPLE 0x05ac +#define USB_DEV_APPLE_IR 0x8240 +#define USB_DEV_APPLE_IR_2 0x8242 + +/* Apple IR Remote evdev mapping */ +#define APPLE_IR_MINUS KEY_VOLUMEDOWN +#define APPLE_IR_PLUS KEY_VOLUMEUP +#define APPLE_IR_MENU KEY_MENU +#define APPLE_IR_FORWARD KEY_NEXTSONG +#define APPLE_IR_PLAY KEY_PLAYPAUSE +#define APPLE_IR_BACKWARD KEY_PREVIOUSSONG + +static const struct { + int linux_keycode; + int value; + int mp_keycode; +} apple_ir_mapping[] = { + { APPLE_IR_PLAY, 1, AR_PLAY }, + { APPLE_IR_PLAY, 2, AR_PLAY_HOLD }, + { APPLE_IR_FORWARD, 1, AR_NEXT }, + { APPLE_IR_FORWARD, 2, AR_NEXT_HOLD }, + { APPLE_IR_BACKWARD, 1, AR_PREV }, + { APPLE_IR_BACKWARD, 2, AR_PREV_HOLD }, + { APPLE_IR_MENU, 1, AR_MENU }, + { APPLE_IR_MENU, 2, AR_MENU_HOLD }, + { APPLE_IR_PLUS, 1, AR_VUP }, + { APPLE_IR_MINUS, 1, AR_VDOWN }, + { -1, -1, -1 } +}; + +int mp_input_appleir_init (char *dev) +{ + int i, fd; + + if (dev) + { + mp_msg (MSGT_INPUT, MSGL_V, MSGTR_INPUT_APPLE_IR_Init, dev); + fd = open (dev, O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + mp_msg (MSGT_INPUT, MSGL_ERR, + MSGTR_INPUT_APPLE_IR_CantOpen, strerror (errno)); + return -1; + } + + return fd; + } + else + { + /* look for a valid AppleIR device on system */ + for (i = 0; i < EVDEV_MAX_EVENTS; i++) + { + struct input_id id; + char file[64]; + + sprintf (file, "/dev/input/event%d", i); + fd = open (file, O_RDONLY | O_NONBLOCK); + if (fd < 0) + continue; + + ioctl (fd, EVIOCGID, &id); + if (id.bustype == BUS_USB && + id.vendor == USB_VENDOR_APPLE && + (id.product == USB_DEV_APPLE_IR ||id.product == USB_DEV_APPLE_IR_2)) + { + mp_msg (MSGT_INPUT, MSGL_V, MSGTR_INPUT_APPLE_IR_Detect, file); + return fd; + } + close (fd); + } + + mp_msg (MSGT_INPUT, MSGL_ERR, + MSGTR_INPUT_APPLE_IR_CantOpen, strerror (errno)); + } + + return -1; +} + +int mp_input_appleir_read (int fd) +{ + struct input_event ev; + int i, r; + + r = read (fd, &ev, sizeof (struct input_event)); + if (r <= 0 || r < sizeof (struct input_event)) + return MP_INPUT_NOTHING; + + /* check for key press only */ + if (ev.type != EV_KEY) + return MP_INPUT_NOTHING; + + /* EvDev Key values: + * 0: key release + * 1: key press + * 2: key auto-repeat + */ + if (ev.value == 0) + return MP_INPUT_NOTHING; + + /* find Linux evdev -> MPlayer keycode mapping */ + for (i = 0; apple_ir_mapping[i].linux_keycode != -1; i++) + if (apple_ir_mapping[i].linux_keycode == ev.code && + apple_ir_mapping[i].value == ev.value) + return apple_ir_mapping[i].mp_keycode; + + return MP_INPUT_NOTHING; +} diff --git a/input/ar.h b/input/ar.h index 10c6aac7a4..31bbd0ade9 100644 --- a/input/ar.h +++ b/input/ar.h @@ -35,8 +35,13 @@ #define AR_VUP (AR_BASE + 8) #define AR_VDOWN (AR_BASE + 9) +/* MacOSX Driver */ int mp_input_ar_init(void); int mp_input_ar_read(int fd); void mp_input_ar_close(int fd); +/* Linux Driver */ +int mp_input_appleir_init(char* dev); +int mp_input_appleir_read(int fd); + #endif /* MPLAYER_AR_H */ diff --git a/input/input.c b/input/input.c index c43afbfa4f..da879cc6a7 100644 --- a/input/input.c +++ b/input/input.c @@ -569,6 +569,7 @@ static char* config_file = "input.conf"; static int use_ar = 1; static char* js_dev = NULL; +static char* ar_dev = NULL; static char* in_file = NULL; static int in_file_fd = -1; @@ -579,6 +580,7 @@ static int mp_input_print_cmd_list(m_option_t* cfg); // Our command line options static m_option_t input_conf[] = { { "conf", &config_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL }, + { "ar-dev", &ar_dev, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL }, { "ar-delay", &ar_delay, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL }, { "ar-rate", &ar_rate, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL }, { "keylist", mp_input_print_key_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL }, @@ -1760,6 +1762,16 @@ mp_input_init(int use_gui) { } #endif +#ifdef HAVE_APPLE_IR + if(use_ar) { + int fd = mp_input_appleir_init(ar_dev); + if(fd < 0) + mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantInitAppleRemote); + else + mp_input_add_key_fd(fd,1,mp_input_appleir_read,(mp_close_func_t)close); + } +#endif + if(in_file) { struct stat st; if(stat(in_file,&st)) -- cgit v1.2.3 From 974d4fadad59e30c60931d38bc50a560af4da7b2 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 18 May 2008 11:56:20 +0000 Subject: Do not enable AppleIR by default. The amount of computers capable of using it is too low in the field to enable it by default. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26797 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'input') diff --git a/input/input.c b/input/input.c index da879cc6a7..d86ec04a3e 100644 --- a/input/input.c +++ b/input/input.c @@ -566,7 +566,7 @@ static int use_joystick = 1, use_lirc = 1, use_lircc = 1; static char* config_file = "input.conf"; /* Apple Remote */ -static int use_ar = 1; +static int use_ar = 0; static char* js_dev = NULL; static char* ar_dev = NULL; -- cgit v1.2.3 From 561e9503aaa6b4592965a02bb32c5b831fc4f51e Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 18 May 2008 12:11:17 +0000 Subject: Keep AppleIR enabled by default on MacOSX but have it disable on Linux. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26799 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'input') diff --git a/input/input.c b/input/input.c index d86ec04a3e..1bbf908728 100644 --- a/input/input.c +++ b/input/input.c @@ -566,7 +566,11 @@ static int use_joystick = 1, use_lirc = 1, use_lircc = 1; static char* config_file = "input.conf"; /* Apple Remote */ +#ifdef HAVE_APPLE_REMOTE +static int use_ar = 1; +#elif HAVE_APPLE_IR static int use_ar = 0; +#endif static char* js_dev = NULL; static char* ar_dev = NULL; -- cgit v1.2.3 From 9171b9dbe69cf6231a2a9a7c1e845ddedd431e03 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 18 May 2008 18:11:05 +0000 Subject: fix compilation of input.c if neither macosx/linux apple remote code is compiled in git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26829 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'input') diff --git a/input/input.c b/input/input.c index 1bbf908728..9f388f347b 100644 --- a/input/input.c +++ b/input/input.c @@ -568,7 +568,7 @@ static char* config_file = "input.conf"; /* Apple Remote */ #ifdef HAVE_APPLE_REMOTE static int use_ar = 1; -#elif HAVE_APPLE_IR +#else static int use_ar = 0; #endif -- cgit v1.2.3 From e3755edad5ad65ad302f4698042dd76aec97c1c3 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 20 May 2008 20:51:22 +0000 Subject: add potentially missing types git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26841 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/appleir.c | 1 + 1 file changed, 1 insertion(+) (limited to 'input') diff --git a/input/appleir.c b/input/appleir.c index a3ec66e8cb..2593f7cb5d 100644 --- a/input/appleir.c +++ b/input/appleir.c @@ -34,6 +34,7 @@ #include #include +#include #include #include "mp_msg.h" -- cgit v1.2.3 From bc212e3500ef776f849a9ee6c04dfaa4994c62f6 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 27 May 2008 18:39:57 +0000 Subject: Add a slave command to stop stream playback. Mostly useful when used with -idle mode. Patch by Mathieu Schroeter ( mathieu dot schroeter at gamesover dot ch ) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26909 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 2 ++ input/input.h | 1 + 2 files changed, 3 insertions(+) (limited to 'input') diff --git a/input/input.c b/input/input.c index 9f388f347b..6fab4c1219 100644 --- a/input/input.c +++ b/input/input.c @@ -64,6 +64,7 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_SPEED_MULT, "speed_mult", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, { MP_CMD_SPEED_SET, "speed_set", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, { MP_CMD_QUIT, "quit", 0, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, + { MP_CMD_STOP, "stop", 0, { {-1,{0}} } }, { MP_CMD_PAUSE, "pause", 0, { {-1,{0}} } }, { MP_CMD_FRAME_STEP, "frame_step", 0, { {-1,{0}} } }, { MP_CMD_PLAY_TREE_STEP, "pt_step",1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT ,{0}}, {-1,{0}} } }, @@ -473,6 +474,7 @@ static const mp_cmd_bind_t def_cmd_binds[] = { { { '!', 0 }, "seek_chapter -1" }, { { '@', 0 }, "seek_chapter 1" }, { { 'A', 0 }, "switch_angle 1" }, + { { 'U', 0 }, "stop" }, { { 0 }, NULL } }; diff --git a/input/input.h b/input/input.h index e6381b3e34..74185ed9e1 100644 --- a/input/input.h +++ b/input/input.h @@ -109,6 +109,7 @@ #define MP_CMD_SWITCH_ANGLE 105 #define MP_CMD_ASS_USE_MARGINS 106 #define MP_CMD_SWITCH_TITLE 107 +#define MP_CMD_STOP 108 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001 -- cgit v1.2.3