kodi
GUIFeatureList.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 "games/GameTypes.h"
13 #include "games/controllers/ControllerTypes.h"
14 #include "games/controllers/input/PhysicalFeature.h"
15 #include "input/joysticks/JoystickTypes.h"
16 
17 class CGUIButtonControl;
19 class CGUIImage;
20 class CGUILabelControl;
21 class CGUIWindow;
22 
23 namespace KODI
24 {
25 namespace GAME
26 {
31 {
32 public:
33  CGUIFeatureList(CGUIWindow* window, GameClientPtr gameClient);
34  ~CGUIFeatureList() override;
35 
36  // implementation of IFeatureList
37  bool Initialize() override;
38  void Deinitialize() override;
39  bool HasButton(JOYSTICK::FEATURE_TYPE type) const override;
40  void Load(const ControllerPtr& controller) override;
41  void OnFocus(unsigned int buttonIndex) override {}
42  void OnSelect(unsigned int buttonIndex) override;
43 
44 private:
45  IFeatureButton* GetButtonControl(unsigned int buttonIndex);
46 
47  void CleanupButtons(void);
48 
49  // Helper functions
50  struct FeatureGroup
51  {
52  std::string groupName;
53  std::vector<CPhysicalFeature> features;
58  bool bIsVirtualKey = false;
59  };
60  std::vector<FeatureGroup> GetFeatureGroups(const std::vector<CPhysicalFeature>& features) const;
61  std::vector<CGUIButtonControl*> GetButtons(const std::vector<CPhysicalFeature>& features,
62  unsigned int startIndex);
63  CGUIButtonControl* GetSelectKeyButton(const std::vector<CPhysicalFeature>& features,
64  unsigned int buttonIndex);
65 
66  // GUI stuff
67  CGUIWindow* const m_window;
68  unsigned int m_buttonCount = 0;
69  CGUIControlGroupList* m_guiList = nullptr;
70  CGUIButtonControl* m_guiButtonTemplate = nullptr;
71  CGUILabelControl* m_guiGroupTitle = nullptr;
72  CGUIImage* m_guiFeatureSeparator = nullptr;
73 
74  // Game window stuff
75  GameClientPtr m_gameClient;
76  ControllerPtr m_controller;
77  IConfigurationWizard* m_wizard;
78 };
79 } // namespace GAME
80 } // namespace KODI
void OnSelect(unsigned int buttonIndex) override
The specified GUI button has been selected.
Definition: GUIFeatureList.cpp:138
bool HasButton(JOYSTICK::FEATURE_TYPE type) const override
Check if the feature type has any buttons in the GUI.
Definition: GUIFeatureList.cpp:249
Definition: GUIButtonControl.h:27
A wizard to direct user input.
Definition: IConfigurationWindow.h:240
void Load(const ControllerPtr &controller) override
Load the features for the specified controller.
Definition: GUIFeatureList.cpp:73
A list populated by the controller&#39;s features.
Definition: IConfigurationWindow.h:110
list of controls that is scrollable
Definition: GUIControlGroupList.h:28
Definition: GUILabelControl.h:24
A GUI button in a feature list (IFeatureList)
Definition: IConfigurationWindow.h:159
bool Initialize() override
Initialize the resource.
Definition: GUIFeatureList.cpp:42
Definition: AudioDecoder.h:18
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
std::shared_ptr< CGameClient > GameClientPtr
Smart pointer to a game client (CGameClient)
Definition: GameTypes.h:29
Definition: GUIImage.h:27
void OnFocus(unsigned int buttonIndex) override
Focus has been set to the specified GUI button.
Definition: GUIFeatureList.h:41
Definition: GUIWindow.h:58
void Deinitialize() override
Deinitialize the resource.
Definition: GUIFeatureList.cpp:63
Definition: GUIFeatureList.h:30