summaryrefslogtreecommitdiffstats
path: root/xbmc/games/controllers/guicontrols/GUIGameController.cpp
blob: 8990cf2269e053c90fd1ed26a261c726f530c0a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 *  Copyright (C) 2014-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "GUIGameController.h"

#include "games/controllers/Controller.h"
#include "games/controllers/ControllerLayout.h"
#include "utils/log.h"

#include <mutex>

using namespace KODI;
using namespace GAME;

CGUIGameController::CGUIGameController(
    int parentID, int controlID, float posX, float posY, float width, float height)
  : CGUIImage(parentID, controlID, posX, posY, width, height, CTextureInfo())
{
  // Initialize CGUIControl
  ControlType = GUICONTROL_GAMECONTROLLER;
}

CGUIGameController::CGUIGameController(const CGUIGameController& from) : CGUIImage(from)
{
  // Initialize CGUIControl
  ControlType = GUICONTROL_GAMECONTROLLER;
}

CGUIGameController* CGUIGameController::Clone(void) const
{
  return new CGUIGameController(*this);
}

void CGUIGameController::Render(void)
{
  CGUIImage::Render();

  std::unique_lock<CCriticalSection> lock(m_mutex);

  if (m_currentController)
  {
    //! @todo Render pressed buttons
  }
}

void CGUIGameController::ActivateController(const ControllerPtr& controller)
{
  std::unique_lock<CCriticalSection> lock(m_mutex);

  if (controller && controller != m_currentController)
  {
    m_currentController = controller;

    lock.unlock();

    //! @todo Sometimes this fails on window init
    SetFileName(m_currentController->Layout().ImagePath());
  }
}