xbmc
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 GAME
22 {
27 {
28 public:
30 
31  ~CGUIDialogButtonCapture() override = default;
32 
33  // implementation of IButtonMapper
34  std::string ControllerID() const override;
35  bool NeedsCooldown() const override { return false; }
36  bool MapPrimitive(JOYSTICK::IButtonMap* buttonMap,
37  IKeymap* keymap,
38  const JOYSTICK::CDriverPrimitive& primitive) override;
39  void OnEventFrame(const JOYSTICK::IButtonMap* buttonMap, bool bMotion) override {}
40  void OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) override {}
41 
42  // implementation of Observer
43  void Notify(const Observable& obs, const ObservableMessage msg) override;
44 
48  void Show();
49 
50 protected:
51  // implementation of CThread
52  void Process() override;
53 
54  virtual std::string GetDialogText() = 0;
55  virtual std::string GetDialogHeader() = 0;
56  virtual bool MapPrimitiveInternal(JOYSTICK::IButtonMap* buttonMap,
57  IKeymap* keymap,
58  const JOYSTICK::CDriverPrimitive& primitive) = 0;
59  virtual void OnClose(bool bAccepted) = 0;
60 
61  CEvent m_captureEvent;
62 
63 private:
64  void InstallHooks();
65  void RemoveHooks();
66 };
67 } // namespace GAME
68 } // namespace KODI
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
void Notify(const Observable &obs, const ObservableMessage msg) override
Process a message from an observable.
Definition: GUIDialogButtonCapture.cpp:116
Definition: Thread.h:44
Definition: GUIDialogButtonCapture.h:26
void OnLateAxis(const JOYSTICK::IButtonMap *buttonMap, unsigned int axisIndex) override
Called when an axis has been detected after mapping began.
Definition: GUIDialogButtonCapture.h:40
std::string ControllerID() const override
The add-on ID of the game controller associated with this button mapper.
Definition: GUIDialogButtonCapture.cpp:31
bool MapPrimitive(JOYSTICK::IButtonMap *buttonMap, IKeymap *keymap, const JOYSTICK::CDriverPrimitive &primitive) override
Handle button/hat press or axis threshold.
Definition: GUIDialogButtonCapture.cpp:71
Interface for mapping buttons to Kodi actions.
Definition: IKeymap.h:22
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:28
void Process() override
Definition: GUIDialogButtonCapture.cpp:57
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:39
Basic driver element associated with input events.
Definition: DriverPrimitive.h:69
bool NeedsCooldown() const override
Return true if the button mapper wants a cooldown between button mapping commands.
Definition: GUIDialogButtonCapture.h:35
Button mapper interface to assign the driver&#39;s raw button/hat/axis elements to physical joystick feat...
Definition: IButtonMapper.h:33
Definition: Observer.h:44
void Show()
Show the dialog.
Definition: GUIDialogButtonCapture.cpp:36