2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "input/joysticks/interfaces/IInputHandler.h"
12 #include "input/keymaps/interfaces/IKeymapEnvironment.h"
21 } // namespace JOYSTICK
25 class CKeymapHandling
;
30 class CControllerActivity
;
35 class CPortInput
: public JOYSTICK::IInputHandler
, public KEYMAP::IKeymapEnvironment
38 CPortInput(JOYSTICK::IInputHandler
* gameInput
);
39 ~CPortInput() override
;
41 void RegisterInput(JOYSTICK::IInputProvider
* provider
);
42 void UnregisterInput(JOYSTICK::IInputProvider
* provider
);
45 float GetActivation() const;
47 // Implementation of IInputHandler
48 std::string
ControllerID() const override
;
49 bool HasFeature(const std::string
& feature
) const override
{ return true; }
50 bool AcceptsInput(const std::string
& feature
) const override
;
51 bool OnButtonPress(const std::string
& feature
, bool bPressed
) override
;
52 void OnButtonHold(const std::string
& feature
, unsigned int holdTimeMs
) override
;
53 bool OnButtonMotion(const std::string
& feature
,
55 unsigned int motionTimeMs
) override
;
56 bool OnAnalogStickMotion(const std::string
& feature
,
59 unsigned int motionTimeMs
) override
;
60 bool OnAccelerometerMotion(const std::string
& feature
, float x
, float y
, float z
) override
;
61 bool OnWheelMotion(const std::string
& feature
,
63 unsigned int motionTimeMs
) override
;
64 bool OnThrottleMotion(const std::string
& feature
,
66 unsigned int motionTimeMs
) override
;
67 void OnInputFrame() override
;
69 // Implementation of IKeymapEnvironment
70 int GetWindowID() const override
;
71 void SetWindowID(int windowId
) override
{}
72 int GetFallthrough(int windowId
) const override
{ return -1; }
73 bool UseGlobalFallthrough() const override
{ return false; }
74 bool UseEasterEgg() const override
{ return false; }
77 // Construction parameters
78 JOYSTICK::IInputHandler
* const m_gameInput
;
80 // Handles input to Kodi
81 std::unique_ptr
<KEYMAP::CKeymapHandling
> m_appInput
;
83 // Prevents input falling through to Kodi when not handled by the game
84 std::unique_ptr
<JOYSTICK::IInputHandler
> m_inputSink
;
86 // Records controller activity
87 std::unique_ptr
<CControllerActivity
> m_controllerActivity
;