| 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 |
{ |
| 28 |
/*! |
| 29 |
* \ingroup games |
| 30 |
*/ |
| 31 |
class CGUIDialogButtonCapture : public JOYSTICK::IButtonMapper, public Observer, protected CThread |
| 32 |
{ |
| 33 |
public: |
| 34 |
CGUIDialogButtonCapture(); |
| 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 |
|
| 50 |
/*! |
| 51 |
* \brief Show the dialog |
| 52 |
*/ |
| 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 |