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/KeymapEnvironment.h"
12 #include "input/joysticks/interfaces/IInputHandler.h"
20 class CKeymapHandling
;
22 } // namespace JOYSTICK
26 class CPortInput
: public JOYSTICK::IInputHandler
, public IKeymapEnvironment
29 CPortInput(JOYSTICK::IInputHandler
* gameInput
);
30 ~CPortInput() override
;
32 void RegisterInput(JOYSTICK::IInputProvider
* provider
);
33 void UnregisterInput(JOYSTICK::IInputProvider
* provider
);
35 JOYSTICK::IInputHandler
* InputHandler() { return m_gameInput
; }
37 // Implementation of IInputHandler
38 std::string
ControllerID() const override
;
39 bool HasFeature(const std::string
& feature
) const override
{ return true; }
40 bool AcceptsInput(const std::string
& feature
) const override
;
41 bool OnButtonPress(const std::string
& feature
, bool bPressed
) override
;
42 void OnButtonHold(const std::string
& feature
, unsigned int holdTimeMs
) override
;
43 bool OnButtonMotion(const std::string
& feature
,
45 unsigned int motionTimeMs
) override
;
46 bool OnAnalogStickMotion(const std::string
& feature
,
49 unsigned int motionTimeMs
) override
;
50 bool OnAccelerometerMotion(const std::string
& feature
, float x
, float y
, float z
) override
;
51 bool OnWheelMotion(const std::string
& feature
,
53 unsigned int motionTimeMs
) override
;
54 bool OnThrottleMotion(const std::string
& feature
,
56 unsigned int motionTimeMs
) override
;
57 void OnInputFrame() override
{}
59 // Implementation of IKeymapEnvironment
60 int GetWindowID() const override
;
61 void SetWindowID(int windowId
) override
{}
62 int GetFallthrough(int windowId
) const override
{ return -1; }
63 bool UseGlobalFallthrough() const override
{ return false; }
64 bool UseEasterEgg() const override
{ return false; }
67 // Construction parameters
68 JOYSTICK::IInputHandler
* const m_gameInput
;
70 // Handles input to Kodi
71 std::unique_ptr
<JOYSTICK::CKeymapHandling
> m_appInput
;
73 // Prevents input falling through to Kodi when not handled by the game
74 std::unique_ptr
<JOYSTICK::IInputHandler
> m_inputSink
;