summaryrefslogtreecommitdiffstats
path: root/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.h
blob: 4ca0d271460259ca9062ec37b6818a456985e249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 *  Copyright (C) 2017-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "GUIDialogButtonCapture.h"

#include <string>
#include <utility>
#include <vector>

namespace KODI
{
namespace GAME
{
class CGUIDialogAxisDetection : public CGUIDialogButtonCapture
{
public:
  CGUIDialogAxisDetection() = default;

  ~CGUIDialogAxisDetection() override = default;

  // specialization of IButtonMapper via CGUIDialogButtonCapture
  bool AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const override;
  void OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) override;

protected:
  // implementation of CGUIDialogButtonCapture
  std::string GetDialogText() override;
  std::string GetDialogHeader() override;
  bool MapPrimitiveInternal(JOYSTICK::IButtonMap* buttonMap,
                            IKeymap* keymap,
                            const JOYSTICK::CDriverPrimitive& primitive) override;
  void OnClose(bool bAccepted) override {}

private:
  void AddAxis(const std::string& deviceLocation, unsigned int axisIndex);

  // Axis types
  using DeviceName = std::string;
  using AxisIndex = unsigned int;
  using AxisEntry = std::pair<DeviceName, AxisIndex>;
  using AxisVector = std::vector<AxisEntry>;

  // Axis detection
  AxisVector m_detectedAxes;
};
} // namespace GAME
} // namespace KODI