Merge pull request #26373 from ksooo/app-fix-multi-resolve-playback
[xbmc.git] / xbmc / games / ports / input / PortInput.h
blob2d1bc21bb98c02d1d09da5eb82075a922f927379
1 /*
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.
7 */
9 #pragma once
11 #include "input/joysticks/interfaces/IInputHandler.h"
12 #include "input/keymaps/interfaces/IKeymapEnvironment.h"
14 #include <memory>
16 namespace KODI
18 namespace JOYSTICK
20 class IInputProvider;
21 } // namespace JOYSTICK
23 namespace KEYMAP
25 class CKeymapHandling;
26 } // namespace KEYMAP
28 namespace GAME
30 class CControllerActivity;
32 /*!
33 * \ingroup games
35 class CPortInput : public JOYSTICK::IInputHandler, public KEYMAP::IKeymapEnvironment
37 public:
38 CPortInput(JOYSTICK::IInputHandler* gameInput);
39 ~CPortInput() override;
41 void RegisterInput(JOYSTICK::IInputProvider* provider);
42 void UnregisterInput(JOYSTICK::IInputProvider* provider);
44 // Input parameters
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,
54 float magnitude,
55 unsigned int motionTimeMs) override;
56 bool OnAnalogStickMotion(const std::string& feature,
57 float x,
58 float y,
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,
62 float position,
63 unsigned int motionTimeMs) override;
64 bool OnThrottleMotion(const std::string& feature,
65 float position,
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; }
76 private:
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;
89 } // namespace GAME
90 } // namespace KODI