Guest User

Untitled

a guest
May 21st, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.63 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..0f385ff 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,17 @@ 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. +  //g_application.getApplicationMessenger().SendKey(keyCode | KEY_VKEY, false);
  91. +  m_key = keyCode | KEY_VKEY;
  92. +  return ACK;
  93. +}
  94. +
  95.  JSON_STATUS CInputOperations::sendAction(int actionID)
  96.  {
  97.    if(!handleScreenSaver())
  98. @@ -56,40 +80,39 @@ JSON_STATUS CInputOperations::sendAction(int actionID)
  99.  JSON_STATUS CInputOperations::activateWindow(int windowID)
  100.  {
  101.    if(!handleScreenSaver())
  102. -  {
  103.      g_application.getApplicationMessenger().ActivateWindow(windowID, std::vector<CStdString>(), false);
  104. -  }
  105. +
  106.    return ACK;
  107.  }
  108.  
  109.  JSON_STATUS CInputOperations::Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  110.  {
  111. -  return sendAction(ACTION_MOVE_LEFT);
  112. +  return sendKey(XBMCVK_LEFT);
  113.  }
  114.  
  115.  JSON_STATUS CInputOperations::Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  116.  {
  117. -  return sendAction(ACTION_MOVE_RIGHT);  
  118. +  return sendKey(XBMCVK_RIGHT);
  119.  }
  120.  
  121.  JSON_STATUS CInputOperations::Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  122.  {
  123. -  return sendAction(ACTION_MOVE_DOWN);  
  124. +  return sendKey(XBMCVK_DOWN);
  125.  }
  126.  
  127.  JSON_STATUS CInputOperations::Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  128.  {
  129. -  return sendAction(ACTION_MOVE_UP);  
  130. +  return sendKey(XBMCVK_UP);
  131.  }
  132.  
  133.  JSON_STATUS CInputOperations::Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  134.  {
  135. -  return sendAction(ACTION_SELECT_ITEM);  
  136. +  return sendKey(XBMCVK_RETURN);
  137.  }
  138.  
  139.  JSON_STATUS CInputOperations::Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  140.  {
  141. -  return sendAction(ACTION_NAV_BACK);  
  142. +  return sendKey(XBMCVK_BACK);
  143.  }
  144.  
  145.  JSON_STATUS CInputOperations::Home(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
  146. diff --git a/xbmc/interfaces/json-rpc/InputOperations.h b/xbmc/interfaces/json-rpc/InputOperations.h
  147. index 4352a79..c900ab1 100644
  148. --- a/xbmc/interfaces/json-rpc/InputOperations.h
  149. +++ b/xbmc/interfaces/json-rpc/InputOperations.h
  150. @@ -20,29 +20,35 @@
  151.   *
  152.   */
  153.  
  154. -#include "utils/StdString.h"
  155.  #include "JSONRPC.h"
  156. +#include "threads/CriticalSection.h"
  157. +#include "utils/StdString.h"
  158.  
  159.  namespace JSONRPC
  160.  {
  161.    class CInputOperations
  162.    {
  163.    public:
  164. +    static uint32_t GetKey();
  165. +    
  166.      static JSON_STATUS Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  167.      static JSON_STATUS Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  168.      static JSON_STATUS Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  169.      static JSON_STATUS Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  170.  
  171. -
  172.      static JSON_STATUS Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  173.  
  174.      static JSON_STATUS Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  175.  
  176.      static JSON_STATUS Home(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
  177. -    
  178. -  private:
  179. +
  180. +    private:
  181. +    static JSON_STATUS sendKey(uint32_t keyCode);
  182.      static JSON_STATUS sendAction(int actionID);
  183.      static JSON_STATUS activateWindow(int windowID);
  184.      static bool        handleScreenSaver();
  185. +
  186. +    static CCriticalSection m_critSection;
  187. +    static uint32_t m_key;
  188.    };
  189.  }
Add Comment
Please, Sign In to add comment