| 1 |
/* |
| 2 |
* Copyright (C) 2016-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 |
#include "DriverReceiving.h" |
| 10 |
|
| 11 |
#include "input/joysticks/DriverPrimitive.h" |
| 12 |
#include "input/joysticks/interfaces/IButtonMap.h" |
| 13 |
#include "input/joysticks/interfaces/IDriverReceiver.h" |
| 14 |
|
| 15 |
using namespace KODI; |
| 16 |
using namespace JOYSTICK; |
| 17 |
|
| 18 |
CDriverReceiving::CDriverReceiving(IDriverReceiver* receiver, IButtonMap* buttonMap) |
| 19 |
: m_receiver(receiver), m_buttonMap(buttonMap) |
| 20 |
{ |
| 21 |
} |
| 22 |
|
| 23 |
bool CDriverReceiving::SetRumbleState(const FeatureName& feature, float magnitude) |
| 24 |
{ |
| 25 |
bool bHandled = false; |
| 26 |
|
| 27 |
if (m_receiver != nullptr && m_buttonMap != nullptr) |
| 28 |
{ |
| 29 |
CDriverPrimitive primitive; |
| 30 |
if (m_buttonMap->GetScalar(feature, primitive)) |
| 31 |
{ |
| 32 |
if (primitive.Type() == PRIMITIVE_TYPE::MOTOR) |
| 33 |
bHandled = m_receiver->SetMotorState(primitive.Index(), magnitude); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
return bHandled; |
| 38 |
} |