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