From ec25a8accefd6330ca03c44abacf8b5c394327be Mon Sep 17 00:00:00 2001 From: "Chang.H.S" Date: Thu, 3 Nov 2011 16:29:19 +0900 Subject: [PATCH] HDMICEC : add new plugin 1. add advanced keys 2. additional menu key --- configure.ac | 3 + lib/driver/Makefile.am | 6 +- lib/driver/Makefile.am.rej | 12 + lib/driver/hdmi_cec.cpp | 77 +++ lib/driver/hdmi_cec.h | 40 ++ .../Plugins/SystemPlugins/HDMICEC/Makefile.am | 8 + .../Plugins/SystemPlugins/HDMICEC/__init__.py | 1 + .../SystemPlugins/HDMICEC/components/HdmiCec.py | 183 +++++++ .../SystemPlugins/HDMICEC/components/Makefile.am | 4 + .../Plugins/SystemPlugins/HDMICEC/hdmicec.png | Bin 0 -> 7733 bytes .../Plugins/SystemPlugins/HDMICEC/meta/Makefile.am | 3 + .../SystemPlugins/HDMICEC/meta/plugin_hdmicec.xml | 15 + lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py | 580 +++++++++++++++++++++ lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- lib/python/Plugins/SystemPlugins/Rules-po.mak | 44 ++ lib/python/Screens/Standby.py | 4 + lib/python/enigma_python.i | 10 + 17 files changed, 989 insertions(+), 3 deletions(-) create mode 100644 lib/driver/Makefile.am.rej create mode 100755 lib/driver/hdmi_cec.cpp create mode 100644 lib/driver/hdmi_cec.h create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/__init__.py create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/hdmicec.png create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/meta/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/meta/plugin_hdmicec.xml create mode 100755 lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py create mode 100755 lib/python/Plugins/SystemPlugins/Rules-po.mak diff --git a/configure.ac b/configure.ac index 5aa3862..b8389fe 100644 --- a/configure.ac +++ b/configure.ac @@ -220,6 +220,9 @@ lib/python/Plugins/SystemPlugins/UI3DSetup/Makefile lib/python/Plugins/SystemPlugins/UI3DSetup/meta/Makefile lib/python/Plugins/SystemPlugins/UIPositionSetup/Makefile lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/Makefile +lib/python/Plugins/SystemPlugins/HDMICEC/Makefile +lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile +lib/python/Plugins/SystemPlugins/HDMICEC/meta/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/driver/Makefile.am b/lib/driver/Makefile.am index b498a6c..a781229 100755 --- a/lib/driver/Makefile.am +++ b/lib/driver/Makefile.am @@ -16,7 +16,8 @@ libenigma_driver_a_SOURCES = \ rc.cpp \ rcconsole.cpp \ rcinput.cpp \ - rfmod.cpp + rfmod.cpp \ + hdmi_cec.cpp driverincludedir = $(pkgincludedir)/lib/driver driverinclude_HEADERS = \ @@ -29,7 +30,8 @@ driverinclude_HEADERS = \ rcdbox.h \ rcdreambox2.h \ rcinput.h \ - rfmod.h + rfmod.h \ + hdmi_cec.h if HAVE_LIBSDL libenigma_driver_a_SOURCES += \ diff --git a/lib/driver/Makefile.am.rej b/lib/driver/Makefile.am.rej new file mode 100644 index 0000000..a93a63d --- /dev/null +++ b/lib/driver/Makefile.am.rej @@ -0,0 +1,12 @@ +--- lib/driver/Makefile.am 2011-07-28 14:07:33.514734895 +0200 ++++ lib/driver/Makefile.am 2011-07-28 14:07:37.014483733 +0200 +@@ -18,7 +18,8 @@ + rcinput.cpp \ + rfmod.cpp \ + memtest.cpp \ +- sc_test.cpp ++ sc_test.cpp \ ++ hdmi_cec.cpp + + driverincludedir = $(pkgincludedir)/lib/driver + driverinclude_HEADERS = \ diff --git a/lib/driver/hdmi_cec.cpp b/lib/driver/hdmi_cec.cpp new file mode 100755 index 0000000..9153470 --- /dev/null +++ b/lib/driver/hdmi_cec.cpp @@ -0,0 +1,77 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +eHdmiCEC *eHdmiCEC::instance = NULL; + +eHdmiCEC::eHdmiCEC() +{ + ASSERT(!instance); + instance = this; + hdmiFd = ::open("/dev/hdmi_cec", O_RDWR | O_NONBLOCK); + if (hdmiFd >= 0) + { + messageNotifier = eSocketNotifier::create(eApp, hdmiFd, eSocketNotifier::Read); + CONNECT(messageNotifier->activated, eHdmiCEC::hdmiEvent); + } +} + +eHdmiCEC::~eHdmiCEC() +{ + if (hdmiFd >= 0) ::close(hdmiFd); +} + +eHdmiCEC *eHdmiCEC::getInstance() +{ + return instance; +} + +void eHdmiCEC::hdmiEvent(int what) +{ + struct cec_message message; + if (::read(hdmiFd, &message, 2) == 2) + { + if (::read(hdmiFd, &message.data, message.length) == message.length) + { + messageReceived(message.address, message.data[0]); + //eDebug("[HDMI-CEC] ******************* received from %02x command: %02x %02x %02x %02x", message.address, message.data[0], message.data[1], message.data[2], message.data[3]); + switch(message.data[0]) + { + case 0x44: + messageReceivedKey(message.address, message.data[1]); + break; + /*case 0x45: + messageReceivedKey(message.address, message.data[1]); + break; + for future functions =) + case 0x99: + messageReceivedKey(message.address, message.data[1]); + SecondmessageReceivedKey(message.address, message.data[2]); + break; + */ + } + } + } +} + +void eHdmiCEC::sendMessage(unsigned char address, unsigned char length, char *data) +{ + if (hdmiFd >= 0) + { + struct cec_message message; + message.address = address; + if (length > sizeof(message.data)) length = sizeof(message.data); + message.length = length; + memcpy(message.data, data, length); + ::write(hdmiFd, &message, 2 + length); + } +} + +eAutoInitP0 init_hdmicec(eAutoInitNumbers::rc, "Hdmi CEC driver"); diff --git a/lib/driver/hdmi_cec.h b/lib/driver/hdmi_cec.h new file mode 100644 index 0000000..f081eea --- /dev/null +++ b/lib/driver/hdmi_cec.h @@ -0,0 +1,40 @@ +#ifndef _hdmi_cec_h +#define _hdmi_cec_h + +#include +#include + +class eSocketNotifier; + +class eHdmiCEC: public Object +{ +#ifndef SWIG +public: +struct cec_message +{ + unsigned char address; + unsigned char length; + unsigned char data[256]; +}__attribute__((packed)); +#endif +protected: + static eHdmiCEC *instance; + int hdmiFd; + ePtr messageNotifier; + void hdmiEvent(int what); +#ifdef SWIG + eHdmiCEC(); + ~eHdmiCEC(); +#endif +public: +#ifndef SWIG + eHdmiCEC(); + ~eHdmiCEC(); +#endif + static eHdmiCEC *getInstance(); + PSignal2 messageReceived; + PSignal2 messageReceivedKey; + void sendMessage(unsigned char address, unsigned char length, char *data); +}; + +#endif diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/Makefile.am b/lib/python/Plugins/SystemPlugins/HDMICEC/Makefile.am new file mode 100755 index 0000000..28fe308 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/HDMICEC/Makefile.am @@ -0,0 +1,8 @@ +installdir = /usr/lib/enigma2/python/Plugins/SystemPlugins/HDMICEC + +install_PYTHON = *.py + +install_DATA = *.png + +SUBDIRS = components meta + diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/__init__.py b/lib/python/Plugins/SystemPlugins/HDMICEC/__init__.py new file mode 100755 index 0000000..5f28270 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/HDMICEC/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py b/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py new file mode 100755 index 0000000..63e9c0c --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py @@ -0,0 +1,183 @@ +import struct +from config import config, ConfigSelection, ConfigYesNo, ConfigSubsection, ConfigText +from enigma import eHdmiCEC, eTimer +from Screens.Standby import inStandby +import Screens.Standby +from Tools import Notifications +import time +from os import system + + + +class HdmiCec: + def __init__(self): + config.hdmicec = ConfigSubsection() + config.hdmicec.enabled = ConfigYesNo(default = True) + config.hdmicec.logenabledserial = ConfigYesNo(default = False) + config.hdmicec.logenabledfile = ConfigYesNo(default = False) + config.hdmicec.tvstandby = ConfigYesNo(default = False) + config.hdmicec.tvwakeup = ConfigYesNo(default = False) + config.hdmicec.boxstandby = ConfigYesNo(default = False) + config.hdmicec.enabletvrc = ConfigYesNo(default = True) + config.hdmicec.active_source_reply = ConfigYesNo(default = True) + config.hdmicec.standby_message = ConfigSelection( + choices = { + "standby,inactive": _("TV standby"), + "standby,avpwroff,inactive,": _("TV + A/V standby"), + "inactive": _("Source inactive"), + "nothing": _("Nothing"), + }, + default = "standby,inactive") + config.hdmicec.deepstandby_message = ConfigSelection( + choices = { + "standby,inactive": _("TV standby"), + "standby,avdeeppwroff,inactive": _("TV + A/V standby"), + "inactive": _("Source inactive"), + "nothing": _("Nothing"), + }, + default = "standby,inactive") + config.hdmicec.wakeup_message = ConfigSelection( + choices = { + "wakeup,active,activevu": _("TV wakeup"), + "wakeup,avpwron,active,activevu": _("TV + A/V wakeup"), + "active": _("Source active"), + "nothing": _("Nothing"), + }, + default = "wakeup,active,activevu") + config.hdmicec.vustandby_message = ConfigSelection( + choices = { + "vustandby": _("VU standby"), + "vudeepstandby": _("VU DeepStandby"), + "vunothing": _("Nothing"), + }, + default = "vustandby") + config.hdmicec.vuwakeup_message = ConfigSelection( + choices = { + "vuwakeup": _("VU wakeup"), + "vunothing": _("Nothing"), + }, + default = "vuwakeup") + config.hdmicec.tvinput = ConfigSelection(default = "1", + choices = [ + ("1", _("HDMI 1")), + ("2", _("HDMI 2")), + ("3", _("HDMI 3")), + ("4", _("HDMI 4")), + ("5", _("HDMI 5"))]) + config.hdmicec.avinput = ConfigSelection(default ="0", + choices = [ + ("0", _("no A/V Receiver")), + ("1", _("HDMI 1")), + ("2", _("HDMI 2")), + ("3", _("HDMI 3")), + ("4", _("HDMI 4")), + ("5", _("HDMI 5"))]) + config.hdmicec.devicename = ConfigSelection( + choices = { + "vuduo": _("VU-Duo"), + "vusolo": _("VU-Solo"), + "vuuno": _("VU-Uno"), + "vuultimo":_("VU-Ultimo"), + }, + default = "vuduo") + + config.misc.standbyCounter.addNotifier(self.enterStandby, initial_call = False) + config.misc.DeepStandbyOn.addNotifier(self.enterDeepStandby, initial_call = False) + self.leaveDeepStandby() + + def sendMessages(self, messages): + for message in messages.split(','): + cmd = None + logcmd = None + addressvaluebroadcast = int("0F",16) + addressvalue = int("0",16) + addressvalueav = int("5",16) + wakeupmessage = int("04",16) + standbymessage=int("36",16) + activesourcemessage=int("82",16) + inactivesourcemessage=int("9D",16) + sendkeymessage = int("44",16) + sendkeypwronmessage = int("6D",16) + sendkeypwroffmessage = int("6C",16) + activevumessage=int("85",16) + physaddress1 = int("0x" + str(config.hdmicec.tvinput.value) + str(config.hdmicec.avinput.value),16) + physaddress2 = int("0x00",16) + + if message == "wakeup": + cmd = struct.pack('B', wakeupmessage) + logcmd = "[HDMI-CEC] ** WakeUpMessage ** send message: %x to address %x" % (wakeupmessage, addressvalue) + elif message == "active": + addressvalue = addressvaluebroadcast + cmd = struct.pack('BBB', activesourcemessage,physaddress1,physaddress2) + logcmd = "[HDMI-CEC] ** ActiveSourceMessage ** send message: %x:%x:%x to address %x" % (activesourcemessage,physaddress1,physaddress2,addressvalue) + elif message == "standby": + cmd = struct.pack('B', standbymessage) + logcmd = "[HDMI-CEC] ** StandByMessage ** send message: %x to address %x" % (standbymessage, addressvalue) + elif message == "inactive": + addressvalue = addressvaluebroadcast + cmd = struct.pack('BBB', inactivesourcemessage,physaddress1,physaddress2) + logcmd = "[HDMI-CEC] ** InActiveSourceMessage ** send message: %x:%x:%x to address %x" % (inactivesourcemessage,physaddress1,physaddress2,addressvalue) + elif message == "avpwron": + cmd = struct.pack('BB', sendkeymessage,sendkeypwronmessage) + addressvalue = addressvalueav + logcmd = "[HDMI-CEC] ** Power on A/V ** send message: %x:%x to address %x" % (sendkeymessage, sendkeypwronmessage, addressvalue) + elif message == "avdeeppwroff": + cmd = struct.pack('BB',sendkeymessage,sendkeypwroffmessage) + addressvalue = addressvalueav + logcmd = "[HDMI-CEC] ** Standby A/V (Deepstandby)** send message: %x:%x to address %x" % (sendkeymessage,sendkeypwroffmessage, addressvalue) + elif message == "avpwroff": + addressvalue = addressvalueav + cmd = struct.pack('BB',sendkeymessage,sendkeypwroffmessage) + logcmd = "[HDMI-CEC] ** Standby A/V ** send message: %x:%x to address %x" % (sendkeymessage,sendkeypwroffmessage, addressvalue) + elif message == "activevu": + addressvalue = addressvaluebroadcast + cmd = struct.pack('B', activevumessage) + logcmd = "[HDMI-CEC] ** Active VU Message ** send message: %x to address %x" % (activevumessage,addressvalue) + if cmd: + eHdmiCEC.getInstance().sendMessage(addressvalue, len(cmd), str(cmd)) + time.sleep(1) + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + + + def leaveStandby(self): + if config.hdmicec.enabled.value is True: + self.sendMessages(config.hdmicec.wakeup_message.value) + + def enterStandby(self, configElement): + from Screens.Standby import inStandby + inStandby.onClose.append(self.leaveStandby) + if config.hdmicec.enabled.value is True: + self.sendMessages(config.hdmicec.standby_message.value) + + def enterDeepStandby(self,configElement): + if config.hdmicec.enabled.value is True: + self.sendMessages(config.hdmicec.deepstandby_message.value) + + def leaveDeepStandby(self): + if config.hdmicec.enabled.value is True: + self.sendMessages(config.hdmicec.wakeup_message.value) + +## not used + def activeSource(self): + if config.hdmicec.enabled.value is True: + physadress1 = "0x" + str(config.hdmicec.tvinput.value) + str(config.hdmicec.avinput.value) + physadress2 = "0x00" + cecmessage = int('0x82',16) + address = int('0x0F',16) + valuethree = int(physadress1,16) + valuefour = int(physadress2,16) + cmd = struct.pack('BBB',cecmessage,valuethree,valuefour) + eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) + if config.hdmicec.enabletvrc.value: + cecmessage = int('0x8E',16) + address = int('0',16) + valuethree = int('0',16) + cmd = struct.pack('BB',cecmessage,valuethree) + eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) + +hdmi_cec = HdmiCec() diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile.am b/lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile.am new file mode 100755 index 0000000..a3b66cf --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile.am @@ -0,0 +1,4 @@ +installdir = /usr/lib/enigma2/python/Components + +install_PYTHON = *.py + diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/hdmicec.png b/lib/python/Plugins/SystemPlugins/HDMICEC/hdmicec.png new file mode 100755 index 0000000000000000000000000000000000000000..a79e36842c94d13c074b16a118079a56d3ac40e2 GIT binary patch literal 7733 zcmcI}XIN9))-FYQN01gVR6&G<1c8K5q)CyEbfhKpP=kctk={XilOjs*2-2iikxdh% zV?eqfMHDXXy}y0Vcb@y)`|HeSty#u1-Z92}=a^&tSdp6QkEqC5$?@>;sFaoDwXa9i z^~+C6eBIywf}6b_Zn(=T>ylnKUs7bm^_t8@$#Ku(|?Qj$~uff`uNMGj?ar{wL1 z((zW;weohbf+0DjrN|Lj_%#@f!dL*YXh$b^I98JLPn+=T`EN0Z6ZoeJ#zB(v;csU^ z12s*coUtOzD zoKoc1Bf<@74cC@e{M+aCN|MtSgK>d_K%SnSLY`0|XEz&=FboC*fgvCWMDSWe(A~=k zV}TWPa_9QX$p6@pN4Z<)xuGmD&ThKS&W=)lZC}yO4dvBmbAuzr6kn zkCL~*prjyRVXz<=DkvSD8Zv%C__^i!9lPZyhhHC}!%Tr_U|BZ_a2Uxa0G41f*|LnPRn&UnWJI(d1JXky;kSA-tHA{L-kY=WilsPj>#xhoS9(ArQ zJ20segG`wAhmL|Y9%Qk-%^Ka698Ypjb~o5(YrUy_{rPqh3b@HG zm>+mbuqD!M=vGk8$=yf|;?B?|Mc`+4hSYIT(2;GOFCPbF*s- z!Js^1Ht@7Qzz;w*DW%pD;;=e-6TZ3>QU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81ZtQkE~fs!_3s;mrnudWDE~?VUW3 zjuas*tJEeYzC9P7tt0ca79|?KoPu;V3Dd< zJeQ3Ahp%)Y22X}o(DS!S>!;sU375`D5)<3&bY9|#SEJ|M(6+WMo|yWx$-N6kfA!f0 zheVHU`<6?>F<9E7=jVCq_p;pI5#Ozc`QO}&=v^B)HfN6qV3fy%$Bm5S%;(uc8K + + + + + + HdmiCecSetup + enigma2-plugin-systemplugins-hdmicec + Support HDMI CEC + Support HDMI CEC + + + + + diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py b/lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py new file mode 100755 index 0000000..415783c --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py @@ -0,0 +1,580 @@ +# -*- coding: utf-8 -*- + +# maintainer: + +#This plugin is free software, you are allowed to +#modify it (if you keep the license), +#but you are not allowed to distribute/publish +#it without source code (this version and your modifications). +#This means you also have to distribute +#source code of your modifications. + + + +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Plugins.Plugin import PluginDescriptor +from Components.ActionMap import ActionMap,NumberActionMap +from enigma import eActionMap +from Components.config import config, getConfigListEntry, ConfigInteger, ConfigSubsection, ConfigSelection, ConfigText, ConfigYesNo, NoSave, ConfigNothing +from Components.ConfigList import ConfigListScreen +from Components.HdmiCec import HdmiCec +from Components.Sources.StaticText import StaticText +from Tools import Notifications +import struct +from enigma import eHdmiCEC +from os import system +from __init__ import _ +from Components.InputDevice import iInputDevices + +class HdmiCecPlugin(Screen,ConfigListScreen): + skin = """ + + + + + + + + + + + """ + def __init__(self, session): + Screen.__init__(self, session) + + + config.hdmicec.input_address = ConfigText(default = "0", visible_width = 50, fixed_size = False) + config.hdmicec.input_value1 = ConfigText(default = "0", visible_width = 50, fixed_size = False) + config.hdmicec.input_value2 = ConfigText(default = "", visible_width = 50, fixed_size = False) + config.hdmicec.input_value3 = ConfigText(default = "", visible_width = 50, fixed_size = False) + config.hdmicec.input_value4 = ConfigText(default = "", visible_width = 50, fixed_size = False) + config.hdmicec.avvolup = NoSave(ConfigNothing()) + config.hdmicec.avvoldown = NoSave(ConfigNothing()) + config.hdmicec.avvolmute = NoSave(ConfigNothing()) + config.hdmicec.avpwroff = NoSave(ConfigNothing()) + config.hdmicec.avpwron = NoSave(ConfigNothing()) + config.hdmicec.tvpwroff = NoSave(ConfigNothing()) + config.hdmicec.tvpwron = NoSave(ConfigNothing()) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Save")) + self["key_yellow"] = StaticText(_("Connect")) + self["key_blue"] = StaticText(_("Disconnect")) + self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions", "NumberActions" ], + { + "ok": self.keyOk, + "cancel": self.keyCancel, + "red": self.keyCancel, + "green": self.keySave, + "yellow": self.keyConnect, + "blue": self.keyDisconnect, + }, -2) + self.list = [] + ConfigListScreen.__init__(self, self.list,session = session) + self.createSetup() + + def createSetup(self): + self.list = [] + self.hdmienabled = getConfigListEntry(_(_("HDMI CEC enabled:")), config.hdmicec.enabled) + self.hdmiactivesourcereply = getConfigListEntry(_(_("Active Source Reply On:")), config.hdmicec.active_source_reply) + self.hdmitvstandby = getConfigListEntry(_("VU standby => TV activity:"), config.hdmicec.standby_message) + self.hdmitvdeepstandby = getConfigListEntry(_("VU deepstandby => TV activity:"), config.hdmicec.deepstandby_message) + self.hdmitvwakeup = getConfigListEntry(_("VU on => TV activity:"), config.hdmicec.wakeup_message) + self.hdmivustandby = getConfigListEntry(_("TV standby => VU+ activity:"), config.hdmicec.vustandby_message) + self.hdmivuwakeup = getConfigListEntry(_("TV on => VU+ activity:"), config.hdmicec.vuwakeup_message) + self.hdmitvinput = getConfigListEntry(_("Choose TV HDMI input:"), config.hdmicec.tvinput) + self.hdmiavinput = getConfigListEntry(_("Choose A/V-Receiver HDMI input:"), config.hdmicec.avinput) + self.hdmiavvolup = getConfigListEntry(_("A/V-Receiver volume up:"), config.hdmicec.avvolup) + self.hdmiavvoldown = getConfigListEntry(_("A/V-Receiver volume down:"), config.hdmicec.avvoldown) + self.hdmiavvolmute = getConfigListEntry(_("A/V-Receiver toggle mute:"), config.hdmicec.avvolmute) + self.hdmiavpwron = getConfigListEntry(_("A/V-Receiver power on:"), config.hdmicec.avpwron) + self.hdmiavpwroff = getConfigListEntry(_("A/V-Receiver power off:"), config.hdmicec.avpwroff) + self.hdmitvpwron = getConfigListEntry(_("TV power on:"), config.hdmicec.tvpwron) + self.hdmitvpwroff = getConfigListEntry(_("TV power off:"), config.hdmicec.tvpwroff) + self.hdmienabletvrc = getConfigListEntry(_("Use TV remotecontrol:"), config.hdmicec.enabletvrc) + self.hdmidevicename = getConfigListEntry(_("Set VU device name:"), config.hdmicec.devicename) + self.hdmiinputaddress = getConfigListEntry(_("Address (0~FF):"), config.hdmicec.input_address) + self.hdmiinputvalue1 = getConfigListEntry("Value 1 (message):", config.hdmicec.input_value1) + self.hdmiinputvalue2 = getConfigListEntry("Value 2 (optional):", config.hdmicec.input_value2) + self.hdmiinputvalue3 = getConfigListEntry("Value 3 (optional):", config.hdmicec.input_value3) + self.hdmiinputvalue4 = getConfigListEntry("Value 4 (optional):", config.hdmicec.input_value4) + self.hdmilogenabledfile = getConfigListEntry("Log to file enabled :", config.hdmicec.logenabledfile) + self.hdmilogenabledserial = getConfigListEntry("Serial log enabled :", config.hdmicec.logenabledserial) +# self.list.append( self.hdmiinputaddress ) +# self.list.append( self.hdmiinputvalue1 ) +# self.list.append( self.hdmiinputvalue2 ) +# self.list.append( self.hdmiinputvalue3 ) +# self.list.append( self.hdmiinputvalue4 ) +# self.list.append( self.hdmilogenabledfile ) + self.list.append( self.hdmienabled ) + if config.hdmicec.enabled.value is True: + self.list.append( self.hdmidevicename ) + self.list.append( self.hdmitvinput ) + self.list.append( self.hdmiavinput ) + self.list.append( self.hdmivuwakeup ) + self.list.append( self.hdmivustandby ) + self.list.append( self.hdmitvwakeup ) + self.list.append( self.hdmitvstandby ) + self.list.append( self.hdmitvdeepstandby ) + if config.hdmicec.avinput.value is not "0": + self.list.append( self.hdmiavvolup ) + self.list.append( self.hdmiavvoldown ) + self.list.append( self.hdmiavvolmute ) + self.list.append( self.hdmiavpwron ) + self.list.append( self.hdmiavpwroff ) + self.list.append( self.hdmitvpwron ) + self.list.append( self.hdmitvpwroff ) + self.list.append( self.hdmienabletvrc ) + self.list.append( self.hdmiactivesourcereply ) + self.list.append( self.hdmilogenabledserial ) + self["config"].list = self.list + self["config"].l.setList(self.list) + + def keyDisconnect(self): + cmd = None + logcmd = None + physaddress1 = int("0x" + str(config.hdmicec.tvinput.value) + str(config.hdmicec.avinput.value),16) + physaddress2 = int("0x00",16) + address = int('0',16) + cecmessage = int('0x9D',16) + cecmessagetwo = physaddress1 + cecmessagethree = physaddress2 + cmd = struct.pack('BBB',cecmessage,cecmessagetwo,cecmessagethree) + logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % (cecmessage,cecmessagetwo,cecmessagethree,address) + + if cmd: + eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) + + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + + def keySend(self): + cmd = None + logcmd = None + addresstmp=config.hdmicec.input_address.value + tmp1=config.hdmicec.input_value1.value + tmp2=config.hdmicec.input_value2.value + tmp3=config.hdmicec.input_value3.value + tmp4=config.hdmicec.input_value4.value + address=int(addresstmp,16) + if address not in range(0,256): + address = 255 + if tmp4: + val1=int(tmp1,16) + val2=int(tmp2,16) + val3=int(tmp3,16) + val4=int(tmp4,16) + if val1 not in range(0,256): + val1 = 00 + if val2 not in range(0,256): + val2 = 00 + if val3 not in range(0,256): + val3 = 00 + if val4 not in range(0,256): + val4 = 00 + cmd = struct.pack('BBBB',val1,val2,val3,val4) + logcmd = "[HDMI-CEC] ** Test Message ** Send message value: %x:%x:%x:%x to address %x" % (val1,val2,val3,val4,address) + else: + + if tmp3: + val1=int(tmp1,16) + val2=int(tmp2,16) + val3=int(tmp3,16) + if val1 not in range(0,256): + val1 = 00 + if val2 not in range(0,256): + val2 = 00 + if val3 not in range(0,256): + val3 = 00 + cmd = struct.pack('BBB',val1,val2,val3) + logcmd = "[HDMI-CEC] ** Test Message ** Send message value: %x:%x:%x to address %x" % (val1,val2,val3,address) + else: + + if tmp2: + val1=int(tmp1,16) + val2=int(tmp2,16) + if val1 not in range(0,256): + val1 = 00 + if val2 not in range(0,256): + val2 = 00 + cmd = struct.pack('BB',val1,val2) + logcmd = "[HDMI-CEC] ** Test Message ** Send message value: %x:%x to address %x" % (val1,val2,address) + else: + val1=int(tmp1,16) + if val1 not in range(0,256): + val1 = 00 + cmd = struct.pack('B',val1) + logcmd = "[HDMI-CEC] ** Test Message ** Send message value: %x to address %x" % (val1, address) + + if cmd: + eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) + + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + + def keyOk(self): + cmd = None + logcmd = None + if self["config"].getCurrent() == self.hdmiavvolup: + address = int("5",16) + cecmessage = int("44",16) + cecmessagetwo = int("41",16) + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + elif self["config"].getCurrent() == self.hdmiavvoldown: + address = int("5",16) + cecmessage = int("44",16) + cecmessagetwo = int("42",16) + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + elif self["config"].getCurrent() == self.hdmiavvolmute: + address = int("5",16) + cecmessage = int("44",16) + cecmessagetwo = int("43",16) + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + elif self["config"].getCurrent() == self.hdmiavpwron: + address = int("5",16) + cecmessage = int("44",16) + cecmessagetwo = int("6D",16) + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + elif self["config"].getCurrent() == self.hdmiavpwroff: + address = int("5",16) + cecmessage = int("44",16) + cecmessagetwo = int("6C",16) + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + elif self["config"].getCurrent() == self.hdmitvpwroff: + address = int("0",16) + cecmessage = int("36",16) + cmd = struct.pack('B',cecmessage) + logcmd = "[HDMI-CEC] send cec message %x to %x" % (cecmessage,address) + elif self["config"].getCurrent() == self.hdmitvpwron: + address = int("0",16) + cecmessage = int("04",16) + cmd = struct.pack('B',cecmessage) + logcmd = "[HDMI-CEC] send cec message %x to %x" % (cecmessage,address) + else: + ConfigListScreen.keySave(self) + if cmd: + eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) + messagecmd = int("45",16) + + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + + def keyConnect(self): + address = 0 + message = 0x85 + messageReceived(address, message) + + def keyLeft(self): + ConfigListScreen.keyLeft(self) + if self["config"].getCurrent() == self.hdmienabled: + self.createSetup() + if self["config"].getCurrent() == self.hdmiavinput: + self.createSetup() + + def keyRight(self): + ConfigListScreen.keyRight(self) + if self["config"].getCurrent() == self.hdmienabled: + self.createSetup() + if self["config"].getCurrent() == self.hdmiavinput: + self.createSetup() + + def keyCancel(self): + self.close() + + def keySave(self): + ConfigListScreen.keySave(self) + +def openconfig(session, **kwargs): + session.open(HdmiCecPlugin) + +def autostart(reason, **kwargs): + global session + if kwargs.has_key("session") and reason == 0: + session = kwargs["session"] + eHdmiCEC.getInstance().messageReceived.get().append(messageReceived) + eHdmiCEC.getInstance().messageReceivedKey.get().append(messageReceivedKey) + +def Plugins(**kwargs): + return [PluginDescriptor(name=_("HDMI-CEC"), description="HDMI-CEC Configuration", where = PluginDescriptor.WHERE_PLUGINMENU, icon="hdmicec.png", needsRestart = True, fnc=openconfig), + PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart)] + +def messageReceived(address, message): + logcmd = "[HDMI-CEC] received cec message %x from %x" % (message, address) + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + + if config.hdmicec.enabled.value is True: + from Screens.Standby import inStandby + from Screens.Standby import Standby + + cmd = None + cmdtwo = None + addresstwo = None + logcmd = None + logcmdtwo = None + + physaddress1 = int("0x" + str(config.hdmicec.tvinput.value) + str(config.hdmicec.avinput.value),16) + physaddress2 = int("0x00",16) + + addresstv = int("0x00",16) + addressav = int("0x05",16) + addressglobal = int("0x0F",16) + + powerstatereportmessage = int("0x90",16) + powerstate = int("0x00",16) + + physaddressmessage = int('0x84',16) + devicetypmessage = int('0x03',16) + + activesourcemessage = int('0x82',16) + + menuonmessage = int('0x8E',16) + menustatemessage = int('0x00',16) + + setnamemessage = int('0x47',16) + + sendkeymessage = int("44",16) + sendkeypwronmessage = int("6D",16) + sendkeypwroffmessage = int("6C",16) + + if message == 0x8f: # request power state + address = addresstv + cecmessage = powerstatereportmessage + cecmessagetwo = powerstate + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + + elif message == 0x83: # request physical address + address = addressglobal + cecmessage = physaddressmessage + cecmessagetwo = physaddress1 + cecmessagethree = physaddress2 + cecmessagefour = devicetypmessage + cmd = struct.pack('BBBB',cecmessage,cecmessagetwo,cecmessagethree,cecmessagefour) + logcmd = "[HDMI-CEC] send cec message %x:%x:%x:%x to %x" % (cecmessage,cecmessagetwo,cecmessagethree,cecmessagefour,address) + + elif message == 0x86: # request streampath + address = addressglobal + cecmessage = activesourcemessage + cecmessagetwo = physaddress1 + cecmessagethree = physaddress2 + cmd = struct.pack('BBB',cecmessage,cecmessagetwo,cecmessagethree) + logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % (cecmessage,cecmessagetwo,cecmessagethree,address) + + if config.hdmicec.enabletvrc.value: + addresstwo = addresstv + cecmessage = menuonmessage + cecmessagetwo = menustatemessage + cmdtwo = struct.pack('BB',cecmessage,cecmessagetwo) + logcmdtwo = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + + elif message == 0x8d: # request menu state + if config.hdmicec.enabletvrc.value: + address = addresstv + cecmessage = menuonmessage + cecmessagetwo = menustatemessage + cmd = struct.pack('BB',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + + elif message == 0x46: # request device name + address = addresstv + cecmessage = setnamemessage + if config.hdmicec.devicename.value == "vuduo": + cecmessagetwo ="VU+ Duo" + cmd = struct.pack('B8s',cecmessage,cecmessagetwo) + elif config.hdmicec.devicename.value == "vusolo": + cecmessagetwo ="VU+ Solo" + cmd = struct.pack('B9s',cecmessage,cecmessagetwo) + elif config.hdmicec.devicename.value == "vuuno": + cecmessagetwo ="VU+ Uno" + cmd = struct.pack('B8s',cecmessage,cecmessagetwo) + elif config.hdmicec.devicename.value == "vuultimo": + cecmessagetwo ="VU+ Ultimo" + cmd = struct.pack('B8s',cecmessage,cecmessagetwo) + else: + cecmessagetwo ="VU+" + cmd = struct.pack('B4s',cecmessage,cecmessagetwo) + logcmd = "[HDMI-CEC] send cec message %x:%s to %x" % (cecmessage,cecmessagetwo,address) + + elif message == 0x85: # request active source + if not inStandby: + address = addressglobal + cecmessage = activesourcemessage + cecmessagetwo = physaddress1 + cecmessagethree = physaddress2 + cmd = struct.pack('BBB',cecmessage,cecmessagetwo,cecmessagethree) + logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % (cecmessage,cecmessagetwo,cecmessagethree,address) + + if config.hdmicec.enabletvrc.value: + addresstwo = addresstv + cecmessage = menuonmessage + cecmessagetwo = menustatemessage + cmdtwo = struct.pack('BB',cecmessage,cecmessagetwo) + logcmdtwo = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + + elif inStandby: + if config.hdmicec.vuwakeup_message.value == "vuwakeup": + inStandby.Power() + address = addressglobal + cecmessage = activesourcemessage + cecmessagetwo = physaddress1 + cecmessagethree = physaddress2 + cmd = struct.pack('BBB',cecmessage,cecmessagetwo,cecmessagethree) + logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % (cecmessage,cecmessagetwo,cecmessagethree,address) + + if config.hdmicec.enabletvrc.value: + addresstwo = addresstv + cecmessage = menuonmessage + cecmessagetwo = menustatemessage + cmdtwo = struct.pack('BB',cecmessage,cecmessagetwo) + logcmdtwo = "[HDMI-CEC] send cec message %x:%x to %x" % (cecmessage,cecmessagetwo,address) + + elif message == 0x36: + if config.hdmicec.vustandby_message.value == "vustandby": + if inStandby == None: + logcmd = "[HDMI-CEC] VU+ STB goto standby" + session.open(Standby) + elif config.hdmicec.vustandby_message.value == "vudeepstandby": + import Screens.Standby + logcmd = "[HDMI-CEC] VU+ STB goto deepstandby" + session.open(Screens.Standby.TryQuitMainloop,1) + + if cmd: + eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) + if cmdtwo: + eHdmiCEC.getInstance().sendMessage(addresstwo, len(cmdtwo), str(cmdtwo)) + + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + if logcmdtwo: + if config.hdmicec.logenabledserial.value: + print logcmdtwo + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmdtwo) + system(filelog) + +def messageReceivedKey(address, message): + logcmd = "[HDMI-CEC] received cec message part two %x from %x" % (message, address) + if logcmd: + if config.hdmicec.logenabledserial.value: + print logcmd + if config.hdmicec.logenabledfile.value: + filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) + system(filelog) + if config.hdmicec.enabled.value is True: + rcdevicename = iInputDevices.getDeviceName('event0') # hschang : get rc device name, /dev/input/event0 + keyaction = eActionMap.getInstance() + key = None +#start translate keycodes + if message == 0x32 or message == 0x09: #key menu + key = int(139) + elif message == 0x20: #key 0 + key = int(11) + elif message == 0x21: #key 1 + key = int(2) + elif message == 0x22: #key 2 + key = int(3) + elif message == 0x23: #key 3 + key = int(4) + elif message == 0x24: #key 4 + key = int(5) + elif message == 0x25: #key 5 + key = int(6) + elif message == 0x26: #key 6 + key = int(7) + elif message == 0x27: #key 7 + key = int(8) + elif message == 0x28: #key 8 + key = int(9) + elif message == 0x29: #key 10 + key = int(10) + elif message == 0x30: #key bouquet up + key = int(402) + elif message == 0x31: #key bouquet down + key = int(403) + elif message == 0x53: #key info/epg + key = int(358) + elif message == 0x00: #key ok + key = int(352) + elif message == 0x03: #key left + key = int(105) + elif message == 0x04: #key right + key = int(106) + elif message == 0x01: #key up + key = int(103) + elif message == 0x02: #key down + key = int(108) + elif message == 0x0d: #key exit + key = int(174) + elif message == 0x72: #key red + key = int(398) + elif message == 0x71: #key blue + key = int(401) + elif message == 0x73: #key green + key = int(399) + elif message == 0x74: #key yellow + key = int(400) + elif message == 0x44: #key play + if rcdevicename.find("advanced"): + key = int(164) # KEY_PLAYPAUSE + else: + key = int(207) # KEY_PLAY + elif message == 0x46: #key pause + if rcdevicename.find("advanced"): + key = int(164) # KEY_PLAYPAUSE + else: + key = int(119) # KEY_PAUSE + elif message == 0x45: #key stop + key = int(128) + elif message == 0x47: #key record + key = int(167) + elif message == 0x49: #fast forward + if rcdevicename.find("advanced"): + key = int(163) # KEY_NEXTSONG + else: + key = int(208) # KEY_FASTFORWARD + elif message == 0x48: #rewind + if rcdevicename.find("advanced"): + key = int(165) # KEY_NEXTSONG + else: + key = int(168) # KEY_FASTFORWARD + elif message == 0x60: #play 2 + key = int(207) + elif message == 0x61: #key pause 2 + if rcdevicename.find("advanced"): + key = int(164) # KEY_PLAYPAUSE + else: + key = int(119) # KEY_PAUSE + elif message == 0x64: #key stop 2 + key = int(128) + elif message == 0x62: #key record 2 + key = int(167) +#end translate keycodes + if key: + keyaction.keyPressed(rcdevicename, key, int(0)) + keyaction.keyPressed(rcdevicename, key, int(1)) diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index 28c3d94..da14371 100755 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \ DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \ CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \ TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \ - Blindscan RemoteControlCode UI3DSetup UIPositionSetup + Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC install_PYTHON = \ __init__.py diff --git a/lib/python/Plugins/SystemPlugins/Rules-po.mak b/lib/python/Plugins/SystemPlugins/Rules-po.mak new file mode 100755 index 0000000..c588e8c --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/Rules-po.mak @@ -0,0 +1,44 @@ +CATEGORY ?= "SystemPlugins" + +plugindir = $(libdir)/enigma2/python/Plugins/$(CATEGORY)/$(PLUGIN) + +LANGMO = $(LANGS:=.mo) +LANGPO = $(LANGS:=.po) + +if UPDATE_PO +# the TRANSLATORS: allows putting translation comments before the to-be-translated line. +$(PLUGIN)-py.pot: $(srcdir)/../*.py + $(XGETTEXT) -L python --from-code=UTF-8 --add-comments="TRANSLATORS:" -d $(PLUGIN) -s -o $@ $^ + +$(PLUGIN)-xml.pot: $(top_srcdir)/xml2po.py $(srcdir)/../*.xml + $(PYTHON) $^ > $@ + +$(PLUGIN).pot: $(PLUGIN)-py.pot $(PLUGIN)-xml.pot + cat $^ | $(MSGUNIQ) --no-location -o $@ - + +%.po: $(PLUGIN).pot + if [ -f $@ ]; then \ + $(MSGMERGE) --backup=none --no-location -s -N -U $@ $< && touch $@; \ + else \ + $(MSGINIT) -l $@ -o $@ -i $< --no-translator; \ + fi +endif + +.po.mo: + $(MSGFMT) -o $@ $< + +BUILT_SOURCES = $(LANGMO) +CLEANFILES = $(LANGMO) $(PLUGIN)-py.pot $(PLUGIN)-xml.pot $(PLUGIN).pot + +dist-hook: $(LANGPO) + +install-data-local: $(LANGMO) + for lang in $(LANGS); do \ + $(mkinstalldirs) $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES; \ + $(INSTALL_DATA) $$lang.mo $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES/$(PLUGIN).mo; \ + done + +uninstall-local: + for lang in $(LANGS); do \ + $(RM) $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES/$(PLUGIN).mo; \ + done diff --git a/lib/python/Screens/Standby.py b/lib/python/Screens/Standby.py index 94a56ee..0c7670b 100644 --- a/lib/python/Screens/Standby.py +++ b/lib/python/Screens/Standby.py @@ -102,8 +102,10 @@ from enigma import quitMainloop, iRecordableService from Screens.MessageBox import MessageBox from time import time from Components.Task import job_manager +from Components.config import ConfigYesNo,NoSave inTryQuitMainloop = False +config.misc.DeepStandbyOn = NoSave(ConfigYesNo(default=False)) class TryQuitMainloop(MessageBox): def __init__(self, session, retvalue=1, timeout=-1, default_yes = True): @@ -160,6 +162,8 @@ class TryQuitMainloop(MessageBox): self.conntected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: + if self.retval ==1: + config.misc.DeepStandbyOn.value=True quitMainloop(self.retval) else: MessageBox.close(self, True) diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 7e250cf..7a42f76 100755 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -90,6 +90,7 @@ is usually caused by not marking PSignals as immutable. #include #include #include +#include #include #include #include @@ -158,6 +159,8 @@ typedef long time_t; %immutable eSocket_UI::socketStateChanged; %immutable eDVBResourceManager::frontendUseMaskChanged; %immutable eAVSwitch::vcr_sb_notifier; +%immutable eHdmiCEC::messageReceived; +%immutable eHdmiCEC::messageReceivedKey; %immutable ePythonMessagePump::recv_msg; %immutable eDVBLocalTimeHandler::m_timeUpdated; %include @@ -207,6 +210,7 @@ typedef long time_t; %include %include %include +%include %include %include %include @@ -262,6 +266,12 @@ public: $1 = $input->get(); } +%template(PSignal2VII) PSignal2; + +%typemap(out) PSignal2VII { + $1 = $input->get(); +} + %{ RESULT SwigFromPython(ePtr &result, PyObject *obj) { -- 2.7.4