kodi
GUIControllerList.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 "IConfigurationWindow.h"
12 #include "addons/AddonEvents.h"
13 #include "games/GameTypes.h"
14 #include "games/controllers/ControllerTypes.h"
15 
16 #include <set>
17 #include <string>
18 
19 class CGUIButtonControl;
21 class CGUIWindow;
22 
23 namespace KODI
24 {
25 namespace GAME
26 {
27 class CGUIControllerWindow;
28 
33 {
34 public:
46  IFeatureList* featureList,
47  GameClientPtr gameClient,
48  std::string controllerId);
49  ~CGUIControllerList() override { Deinitialize(); }
50 
51  // implementation of IControllerList
52  bool Initialize() override;
53  void Deinitialize() override;
54  bool Refresh(const std::string& controllerId) override;
55  void OnFocus(unsigned int controllerIndex) override;
56  void OnSelect(unsigned int controllerIndex) override;
57  int GetFocusedController() const override { return m_focusedController; }
58  void ResetController() override;
59 
60 private:
61  bool RefreshControllers(void);
62 
63  void CleanupButtons(void);
64  void OnEvent(const ADDON::AddonEvent& event);
65 
66  // GUI stuff
67  CGUIWindow* const m_guiWindow;
68  IFeatureList* const m_featureList;
69  CGUIControlGroupList* m_controllerList = nullptr;
70  CGUIButtonControl* m_controllerButton = nullptr;
71 
72  // Game stuff
73  ControllerVector m_controllers;
74  int m_focusedController = -1; // Initially unfocused
75  GameClientPtr m_gameClient;
76  std::string m_controllerId;
77 };
78 } // namespace GAME
79 } // namespace KODI
bool Refresh(const std::string &controllerId) override
Refresh the contents of the list.
Definition: GUIControllerList.cpp:79
Definition: GUIButtonControl.h:27
Definition: GUIControllerList.h:32
A list populated by the controller&#39;s features.
Definition: IConfigurationWindow.h:110
list of controls that is scrollable
Definition: GUIControlGroupList.h:28
CGUIControllerList(CGUIWindow *window, IFeatureList *featureList, GameClientPtr gameClient, std::string controllerId)
Create a GUI controller list.
Definition: GUIControllerList.cpp:41
int GetFocusedController() const override
Get the index of the focused controller.
Definition: GUIControllerList.h:57
A list populated by installed controllers for the controller configuration window.
Definition: IConfigurationWindow.h:47
Definition: AudioDecoder.h:18
std::shared_ptr< CGameClient > GameClientPtr
Smart pointer to a game client (CGameClient)
Definition: GameTypes.h:29
Definition: AddonEvents.h:18
void OnSelect(unsigned int controllerIndex) override
The specified controller has been selected.
Definition: GUIControllerList.cpp:141
void OnFocus(unsigned int controllerIndex) override
Definition: GUIControllerList.cpp:119
Definition: GUIWindow.h:58
void Deinitialize() override
Deinitialize the resource.
Definition: GUIControllerList.cpp:69
bool Initialize() override
Initialize the resource.
Definition: GUIControllerList.cpp:53
std::vector< ControllerPtr > ControllerVector
Vector of smart pointers to a game controller (CController)
Definition: ControllerTypes.h:32
void ResetController() override
Reset the focused controller.
Definition: GUIControllerList.cpp:146