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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
/*****************************************************************************
* This file is part of the BlueDevil project *
* *
* Copyright (C) 2010 Rafael Fernández López <ereslibre@kde.org> *
* Copyright (C) 2010 UFO Coders <info@ufocoders.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*****************************************************************************/
#include "bluedevilutils.h"
#include <QtCore/QString>
namespace BlueDevil {
quint32 stringToType(const QString &stringType)
{
if (stringType == "any") {
return BLUETOOTH_TYPE_ANY;
} else if (stringType == "mouse") {
return BLUETOOTH_TYPE_MOUSE;
} else if (stringType == "keyboard") {
return BLUETOOTH_TYPE_KEYBOARD;
} else if (stringType == "headset") {
return BLUETOOTH_TYPE_HEADSET;
} else if (stringType == "headphones") {
return BLUETOOTH_TYPE_HEADPHONES;
} else if (stringType == "audio") {
return BLUETOOTH_TYPE_OTHER_AUDIO;
} else if (stringType == "printer") {
return BLUETOOTH_TYPE_PRINTER;
} else if (stringType == "network") {
return BLUETOOTH_TYPE_NETWORK;
}
return BLUETOOTH_TYPE_ANY;
}
quint32 classToType(quint32 classNum)
{
switch ((classNum & 0x1f00) >> 8) {
case 0x01:
return BLUETOOTH_TYPE_COMPUTER;
case 0x02:
switch ((classNum & 0xfc) >> 2) {
case 0x01:
case 0x02:
case 0x03:
case 0x05:
return BLUETOOTH_TYPE_PHONE;
case 0x04:
return BLUETOOTH_TYPE_MODEM;
}
break;
case 0x03:
return BLUETOOTH_TYPE_NETWORK;
case 0x04:
switch ((classNum & 0xfc) >> 2) {
case 0x01:
case 0x02:
return BLUETOOTH_TYPE_HEADSET;
case 0x06:
return BLUETOOTH_TYPE_HEADPHONES;
default:
return BLUETOOTH_TYPE_OTHER_AUDIO;
}
break;
case 0x05:
switch ((classNum & 0xc0) >> 6) {
case 0x00:
switch ((classNum & 0x1e) >> 2) {
case 0x01:
case 0x02:
return BLUETOOTH_TYPE_JOYPAD;
}
break;
case 0x01:
return BLUETOOTH_TYPE_KEYBOARD;
case 0x02:
switch ((classNum & 0x1e) >> 2) {
case 0x05:
return BLUETOOTH_TYPE_TABLET;
default:
return BLUETOOTH_TYPE_MOUSE;
}
}
break;
case 0x06:
if (classNum & 0x80)
return BLUETOOTH_TYPE_PRINTER;
if (classNum & 0x20)
return BLUETOOTH_TYPE_CAMERA;
break;
}
return 0;
}
}
|