diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/peripherals/addons/AddonInputHandling.h | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/peripherals/addons/AddonInputHandling.h')
-rw-r--r-- | xbmc/peripherals/addons/AddonInputHandling.h | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/xbmc/peripherals/addons/AddonInputHandling.h b/xbmc/peripherals/addons/AddonInputHandling.h new file mode 100644 index 0000000..295e6d4 --- /dev/null +++ b/xbmc/peripherals/addons/AddonInputHandling.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "input/joysticks/interfaces/IDriverHandler.h" +#include "input/joysticks/interfaces/IInputReceiver.h" +#include "input/keyboard/interfaces/IKeyboardDriverHandler.h" +#include "input/mouse/interfaces/IMouseDriverHandler.h" + +#include <memory> + +namespace KODI +{ +namespace JOYSTICK +{ +class IButtonMap; +class IDriverReceiver; +class IInputHandler; +} // namespace JOYSTICK + +namespace KEYBOARD +{ +class IKeyboardInputHandler; +} + +namespace MOUSE +{ +class IMouseInputHandler; +} +} // namespace KODI + +namespace PERIPHERALS +{ +class CPeripheral; +class CPeripherals; +class CPeripheralAddon; + +class CAddonInputHandling : public KODI::JOYSTICK::IDriverHandler, + public KODI::JOYSTICK::IInputReceiver, + public KODI::KEYBOARD::IKeyboardDriverHandler, + public KODI::MOUSE::IMouseDriverHandler +{ +public: + CAddonInputHandling(CPeripherals& manager, + CPeripheral* peripheral, + std::shared_ptr<CPeripheralAddon> addon, + KODI::JOYSTICK::IInputHandler* handler, + KODI::JOYSTICK::IDriverReceiver* receiver); + + CAddonInputHandling(CPeripherals& manager, + CPeripheral* peripheral, + std::shared_ptr<CPeripheralAddon> addon, + KODI::KEYBOARD::IKeyboardInputHandler* handler); + + CAddonInputHandling(CPeripherals& manager, + CPeripheral* peripheral, + std::shared_ptr<CPeripheralAddon> addon, + KODI::MOUSE::IMouseInputHandler* handler); + + ~CAddonInputHandling(void) override; + + bool Load(); + + // implementation of IDriverHandler + bool OnButtonMotion(unsigned int buttonIndex, bool bPressed) override; + bool OnHatMotion(unsigned int hatIndex, KODI::JOYSTICK::HAT_STATE state) override; + bool OnAxisMotion(unsigned int axisIndex, + float position, + int center, + unsigned int range) override; + void OnInputFrame(void) override; + + // implementation of IKeyboardDriverHandler + bool OnKeyPress(const CKey& key) override; + void OnKeyRelease(const CKey& key) override; + + // implementation of IMouseDriverHandler + bool OnPosition(int x, int y) override; + bool OnButtonPress(KODI::MOUSE::BUTTON_ID button) override; + void OnButtonRelease(KODI::MOUSE::BUTTON_ID button) override; + + // implementation of IInputReceiver + bool SetRumbleState(const KODI::JOYSTICK::FeatureName& feature, float magnitude) override; + +private: + // Construction parameters + CPeripherals& m_manager; + CPeripheral* const m_peripheral; + const std::shared_ptr<CPeripheralAddon> m_addon; + KODI::JOYSTICK::IInputHandler* const m_joystickInputHandler{nullptr}; + KODI::JOYSTICK::IDriverReceiver* const m_joystickDriverReceiver{nullptr}; + KODI::KEYBOARD::IKeyboardInputHandler* m_keyboardInputHandler{nullptr}; + KODI::MOUSE::IMouseInputHandler* const m_mouseInputHandler{nullptr}; + + // Input parameters + std::unique_ptr<KODI::JOYSTICK::IDriverHandler> m_joystickDriverHandler; + std::unique_ptr<KODI::JOYSTICK::IInputReceiver> m_joystickInputReceiver; + std::unique_ptr<KODI::KEYBOARD::IKeyboardDriverHandler> m_keyboardDriverHandler; + std::unique_ptr<KODI::MOUSE::IMouseDriverHandler> m_mouseDriverHandler; + std::unique_ptr<KODI::JOYSTICK::IButtonMap> m_buttonMap; +}; +} // namespace PERIPHERALS |