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 #include "GUIGameController.h"
10
11 #include "games/controllers/Controller.h"
12 #include "games/controllers/ControllerLayout.h"
13 #include "threads/SingleLock.h"
14 #include "utils/log.h"
15
16 using namespace KODI;
17 using namespace GAME;
18
CGUIGameController(int parentID,int controlID,float posX,float posY,float width,float height)19 CGUIGameController::CGUIGameController(
20 int parentID, int controlID, float posX, float posY, float width, float height)
21 : CGUIImage(parentID, controlID, posX, posY, width, height, CTextureInfo())
22 {
23 // Initialize CGUIControl
24 ControlType = GUICONTROL_GAMECONTROLLER;
25 }
26
CGUIGameController(const CGUIGameController & from)27 CGUIGameController::CGUIGameController(const CGUIGameController& from) : CGUIImage(from)
28 {
29 // Initialize CGUIControl
30 ControlType = GUICONTROL_GAMECONTROLLER;
31 }
32
Clone(void) const33 CGUIGameController* CGUIGameController::Clone(void) const
34 {
35 return new CGUIGameController(*this);
36 }
37
Render(void)38 void CGUIGameController::Render(void)
39 {
40 CGUIImage::Render();
41
42 CSingleLock lock(m_mutex);
43
44 if (m_currentController)
45 {
46 //! @todo Render pressed buttons
47 }
48 }
49
ActivateController(const ControllerPtr & controller)50 void CGUIGameController::ActivateController(const ControllerPtr& controller)
51 {
52 CSingleLock lock(m_mutex);
53
54 if (controller && controller != m_currentController)
55 {
56 m_currentController = controller;
57
58 lock.Leave();
59
60 //! @todo Sometimes this fails on window init
61 SetFileName(m_currentController->Layout().ImagePath());
62 }
63 }
64