From fc2f5b2cd655f1391f2abda1b39e37cdec98a951 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 17 Oct 2003 15:35:43 +0000 Subject: Initial revision --- lib/driver/Makefile.am | 7 ++ lib/driver/Makefile.in | 313 +++++++++++++++++++++++++++++++++++++++++++++++ lib/driver/input_fake.h | 84 +++++++++++++ lib/driver/rc.cpp | 245 +++++++++++++++++++++++++++++++++++++ lib/driver/rc.h | 226 ++++++++++++++++++++++++++++++++++ lib/driver/rcdbox.h | 61 +++++++++ lib/driver/rcdreambox2.h | 51 ++++++++ lib/driver/rcinput.cpp | 126 +++++++++++++++++++ lib/driver/rcinput.h | 17 +++ lib/driver/rfmod.h | 33 +++++ lib/driver/streamwd.h | 28 +++++ 11 files changed, 1191 insertions(+) create mode 100644 lib/driver/Makefile.am create mode 100644 lib/driver/Makefile.in create mode 100644 lib/driver/input_fake.h create mode 100644 lib/driver/rc.cpp create mode 100644 lib/driver/rc.h create mode 100644 lib/driver/rcdbox.h create mode 100644 lib/driver/rcdreambox2.h create mode 100644 lib/driver/rcinput.cpp create mode 100644 lib/driver/rcinput.h create mode 100644 lib/driver/rfmod.h create mode 100644 lib/driver/streamwd.h (limited to 'lib/driver') diff --git a/lib/driver/Makefile.am b/lib/driver/Makefile.am new file mode 100644 index 00000000..eff4486f --- /dev/null +++ b/lib/driver/Makefile.am @@ -0,0 +1,7 @@ +INCLUDES = \ + -I$(top_srcdir)/include + +noinst_LIBRARIES = libenigma_driver.a + +libenigma_driver_a_SOURCES = \ + rc.cpp rcinput.cpp \ No newline at end of file diff --git a/lib/driver/Makefile.in b/lib/driver/Makefile.in new file mode 100644 index 00000000..4c7b1125 --- /dev/null +++ b/lib/driver/Makefile.in @@ -0,0 +1,313 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AMTAR = @AMTAR@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CC = @CC@ +CONFIGDIR = @CONFIGDIR@ +CXX = @CXX@ +DATADIR = @DATADIR@ +DEPDIR = @DEPDIR@ +DRIVER = @DRIVER@ +DUMMYPOFILES = @DUMMYPOFILES@ +EXEEXT = @EXEEXT@ +FONTDIR = @FONTDIR@ +GAMESDIR = @GAMESDIR@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBDIR = @LIBDIR@ +MAINT = @MAINT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ +PLUGINDIR = @PLUGINDIR@ +POFILES = @POFILES@ +RANLIB = @RANLIB@ +UCODEDIR = @UCODEDIR@ +UPDATEPOFILES = @UPDATEPOFILES@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +_LIBDIR = @_LIBDIR@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ +targetdatadir = @targetdatadir@ +targetlocalstatedir = @targetlocalstatedir@ +targetprefix = @targetprefix@ +targetsysconfdir = @targetsysconfdir@ + +INCLUDES = \ + -I$(top_srcdir)/include + + +noinst_LIBRARIES = libenigma_driver.a + +libenigma_driver_a_SOURCES = \ + rc.cpp rcinput.cpp + +subdir = lib/driver +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + +libenigma_driver_a_AR = $(AR) cru +libenigma_driver_a_LIBADD = +am_libenigma_driver_a_OBJECTS = rc.$(OBJEXT) rcinput.$(OBJEXT) +libenigma_driver_a_OBJECTS = $(am_libenigma_driver_a_OBJECTS) + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/rc.Po $(DEPDIR)/rcinput.Po +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +CXXFLAGS = @CXXFLAGS@ +DIST_SOURCES = $(libenigma_driver_a_SOURCES) +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libenigma_driver_a_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu lib/driver/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +AR = ar + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libenigma_driver.a: $(libenigma_driver_a_OBJECTS) $(libenigma_driver_a_DEPENDENCIES) + -rm -f libenigma_driver.a + $(libenigma_driver_a_AR) libenigma_driver.a $(libenigma_driver_a_OBJECTS) $(libenigma_driver_a_LIBADD) + $(RANLIB) libenigma_driver.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rcinput.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.cpp.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(CXXCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< + +.cpp.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(CXXCOMPILE) -c -o $@ `cygpath -w $<` +CXXDEPMODE = @CXXDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-tags distdir dvi \ + dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/lib/driver/input_fake.h b/lib/driver/input_fake.h new file mode 100644 index 00000000..7aecc9f9 --- /dev/null +++ b/lib/driver/input_fake.h @@ -0,0 +1,84 @@ +#ifndef _INPUT_FAKE_H +#define _INPUT_FAKE_H + +#include + + +#if !defined(KEY_OK) + +/** + * define some additional remote control keys in case they + * were not already defined above in + */ + +#define KEY_OK 0x160 +#define KEY_SELECT 0x161 +#define KEY_GOTO 0x162 +#define KEY_CLEAR 0x163 +#define KEY_POWER2 0x164 +#define KEY_OPTION 0x165 +#define KEY_INFO 0x166 +#define KEY_TIME 0x167 +#define KEY_VENDOR 0x168 +#define KEY_ARCHIVE 0x169 +#define KEY_PROGRAM 0x16a +#define KEY_CHANNEL 0x16b +#define KEY_FAVORITES 0x16c +#define KEY_EPG 0x16d +#define KEY_PVR 0x16e +#define KEY_MHP 0x16f +#define KEY_LANGUAGE 0x170 +#define KEY_TITLE 0x171 +#define KEY_SUBTITLE 0x172 +#define KEY_ANGLE 0x173 +#define KEY_ZOOM 0x174 +#define KEY_MODE 0x175 +#define KEY_KEYBOARD 0x176 +#define KEY_SCREEN 0x177 +#define KEY_PC 0x178 +#define KEY_TV 0x179 +#define KEY_TV2 0x17a +#define KEY_VCR 0x17b +#define KEY_VCR2 0x17c +#define KEY_SAT 0x17d +#define KEY_SAT2 0x17e +#define KEY_CD 0x17f +#define KEY_TAPE 0x180 +#define KEY_RADIO 0x181 +#define KEY_TUNER 0x182 +#define KEY_PLAYER 0x183 +#define KEY_TEXT 0x184 +#define KEY_DVD 0x185 +#define KEY_AUX 0x186 +#define KEY_MP3 0x187 +#define KEY_AUDIO 0x188 +#define KEY_VIDEO 0x189 +#define KEY_DIRECTORY 0x18a +#define KEY_LIST 0x18b +#define KEY_MEMO 0x18c +#define KEY_CALENDAR 0x18d +#define KEY_RED 0x18e +#define KEY_GREEN 0x18f +#define KEY_YELLOW 0x190 +#define KEY_BLUE 0x191 +#define KEY_CHANNELUP 0x192 +#define KEY_CHANNELDOWN 0x193 +#define KEY_FIRST 0x194 +#define KEY_LAST 0x195 +#define KEY_AB 0x196 +#define KEY_PLAY 0x197 +#define KEY_RESTART 0x198 +#define KEY_SLOW 0x199 +#define KEY_SHUFFLE 0x19a +#define KEY_FASTFORWARD 0x19b +#define KEY_PREVIOUS 0x19c +#define KEY_NEXT 0x19d +#define KEY_DIGITS 0x19e +#define KEY_TEEN 0x19f +#define KEY_TWEN 0x1a0 +#define KEY_BREAK 0x1a1 + + +#endif /* !defined(KEY_OK) */ +#endif /* _INPUT_FAKE_H */ + diff --git a/lib/driver/rc.cpp b/lib/driver/rc.cpp new file mode 100644 index 00000000..790c5f6c --- /dev/null +++ b/lib/driver/rc.cpp @@ -0,0 +1,245 @@ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* + * note on the enigma input layer: + * the enigma input layer (rc*) supports n different devices which + * all have completely different interfaces, mapped down to 32bit + + * make/break/release codes mapped down (via xml files) to "actions". + * this was necessary to support multiple remote controls with proprietary + * interfaces. now everybody is using input devices, and thus adding + * another input layer seems to be a bit overkill. BUT: + * image a remote control with two hundred buttons. each and every function + * in enigma can be bound to a button. no need to use them twice. + * for example, you would have KEY_MENU assigned to a menu for setup etc., + * but no audio and video settings, since you have special keys for that, + * and you don't want to display a big menu with entries that are available + * with another single key. + * then image a remote control with ten buttons. do you really want to waste + * KEY_MENU for a simple menu? you need the audio/video settings there too. + * take this just as a (bad) example. another (better) example might be front- + * button-keys. usually you have KEY_UP, KEY_DOWN, KEY_POWER. you don't want + * them to behave like the remote-control-KEY_UP, KEY_DOWN and KEY_POWER, + * don't you? + * so here we can map same keys of different input devices to different + * actions. have fun. + */ + +int eRCDevice::getKeyCompatibleCode(const eRCKey &) const +{ + return -1; +} + +eRCDevice::eRCDevice(eString id, eRCDriver *driver): driver(driver), id(id) +{ + input=driver->getInput(); + driver->addCodeListener(this); + eRCInput::getInstance()->addDevice(id, this); +} + +eRCDevice::~eRCDevice() +{ + driver->removeCodeListener(this); + eRCInput::getInstance()->removeDevice(id.c_str()); +} + +eRCDriver::eRCDriver(eRCInput *input): input(input), enabled(1) +{ +} + +eRCDriver::~eRCDriver() +{ + for (std::list::iterator i=listeners.begin(); i!=listeners.end(); ++i) + delete *i; +} + +void eRCShortDriver::keyPressed(int) +{ + __u16 rccode; + while (1) + { + if (read(handle, &rccode, 2)!=2) + break; + if (enabled && !input->islocked()) + for (std::list::iterator i(listeners.begin()); i!=listeners.end(); ++i) + (*i)->handleCode(rccode); + } +} + +eRCShortDriver::eRCShortDriver(const char *filename): eRCDriver(eRCInput::getInstance()) +{ + handle=open(filename, O_RDONLY|O_NONBLOCK); + if (handle<0) + { + eDebug("failed to open %s", filename); + sn=0; + } else + { + sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read); + CONNECT(sn->activated, eRCShortDriver::keyPressed); + eRCInput::getInstance()->setFile(handle); + } +} + +eRCShortDriver::~eRCShortDriver() +{ + if (handle>=0) + close(handle); + if (sn) + delete sn; +} + +void eRCInputEventDriver::keyPressed(int) +{ + struct input_event ev; + while (1) + { + if (read(handle, &ev, sizeof(struct input_event))!=sizeof(struct input_event)) + break; + if (enabled && !input->islocked()) + for (std::list::iterator i(listeners.begin()); i!=listeners.end(); ++i) + (*i)->handleCode((int)&ev); + } +} + +eRCInputEventDriver::eRCInputEventDriver(const char *filename): eRCDriver(eRCInput::getInstance()) +{ + handle=open(filename, O_RDONLY|O_NONBLOCK); + if (handle<0) + { + eDebug("failed to open %s", filename); + sn=0; + } else + { + sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read); + CONNECT(sn->activated, eRCInputEventDriver::keyPressed); + eRCInput::getInstance()->setFile(handle); + } +} + +eString eRCInputEventDriver::getDeviceName() +{ + char name[128]=""; + if (handle >= 0) + ::ioctl(handle, EVIOCGNAME(128), name); + return name; +} + +eRCInputEventDriver::~eRCInputEventDriver() +{ + if (handle>=0) + close(handle); + if (sn) + delete sn; +} + +eRCConfig::eRCConfig() +{ + reload(); +} + +eRCConfig::~eRCConfig() +{ + save(); +} + +void eRCConfig::set( int delay, int repeat ) +{ + rdelay = delay; + rrate = repeat; +} + +void eRCConfig::reload() +{ + rdelay=500; + rrate=100; + if ( eConfig::getInstance()->getKey("/ezap/rc/repeatRate", rrate) ) + save(); + eConfig::getInstance()->getKey("/ezap/rc/repeatDelay", rdelay); +} + +void eRCConfig::save() +{ + eConfig::getInstance()->setKey("/ezap/rc/repeatRate", rrate); + eConfig::getInstance()->setKey("/ezap/rc/repeatDelay", rdelay); +} + +eRCInput *eRCInput::instance; + +eRCInput::eRCInput() +{ + ASSERT( !instance); + instance=this; + handle = -1; + locked = 0; +} + +eRCInput::~eRCInput() +{ +} + +void eRCInput::close() +{ +} + +bool eRCInput::open() +{ + return false; +} + +int eRCInput::lock() +{ + locked=1; + return handle; +} + +void eRCInput::unlock() +{ + if (locked) + locked=0; +} + +void eRCInput::setFile(int newh) +{ + handle=newh; +} + +void eRCInput::addDevice(const eString &id, eRCDevice *dev) +{ + devices.insert(std::pair(id, dev)); +} + +void eRCInput::removeDevice(const eString &id) +{ + devices.erase(id); +} + +eRCDevice *eRCInput::getDevice(const eString &id) +{ + std::map::iterator i=devices.find(id); + if (i == devices.end()) + { + eDebug("failed, possible choices are:"); + for (std::map::iterator i=devices.begin(); i != devices.end(); ++i) + eDebug("%s", i->first.c_str()); + return 0; + } + return i->second; +} + +std::map &eRCInput::getDevices() +{ + return devices; +} + +eAutoInitP0 init_rcinput(eAutoInitNumbers::rc, "RC Input layer"); diff --git a/lib/driver/rc.h b/lib/driver/rc.h new file mode 100644 index 00000000..557be5ea --- /dev/null +++ b/lib/driver/rc.h @@ -0,0 +1,226 @@ +#ifndef __rc_h +#define __rc_h + +#include +#include + +#include +#include +#include + +class eRCInput; +class eRCDriver; +class eRCKey; + +/** + * \brief A remote control. + * + * Handles one remote control. Gets codes from a \ref eRCDriver. Produces events in \ref eRCInput. + */ +class eRCDevice: public Object +{ +protected: + eRCInput *input; + eRCDriver *driver; + eString id; +public: + /** + * \brief Constructs a new remote control. + * + * \param id The identifier of the RC, for use in settings. + * \param input The \ref eRCDriver where this remote gets its codes from. + */ + eRCDevice(eString id, eRCDriver *input); + ~eRCDevice(); + /** + * \brief Handles a device specific code. + * + * Generates events in \ref eRCInput. code is highly device- and driver dependant. + * For Example, it might be 16bit codes with one bit make/break or special codes + * for repeat. + */ + virtual void handleCode(int code)=0; + /** + * \brief Get user readable description. + * \result The description. + */ + virtual const char *getDescription() const=0; + const eString getIdentifier() const { return id; } + /** + * \brief Get a description for a specific key. + * \param key The key to get the description for. + * \result User readable description of given key. + */ + virtual const char *getKeyDescription(const eRCKey &key) const=0; + /** + * \brief Get a dbox2-compatible keycode. + * + * THIS IS DEPRECATED! DON'T USE IT UNLESS YOU NEED IT! + * \param key The key to get the compatible code for. + * \result The dbox2-compatible code. (new RC as defined in enum). + */ + virtual int getKeyCompatibleCode(const eRCKey &key) const; +}; + +/** + * Receives codes from one or more remote controls. + */ +class eRCDriver: public Object +{ +protected: + std::list listeners; + eRCInput *input; + int enabled; +public: + /** + * \brief Constructs a driver. + * + * \param input The RCInput to bind this driver to. + */ + eRCDriver(eRCInput *input); + /** + * \brief Get pointer to key-consumer. + */ + eRCInput *getInput() const { return input; } + /** + * \brief Adds a code lister + */ + void addCodeListener(eRCDevice *dev) + { + listeners.push_back(dev); + } + void removeCodeListener(eRCDevice *dev) + { + listeners.remove(dev); + } + ~eRCDriver(); + + void enable(int en) { enabled=en; } +}; + +class eRCShortDriver: public eRCDriver +{ +protected: + int handle; + eSocketNotifier *sn; + void keyPressed(int); +public: + eRCShortDriver(const char *filename); + ~eRCShortDriver(); +}; + +class eRCInputEventDriver: public eRCDriver +{ +protected: + int handle; + eSocketNotifier *sn; + void keyPressed(int); +public: + eString getDeviceName(); + eRCInputEventDriver(const char *filename); + ~eRCInputEventDriver(); +}; + +class eRCKey +{ +public: + eRCDevice *producer; + int code, flags; + + eRCKey(eRCDevice *producer, int code, int flags): + producer(producer), code(code), flags(flags) + { + } + enum + { + flagBreak=1, + flagRepeat=2 + }; + + bool operator<(const eRCKey &r) const + { + if (r.producer == producer) + { + if (r.code == code) + { + if (r.flags < flags) + return 1; + else + return 0; + } else if (r.code < code) + return 1; + else + return 0; + } else if (r.producer < producer) + return 1; + else + return 0; + } +}; + +class eRCConfig +{ +public: + eRCConfig(); + ~eRCConfig(); + void reload(); + void save(); + void set(int delay, int repeat); + int rdelay, // keypress delay after first keypress to begin of repeat (in ms) + rrate; // repeat rate (in ms) +}; + +class eRCInput: public Object +{ + int locked; + int handle; + static eRCInput *instance; + +public: + struct lstr + { + bool operator()(const eString &a, const eString &b) const + { + return a devices; +public: + Signal1 keyEvent; + enum + { + RC_0=0, RC_1=0x1, RC_2=0x2, RC_3=0x3, RC_4=0x4, RC_5=0x5, RC_6=0x6, RC_7=0x7, + RC_8=0x8, RC_9=0x9, + RC_RIGHT=10, RC_LEFT=11, RC_UP=12, RC_DOWN=13, RC_OK=14, RC_MUTE=15, + RC_STANDBY=16, RC_GREEN=17, RC_YELLOW=18, RC_RED=19, RC_BLUE=20, RC_PLUS=21, RC_MINUS=22, + RC_HELP=23, RC_DBOX=24, + RC_UP_LEFT=27, RC_UP_RIGHT=28, RC_DOWN_LEFT=29, RC_DOWN_RIGHT=30, RC_HOME=31 + }; + eRCInput(); + ~eRCInput(); + + int lock(); + void unlock(); + int islocked() { return locked; } + void close(); + bool open(); + + void setFile(int handle); + + void keyPressed(const eRCKey &key) + { + /*emit*/ keyEvent(key); + } + + void addDevice(const eString &id, eRCDevice *dev); + void removeDevice(const eString &id); + eRCDevice *getDevice(const eString &id); + std::map &getDevices(); + + static eRCInput *getInstance() { return instance; } + + eRCConfig config; +}; + +#endif diff --git a/lib/driver/rcdbox.h b/lib/driver/rcdbox.h new file mode 100644 index 00000000..bd361f67 --- /dev/null +++ b/lib/driver/rcdbox.h @@ -0,0 +1,61 @@ +#ifndef DISABLE_DBOX_RC + +#ifndef __rcdbox_h +#define __rcdbox_h + +#include + +class eRCDeviceDBoxOld: public eRCDevice +{ + int last, ccode; + eTimer timeout, repeattimer; +private: + void timeOut(); + void repeat(); +public: + void handleCode(int code); + eRCDeviceDBoxOld(eRCDriver *driver); + const char *getDescription() const; + const char *getKeyDescription(const eRCKey &key) const; + int getKeyCompatibleCode(const eRCKey &key) const; +}; + +class eRCDeviceDBoxNew: public eRCDevice +{ + int last, ccode; + eTimer timeout, repeattimer; +private: + void timeOut(); + void repeat(); +public: + void handleCode(int code); + eRCDeviceDBoxNew(eRCDriver *driver); + const char *getDescription() const; + const char *getKeyDescription(const eRCKey &key) const; + int getKeyCompatibleCode(const eRCKey &key) const; +}; + +class eRCDeviceDBoxButton: public eRCDevice +{ + int last; + eTimer repeattimer; +private: + void repeat(); +public: + void handleCode(int code); + eRCDeviceDBoxButton(eRCDriver *driver); + const char *getDescription() const; + + const char *getKeyDescription(const eRCKey &key) const; + int getKeyCompatibleCode(const eRCKey &key) const; +}; + +class eRCDBoxDriver: public eRCShortDriver +{ +public: + eRCDBoxDriver(); +}; + +#endif + +#endif // DISABLE_DBOX_RC diff --git a/lib/driver/rcdreambox2.h b/lib/driver/rcdreambox2.h new file mode 100644 index 00000000..e77beb4e --- /dev/null +++ b/lib/driver/rcdreambox2.h @@ -0,0 +1,51 @@ +#ifndef DISABLE_DREAMBOX_RC + +#ifndef __rcdreambox2_h +#define __rcdreambox2_h + +#include + +class eRCDeviceDreambox2: public eRCDevice +{ + int last, ccode; + eTimer timeout, repeattimer; +private: + void timeOut(); + void repeat(); +public: + void handleCode(int code); + eRCDeviceDreambox2(eRCDriver *driver); + const char *getDescription() const; + const char *getKeyDescription(const eRCKey &key) const; + int getKeyCompatibleCode(const eRCKey &key) const; +}; + +class eRCDreamboxDriver2: public eRCShortDriver +{ +public: + eRCDreamboxDriver2(); +}; + +class eRCDeviceDreamboxButton: public eRCDevice +{ + int last; + eTimer repeattimer; +private: + void repeat(); +public: + void handleCode(int code); + eRCDeviceDreamboxButton(eRCDriver *driver); + const char *getDescription() const; + + const char *getKeyDescription(const eRCKey &key) const; + int getKeyCompatibleCode(const eRCKey &key) const; +}; + +class eRCDreamboxButtonDriver: public eRCShortDriver +{ +public: + eRCDreamboxButtonDriver(); +}; +#endif + +#endif // DISABLE_DREAMBOX_RC diff --git a/lib/driver/rcinput.cpp b/lib/driver/rcinput.cpp new file mode 100644 index 00000000..041330a1 --- /dev/null +++ b/lib/driver/rcinput.cpp @@ -0,0 +1,126 @@ +#include + +#include +#include +#include + +#include +#include +#include +#include + +void eRCDeviceInputDev::handleCode(int rccode) +{ + struct input_event *ev = (struct input_event *)rccode; + if (ev->type!=EV_KEY) + return; + eDebug("%x %x %x", ev->value, ev->code, ev->type); + switch (ev->value) + { + case 0: + /*emit*/ input->keyPressed(eRCKey(this, ev->code, eRCKey::flagBreak)); + break; + case 1: + /*emit*/ input->keyPressed(eRCKey(this, ev->code, 0)); + break; + case 2: + /*emit*/ input->keyPressed(eRCKey(this, ev->code, eRCKey::flagRepeat)); + break; + } +} + +eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver): eRCDevice(driver->getDeviceName(), driver) +{ +} + +const char *eRCDeviceInputDev::getDescription() const +{ + return id.c_str(); +} + +const char *eRCDeviceInputDev::getKeyDescription(const eRCKey &key) const +{ + switch (key.code) + { + case KEY_0: return "0"; + case KEY_1: return "1"; + case KEY_2: return "2"; + case KEY_3: return "3"; + case KEY_4: return "4"; + case KEY_5: return "5"; + case KEY_6: return "6"; + case KEY_7: return "7"; + case KEY_8: return "8"; + case KEY_9: return "9"; + case KEY_RIGHT: return "rechts"; + case KEY_LEFT: return "links"; + case KEY_UP: return "oben"; + case KEY_DOWN: return "unten"; + case KEY_OK: return "ok"; + case KEY_MUTE: return "mute"; + case KEY_POWER: return "power"; + case KEY_GREEN: return "gruen"; + case KEY_YELLOW: return "gelb"; + case KEY_RED: return "rot"; + case KEY_BLUE: return "blau"; + case KEY_VOLUMEUP: return "Lautstaerke plus"; + case KEY_VOLUMEDOWN: return "Lautstaerke minus"; + case KEY_HELP: return "?"; + case KEY_SETUP: return "d-Box"; +#if 0 + case KEY_TOPLEFT: return "oben links"; + case KEY_TOPRIGHT: return "oben rechts"; + case KEY_BOTTOMLEFT: return "unten links"; + case KEY_BOTTOMRIGHT: return "unten rechts"; +#endif + case KEY_HOME: return "home"; + default: return 0; + } +} + +int eRCDeviceInputDev::getKeyCompatibleCode(const eRCKey &key) const +{ + switch (key.code) + { + case KEY_0: return eRCInput::RC_0; + case KEY_1: return eRCInput::RC_1; + case KEY_2: return eRCInput::RC_2; + case KEY_3: return eRCInput::RC_3; + case KEY_4: return eRCInput::RC_4; + case KEY_5: return eRCInput::RC_5; + case KEY_6: return eRCInput::RC_6; + case KEY_7: return eRCInput::RC_7; + case KEY_8: return eRCInput::RC_8; + case KEY_9: return eRCInput::RC_9; + case KEY_RIGHT: return eRCInput::RC_RIGHT; + case KEY_LEFT: return eRCInput::RC_LEFT; + case KEY_UP: return eRCInput::RC_UP; + case KEY_DOWN: return eRCInput::RC_DOWN; + case KEY_OK: return eRCInput::RC_OK; + case KEY_MUTE: return eRCInput::RC_MUTE; + case KEY_POWER: return eRCInput::RC_STANDBY; + case KEY_GREEN: return eRCInput::RC_GREEN; + case KEY_YELLOW: return eRCInput::RC_YELLOW; + case KEY_RED: return eRCInput::RC_RED; + case KEY_VOLUMEUP: return eRCInput::RC_PLUS; + case KEY_BLUE: return eRCInput::RC_BLUE; + case KEY_VOLUMEDOWN: return eRCInput::RC_MINUS; + case KEY_HELP: return eRCInput::RC_HELP; + case KEY_SETUP: return eRCInput::RC_DBOX; + case KEY_HOME: return eRCInput::RC_HOME; + } + return -1; +} + + +class eInputDeviceInit +{ + eRCInputEventDriver driver; + eRCDeviceInputDev deviceInputDev; +public: + eInputDeviceInit(): driver("/dev/input/event0"), deviceInputDev(&driver) + { + } +}; + +eAutoInitP0 init_rcinputdev(eAutoInitNumbers::rc+1, "input device driver"); diff --git a/lib/driver/rcinput.h b/lib/driver/rcinput.h new file mode 100644 index 00000000..c13eafb1 --- /dev/null +++ b/lib/driver/rcinput.h @@ -0,0 +1,17 @@ +#ifndef __rcdbox_h +#define __rcdbox_h + +#include + +class eRCDeviceInputDev: public eRCDevice +{ +public: + void handleCode(int code); + eRCDeviceInputDev(eRCInputEventDriver *driver); + const char *getDescription() const; + + const char *getKeyDescription(const eRCKey &key) const; + int getKeyCompatibleCode(const eRCKey &key) const; +}; + +#endif diff --git a/lib/driver/rfmod.h b/lib/driver/rfmod.h new file mode 100644 index 00000000..e3acc47d --- /dev/null +++ b/lib/driver/rfmod.h @@ -0,0 +1,33 @@ +#ifdef ENABLE_RFMOD + +#ifndef __erfmod_h +#define __erfmod_h + +#include + +class eRFmod: public Object +{ + static eRFmod *instance; + + int rfmodfd; + int channel,soundsubcarrier,soundenable,finetune; + +public: + eRFmod(); + ~eRFmod(); + + void init(); + + static eRFmod *getInstance(); + + int save(); + + int setChannel(int channel); + int setSoundSubCarrier(int val); + int setSoundEnable(int val); + int setFinetune(int val); + int setTestPattern(int val); +}; +#endif + +#endif // ENABLE_RFMOD diff --git a/lib/driver/streamwd.h b/lib/driver/streamwd.h new file mode 100644 index 00000000..ae8498ff --- /dev/null +++ b/lib/driver/streamwd.h @@ -0,0 +1,28 @@ +#ifndef __streamwd_h +#define __streamwd_h + +#include +#include +#include +#include + +class eStreamWatchdog: public Object +{ + eSocketNotifier* sn; + int handle; + int isanamorph; + static eStreamWatchdog *instance; +private: + void check(int); + int getVCRActivity(); +public: + void reloadSettings(); + eStreamWatchdog(); + ~eStreamWatchdog(); + static eStreamWatchdog *getInstance(); + int isAnamorph(); + Signal1 AspectRatioChanged; + Signal1 VCRActivityChanged; +}; + +#endif -- cgit v1.2.3