Skip to content
This repository
Browse code

jsonrpc: cleanup CInputOperations to use actions instead of virtual keys

  • Loading branch information...
commit b6db266119aa38424a25b1136f073b8350037dda 1 parent d6be53a
Sascha Montellese authored October 15, 2012
27  xbmc/Application.cpp
@@ -148,9 +148,6 @@
148 148
 #ifdef HAS_EVENT_SERVER
149 149
 #include "network/EventServer.h"
150 150
 #endif
151  
-#ifdef HAS_JSONRPC
152  
-#include "interfaces/json-rpc/InputOperations.h"
153  
-#endif
154 151
 #ifdef HAS_DBUS
155 152
 #include <dbus/dbus.h>
156 153
 #endif
@@ -2949,7 +2946,6 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
2949 2946
 #endif
2950 2947
 
2951 2948
     // process input actions
2952  
-    ProcessJsonRpcButtons();
2953 2949
     ProcessRemote(frameTime);
2954 2950
     ProcessGamepad(frameTime);
2955 2951
     ProcessEventServer(frameTime);
@@ -3142,29 +3138,6 @@ bool CApplication::ProcessMouse()
3142 3138
                           mouseaction.GetName()));
3143 3139
 }
3144 3140
 
3145  
-bool CApplication::ProcessJsonRpcButtons()
3146  
-{
3147  
-#ifdef HAS_JSONRPC
3148  
-  CKey tempKey(JSONRPC::CInputOperations::GetKey());
3149  
-  if (tempKey.GetButtonCode() == KEY_UNICODE && tempKey.GetUnicode() != 0)
3150  
-  {
3151  
-    XBMC_Event event = { 0 };
3152  
-    event.type = XBMC_KEYDOWN;
3153  
-    event.key.type = XBMC_KEYDOWN;
3154  
-    event.key.keysym.unicode = (uint16_t)tempKey.GetUnicode();
3155  
-    event.key.keysym.sym = (XBMCKey)tempKey.GetUnicode();
3156  
-
3157  
-    return OnEvent(event);
3158  
-  }
3159  
-  if (tempKey.GetButtonCode() != KEY_INVALID)
3160  
-  {
3161  
-    tempKey.SetFromService(true);
3162  
-    return OnKey(tempKey);
3163  
-  }
3164  
-#endif
3165  
-  return false;
3166  
-}
3167  
-
3168 3141
 bool CApplication::ProcessEventServer(float frameTime)
3169 3142
 {
3170 3143
 #ifdef HAS_EVENT_SERVER
1  xbmc/Application.h
@@ -446,7 +446,6 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
446 446
   bool ProcessGamepad(float frameTime);
447 447
   bool ProcessEventServer(float frameTime);
448 448
   bool ProcessPeripherals(float frameTime);
449  
-  bool ProcessJsonRpcButtons();
450 449
   bool ProcessJoystickEvent(const std::string& joystickName, int button, bool isAxis, float fAmount, unsigned int holdTime = 0);
451 450
   int  GetActiveWindowID(void);
452 451
 
36  xbmc/interfaces/json-rpc/InputOperations.cpp
@@ -32,17 +32,6 @@
32 32
 
33 33
 using namespace JSONRPC;
34 34
 
35  
-CCriticalSection CInputOperations::m_critSection;
36  
-CKey CInputOperations::m_key(KEY_INVALID);
37  
-
38  
-CKey CInputOperations::GetKey()
39  
-{
40  
-  CSingleLock lock(m_critSection);
41  
-  CKey currentKey = m_key;
42  
-  m_key = CKey(KEY_INVALID);
43  
-  return currentKey;
44  
-}
45  
-
46 35
 //TODO the breakage of the screensaver should be refactored
47 36
 //to one central super duper place for getting rid of
48 37
 //1 million dupes
@@ -60,19 +49,6 @@ bool CInputOperations::handleScreenSaver()
60 49
   return screenSaverBroken;
61 50
 }
62 51
 
63  
-JSONRPC_STATUS CInputOperations::SendKey(uint32_t keyCode, bool unicode /* = false */)
64  
-{
65  
-  if (keyCode == KEY_INVALID)
66  
-    return InternalError;
67  
-
68  
-  CSingleLock lock(m_critSection);
69  
-  if (unicode)
70  
-    m_key = CKey(0, (wchar_t)keyCode, 0, 0, 0);
71  
-  else
72  
-    m_key = CKey(keyCode | KEY_VKEY);
73  
-  return ACK;
74  
-}
75  
-
76 52
 JSONRPC_STATUS CInputOperations::SendAction(int actionID, bool wakeScreensaver /* = true */, bool waitResult /* = false */)
77 53
 {
78 54
   if(!wakeScreensaver || !handleScreenSaver())
@@ -116,32 +92,32 @@ JSONRPC_STATUS CInputOperations::ExecuteAction(const CStdString &method, ITransp
116 92
 
117 93
 JSONRPC_STATUS CInputOperations::Left(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
118 94
 {
119  
-  return SendKey(XBMCVK_LEFT);
  95
+  return SendAction(ACTION_MOVE_LEFT);
120 96
 }
121 97
 
122 98
 JSONRPC_STATUS CInputOperations::Right(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
123 99
 {
124  
-  return SendKey(XBMCVK_RIGHT);
  100
+  return SendAction(ACTION_MOVE_RIGHT);
125 101
 }
126 102
 
127 103
 JSONRPC_STATUS CInputOperations::Down(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
128 104
 {
129  
-  return SendKey(XBMCVK_DOWN);
  105
+  return SendAction(ACTION_MOVE_DOWN);
130 106
 }
131 107
 
132 108
 JSONRPC_STATUS CInputOperations::Up(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
133 109
 {
134  
-  return SendKey(XBMCVK_UP);
  110
+  return SendAction(ACTION_MOVE_UP);
135 111
 }
136 112
 
137 113
 JSONRPC_STATUS CInputOperations::Select(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
138 114
 {
139  
-  return SendKey(XBMCVK_RETURN);
  115
+  return SendAction(ACTION_SELECT_ITEM);
140 116
 }
141 117
 
142 118
 JSONRPC_STATUS CInputOperations::Back(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
143 119
 {
144  
-  return SendKey(XBMCVK_BACK);
  120
+  return SendAction(ACTION_NAV_BACK);
145 121
 }
146 122
 
147 123
 JSONRPC_STATUS CInputOperations::ContextMenu(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
6  xbmc/interfaces/json-rpc/InputOperations.h
@@ -29,8 +29,6 @@ namespace JSONRPC
29 29
   class CInputOperations
30 30
   {
31 31
   public:
32  
-    static CKey GetKey();
33  
-
34 32
     static JSONRPC_STATUS SendText(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
35 33
     static JSONRPC_STATUS ExecuteAction(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
36 34
 
@@ -48,14 +46,10 @@ namespace JSONRPC
48 46
     static JSONRPC_STATUS ShowCodec(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
49 47
     static JSONRPC_STATUS ShowOSD(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
50 48
 
51  
-    static JSONRPC_STATUS SendKey(uint32_t keyCode, bool unicode = false);
52 49
     static JSONRPC_STATUS SendAction(int actionID, bool wakeScreensaver = true, bool waitResult = false);
53 50
 
54 51
   private:
55 52
     static JSONRPC_STATUS activateWindow(int windowID);
56 53
     static bool        handleScreenSaver();
57  
-
58  
-    static CCriticalSection m_critSection;
59  
-    static CKey m_key;
60 54
   };
61 55
 }

0 notes on commit b6db266

Please sign in to comment.
Something went wrong with that request. Please try again.