kodi
GUIGameController.h
1 /*
2  * Copyright (C) 2014-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 "games/controllers/ControllerTypes.h"
12 #include "guilib/GUIImage.h"
13 
14 #include <mutex>
15 
16 namespace KODI
17 {
18 namespace GAME
19 {
24 {
25 public:
26  CGUIGameController(int parentID,
27  int controlID,
28  float posX,
29  float posY,
30  float width,
31  float height,
32  const CTextureInfo& texture);
34 
35  ~CGUIGameController() override = default;
36 
37  // implementation of CGUIControl via CGUIImage
38  CGUIGameController* Clone() const override;
39  void DoProcess(unsigned int currentTime, CDirtyRegionList& dirtyregions) override;
40  void UpdateInfo(const CGUIListItem* item = nullptr) override;
41 
42  // GUI functions
43  void SetControllerID(const GUILIB::GUIINFO::CGUIInfoLabel& controllerId);
44  void SetControllerAddress(const GUILIB::GUIINFO::CGUIInfoLabel& controllerAddress);
45  void SetControllerDiffuse(const GUILIB::GUIINFO::CGUIInfoColor& color);
46  void SetPortAddress(const GUILIB::GUIINFO::CGUIInfoLabel& portAddress);
47  void SetPeripheralLocation(const GUILIB::GUIINFO::CGUIInfoLabel& peripheralLocation);
48 
49  // Game functions
50  void ActivateController(const std::string& controllerId);
51  void ActivateController(const ControllerPtr& controller);
52  std::string GetPortAddress();
53  std::string GetPeripheralLocation();
54 
55 private:
56  // GUI functions
57  void SetActivation(float activation);
58 
59  // GUI parameters
60  GUILIB::GUIINFO::CGUIInfoLabel m_controllerIdInfo;
61  GUILIB::GUIINFO::CGUIInfoLabel m_controllerAddressInfo;
62  GUILIB::GUIINFO::CGUIInfoColor m_controllerDiffuse;
63  GUILIB::GUIINFO::CGUIInfoLabel m_portAddressInfo;
64  GUILIB::GUIINFO::CGUIInfoLabel m_peripheralLocationInfo;
65 
66  // Game parameters
67  ControllerPtr m_currentController;
68  std::string m_portAddress;
69  std::string m_peripheralLocation;
70 
71  // Synchronization parameters
72  std::mutex m_mutex;
73 };
74 } // namespace GAME
75 } // namespace KODI
Definition: GUIListItem.h:29
Definition: GUIInfoLabel.h:31
Definition: GUIGameController.h:23
Definition: GUITexture.h:51
Definition: AudioDecoder.h:18
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
Definition: GUIImage.h:27
Definition: GUIInfoColor.h:30