summaryrefslogtreecommitdiffstats
path: root/xbmc/input/joysticks/generic/DriverReceiving.cpp
blob: bf52f4ffa40b33ad11c3e12bf511814e529f5ff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 *  Copyright (C) 2016-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "DriverReceiving.h"

#include "input/joysticks/DriverPrimitive.h"
#include "input/joysticks/interfaces/IButtonMap.h"
#include "input/joysticks/interfaces/IDriverReceiver.h"

using namespace KODI;
using namespace JOYSTICK;

CDriverReceiving::CDriverReceiving(IDriverReceiver* receiver, IButtonMap* buttonMap)
  : m_receiver(receiver), m_buttonMap(buttonMap)
{
}

bool CDriverReceiving::SetRumbleState(const FeatureName& feature, float magnitude)
{
  bool bHandled = false;

  if (m_receiver != nullptr && m_buttonMap != nullptr)
  {
    CDriverPrimitive primitive;
    if (m_buttonMap->GetScalar(feature, primitive))
    {
      if (primitive.Type() == PRIMITIVE_TYPE::MOTOR)
        bHandled = m_receiver->SetMotorState(primitive.Index(), magnitude);
    }
  }

  return bHandled;
}