| 1 |
/* |
| 2 |
* Copyright (C) 2015-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/IInputHandler.h" |
| 12 |
|
| 13 |
namespace KODI |
| 14 |
{ |
| 15 |
namespace JOYSTICK |
| 16 |
{ |
| 17 |
/*! |
| 18 |
* \ingroup joystick |
| 19 |
* |
| 20 |
* \brief Monitors joystick input and resets screensaver/shutdown timers |
| 21 |
* whenever motion occurs. |
| 22 |
*/ |
| 23 |
class CJoystickMonitor : public IInputHandler |
| 24 |
{ |
| 25 |
public: |
| 26 |
// implementation of IInputHandler |
| 27 |
std::string ControllerID() const override; |
| 28 |
bool HasFeature(const FeatureName& feature) const override { return true; } |
| 29 |
bool AcceptsInput(const FeatureName& feature) const override; |
| 30 |
bool OnButtonPress(const FeatureName& feature, bool bPressed) override; |
| 31 |
void OnButtonHold(const FeatureName& feature, unsigned int holdTimeMs) override {} |
| 32 |
bool OnButtonMotion(const FeatureName& feature, |
| 33 |
float magnitude, |
| 34 |
unsigned int motionTimeMs) override; |
| 35 |
bool OnAnalogStickMotion(const FeatureName& feature, |
| 36 |
float x, |
| 37 |
float y, |
| 38 |
unsigned int motionTimeMs) override; |
| 39 |
bool OnAccelerometerMotion(const FeatureName& feature, float x, float y, float z) override |
| 40 |
{ |
| 41 |
return false; |
| 42 |
} |
| 43 |
bool OnWheelMotion(const FeatureName& feature, |
| 44 |
float position, |
| 45 |
unsigned int motionTimeMs) override; |
| 46 |
bool OnThrottleMotion(const FeatureName& feature, |
| 47 |
float position, |
| 48 |
unsigned int motionTimeMs) override; |
| 49 |
void OnInputFrame() override {} |
| 50 |
|
| 51 |
private: |
| 52 |
/*! |
| 53 |
* \brief Reset screensaver and shutdown timers |
| 54 |
* \return True if the application was woken from screensaver |
| 55 |
*/ |
| 56 |
bool ResetTimers(void); |
| 57 |
}; |
| 58 |
} // namespace JOYSTICK |
| 59 |
} // namespace KODI |