xbmc
GUIDialogAxisDetection.h
1 /*
2  * Copyright (C) 2017-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 "GUIDialogButtonCapture.h"
12 
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 namespace KODI
18 {
19 namespace GAME
20 {
22 {
23 public:
24  CGUIDialogAxisDetection() = default;
25 
26  ~CGUIDialogAxisDetection() override = default;
27 
28  // specialization of IButtonMapper via CGUIDialogButtonCapture
29  bool AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const override;
30  void OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) override;
31 
32 protected:
33  // implementation of CGUIDialogButtonCapture
34  std::string GetDialogText() override;
35  std::string GetDialogHeader() override;
36  bool MapPrimitiveInternal(JOYSTICK::IButtonMap* buttonMap,
37  IKeymap* keymap,
38  const JOYSTICK::CDriverPrimitive& primitive) override;
39  void OnClose(bool bAccepted) override {}
40 
41 private:
42  void AddAxis(const std::string& deviceLocation, unsigned int axisIndex);
43 
44  // Axis types
45  using DeviceName = std::string;
46  using AxisIndex = unsigned int;
47  using AxisEntry = std::pair<DeviceName, AxisIndex>;
48  using AxisVector = std::vector<AxisEntry>;
49 
50  // Axis detection
51  AxisVector m_detectedAxes;
52 };
53 } // namespace GAME
54 } // namespace KODI
Definition: GUIDialogButtonCapture.h:23
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
bool AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const override
Return true if the button mapper accepts primitives of the given type.
Definition: GUIDialogAxisDetection.cpp:53
PRIMITIVE_TYPE
Type of driver primitive.
Definition: JoystickTypes.h:150
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: GUIDialogAxisDetection.h:21
Basic driver element associated with input events.
Definition: DriverPrimitive.h:69
void OnLateAxis(const JOYSTICK::IButtonMap *buttonMap, unsigned int axisIndex) override
Called when an axis has been detected after mapping began.
Definition: GUIDialogAxisDetection.cpp:66