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 
23 {
24 public:
25  explicit CInputSink(JOYSTICK::IInputHandler* gameInput);
26 
27  ~CInputSink() override = default;
28 
29  // Implementation of IInputHandler
30  std::string ControllerID() const override;
31  bool HasFeature(const std::string& feature) const override { return true; }
32  bool AcceptsInput(const std::string& feature) const override;
33  bool OnButtonPress(const std::string& feature, bool bPressed) override;
34  void OnButtonHold(const std::string& feature, unsigned int holdTimeMs) override {}
35  bool OnButtonMotion(const std::string& feature,
36  float magnitude,
37  unsigned int motionTimeMs) override;
38  bool OnAnalogStickMotion(const std::string& feature,
39  float x,
40  float y,
41  unsigned int motionTimeMs) override;
42  bool OnAccelerometerMotion(const std::string& feature, float x, float y, float z) override;
43  bool OnWheelMotion(const std::string& feature,
44  float position,
45  unsigned int motionTimeMs) override;
46  bool OnThrottleMotion(const std::string& feature,
47  float position,
48  unsigned int motionTimeMs) override;
49  void OnInputFrame() override {}
50 
51 private:
52  // Construction parameters
53  JOYSTICK::IInputHandler* m_gameInput;
54 };
55 } // namespace GAME
56 } // namespace KODI
bool HasFeature(const std::string &feature) const override
Return true if the input handler accepts the given feature.
Definition: InputSink.h:31
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:34
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:49
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:22
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