]> git.vomp.tv Git - vompclient.git/commitdiff
Improve cec handling in remote linux
authorMarten Richter <marten.richter@freenet.de>
Sat, 23 Nov 2013 10:03:55 +0000 (11:03 +0100)
committerMarten Richter <marten.richter@freenet.de>
Sat, 23 Nov 2013 10:03:55 +0000 (11:03 +0100)
command.cc
command.h
remote.h
remotelinux.cc
remotelinux.h

index 1406d86c722988c29e869f3053d3ca4c04d01f19..ada68c6fa9e41f0598f01f8b8785a43af105808f 100644 (file)
@@ -504,6 +504,16 @@ void Command::handleCommand(int button)
       doStandby();
       return;
     }
+    case Remote::POWERON:
+    {
+      doPowerOn();
+      return;
+    }
+    case Remote::POWEROFF:
+    {
+      doPowerOff();
+      return;
+    }
     case Remote::OK:
     {
       // FIXME
@@ -532,6 +542,19 @@ void Command::sig1()
 }
 
 void Command::doStandby()
+{
+  if (isStandby)
+  {
+    doPowerOn();
+  }
+  else
+  {
+   doPowerOff();
+  }
+}
+
+
+void Command::doPowerOn()
 {
   if (isStandby)
   {
@@ -545,7 +568,11 @@ void Command::doStandby()
     boxstack->add(vconnect);
     vconnect->run();
   }
-  else
+}
+
+void Command::doPowerOff()
+{
+  if (!isStandby)
   {
     VDR::getInstance()->shutdownVDR();
     boxstack->removeAll();
index 4ce464b19e54c654a8780333f55de7863d13405b..746b01121d64d9c7bf71977dd4b237d2049b086c 100644 (file)
--- a/command.h
+++ b/command.h
@@ -68,6 +68,8 @@ class Command : public MessageQueue
   private:
     void handleCommand(int);
     void doStandby();
+    void doPowerOn();
+    void doPowerOff();
     void doJustConnected(VConnect* vconnect);
     void doWallpaper();
     void doFromTheTop(bool which);  // true - show vinfo,wait. false - del vinfo,restart
index 72c0292ee91cf68227f6cf193edc3d958cc943c9..19f370190593f665610cc7903f1a8b0645a24fb4 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -138,6 +138,9 @@ class Remote: public AbstractOption
 
     // Android only
     const static UCHAR PLAYPAUSE       = 201;
+    // cec only
+    const static UCHAR POWERON       = 202;
+    const static UCHAR POWEROFF       = 203;
 
 
     // Remote types
index 77262381707861ac5dc93f382cb49c9fda6a04eb..c0af03678c7048d5de09d14704d70fb47e572825 100644 (file)
@@ -58,6 +58,8 @@ RemoteLinux::RemoteLinux()
   initted = 0;
   curcec=0;
   hascurcec=false;
+  haspower=false;
+  powerkey=0;
   signal=false;
   cec_adap=NULL;
   num_loop=0;
@@ -133,6 +135,7 @@ int RemoteLinux::initCec() {
        cec_callbacks.CBCecKeyPress = cecKeyPress;
        cec_callbacks.CBCecCommand = cecCommand;
        cec_callbacks.CBCecConfigurationChanged = cecConfigurationChanged;
+       cec_callbacks.CBCecSourceActivated = cecSourceActivated;
        cec_config.clientVersion=LIBCEC_VERSION_CURRENT;
        cec_config.bActivateSource=1;
        cec_config.bUseTVMenuLanguage=1;
@@ -262,6 +265,10 @@ UCHAR RemoteLinux::getButtonPress(int waitType) {
                                hascurcec = false;
                                return (UCHAR) TranslateHWC(W_G_HCW(W_HCW_CEC,curcec));
                        }
+                       if (haspower) {
+                               haspower =false;
+                               return powerkey;
+                       }
                        ret = NA_NONE;
                } else {
                        if (retval == -1) {
@@ -911,6 +918,34 @@ int RemoteLinux::cecKeyPress(void*param, const cec_keypress &key)
 int RemoteLinux::cecCommand(void *param, const cec_command &command)
 {
        Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command.opcode);
+       switch (command.opcode) {
+       case CEC_OPCODE_STANDBY: {
+               if (command.initiator==CECDEVICE_TV) {
+                       ((RemoteLinux*)Remote::getInstance())->incomingPowerkey(POWEROFF);
+               }
+       } break;
+       case CEC_OPCODE_DECK_CONTROL: {
+               if (command.initiator==CECDEVICE_TV && command.parameters.size == 1
+                               && command.parameters[0]==CEC_DECK_CONTROL_MODE_STOP) {
+                       ((RemoteLinux*)Remote::getInstance())->incomingCECkey(CEC_USER_CONTROL_CODE_STOP);
+
+               }
+
+       } break;
+       case CEC_OPCODE_PLAY: {
+               if (command.initiator==CECDEVICE_TV && command.parameters.size == 1) {
+                       if (command.parameters[0]==CEC_PLAY_MODE_PLAY_FORWARD) {
+                               ((RemoteLinux*)Remote::getInstance())->incomingCECkey(CEC_USER_CONTROL_CODE_PLAY);
+                       } else if (command.parameters[0]==CEC_PLAY_MODE_PLAY_STILL) {
+                               ((RemoteLinux*)Remote::getInstance())->incomingCECkey(CEC_USER_CONTROL_CODE_PAUSE);
+                       }
+               }
+
+
+       } break;
+       default:
+               break;
+       };
        return 1;
 }
 
@@ -921,6 +956,14 @@ int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration
 
 }
 
+void  RemoteLinux::cecSourceActivated(void*param, const cec_logical_address address, const uint8_t activated)
+{
+       Log::getInstance()->log("Remote", Log::DEBUG, "CECSourceActivated: %d %d", address, activated);
+       if (activated==1) {
+               ((RemoteLinux*)Remote::getInstance())->incomingPowerkey(POWERON);
+       }
+}
+
 void RemoteLinux::incomingCECkey(int keys)
 {
        curcec=keys;
@@ -928,6 +971,11 @@ void RemoteLinux::incomingCECkey(int keys)
 
 }
 
+void RemoteLinux::incomingPowerkey(UCHAR key){
+       haspower=true;
+       powerkey=key;
+}
+
 bool RemoteLinux::loadOptionsfromServer(VDR* vdr)
 {
 
index 9f65884135997551356c8198272a2055e8486e55..bce876008fc19319d8e681babea6ee868a9ff0ab 100644 (file)
@@ -77,6 +77,8 @@ class RemoteLinux : public Remote
        int curcec;
     bool hascurcec;
     bool cechandlesvolume;
+    bool haspower;
+    UCHAR powerkey;
 
     UCHAR TranslateHWCFixed(ULLONG code);
     void InitKeymap();
@@ -88,11 +90,13 @@ class RemoteLinux : public Remote
     CEC::ICECCallbacks cec_callbacks;
 
     void incomingCECkey(int keys);
+    void incomingPowerkey(UCHAR key);
 
        static int cecLogMessage(void *param, const CEC::cec_log_message &message);
        static int cecKeyPress(void*param, const CEC::cec_keypress &key);
        static int cecCommand(void *param, const CEC::cec_command &command);
        static int cecConfigurationChanged(void *param, const CEC::libcec_configuration &config);
+       static void cecSourceActivated(void*param, const CEC::cec_logical_address address, const uint8_t activated);
 
 };