kodi
GUIDialogButtonCapture.h
1 /*
2  * Copyright (C) 2016-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 "input/joysticks/interfaces/IButtonMapper.h"
12 #include "threads/Event.h"
13 #include "threads/Thread.h"
14 #include "utils/Observer.h"
15 
16 #include <string>
17 #include <vector>
18 
19 namespace KODI
20 {
21 namespace KEYMAP
22 {
23 class IKeymap;
24 } // namespace KEYMAP
25 
26 namespace GAME
27 {
32 {
33 public:
35 
36  ~CGUIDialogButtonCapture() override = default;
37 
38  // implementation of IButtonMapper
39  std::string ControllerID() const override;
40  bool NeedsCooldown() const override { return false; }
41  bool MapPrimitive(JOYSTICK::IButtonMap* buttonMap,
42  KEYMAP::IKeymap* keymap,
43  const JOYSTICK::CDriverPrimitive& primitive) override;
44  void OnEventFrame(const JOYSTICK::IButtonMap* buttonMap, bool bMotion) override {}
45  void OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) override {}
46 
47  // implementation of Observer
48  void Notify(const Observable& obs, const ObservableMessage msg) override;
49 
53  void Show();
54 
55 protected:
56  // implementation of CThread
57  void Process() override;
58 
59  virtual std::string GetDialogText() = 0;
60  virtual std::string GetDialogHeader() = 0;
61  virtual bool MapPrimitiveInternal(JOYSTICK::IButtonMap* buttonMap,
62  KEYMAP::IKeymap* keymap,
63  const JOYSTICK::CDriverPrimitive& primitive) = 0;
64  virtual void OnClose(bool bAccepted) = 0;
65 
66  CEvent m_captureEvent;
67 
68 private:
69  void InstallHooks();
70  void RemoveHooks();
71 };
72 } // namespace GAME
73 } // namespace KODI
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: Thread.h:44
Definition: GUIDialogButtonCapture.h:31
void OnLateAxis(const JOYSTICK::IButtonMap *buttonMap, unsigned int axisIndex) override
Called when an axis has been detected after mapping began.
Definition: GUIDialogButtonCapture.h:45
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:29
Definition: AudioDecoder.h:18
Definition: Observer.h:31
void OnEventFrame(const JOYSTICK::IButtonMap *buttonMap, bool bMotion) override
Called once per event frame to notify the implementation of motion status.
Definition: GUIDialogButtonCapture.h:44
Basic driver element associated with input events.
Definition: DriverPrimitive.h:70
bool NeedsCooldown() const override
Return true if the button mapper wants a cooldown between button mapping commands.
Definition: GUIDialogButtonCapture.h:40
Button mapper interface to assign the driver&#39;s raw button/hat/axis elements to physical joystick feat...
Definition: IButtonMapper.h:37
Definition: Observer.h:44
Interface for mapping buttons to Kodi actions.
Definition: IKeymap.h:28