]> git.vomp.tv Git - vompclient.git/commitdiff
WIP
authorChris Tallon <chris@vomp.tv>
Mon, 17 Feb 2020 16:17:47 +0000 (16:17 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 17 Feb 2020 16:17:47 +0000 (16:17 +0000)
23 files changed:
abstractoption.cc
abstractoption.h
audioomx.cc
audioomx.h
audiowin.cc
audiowin.h
command.cc
input.cc
input.h
inputcec.cc
inputcec.h
inputlinux.cc
inputlinux.h
inputman.cc
inputman.h
inputudp.h
mediaoptions.cc
mediaoptions.h
videoomx.cc
videoomx.h
videowin.cc
videowin.h
wremoteconfig.cc

index 586a8f729384b1b480dfbc17b328d68a44738eae..6e9d13a1bcaee52a43a359587b39c875b840d92c 100644 (file)
@@ -22,7 +22,7 @@
 #include "option.h"
 
 /*
-bool AbstractOption::loadOptionsfromServer(VDR* vdr)
+bool AbstractOption::loadOptionsFromServer(VDR* vdr)
 {
     return true;
 }
index 21338dd43b1c6ca6e5bfdda708c39aac55c57d66..7933300c38162a602fefb18eba04a355e937160c 100644 (file)
@@ -31,7 +31,7 @@ class AbstractOption
 {
   public:
        // inline definition allows plugins architecture for audio video
-    virtual bool loadOptionsfromServer(VDR*) { return true; };
+    virtual bool loadOptionsFromServer(VDR*) { return true; };
     virtual bool saveOptionstoServer() { return true; };
     virtual bool addOptionPagesToWTB(WTabBar*) { return true; };
     virtual bool addOptionsToPanes(int /* panenumber */, Options*, WOptionPane*) { return true; };
index b664925e68809fee80694164c98cd2e14b25ef1f..f948e765db68a802f500e73b6ad3c1f56cf41a50 100644 (file)
@@ -182,7 +182,7 @@ int AudioOMX::shutdown()
   return 1;
 }
 
-bool AudioOMX::loadOptionsfromServer(VDR* vdr)
+bool AudioOMX::loadOptionsFromServer(VDR* vdr)
 {
          Log::getInstance()->log("Audio", Log::DEBUG, "AudioOMX config load");
     char *name=vdr->configLoad("AudioOMX","AC3DecodingMode");
index 326038002d4a2c25fd4fcc08d9e60702db9dcbb6..c1a31a5f624b79330b258c11925649c348739975 100644 (file)
@@ -92,7 +92,7 @@ class AudioOMX : public Audio
 
        UCHAR getLastAType() {return lastAType;}
 
-       bool loadOptionsfromServer(VDR* vdr);
+       bool loadOptionsFromServer(VDR* vdr);
        bool saveOptionstoServer();
        bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
        bool handleOptionChanges(Option* option);
index 9903890ba72fd1c053649ff23be5c2067714dd8f..7e7a214e2839dfa8ec5e9894201cc2c42e5b5114 100644 (file)
@@ -308,7 +308,7 @@ void AudioWin::initMp3FilterDatabase()
     filtmap->Release();
 }
 
-bool AudioWin::loadOptionsfromServer(VDR* vdr)
+bool AudioWin::loadOptionsFromServer(VDR* vdr)
 {
     char *name=vdr->configLoad("DirectShow","AudioFilter");
     
index c3eed89fd6886afaa13e5a2ba8e093fe0f2eba1c..8617e6c7bfd896119f3103b2412dc3bed0cb3ef8 100644 (file)
@@ -58,7 +58,7 @@ class AudioWin : public Audio
     int unMute();
     int write(char *buf, int len);
 
-    bool loadOptionsfromServer(VDR* vdr);
+    bool loadOptionsFromServer(VDR* vdr);
     bool saveOptionstoServer();
     bool addOptionPagesToWTB(WTabBar *wtb);
 
index 96336f673d5644b24e7997fce36696d9b10cf8c8..ab7b75850d9baf09436ff49cbb4a376e088630f4 100644 (file)
@@ -1010,9 +1010,9 @@ void Command::doJustConnected(VConnect* vconnect)
     Wol::getInstance()->setEnabled(true);
   }
   /* device dependend config */
-  audio->loadOptionsfromServer(vdr);
-  video->loadOptionsfromServer(vdr);
-  inputMan->loadOptionsfromServer(vdr);
+  audio->loadOptionsFromServer(vdr);
+  video->loadOptionsFromServer(vdr);
+  inputMan->loadOptionsFromServer(vdr);
 
   video->executePendingModeChanges();
   // config done
index a7767c955c1cceb414063c9548bd24abe6c45488..1314ca3c319b21218677361aff23f866d0c032af 100644 (file)
--- a/input.cc
+++ b/input.cc
 #include "inputman.h"
 #include "input.h"
 
-Input::Input()
+void Input::ResetToDefault()
 {
-  learnmode = NOLEARNMODE;
+  translist.clear();
+  InitHWCListwithDefaults();
 }
 
-Input::~Input()
+UCHAR Input::TranslateHWC(int code)
 {
-}
+  UCHAR ret = TranslateHWCFixed(code);
 
-void Input::EnterLearningMode(UCHAR command)
-{
-  learnmode = command; //Armed
-}
+  if (ret != NA_UNKNOWN) // Found in fixed list
+  {
+    InputMan::getInstance()->cancelLearnMode(); // Just in case
+    return ret;
+  }
 
-void Input::ResetToDefault()
-{
-  translist.clear();
-  InitHWCListwithDefaults();
+  return TranslateHWCList(code);
 }
 
 UCHAR Input::TranslateHWCList(int code)
 {
-  if (learnmode != NOLEARNMODE)
+  if (learnMode != NOLEARNMODE)
   {
-    setHWCtoCommand(code, learnmode);
-    learnmode = NOLEARNMODE;
+    setHWCtoCommand(code, learnMode);
+    InputMan::getInstance()->cancelLearnMode();
     return NA_LEARN;
   }
   RemoteTranslationList::iterator it = translist.find(code);
@@ -67,31 +66,12 @@ UCHAR Input::TranslateHWCList(int code)
   }
 }
 
-UCHAR Input::TranslateHWC(int code)
-{
-  UCHAR ret = TranslateHWCFixed(code);
-  if (ret == NA_UNKNOWN)
-  {
-    ret = TranslateHWCList(code);
-  }
-  else
-  {
-    learnmode = NOLEARNMODE;
-  }
-
-  if (ret == NA_UNKNOWN)
-  {
-    return NA_UNKNOWN;
-  }
-  return ret;
-}
-
 void Input::setHWCtoCommand(ULLONG hcw, UCHAR command)
 {
   translist[hcw] = command;
 }
 
-void Input::unsetHWC(ULLONG hcw)
+void Input::unsetHWC(ULLONG hcw) // FIXME never used
 {
   translist.erase(hcw);
 }
@@ -100,11 +80,11 @@ void Input::LoadKeysConfig(VDR *vdr,const char *cfg)
 {
        ULONG number=0;
        if (sscanf(cfg,"%ld",&number) != 1) return;
-       Log::getInstance()->log("Input", Log::INFO, "Config General/Remote keys num keys %d",number);
+       Log::getInstance()->log("Input", Log::INFO, "Config Input/Remote keys num keys %d",number);
        char keybuf[1024];
        for (ULONG i = 0; i < number; i++) {
                sprintf(keybuf, "RemoteKey%lu", i);
-               const char *keytrans = vdr->configLoad("General", keybuf);
+               const char *keytrans = vdr->configLoad(modName(), keybuf);
                if (keytrans) {
                        ULONG ul1, ul2;
                        ULONG uc;
@@ -117,6 +97,9 @@ void Input::LoadKeysConfig(VDR *vdr,const char *cfg)
        }
 }
 
+// FIXME - These two still use the bit shifting stuff. Leave it for now, might still
+// need it for Windows
+
 void Input::SaveKeysConfig()
 {
   int number=0;
@@ -128,36 +111,28 @@ void Input::SaveKeysConfig()
          sprintf(buffer,"%08lXI%08lXK%02X",
                          (ULONG)it->first ,(ULONG) (it->first >> 32), it->second);
          sprintf(keybuf,"RemoteKey%d",number);
-         VDR::getInstance()->configSave("General",keybuf,buffer);
+         VDR::getInstance()->configSave(modName(), keybuf, buffer);
          number++;
   }
   sprintf(buffer,"%d",number);
-  VDR::getInstance()->configSave("General","RemoteKeyNum",buffer);
+  VDR::getInstance()->configSave(modName(), "RemoteKeyNum", buffer);
 }
 
-
-// bool Input::addOptionPagesToWTB(WTabBar *wtb)
-// {
-//     WRemoteConfig* wrc = new WRemoteConfig();
-//     wtb->addTab(tr("Remote Control"), wrc);
-//     return true;
-// }
-
-bool Input::loadOptionsfromServer(VDR* vdr)
+bool Input::loadOptionsFromServer(VDR* vdr)
 {
    // Set remote keys
   char * config;
-  config = vdr->configLoad("General", "RemoteKeyNum");
+  config = vdr->configLoad(modName(), "RemoteKeyNum");
 
   if (config)
   {
-    Log::getInstance()->log("Input", Log::INFO, "Config General/Remote keys load");
+    Log::getInstance()->log("Input", Log::INFO, "Config Input/Remote keys load");
     LoadKeysConfig(vdr,config);
     delete[] config;
   }
   else
   {
-    Log::getInstance()->log("Input", Log::INFO, "Config General/Remote keys not found");
+    Log::getInstance()->log("Input", Log::INFO, "Config Input/Remote keys not found");
     InitHWCListwithDefaults();
   }
   return true;
@@ -175,7 +150,7 @@ void Input::sendInputKey(int key)
   m->message = Message::INPUT_EVENT;
   m->to = Command::getInstance();
   m->from = this;
-  m->parameter = TranslateHWC(key);
+  m->parameter = key;
   MessageQueue::getInstance()->postMessage(m);
 }
 
diff --git a/input.h b/input.h
index 37c7b6c7412c37c67b7b9ec2bea08d83266c3c84..e7842ef5bace9902b5d1424b446db8b51d185132 100644 (file)
--- a/input.h
+++ b/input.h
@@ -35,22 +35,17 @@ typedef std::map<ULLONG, UCHAR> RemoteTranslationList;
 class Input: public AbstractOption
 {
   public:
-    Input();
-    virtual ~Input();
-
     virtual bool start() { return false; }
     virtual void stop() {}
 
     // Abstract Option interface
- //   virtual bool addOptionPagesToWTB(WTabBar *wtb);
-    virtual bool loadOptionsfromServer(VDR* vdr);
+    virtual bool loadOptionsFromServer(VDR* vdr);
     virtual bool saveOptionstoServer();
 
     void setHWCtoCommand(ULLONG hcw, UCHAR command);
     void unsetHWC(ULLONG hcw);
     void LoadKeysConfig(VDR* vdr, const char* keynum);
     void SaveKeysConfig();
-    void EnterLearningMode(UCHAR command);
 
     virtual bool init()=0;
     virtual void shutdown()=0;
@@ -64,7 +59,8 @@ class Input: public AbstractOption
     virtual void InitHWCListwithDefaults()=0;
     std::string getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey);
     char* CommandTranslateStr(UCHAR command);
-    void EnterLearnMode(UCHAR command);
+    void EnterLearnMode(UCHAR /* command */ ) {}; // Override and set lernMode to command
+    void cancelLearnMode() { learnMode = NOLEARNMODE; }
     void ResetToDefault();
     virtual std::string getHardwareKeyName(int hardwareKey)=0;
 
@@ -137,12 +133,13 @@ class Input: public AbstractOption
     const static UCHAR POWEROFF    = 203;
 
   protected:
+    virtual const char* modName()=0;
+    RemoteTranslationList translist;
+    int learnMode{NOLEARNMODE};
+
     virtual UCHAR TranslateHWCFixed(int code)=0;
     UCHAR TranslateHWCList(int code);
     UCHAR TranslateHWC(int code);
-    
-    ULONG learnmode;
-    RemoteTranslationList translist;
 
     void sendInputKey(int key);
 };
index 97cec37171681dff8fe47f995fafcb9d00de0d12..976101a4eb798ed9344fc9b169e3f75ed0fc3b4d 100644 (file)
@@ -163,7 +163,7 @@ void InputCEC::volumeMute()
   cec_adap->AudioToggleMute();
 }
 
-bool InputCEC::loadOptionsfromServer(VDR* vdr)
+bool InputCEC::loadOptionsFromServer(VDR* vdr)
 {
    // Set remote keys
   char* name;
@@ -175,7 +175,7 @@ bool InputCEC::loadOptionsfromServer(VDR* vdr)
     else if (STRCASECMP(name, "Cec") == 0) cechandlesvolume = true;
     delete[] name;
   }
-  return Input::loadOptionsfromServer(vdr);
+  return Input::loadOptionsFromServer(vdr);
 }
 
 bool InputCEC::saveOptionstoServer()
index 172ccfa40d4945065c498a12b58d85e5696ea58a..11f9973fcba42bffd67faf41ebce8b465971c19c 100644 (file)
@@ -36,7 +36,7 @@ class InputCEC : public Input
     void volumeMute();
     void changePowerState(bool poweron);
 
-    bool loadOptionsfromServer(VDR* vdr);
+    bool loadOptionsFromServer(VDR* vdr);
     bool saveOptionstoServer();
     bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
     bool handleOptionChanges(Option* option);
@@ -45,6 +45,8 @@ class InputCEC : public Input
     const char* getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey);
 
   private:
+    constexpr static char* myModName = "InputCEC";
+    const char* modName() { return myModName; }
     void InitKeymap();
     void InitHWCListwithDefaults();
     UCHAR TranslateHWCFixed(int code);
index f7083d71f3d3f668c3046db3ecde3c3c7a2f0924..4c07644263e70eaa1d27e5d73d7d6b498276d79a 100644 (file)
@@ -129,6 +129,8 @@ UCHAR InputLinux::TranslateHWCFixed(int code)
 
 void InputLinux::InitHWCListwithDefaults()
 {
+  Log::getInstance()->log("InputLinux", Log::INFO, "InitHWCListwithDefaults");
+
   // Processing VK_Messages
   translist[KEY_9] = NINE;
   translist[KEY_8] = EIGHT;
@@ -504,6 +506,11 @@ std::string InputLinux::getHardwareKeyName(int hardwareKey)
   return retval;
 }
 
+void InputLinux::EnterLearningMode(UCHAR vompKey)
+{
+  learnMode = vompKey; // Armed
+}
+
 bool InputLinux::start()
 {
   Log::getInstance()->log("Input", Log::INFO, "start called");
index 5cbfe86602a98116061ac616cadfdc241916c7ff..fd69f0ca115c8e67f78fb4c3d0ee750e2190475a 100644 (file)
@@ -36,18 +36,21 @@ class InputLinux : public Input
 
     std::string getHardwareKeyName(int hardwareKey);
     const char* getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey);
+    void EnterLearningMode(UCHAR vompKey);
 
     bool start();
     void stop();
 
   private:
+    constexpr static char* myModName = "InputLinux";
+    const char* modName() { return myModName; }
+
     int initted{};
 
     void InitKeymap();
     void InitHWCListwithDefaults();
     UCHAR TranslateHWCFixed(int code);
 
-
     std::vector<int> devices;
 
     std::thread listenThread;
index edbf4bd57406764e6bc8b92a8f1f779db756c93a..ef13be5448bc9df2094fe5acbb633784d5f0e5fb 100644 (file)
@@ -54,9 +54,9 @@ bool InputMan::init()
   i1 = inputLinux->init();
   if (!i1) { delete inputLinux; inputLinux = NULL; }
 
-//  inputCEC = new InputCEC();
-//  i2 = inputCEC->init();
-//  if (!i2) { delete inputCEC; inputCEC = NULL; }
+  inputCEC = new InputCEC();
+  i2 = inputCEC->init();
+  if (!i2) { delete inputCEC; inputCEC = NULL; }
 #endif
 
   inputUDP = new InputUDP();
@@ -176,15 +176,20 @@ bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane*
 
 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
 {
-  //if (inputLinux) inputLinux->addOptionPagesToWTB(wtb);
-  //if (inputCEC) inputCEC->addOptionPagesToWTB(wtb);
-
   WRemoteConfig* wrc = new WRemoteConfig();
   wtb->addTab(tr("Remote Control"), wrc);
 
   return true; // FIXME
 }
 
+bool InputMan::loadOptionsFromServer(VDR* vdr)
+{
+  if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
+  if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
+
+  return true; // FIXME
+}
+
 bool InputMan::saveOptionstoServer()
 {
   if (inputLinux) inputLinux->saveOptionstoServer();
@@ -350,3 +355,26 @@ std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
 
   return keyNames;
 }
+
+void InputMan::ResetToDefault()
+{
+  if (inputLinux) inputLinux->ResetToDefault();
+
+  if (inputCEC) inputCEC->ResetToDefault();
+
+  if (inputUDP) inputUDP->ResetToDefault();
+}
+
+void InputMan::EnterLearningMode(UCHAR vompKey)
+{
+  if (inputLinux) inputLinux->EnterLearningMode(vompKey);
+
+//  if (inputCEC) inputCEC->EnterLearningMode();  FIXME - is there any such thing?
+}
+
+void InputMan::cancelLearnMode()
+{
+  if (inputLinux) inputLinux->cancelLearnMode();
+  if (inputCEC) inputCEC->cancelLearnMode();
+  if (inputUDP) inputUDP->cancelLearnMode();
+}
index 1086bf23aa5b8c88af4de7bccbacbf0cabce150d..f799afce00aedcf0d148f3936eec2fe390d6ed15 100644 (file)
@@ -111,6 +111,7 @@ class InputMan: public AbstractOption
     // Abstract Option interface
     bool addOptionPagesToWTB(WTabBar* wtb);
     bool addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane);
+    bool loadOptionsFromServer(VDR*);
     bool saveOptionstoServer();
 
     static const char* getVompKeyName(UCHAR vompKey);
@@ -118,6 +119,10 @@ class InputMan: public AbstractOption
     std::string getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey);
     std::string getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey);
 
+    void EnterLearningMode(UCHAR vompKey);
+    void cancelLearnMode();
+    void ResetToDefault();
+
   private:
     static InputMan* instance;
 
index 1b634a08412ba9721f10b8ff19ed9a9ab4e8701e..1b61d1aaf5744767af0c9422b25c609be4f42f0b 100644 (file)
@@ -39,14 +39,16 @@ class InputUDP : public Input
     bool start();
     void stop();
 
-    // FIXME these 2..
+    // InputUDP doesn't do any translation stuff so just keep everything happy here
     void InitHWCListwithDefaults() {};
     UCHAR TranslateHWCFixed(int code) { return code; };
     const char* getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey);
     std::string getHardwareKeyName(int hardwareKey);
 
-
   private:
+    constexpr static char* myModName = "InputUDP";
+    const char* modName() { return myModName; }
+
     bool initted{};
     DatagramSocket* ds{};
     Log* log{};
index 25003547c396b5c768a3f175ada7b3d80c561626..8bbde1813237ca5a5abc24285926f983878be06e 100644 (file)
@@ -59,7 +59,7 @@ MediaOptions::~MediaOptions()
 
 }
 
-bool MediaOptions::loadOptionsfromServer(VDR* vdr)
+bool MediaOptions::loadOptionsFromServer(VDR* vdr)
 {
     return true;
 }
index f2ad8cbe97cc74828b504f6081207c27cd23d85a..5a9fe386d27a0961be3e7eb249bbd95ccdaad95c 100644 (file)
@@ -38,7 +38,7 @@ class MediaOptions: AbstractOption
   public:
     MediaOptions();
     virtual ~MediaOptions();
-    virtual bool loadOptionsfromServer(VDR* vdr);
+    virtual bool loadOptionsFromServer(VDR* vdr);
     virtual bool saveOptionstoServer();
     //this can be called without the pane being active
     bool externSaveOptionstoServer();
index eed1f7cff48da9eaa3ab429f93b14384cd8418dc..8072910af2f2574768a5306cf6700f8a78050e21 100644 (file)
@@ -241,7 +241,7 @@ int VideoOMX::shutdown()
 
 
 
-bool VideoOMX::loadOptionsfromServer(VDR* vdr)
+bool VideoOMX::loadOptionsFromServer(VDR* vdr)
 {
        Log::getInstance()->log("Video", Log::DEBUG, "VideoOMX config load");
     char *name=vdr->configLoad("VideoOMX","SDDeinterlacing");
index 7b8ad149b43afa35f97d3453070ba07e98805626..a17b6b1bc5a2eb374e6af6dab075bce9eb0abd60 100644 (file)
@@ -129,7 +129,7 @@ class VideoOMX : public Video
        long long SetStartAudioOffset(long long curreftime, bool *rsync);
        virtual void ResetTimeOffsets();
 
-       bool loadOptionsfromServer(VDR* vdr);
+       bool loadOptionsFromServer(VDR* vdr);
        bool saveOptionstoServer();
        bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
        bool handleOptionChanges(Option* option);
index 2e73b7ebb2b83802727dc0934ee9c985cb3794ae..dcbf5dcb9b9fa99297397c2a1202aeec77896f01 100644 (file)
@@ -386,7 +386,7 @@ void VideoWin::initH264FilterDatabase()
     filtmap->Release();
 }
 
-bool VideoWin::loadOptionsfromServer(VDR* vdr)
+bool VideoWin::loadOptionsFromServer(VDR* vdr)
 {
     char *name=vdr->configLoad("DirectShow","VideoFilter");
     
index 43ea009d2a7ae4a89370249c2b924b48808058c6..f5a98c56799e2b3bc71202dfc748aa467f021a44 100644 (file)
@@ -93,7 +93,7 @@ public:
 //     ULLONG frameNumberToTimecode(ULONG framenumber);
        ULLONG getCurrentTimestamp();
 
-       bool loadOptionsfromServer(VDR* vdr);
+       bool loadOptionsFromServer(VDR* vdr);
        bool saveOptionstoServer();
        bool addOptionPagesToWTB(WTabBar *wtb);
        bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
index 9eb5fb5da46964df7e2f0da10e36c6e3d98c1660..3aeef85fec0755641b485e645d782bfae4da2885 100644 (file)
@@ -230,7 +230,7 @@ int WRemoteConfig::handleCommand(int command)
     case Input::OK:
     {
       learnmode = true;
-     // remote->EnterLearningMode(sl.getCurrentOptionData()); FIXME
+      InputMan::getInstance()->EnterLearningMode(sl.getCurrentOptionData());
       return 1;
     }
     case Input::BACK:
@@ -254,7 +254,7 @@ int WRemoteConfig::handleCommand(int command)
     }
     case Input::MENU:
     {
-   //   remote->ResetToDefault(); FIXME
+      InputMan::getInstance()->ResetToDefault();
       initSelectList(false);
       return 1;
     }