xbmc
PortInput.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 "input/KeymapEnvironment.h"
12 #include "input/joysticks/interfaces/IInputHandler.h"
13 
14 #include <memory>
15 
16 namespace KODI
17 {
18 namespace JOYSTICK
19 {
20 class CKeymapHandling;
21 class IInputProvider;
22 } // namespace JOYSTICK
23 
24 namespace GAME
25 {
26 class CControllerActivity;
27 
32 {
33 public:
35  ~CPortInput() override;
36 
37  void RegisterInput(JOYSTICK::IInputProvider* provider);
38  void UnregisterInput(JOYSTICK::IInputProvider* provider);
39 
40  // Input parameters
41  float GetActivation() const;
42 
43  // Implementation of IInputHandler
44  std::string ControllerID() const override;
45  bool HasFeature(const std::string& feature) const override { return true; }
46  bool AcceptsInput(const std::string& feature) const override;
47  bool OnButtonPress(const std::string& feature, bool bPressed) override;
48  void OnButtonHold(const std::string& feature, unsigned int holdTimeMs) override;
49  bool OnButtonMotion(const std::string& feature,
50  float magnitude,
51  unsigned int motionTimeMs) override;
52  bool OnAnalogStickMotion(const std::string& feature,
53  float x,
54  float y,
55  unsigned int motionTimeMs) override;
56  bool OnAccelerometerMotion(const std::string& feature, float x, float y, float z) override;
57  bool OnWheelMotion(const std::string& feature,
58  float position,
59  unsigned int motionTimeMs) override;
60  bool OnThrottleMotion(const std::string& feature,
61  float position,
62  unsigned int motionTimeMs) override;
63  void OnInputFrame() override;
64 
65  // Implementation of IKeymapEnvironment
66  int GetWindowID() const override;
67  void SetWindowID(int windowId) override {}
68  int GetFallthrough(int windowId) const override { return -1; }
69  bool UseGlobalFallthrough() const override { return false; }
70  bool UseEasterEgg() const override { return false; }
71 
72 private:
73  // Construction parameters
74  JOYSTICK::IInputHandler* const m_gameInput;
75 
76  // Handles input to Kodi
77  std::unique_ptr<JOYSTICK::CKeymapHandling> m_appInput;
78 
79  // Prevents input falling through to Kodi when not handled by the game
80  std::unique_ptr<JOYSTICK::IInputHandler> m_inputSink;
81 
82  // Records controller activity
83  std::unique_ptr<CControllerActivity> m_controllerActivity;
84 };
85 } // namespace GAME
86 } // namespace KODI
int GetFallthrough(int windowId) const override
Get the fallthrough window to when a key definition is missing.
Definition: PortInput.h:68
bool HasFeature(const std::string &feature) const override
Return true if the input handler accepts the given feature.
Definition: PortInput.h:45
Interface for classes that can provide input.
Definition: IInputProvider.h:21
void SetWindowID(int windowId) override
Set the window ID.
Definition: PortInput.h:67
bool UseGlobalFallthrough() const override
Specify if the global keymap should be used when the window and fallback window are undefined...
Definition: PortInput.h:69
bool UseEasterEgg() const override
Specify if the agent should monitor for easter egg presses.
Definition: PortInput.h:70
Definition: PortInput.h:31
Definition: AudioDecoder.h:18
Interface for handling input events for game controllers.
Definition: IInputHandler.h:25
Customizes the environment in which keymapping is performed.
Definition: IKeymapEnvironment.h:21