xbmc
InputHandling.h
1 /*
2  * Copyright (C) 2014-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 "FeatureHandling.h"
13 #include "input/joysticks/interfaces/IDriverHandler.h"
14 
15 #include <map>
16 
17 namespace KODI
18 {
19 namespace JOYSTICK
20 {
21 class CDriverPrimitive;
22 class CGUIDialogNewJoystick;
23 class IInputHandler;
24 class IButtonMap;
25 
40 {
41 public:
42  CInputHandling(IInputHandler* handler, IButtonMap* buttonMap);
43 
44  ~CInputHandling() override;
45 
46  // implementation of IDriverHandler
47  bool OnButtonMotion(unsigned int buttonIndex, bool bPressed) override;
48  bool OnHatMotion(unsigned int hatIndex, HAT_STATE state) override;
49  bool OnAxisMotion(unsigned int axisIndex,
50  float position,
51  int center,
52  unsigned int range) override;
53  void OnInputFrame() override;
54 
55 private:
56  bool OnDigitalMotion(const CDriverPrimitive& source, bool bPressed);
57  bool OnAnalogMotion(const CDriverPrimitive& source, float magnitude);
58 
59  CJoystickFeature* CreateFeature(const FeatureName& featureName);
60 
61  IInputHandler* const m_handler;
62  IButtonMap* const m_buttonMap;
63 
64  std::map<FeatureName, FeaturePtr> m_features;
65 
66  static CGUIDialogNewJoystick* const m_dialog;
67 };
68 } // namespace JOYSTICK
69 } // namespace KODI
Definition: IInputHandler.h:16
bool OnButtonMotion(unsigned int buttonIndex, bool bPressed) override
Handle button motion.
Definition: InputHandling.cpp:34
Interface defining methods to handle joystick events for raw driver elements (buttons, hats, axes)
Definition: IDriverHandler.h:21
bool OnHatMotion(unsigned int hatIndex, HAT_STATE state) override
Handle hat motion.
Definition: InputHandling.cpp:39
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:28
void OnInputFrame() override
Handle buffered input motion for features that require multiple axes.
Definition: InputHandling.cpp:89
Class to translate input from the driver into higher-level features.
Definition: InputHandling.h:39
Definition: AudioDecoder.h:18
bool OnAxisMotion(unsigned int axisIndex, float position, int center, unsigned int range) override
Handle axis motion.
Definition: InputHandling.cpp:55
Interface for handling input events for game controllers.
Definition: IInputHandler.h:25
Definition: GUIDialogNewJoystick.h:17
Basic driver element associated with input events.
Definition: DriverPrimitive.h:69
std::string FeatureName
Name of a physical feature belonging to the joystick.
Definition: JoystickTypes.h:28
Base class for joystick features.
Definition: FeatureHandling.h:33