kodi
AddonButtonMapping.h
1 /*
2  * Copyright (C) 2014-2024 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/joysticks/interfaces/IButtonMapCallback.h"
12 #include "input/joysticks/interfaces/IDriverHandler.h"
13 #include "input/keyboard/interfaces/IKeyboardDriverHandler.h"
14 #include "input/mouse/interfaces/IMouseDriverHandler.h"
15 
16 #include <memory>
17 
18 namespace KODI
19 {
20 namespace JOYSTICK
21 {
22 class CButtonMapping;
23 class IButtonMap;
24 class IButtonMapper;
25 } // namespace JOYSTICK
26 } // namespace KODI
27 
28 namespace PERIPHERALS
29 {
30 class CPeripheral;
31 class CPeripherals;
32 
40 {
41 public:
43  CPeripheral* peripheral,
45 
46  ~CAddonButtonMapping(void) override;
47 
48  // implementation of IDriverHandler
49  bool OnButtonMotion(unsigned int buttonIndex, bool bPressed) override;
50  bool OnHatMotion(unsigned int hatIndex, KODI::JOYSTICK::HAT_STATE state) override;
51  bool OnAxisMotion(unsigned int axisIndex,
52  float position,
53  int center,
54  unsigned int range) override;
55  void OnInputFrame(void) override;
56 
57  // implementation of IKeyboardDriverHandler
58  bool OnKeyPress(const CKey& key) override;
59  void OnKeyRelease(const CKey& key) override;
60 
61  // implementation of IMouseDriverHandler
62  bool OnPosition(int x, int y) override;
63  bool OnButtonPress(KODI::MOUSE::BUTTON_ID button) override;
64  void OnButtonRelease(KODI::MOUSE::BUTTON_ID button) override;
65 
66  // implementation of IButtonMapCallback
67  void SaveButtonMap() override;
68  void ResetIgnoredPrimitives() override;
69  void RevertButtonMap() override;
70 
71 private:
72  std::unique_ptr<KODI::JOYSTICK::CButtonMapping> m_buttonMapping;
73  std::unique_ptr<KODI::JOYSTICK::IButtonMap> m_buttonMap;
74 };
75 } // namespace PERIPHERALS
BUTTON_ID
Buttons on a mouse.
Definition: MouseTypes.h:26
Definition: RetroPlayerInput.h:15
Interface defining methods to handle joystick events for raw driver elements (buttons, hats, axes)
Definition: IDriverHandler.h:23
Definition: AudioDecoder.h:18
Interface for handling mouse driver events.
Definition: IMouseDriverHandler.h:22
Button mapper interface to assign the driver&#39;s raw button/hat/axis elements to physical joystick feat...
Definition: IButtonMapper.h:37
Interface for handling keyboard events.
Definition: IKeyboardDriverHandler.h:22
Interface for handling button maps.
Definition: IButtonMapCallback.h:20
Definition: AddonButtonMapping.h:36
Definition: Peripheral.h:71
Definition: Key.h:17
Definition: Peripherals.h:56