summaryrefslogtreecommitdiffstats
path: root/xbmc/peripherals/bus/virtual/PeripheralBusApplication.cpp
blob: 4dad03c490d8b1924d5e2b88d3fa025019af5792 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 *  Copyright (C) 2015-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 "PeripheralBusApplication.h"

#include "ServiceBroker.h"
#include "guilib/LocalizeStrings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"

using namespace PERIPHERALS;

CPeripheralBusApplication::CPeripheralBusApplication(CPeripherals& manager)
  : CPeripheralBus("PeripBusApplication", manager, PERIPHERAL_BUS_APPLICATION)
{
  // Initialize CPeripheralBus
  m_bNeedsPolling = false;
}

void CPeripheralBusApplication::Initialise(void)
{
  CPeripheralBus::Initialise();
  TriggerDeviceScan();
}

bool CPeripheralBusApplication::PerformDeviceScan(PeripheralScanResults& results)
{
  {
    PeripheralScanResult result(Type());
    result.m_type = PERIPHERAL_KEYBOARD;
    result.m_strDeviceName = g_localizeStrings.Get(35150); // "Keyboard"
    result.m_strLocation = PeripheralTypeTranslator::TypeToString(PERIPHERAL_KEYBOARD);
    result.m_iVendorId = 0;
    result.m_iProductId = 0;
    result.m_mappedType = PERIPHERAL_KEYBOARD;
    result.m_mappedBusType = Type();
    result.m_iSequence = 0;

    if (!results.ContainsResult(result))
      results.m_results.push_back(result);
  }

  bool bHasMouse = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
      CSettings::SETTING_INPUT_ENABLEMOUSE);

  //! @todo Fix game clients to handle mouse disconnecting
  //! For now mouse is always connected
  bHasMouse = true;

  if (bHasMouse)
  {
    PeripheralScanResult result(Type());
    result.m_type = PERIPHERAL_MOUSE;
    result.m_strDeviceName = g_localizeStrings.Get(35171); // "Mouse"
    result.m_strLocation = PeripheralTypeTranslator::TypeToString(PERIPHERAL_MOUSE);
    result.m_iVendorId = 0;
    result.m_iProductId = 0;
    result.m_mappedType = PERIPHERAL_MOUSE;
    result.m_mappedBusType = Type();
    result.m_iSequence = 0;

    if (!results.ContainsResult(result))
      results.m_results.push_back(result);
  }

  return true;
}

void CPeripheralBusApplication::GetDirectory(const std::string& strPath, CFileItemList& items) const
{
  // Don't list virtual devices in the GUI
}

std::string CPeripheralBusApplication::MakeLocation(unsigned int controllerIndex) const
{
  return std::to_string(controllerIndex);
}