kodi
InputHandling.h
1 /*
2  * Copyright (C) 2014-2024 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"
12 #include "input/joysticks/JoystickTypes.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 
41 {
42 public:
43  CInputHandling(IInputHandler* handler, IButtonMap* buttonMap);
44 
45  ~CInputHandling() override;
46 
47  // implementation of IDriverHandler
48  bool OnButtonMotion(unsigned int buttonIndex, bool bPressed) override;
49  bool OnHatMotion(unsigned int hatIndex, HAT_STATE state) override;
50  bool OnAxisMotion(unsigned int axisIndex,
51  float position,
52  int center,
53  unsigned int range) override;
54  void OnInputFrame() override;
55 
56 private:
57  bool OnDigitalMotion(const CDriverPrimitive& source, bool bPressed);
58  bool OnAnalogMotion(const CDriverPrimitive& source, float magnitude);
59 
60  CJoystickFeature* CreateFeature(const FeatureName& featureName);
61 
62  IInputHandler* const m_handler;
63  IButtonMap* const m_buttonMap;
64 
65  std::map<FeatureName, FeaturePtr> m_features;
66 
67  static CGUIDialogNewJoystick* const m_dialog;
68 };
69 } // namespace JOYSTICK
70 } // 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:23
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:29
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:40
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:26
Definition: GUIDialogNewJoystick.h:20
Basic driver element associated with input events.
Definition: DriverPrimitive.h:70
Base class for joystick features.
Definition: FeatureHandling.h:34