xbmc
InputSink.h
1 /*
2  * Copyright (C) 2017-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 "input/joysticks/interfaces/IInputHandler.h"
12 
13 namespace KODI
14 {
15 namespace GAME
16 {
17 class CGameClient;
18 
20 {
21 public:
22  explicit CInputSink(JOYSTICK::IInputHandler* gameInput);
23 
24  ~CInputSink() override = default;
25 
26  // Implementation of IInputHandler
27  std::string ControllerID() const override;
28  bool HasFeature(const std::string& feature) const override { return true; }
29  bool AcceptsInput(const std::string& feature) const override;
30  bool OnButtonPress(const std::string& feature, bool bPressed) override;
31  void OnButtonHold(const std::string& feature, unsigned int holdTimeMs) override {}
32  bool OnButtonMotion(const std::string& feature,
33  float magnitude,
34  unsigned int motionTimeMs) override;
35  bool OnAnalogStickMotion(const std::string& feature,
36  float x,
37  float y,
38  unsigned int motionTimeMs) override;
39  bool OnAccelerometerMotion(const std::string& feature, float x, float y, float z) override;
40  bool OnWheelMotion(const std::string& feature,
41  float position,
42  unsigned int motionTimeMs) override;
43  bool OnThrottleMotion(const std::string& feature,
44  float position,
45  unsigned int motionTimeMs) override;
46  void OnInputFrame() override {}
47 
48 private:
49  // Construction parameters
50  JOYSTICK::IInputHandler* m_gameInput;
51 };
52 } // namespace GAME
53 } // namespace KODI
bool HasFeature(const std::string &feature) const override
Return true if the input handler accepts the given feature.
Definition: InputSink.h:28
bool OnThrottleMotion(const std::string &feature, float position, unsigned int motionTimeMs) override
A throttle has changed state.
Definition: InputSink.cpp:62
bool OnButtonPress(const std::string &feature, bool bPressed) override
A digital button has been pressed or released.
Definition: InputSink.cpp:30
bool OnWheelMotion(const std::string &feature, float position, unsigned int motionTimeMs) override
A wheel has changed state.
Definition: InputSink.cpp:55
void OnButtonHold(const std::string &feature, unsigned int holdTimeMs) override
A digital button has been pressed for more than one event frame.
Definition: InputSink.h:31
bool OnButtonMotion(const std::string &feature, float magnitude, unsigned int motionTimeMs) override
An analog button (trigger or a pressure-sensitive button) has changed state.
Definition: InputSink.cpp:35
void OnInputFrame() override
Called at the end of the frame that provided input.
Definition: InputSink.h:46
Controller configuration window.
Definition: AudioDecoder.h:18
bool OnAccelerometerMotion(const std::string &feature, float x, float y, float z) override
An accelerometer's state has changed.
Definition: InputSink.cpp:50
Definition: InputSink.h:19
Interface for handling input events for game controllers.
Definition: IInputHandler.h:25
bool AcceptsInput(const std::string &feature) const override
Return true if the input handler is currently accepting input for the given feature.
Definition: InputSink.cpp:25
std::string ControllerID() const override
The add-on ID of the game controller associated with this input handler.
Definition: InputSink.cpp:20
bool OnAnalogStickMotion(const std::string &feature, float x, float y, unsigned int motionTimeMs) override
An analog stick has moved.
Definition: InputSink.cpp:42