| 1 |
/* |
| 2 |
* Copyright (C) 2023-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 "games/controllers/ControllerTypes.h" |
| 12 |
#include "input/joysticks/interfaces/IInputHandler.h" |
| 13 |
#include "peripherals/PeripheralTypes.h" |
| 14 |
|
| 15 |
namespace KODI |
| 16 |
{ |
| 17 |
namespace GAME |
| 18 |
{ |
| 19 |
class CControllerActivity; |
| 20 |
|
| 21 |
/*! |
| 22 |
* \ingroup games |
| 23 |
* |
| 24 |
* \brief Handles game controller events for game agent functionality |
| 25 |
*/ |
| 26 |
class CAgentJoystick : public JOYSTICK::IInputHandler |
| 27 |
{ |
| 28 |
public: |
| 29 |
CAgentJoystick(PERIPHERALS::PeripheralPtr peripheral); |
| 30 |
|
| 31 |
~CAgentJoystick() override; |
| 32 |
|
| 33 |
void Initialize(); |
| 34 |
void Deinitialize(); |
| 35 |
void ClearButtonState(); |
| 36 |
|
| 37 |
// Input parameters |
| 38 |
float GetActivation() const; |
| 39 |
ControllerPtr Appearance() const { return m_controllerAppearance; } |
| 40 |
|
| 41 |
// Implementation of IJoystickHandler |
| 42 |
std::string ControllerID() const override; |
| 43 |
bool HasFeature(const std::string& feature) const override; |
| 44 |
bool AcceptsInput(const std::string& feature) const override; |
| 45 |
bool OnButtonPress(const std::string& feature, bool bPressed) override; |
| 46 |
void OnButtonHold(const std::string& feature, unsigned int holdTimeMs) override; |
| 47 |
bool OnButtonMotion(const std::string& feature, |
| 48 |
float magnitude, |
| 49 |
unsigned int motionTimeMs) override; |
| 50 |
bool OnAnalogStickMotion(const std::string& feature, |
| 51 |
float x, |
| 52 |
float y, |
| 53 |
unsigned int motionTimeMs) override; |
| 54 |
bool OnAccelerometerMotion(const std::string& feature, float x, float y, float z) override |
| 55 |
{ |
| 56 |
return false; |
| 57 |
} |
| 58 |
bool OnWheelMotion(const std::string& feature, |
| 59 |
float position, |
| 60 |
unsigned int motionTimeMs) override; |
| 61 |
bool OnThrottleMotion(const std::string& feature, |
| 62 |
float position, |
| 63 |
unsigned int motionTimeMs) override; |
| 64 |
void OnInputFrame() override; |
| 65 |
|
| 66 |
private: |
| 67 |
// Construction parameters |
| 68 |
const PERIPHERALS::PeripheralPtr m_peripheral; |
| 69 |
|
| 70 |
// Input state |
| 71 |
std::unique_ptr<CControllerActivity> m_controllerActivity; |
| 72 |
ControllerPtr m_controllerAppearance; |
| 73 |
}; |
| 74 |
} // namespace GAME |
| 75 |
} // namespace KODI |