xbmc
GameClientJoystick.h
1 /*
2  * Copyright (C) 2015-2018 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 "games/controllers/ControllerTypes.h"
12 #include "input/joysticks/interfaces/IInputHandler.h"
13 
14 #include <memory>
15 
16 namespace KODI
17 {
18 namespace JOYSTICK
19 {
20 class IInputProvider;
21 }
22 
23 namespace GAME
24 {
25 class CGameClient;
26 class CPortInput;
27 
35 {
36 public:
45  const std::string& portAddress,
46  const ControllerPtr& controller);
47 
48  ~CGameClientJoystick() override;
49 
50  void RegisterInput(JOYSTICK::IInputProvider* inputProvider);
51  void UnregisterInput(JOYSTICK::IInputProvider* inputProvider);
52 
53  // Implementation of IInputHandler
54  std::string ControllerID() const override;
55  bool HasFeature(const std::string& feature) const override;
56  bool AcceptsInput(const std::string& feature) const override;
57  bool OnButtonPress(const std::string& feature, bool bPressed) override;
58  void OnButtonHold(const std::string& feature, unsigned int holdTimeMs) override {}
59  bool OnButtonMotion(const std::string& feature,
60  float magnitude,
61  unsigned int motionTimeMs) override;
62  bool OnAnalogStickMotion(const std::string& feature,
63  float x,
64  float y,
65  unsigned int motionTimeMs) override;
66  bool OnAccelerometerMotion(const std::string& feature, float x, float y, float z) override;
67  bool OnWheelMotion(const std::string& feature,
68  float position,
69  unsigned int motionTimeMs) override;
70  bool OnThrottleMotion(const std::string& feature,
71  float position,
72  unsigned int motionTimeMs) override;
73  void OnInputFrame() override {}
74 
75  bool SetRumble(const std::string& feature, float magnitude);
76 
77 private:
78  // Construction parameters
79  CGameClient& m_gameClient;
80  const std::string m_portAddress;
81  const ControllerPtr m_controller;
82 
83  // Input parameters
84  std::unique_ptr<CPortInput> m_portInput;
85 };
86 } // namespace GAME
87 } // namespace KODI
Interface for classes that can provide input.
Definition: IInputProvider.h:21
void OnButtonHold(const std::string &feature, unsigned int holdTimeMs) override
A digital button has been pressed for more than one event frame.
Definition: GameClientJoystick.h:58
Interface between Kodi and Game add-ons.
Definition: GameClient.h:115
Controller configuration window.
Definition: AudioDecoder.h:18
Handles game controller events for games.
Definition: GameClientJoystick.h:34
Interface for handling input events for game controllers.
Definition: IInputHandler.h:25
void OnInputFrame() override
Called at the end of the frame that provided input.
Definition: GameClientJoystick.h:73