3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
25 #include "PlatformDefs.h"
27 #include "utils/StdString.h"
33 enum PeripheralBusType
35 PERIPHERAL_BUS_UNKNOWN = 0,
41 enum PeripheralFeature
56 PERIPHERAL_UNKNOWN = 0,
73 struct PeripheralDeviceMapping
75 std::vector<PeripheralID> m_PeripheralID;
76 PeripheralBusType m_busType;
77 PeripheralType m_class;
78 CStdString m_strDeviceName;
79 PeripheralType m_mappedTo;
80 std::map<CStdString, CSetting *> m_settings;
83 class PeripheralTypeTranslator
86 static const char *TypeToString(const PeripheralType type)
90 case PERIPHERAL_BLUETOOTH:
100 case PERIPHERAL_NYXBOARD:
102 case PERIPHERAL_TUNER:
104 case PERIPHERAL_IMON:
111 static PeripheralType GetTypeFromString(const CStdString &strType)
113 CStdString strTypeLowerCase(strType);
114 strTypeLowerCase.ToLower();
116 if (strTypeLowerCase.Equals("bluetooth"))
117 return PERIPHERAL_BLUETOOTH;
118 else if (strTypeLowerCase.Equals("cec"))
119 return PERIPHERAL_CEC;
120 else if (strTypeLowerCase.Equals("disk"))
121 return PERIPHERAL_DISK;
122 else if (strTypeLowerCase.Equals("hid"))
123 return PERIPHERAL_HID;
124 else if (strTypeLowerCase.Equals("nic"))
125 return PERIPHERAL_NIC;
126 else if (strTypeLowerCase.Equals("nyxboard"))
127 return PERIPHERAL_NYXBOARD;
128 else if (strTypeLowerCase.Equals("tuner"))
129 return PERIPHERAL_TUNER;
130 else if (strTypeLowerCase.Equals("imon"))
131 return PERIPHERAL_IMON;
133 return PERIPHERAL_UNKNOWN;
136 static const char *BusTypeToString(const PeripheralBusType type)
140 case PERIPHERAL_BUS_USB:
142 case PERIPHERAL_BUS_PCI:
144 case PERIPHERAL_BUS_RPI:
151 static PeripheralBusType GetBusTypeFromString(const CStdString &strType)
153 CStdString strTypeLowerCase(strType);
154 strTypeLowerCase.ToLower();
156 if (strTypeLowerCase.Equals("usb"))
157 return PERIPHERAL_BUS_USB;
158 else if (strTypeLowerCase.Equals("pci"))
159 return PERIPHERAL_BUS_PCI;
160 else if (strTypeLowerCase.Equals("rpi"))
161 return PERIPHERAL_BUS_RPI;
163 return PERIPHERAL_BUS_UNKNOWN;
166 static int HexStringToInt(const char *strHex)
169 sscanf(strHex, "%x", &iVal);
173 static void FormatHexString(int iVal, CStdString &strHexString)
180 strHexString.Format("%04X", iVal);