From 716b1c96b938de8562a65bd7082741c5f1ccd3a3 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 6 Feb 2011 01:39:54 +0100 Subject: [PATCH] neutrino: add rcsim --- src/Makefile.am | 4 +- src/create_rcsim_h.sh | 56 ++++++++++ src/rcsim.c | 246 ++++++++++++++++++++++++++++++++++++++++++ src/rcsim.h | 174 ++++++++++++++++++++++++++++++ 4 files changed, 479 insertions(+), 1 deletion(-) create mode 100644 src/create_rcsim_h.sh create mode 100644 src/rcsim.c create mode 100644 src/rcsim.h diff --git a/src/Makefile.am b/src/Makefile.am index 3f3d13361..b2efb30f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,10 +30,12 @@ else VORBISLIBS = -lvorbisfile -lvorbis -logg endif -bin_PROGRAMS = neutrino +bin_PROGRAMS = neutrino rcsim neutrino_SOURCES = neutrino_menue.cpp neutrino.cpp +rcsim_SOURCES = rcsim.c rcsim.h + AM_CPPFLAGS = if ENABLE_FLAC diff --git a/src/create_rcsim_h.sh b/src/create_rcsim_h.sh new file mode 100644 index 000000000..90bcab10e --- /dev/null +++ b/src/create_rcsim_h.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# +# create a rcsim.h file from the rcinput header +# (C) 2011 Stefan Seyfried +# License: GPL v2 +# +# usage: sh ./create_rcsim_h.sh > rcsim.h + +cat << EOF +#ifndef KEY_GAMES +#define KEY_GAMES 0x1a1 /* Media Select Games */ +#endif + +#ifndef KEY_TOPLEFT +#define KEY_TOPLEFT 0x1a2 +#endif + +#ifndef KEY_TOPRIGHT +#define KEY_TOPRIGHT 0x1a3 +#endif + +#ifndef KEY_BOTTOMLEFT +#define KEY_BOTTOMLEFT 0x1a4 +#endif + +#ifndef KEY_BOTTOMRIGHT +#define KEY_BOTTOMRIGHT 0x1a5 +#endif + +#define KEY_POWERON KEY_FN_F1 +#define KEY_POWEROFF KEY_FN_F2 +#define KEY_STANDBYON KEY_FN_F3 +#define KEY_STANDBYOFF KEY_FN_F4 +#define KEY_MUTEON KEY_FN_F5 +#define KEY_MUTEOFF KEY_FN_F6 +#define KEY_ANALOGON KEY_FN_F7 +#define KEY_ANALOGOFF KEY_FN_F8 + +enum { +EOF +sed -n '/^[[:space:]]*RC_0/,/^[[:space:]]*RC_analog_off/s/^[[:space:]]*/ /p' driver/rcinput.h +cat << EOF +}; + +struct key{ + char *name; + unsigned long code; +}; + +static const struct key keyname[] = { +EOF +sed -n '/^[[:space:]]*RC_0/,/^[[:space:]]*RC_analog_off/ s/^.*=[[:space:]]*\(KEY_.*\),.*/ { "\1", \1 },/p' driver/rcinput.h +cat << EOF +}; + +EOF diff --git a/src/rcsim.c b/src/rcsim.c new file mode 100644 index 000000000..841cdf083 --- /dev/null +++ b/src/rcsim.c @@ -0,0 +1,246 @@ +/****************************************************************************** + * rcsim - rcsim.c + * + * simulates the remote control, sends the requested key + * + * (c) 2003 Carsten Juttner (carjay@gmx.net) + * (c) 2009 Stefan Seyfried, add code to use the neutrino socket instead + * of the input subsystem for dreambox / tripledragon + * (c) 2011 Stefan Seyfried, convert driver/rcinput.h via script to + * rcsim.h for automated import of new keys + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. + * + ******************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* if you want use HAVE_XX_HARDWARE, better include config.h :-) */ +#include "config.h" + +#ifdef HAVE_DBOX_HARDWARE +#define EVENTDEV "/dev/input/event0" +#else +/* dreambox and tripledragon do not use a "normal" input device, so we cannot + (ab-)use the event repeating function of it. use the neutrino socket instead. */ +#include +#include +#define NEUTRINO_SOCKET "/tmp/neutrino.sock" + +/* those structs / values are stolen from libeventserver */ +struct eventHead +{ + unsigned int eventID; + unsigned int initiatorID; + unsigned int dataSize; +}; + +enum initiators +{ + INITID_CONTROLD, + INITID_SECTIONSD, + INITID_ZAPIT, + INITID_TIMERD, + INITID_HTTPD, + INITID_NEUTRINO, + INITID_GENERIC_INPUT_EVENT_PROVIDER +}; +#endif + +enum { // not defined in input.h but used like that, at least in 2.4.22 + KEY_RELEASED = 0, + KEY_PRESSED, + KEY_AUTOREPEAT +}; + +#include "rcsim.h" + +void usage(char *n){ + unsigned int keynum = sizeof(keyname)/sizeof(struct key); + unsigned int i; + printf ("rcsim v1.1\nUsage: %s [