Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
- index 42da1a2..8f4ea99 100644
- --- a/xbmc/Application.cpp
- +++ b/xbmc/Application.cpp
- @@ -96,6 +96,8 @@
- #include "input/XBMC_vkeys.h"
- #include "input/MouseStat.h"
- +#include "interfaces/json-rpc/InputOperations.h"
- +
- #if defined(FILESYSTEM) && !defined(_LINUX)
- #include "filesystem/FileDAAP.h"
- #endif
- @@ -2691,6 +2693,7 @@ void CApplication::FrameMove(bool processEvents)
- // process input actions
- CWinEvents::MessagePump();
- ProcessHTTPApiButtons();
- + ProcessJsonRpcButtons();
- ProcessRemote(frameTime);
- ProcessGamepad(frameTime);
- ProcessEventServer(frameTime);
- @@ -2962,8 +2965,18 @@ bool CApplication::ProcessHTTPApiButtons()
- return true;
- }
- }
- +#endif
- return false;
- +}
- +
- +bool CApplication::ProcessJsonRpcButtons()
- +{
- +#ifdef HAS_JSONRPC
- + CKey tempKey(JSONRPC::CInputOperations::GetKey());
- + if (tempKey.GetButtonCode() != KEY_INVALID)
- + return OnKey(tempKey);
- #endif
- + return false;
- }
- bool CApplication::ProcessEventServer(float frameTime)
- diff --git a/xbmc/Application.h b/xbmc/Application.h
- index 4282e41..6e6a005 100644
- --- a/xbmc/Application.h
- +++ b/xbmc/Application.h
- @@ -362,6 +362,7 @@ protected:
- bool ProcessEventServer(float frameTime);
- bool ProcessPeripherals(float frameTime);
- bool ProcessHTTPApiButtons();
- + bool ProcessJsonRpcButtons();
- bool ProcessJoystickEvent(const std::string& joystickName, int button, bool isAxis, float fAmount);
- float NavigationIdleTime();
- diff --git a/xbmc/interfaces/json-rpc/InputOperations.cpp b/xbmc/interfaces/json-rpc/InputOperations.cpp
- index e24c9d6..0f385ff 100644
- --- a/xbmc/interfaces/json-rpc/InputOperations.cpp
- +++ b/xbmc/interfaces/json-rpc/InputOperations.cpp
- @@ -22,9 +22,22 @@
- #include "InputOperations.h"
- #include "Application.h"
- #include "guilib/GUIAudioManager.h"
- +#include "input/XBMC_vkeys.h"
- +#include "threads/SingleLock.h"
- using namespace JSONRPC;
- +CCriticalSection CInputOperations::m_critSection;
- +uint32_t CInputOperations::m_key = KEY_INVALID;
- +
- +uint32_t CInputOperations::GetKey()
- +{
- + CSingleLock lock(m_critSection);
- + uint32_t currentKey = m_key;
- + m_key = KEY_INVALID;
- + return currentKey;
- +}
- +
- //TODO the breakage of the screensaver should be refactored
- //to one central super duper place for getting rid of
- //1 million dupes
- @@ -42,6 +55,17 @@ bool CInputOperations::handleScreenSaver()
- return screenSaverBroken;
- }
- +JSON_STATUS CInputOperations::sendKey(uint32_t keyCode)
- +{
- + if (keyCode == KEY_INVALID)
- + return InternalError;
- +
- + CSingleLock lock(m_critSection);
- + //g_application.getApplicationMessenger().SendKey(keyCode | KEY_VKEY, false);
- + m_key = keyCode | KEY_VKEY;
- + return ACK;
- +}
- +
- JSON_STATUS CInputOperations::sendAction(int actionID)
- {
- if(!handleScreenSaver())
- @@ -56,40 +80,39 @@ JSON_STATUS CInputOperations::sendAction(int actionID)
- JSON_STATUS CInputOperations::activateWindow(int windowID)
- {
- if(!handleScreenSaver())
- - {
- g_application.getApplicationMessenger().ActivateWindow(windowID, std::vector<CStdString>(), false);
- - }
- +
- return ACK;
- }
- JSON_STATUS CInputOperations::Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- {
- - return sendAction(ACTION_MOVE_LEFT);
- + return sendKey(XBMCVK_LEFT);
- }
- JSON_STATUS CInputOperations::Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- {
- - return sendAction(ACTION_MOVE_RIGHT);
- + return sendKey(XBMCVK_RIGHT);
- }
- JSON_STATUS CInputOperations::Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- {
- - return sendAction(ACTION_MOVE_DOWN);
- + return sendKey(XBMCVK_DOWN);
- }
- JSON_STATUS CInputOperations::Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- {
- - return sendAction(ACTION_MOVE_UP);
- + return sendKey(XBMCVK_UP);
- }
- JSON_STATUS CInputOperations::Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- {
- - return sendAction(ACTION_SELECT_ITEM);
- + return sendKey(XBMCVK_RETURN);
- }
- JSON_STATUS CInputOperations::Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- {
- - return sendAction(ACTION_NAV_BACK);
- + return sendKey(XBMCVK_BACK);
- }
- JSON_STATUS CInputOperations::Home(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
- diff --git a/xbmc/interfaces/json-rpc/InputOperations.h b/xbmc/interfaces/json-rpc/InputOperations.h
- index 4352a79..c900ab1 100644
- --- a/xbmc/interfaces/json-rpc/InputOperations.h
- +++ b/xbmc/interfaces/json-rpc/InputOperations.h
- @@ -20,29 +20,35 @@
- *
- */
- -#include "utils/StdString.h"
- #include "JSONRPC.h"
- +#include "threads/CriticalSection.h"
- +#include "utils/StdString.h"
- namespace JSONRPC
- {
- class CInputOperations
- {
- public:
- + static uint32_t GetKey();
- +
- static JSON_STATUS Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- static JSON_STATUS Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- static JSON_STATUS Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- static JSON_STATUS Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- -
- static JSON_STATUS Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- static JSON_STATUS Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- static JSON_STATUS Home(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result);
- -
- - private:
- +
- + private:
- + static JSON_STATUS sendKey(uint32_t keyCode);
- static JSON_STATUS sendAction(int actionID);
- static JSON_STATUS activateWindow(int windowID);
- static bool handleScreenSaver();
- +
- + static CCriticalSection m_critSection;
- + static uint32_t m_key;
- };
- }
Add Comment
Please, Sign In to add comment