Guest User

Untitled

a guest
May 21st, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.55 KB | None | 0 0
  1. diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
  2. index 42da1a2..8f4ea99 100644
  3. --- a/xbmc/Application.cpp
  4. +++ b/xbmc/Application.cpp
  5. @@ -96,6 +96,8 @@
  6.  #include "input/XBMC_vkeys.h"
  7.  #include "input/MouseStat.h"
  8.  
  9. +#include "interfaces/json-rpc/InputOperations.h"
  10. +
  11.  #if defined(FILESYSTEM) && !defined(_LINUX)
  12.  #include "filesystem/FileDAAP.h"
  13.  #endif
  14. @@ -2691,6 +2693,7 @@ void CApplication::FrameMove(bool processEvents)
  15.      // process input actions
  16.      CWinEvents::MessagePump();
  17.      ProcessHTTPApiButtons();
  18. +    ProcessJsonRpcButtons();
  19.      ProcessRemote(frameTime);
  20.      ProcessGamepad(frameTime);
  21.      ProcessEventServer(frameTime);
  22. @@ -2962,8 +2965,18 @@ bool CApplication::ProcessHTTPApiButtons()
  23.        return true;
  24.      }
  25.    }
  26. +#endif
  27.    return false;
  28. +}
  29. +
  30. +bool CApplication::ProcessJsonRpcButtons()
  31. +{
  32. +#ifdef HAS_JSONRPC
  33. +  CKey tempKey(JSONRPC::CInputOperations::GetKey());
  34. +  if (tempKey.GetButtonCode() != KEY_INVALID)
  35. +    return OnKey(tempKey);
  36.  #endif
  37. +  return false;
  38.  }
  39.  
  40.  bool CApplication::ProcessEventServer(float frameTime)
  41. diff --git a/xbmc/Application.h b/xbmc/Application.h
  42. index 4282e41..6e6a005 100644
  43. --- a/xbmc/Application.h
  44. +++ b/xbmc/Application.h
  45. @@ -362,6 +362,7 @@ protected:
  46.    bool ProcessEventServer(float frameTime);
  47.    bool ProcessPeripherals(float frameTime);
  48.    bool ProcessHTTPApiButtons();
  49. +  bool ProcessJsonRpcButtons();
  50.    bool ProcessJoystickEvent(const std::string& joystickName, int button, bool isAxis, float fAmount);
  51.  
  52.    float NavigationIdleTime();
  53. diff --git a/xbmc/interfaces/json-rpc/InputOperations.cpp b/xbmc/interfaces/json-rpc/InputOperations.cpp
  54. index e24c9d6..4ad75ce 100644
  55. --- a/xbmc/interfaces/json-rpc/InputOperations.cpp
  56. +++ b/xbmc/interfaces/json-rpc/InputOperations.cpp
  57. @@ -22,9 +22,22 @@
  58.  #include "InputOperations.h"
  59.  #include "Application.h"
  60.  #include "guilib/GUIAudioManager.h"
  61. +#include "input/XBMC_vkeys.h"
  62. +#include "threads/SingleLock.h"
  63.  
  64.  using namespace JSONRPC;
  65.  
  66. +CCriticalSection CInputOperations::m_critSection;
  67. +uint32_t CInputOperations::m_key = KEY_INVALID;
  68. +
  69. +uint32_t CInputOperations::GetKey()
  70. +{
  71. +  CSingleLock lock(m_critSection);
  72. +  uint32_t currentKey = m_key;
  73. +  m_key = KEY_INVALID;
  74. +  return currentKey;
  75. +}
  76. +
  77.  //TODO the breakage of the screensaver should be refactored
  78.  //to one central super duper place for getting rid of
  79.  //1 million dupes
  80. @@ -42,6 +55,16 @@ bool CInputOperations::handleScreenSaver()
  81.    return screenSaverBroken;
  82.  }
  83.  
  84. +JSON_STATUS CInputOperations::sendKey(uint32_t keyCode)
  85. +{
  86. +  if (keyCode == KEY_INVALID)
  87. +    return InternalError;
  88. +
  89. +  CSingleLock lock(m_critSection);
  90. +  m_key = keyCode | KEY_VKEY;
  91. +  return ACK;
  92. +}
  93. +
  94.  JSON_STATUS CInputOperations::sendAction(int actionID)
  95.  {
  96.    if(!handleScreenSaver())
  97. @@ -56,40 +79,39 @@ JSON_STATUS CInputOperations::sendAction(int actionID)
  98.  JSON_STATUS CInputOperations::activateWindow(int windowID)
  99.  {
  100.    if(!handleScreenSaver())
  101. -  {
  102.      g_application.getApplicationMessenger().ActivateWindow(windowID, std::vector<CStdString>(), false);
  103. -  }
  104. +
  105.    return ACK;
  106.  }
  107.  
  108.  JSON_STATUS CInputOperations::Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  109.  {
  110. -  return sendAction(ACTION_MOVE_LEFT);
  111. +  return sendKey(XBMCVK_LEFT);
  112.  }
  113.  
  114.  JSON_STATUS CInputOperations::Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  115.  {
  116. -  return sendAction(ACTION_MOVE_RIGHT);  
  117. +  return sendKey(XBMCVK_RIGHT);
  118.  }
  119.  
  120.  JSON_STATUS CInputOperations::Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  121.  {
  122. -  return sendAction(ACTION_MOVE_DOWN);  
  123. +  return sendKey(XBMCVK_DOWN);
  124.  }
  125.  
  126.  JSON_STATUS CInputOperations::Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  127.  {
  128. -  return sendAction(ACTION_MOVE_UP);  
  129. +  return sendKey(XBMCVK_UP);
  130.  }
  131.  
  132.  JSON_STATUS CInputOperations::Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  133.  {
  134. -  return sendAction(ACTION_SELECT_ITEM);  
  135. +  return sendKey(XBMCVK_RETURN);
  136.  }
  137.  
  138.  JSON_STATUS CInputOperations::Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  139.  {
  140. -  return sendAction(ACTION_NAV_BACK);  
  141. +  return sendKey(XBMCVK_BACK);
  142.  }
  143.  
  144.  JSON_STATUS CInputOperations::Home(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  145. diff --git a/xbmc/interfaces/json-rpc/InputOperations.h b/xbmc/interfaces/json-rpc/InputOperations.h
  146. index 4352a79..c900ab1 100644
  147. --- a/xbmc/interfaces/json-rpc/InputOperations.h
  148. +++ b/xbmc/interfaces/json-rpc/InputOperations.h
  149. @@ -20,29 +20,35 @@
  150.   *
  151.   */
  152.  
  153. -#include "utils/StdString.h"
  154.  #include "JSONRPC.h"
  155. +#include "threads/CriticalSection.h"
  156. +#include "utils/StdString.h"
  157.  
  158.  namespace JSONRPC
  159.  {
  160.    class CInputOperations
  161.    {
  162.    public:
  163. +    static uint32_t GetKey();
  164. +    
  165.      static JSON_STATUS Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  166.      static JSON_STATUS Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  167.      static JSON_STATUS Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  168.      static JSON_STATUS Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  169.  
  170. -
  171.      static JSON_STATUS Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  172.  
  173.      static JSON_STATUS Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  174.  
  175.      static JSON_STATUS Home(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  176. -    
  177. -  private:
  178. +
  179. +    private:
  180. +    static JSON_STATUS sendKey(uint32_t keyCode);
  181.      static JSON_STATUS sendAction(int actionID);
  182.      static JSON_STATUS activateWindow(int windowID);
  183.      static bool        handleScreenSaver();
  184. +
  185. +    static CCriticalSection m_critSection;
  186. +    static uint32_t m_key;
  187.    };
  188.  }
Add Comment
Please, Sign In to add comment