1 /*
2  *  Copyright (C) 2016-2018 Team Kodi
3  *  This file is part of Kodi - https://kodi.tv
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/Thread.h"
12 
13 #include <string>
14 #include <vector>
15 
16 namespace KODI
17 {
18 namespace JOYSTICK
19 {
20 class IInputReceiver;
21 
22 class CRumbleGenerator : public CThread
23 {
24 public:
25   CRumbleGenerator();
26 
~CRumbleGenerator()27   ~CRumbleGenerator() override { AbortRumble(); }
28 
29   std::string ControllerID() const;
30 
31   void NotifyUser(IInputReceiver* receiver);
32   bool DoTest(IInputReceiver* receiver);
33 
AbortRumble(void)34   void AbortRumble(void) { StopThread(); }
35 
36 protected:
37   // implementation of CThread
38   void Process() override;
39 
40 private:
41   enum RUMBLE_TYPE
42   {
43     RUMBLE_UNKNOWN,
44     RUMBLE_NOTIFICATION,
45     RUMBLE_TEST,
46   };
47 
48   static std::vector<std::string> GetMotors(const std::string& controllerId);
49 
50   // Construction param
51   const std::vector<std::string> m_motors;
52 
53   // Test param
54   IInputReceiver* m_receiver = nullptr;
55   RUMBLE_TYPE m_type = RUMBLE_UNKNOWN;
56 };
57 } // namespace JOYSTICK
58 } // namespace KODI
59