| 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 |
#include "PeripheralBusApplication.h" |
| 10 |
|
| 11 |
#include "ServiceBroker.h" |
| 12 |
#include "guilib/LocalizeStrings.h" |
| 13 |
#include "settings/Settings.h" |
| 14 |
#include "settings/SettingsComponent.h" |
| 15 |
#include "utils/StringUtils.h" |
| 16 |
|
| 17 |
using namespace PERIPHERALS; |
| 18 |
|
| 19 |
CPeripheralBusApplication::CPeripheralBusApplication(CPeripherals& manager) |
| 20 |
: CPeripheralBus("PeripBusApplication", manager, PERIPHERAL_BUS_APPLICATION) |
| 21 |
{ |
| 22 |
// Initialize CPeripheralBus |
| 23 |
m_bNeedsPolling = false; |
| 24 |
} |
| 25 |
|
| 26 |
void CPeripheralBusApplication::Initialise(void) |
| 27 |
{ |
| 28 |
CPeripheralBus::Initialise(); |
| 29 |
TriggerDeviceScan(); |
| 30 |
} |
| 31 |
|
| 32 |
bool CPeripheralBusApplication::PerformDeviceScan(PeripheralScanResults& results) |
| 33 |
{ |
| 34 |
{ |
| 35 |
PeripheralScanResult result(Type()); |
| 36 |
result.m_type = PERIPHERAL_KEYBOARD; |
| 37 |
result.m_strDeviceName = g_localizeStrings.Get(35150); // "Keyboard" |
| 38 |
result.m_strLocation = PeripheralTypeTranslator::TypeToString(PERIPHERAL_KEYBOARD); |
| 39 |
result.m_iVendorId = 0; |
| 40 |
result.m_iProductId = 0; |
| 41 |
result.m_mappedType = PERIPHERAL_KEYBOARD; |
| 42 |
result.m_mappedBusType = Type(); |
| 43 |
result.m_iSequence = 0; |
| 44 |
|
| 45 |
if (!results.ContainsResult(result)) |
| 46 |
results.m_results.push_back(result); |
| 47 |
} |
| 48 |
|
| 49 |
bool bHasMouse = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( |
| 50 |
CSettings::SETTING_INPUT_ENABLEMOUSE); |
| 51 |
|
| 52 |
//! @todo Fix game clients to handle mouse disconnecting |
| 53 |
//! For now mouse is always connected |
| 54 |
bHasMouse = true; |
| 55 |
|
| 56 |
if (bHasMouse) |
| 57 |
{ |
| 58 |
PeripheralScanResult result(Type()); |
| 59 |
result.m_type = PERIPHERAL_MOUSE; |
| 60 |
result.m_strDeviceName = g_localizeStrings.Get(35171); // "Mouse" |
| 61 |
result.m_strLocation = PeripheralTypeTranslator::TypeToString(PERIPHERAL_MOUSE); |
| 62 |
result.m_iVendorId = 0; |
| 63 |
result.m_iProductId = 0; |
| 64 |
result.m_mappedType = PERIPHERAL_MOUSE; |
| 65 |
result.m_mappedBusType = Type(); |
| 66 |
result.m_iSequence = 0; |
| 67 |
|
| 68 |
if (!results.ContainsResult(result)) |
| 69 |
results.m_results.push_back(result); |
| 70 |
} |
| 71 |
|
| 72 |
return true; |
| 73 |
} |
| 74 |
|
| 75 |
void CPeripheralBusApplication::GetDirectory(const std::string& strPath, CFileItemList& items) const |
| 76 |
{ |
| 77 |
// Don't list virtual devices in the GUI |
| 78 |
} |
| 79 |
|
| 80 |
std::string CPeripheralBusApplication::MakeLocation(unsigned int controllerIndex) const |
| 81 |
{ |
| 82 |
return std::to_string(controllerIndex); |
| 83 |
} |