kodi
GUISelectKeyButton.h
1 /*
2  * Copyright (C) 2017-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 "GUIFeatureButton.h"
12 #include "games/controllers/input/PhysicalFeature.h"
13 
14 namespace KODI
15 {
16 namespace GAME
17 {
22 {
23 public:
24  CGUISelectKeyButton(const CGUIButtonControl& buttonTemplate,
25  IConfigurationWizard* wizard,
26  unsigned int index);
27 
28  ~CGUISelectKeyButton() override = default;
29 
30  // implementation of IFeatureButton
31  const CPhysicalFeature& Feature(void) const override;
32  bool AllowWizard() const override { return false; }
33  bool PromptForInput(CEvent& waitEvent) override;
34  bool IsFinished() const override;
35  bool NeedsKey() const override { return m_state == STATE::NEED_KEY; }
36  void SetKey(const CPhysicalFeature& key) override;
37  void Reset() override;
38 
39 private:
40  static CPhysicalFeature GetFeature();
41 
42  enum class STATE
43  {
44  NEED_KEY,
45  NEED_INPUT,
46  FINISHED,
47  };
48 
49  STATE m_state = STATE::NEED_KEY;
50 
51  CPhysicalFeature m_selectedKey;
52 };
53 } // namespace GAME
54 } // namespace KODI
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: GUIButtonControl.h:27
bool PromptForInput(CEvent &waitEvent) override
Prompt the user for a single input element.
Definition: GUISelectKeyButton.cpp:33
A wizard to direct user input.
Definition: IConfigurationWindow.h:240
Definition: GUIFeatureButton.h:24
Definition: GUISelectKeyButton.h:21
const CPhysicalFeature & Feature(void) const override
Get the feature represented by this button.
Definition: GUISelectKeyButton.cpp:25
void SetKey(const CPhysicalFeature &key) override
Set the pressed key that the user will be prompted to map.
Definition: GUISelectKeyButton.cpp:73
Definition: AudioDecoder.h:18
bool IsFinished() const override
Check if the button supports further calls to PromptForInput()
Definition: GUISelectKeyButton.cpp:68
void Reset() override
Reset button after prompting for input has finished.
Definition: GUISelectKeyButton.cpp:78
bool NeedsKey() const override
True if the button is waiting for a key press.
Definition: GUISelectKeyButton.h:35
Definition: PhysicalFeature.h:30
bool AllowWizard() const override
Allow the wizard to include this feature in a list of buttons to map.
Definition: GUISelectKeyButton.h:32