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 {
24 {
25 public:
27 
28  ~CGUIDialogButtonCapture() override = default;
29 
30  // implementation of IButtonMapper
31  std::string ControllerID() const override;
32  bool NeedsCooldown() const override { return false; }
33  bool MapPrimitive(JOYSTICK::IButtonMap* buttonMap,
34  IKeymap* keymap,
35  const JOYSTICK::CDriverPrimitive& primitive) override;
36  void OnEventFrame(const JOYSTICK::IButtonMap* buttonMap, bool bMotion) override {}
37  void OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) override {}
38 
39  // implementation of Observer
40  void Notify(const Observable& obs, const ObservableMessage msg) override;
41 
45  void Show();
46 
47 protected:
48  // implementation of CThread
49  void Process() override;
50 
51  virtual std::string GetDialogText() = 0;
52  virtual std::string GetDialogHeader() = 0;
53  virtual bool MapPrimitiveInternal(JOYSTICK::IButtonMap* buttonMap,
54  IKeymap* keymap,
55  const JOYSTICK::CDriverPrimitive& primitive) = 0;
56  virtual void OnClose(bool bAccepted) = 0;
57 
58  CEvent m_captureEvent;
59 
60 private:
61  void InstallHooks();
62  void RemoveHooks();
63 };
64 } // namespace GAME
65 } // 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:117
Definition: Thread.h:44
Definition: GUIDialogButtonCapture.h:23
void OnLateAxis(const JOYSTICK::IButtonMap *buttonMap, unsigned int axisIndex) override
Called when an axis has been detected after mapping began.
Definition: GUIDialogButtonCapture.h:37
std::string ControllerID() const override
The add-on ID of the game controller associated with this button mapper.
Definition: GUIDialogButtonCapture.cpp:32
bool MapPrimitive(JOYSTICK::IButtonMap *buttonMap, IKeymap *keymap, const JOYSTICK::CDriverPrimitive &primitive) override
Handle button/hat press or axis threshold.
Definition: GUIDialogButtonCapture.cpp:72
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:58
Controller configuration window.
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:36
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:32
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:37