xbmc
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 {
19 {
20 public:
21  CGUISelectKeyButton(const CGUIButtonControl& buttonTemplate,
22  IConfigurationWizard* wizard,
23  unsigned int index);
24 
25  ~CGUISelectKeyButton() override = default;
26 
27  // implementation of IFeatureButton
28  const CPhysicalFeature& Feature(void) const override;
29  bool AllowWizard() const override { return false; }
30  bool PromptForInput(CEvent& waitEvent) override;
31  bool IsFinished() const override;
32  bool NeedsKey() const override { return m_state == STATE::NEED_KEY; }
33  void SetKey(const CPhysicalFeature& key) override;
34  void Reset() override;
35 
36 private:
37  static CPhysicalFeature GetFeature();
38 
39  enum class STATE
40  {
41  NEED_KEY,
42  NEED_INPUT,
43  FINISHED,
44  };
45 
46  STATE m_state = STATE::NEED_KEY;
47 
48  CPhysicalFeature m_selectedKey;
49 };
50 } // namespace GAME
51 } // 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:221
Definition: GUIFeatureButton.h:21
Definition: GUISelectKeyButton.h:18
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
Controller configuration window.
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:32
Definition: PhysicalFeature.h:24
bool AllowWizard() const override
Allow the wizard to include this feature in a list of buttons to map.
Definition: GUISelectKeyButton.h:29