OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | 5 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 case 0x05: | 103 case 0x05: |
104 // Modems: wired or voice gateway and common ISDN access. | 104 // Modems: wired or voice gateway and common ISDN access. |
105 return DEVICE_MODEM; | 105 return DEVICE_MODEM; |
106 } | 106 } |
107 break; | 107 break; |
108 case 0x05: | 108 case 0x05: |
109 // Peripheral major device class. | 109 // Peripheral major device class. |
110 switch ((bluetooth_class_ & 0xc0) >> 6) { | 110 switch ((bluetooth_class_ & 0xc0) >> 6) { |
111 case 0x00: | 111 case 0x00: |
112 // "Not a keyboard or pointing device." | 112 // "Not a keyboard or pointing device." |
113 return DEVICE_PERIPHERAL; | 113 switch ((bluetooth_class_ & 0x01e) >> 2) { |
| 114 case 0x01: |
| 115 // Joystick. |
| 116 return DEVICE_JOYSTICK; |
| 117 case 0x02: |
| 118 // Gamepad. |
| 119 return DEVICE_GAMEPAD; |
| 120 default: |
| 121 return DEVICE_PERIPHERAL; |
| 122 } |
| 123 break; |
114 case 0x01: | 124 case 0x01: |
115 // Keyboard. | 125 // Keyboard. |
116 return DEVICE_KEYBOARD; | 126 return DEVICE_KEYBOARD; |
117 case 0x02: | 127 case 0x02: |
118 // Pointing device. | 128 // Pointing device. |
119 switch ((bluetooth_class_ & 0x01e) >> 2) { | 129 switch ((bluetooth_class_ & 0x01e) >> 2) { |
120 case 0x05: | 130 case 0x05: |
121 // Digitizer tablet. | 131 // Digitizer tablet. |
122 return DEVICE_TABLET; | 132 return DEVICE_TABLET; |
123 default: | 133 default: |
124 // Mouse. | 134 // Mouse. |
125 return DEVICE_MOUSE; | 135 return DEVICE_MOUSE; |
126 } | 136 } |
127 break; | 137 break; |
128 case 0x03: | 138 case 0x03: |
129 // Combo device. | 139 // Combo device. |
130 return DEVICE_KEYBOARD_MOUSE_COMBO; | 140 return DEVICE_KEYBOARD_MOUSE_COMBO; |
131 } | 141 } |
132 break; | 142 break; |
133 } | 143 } |
134 | 144 |
135 return DEVICE_UNKNOWN; | 145 return DEVICE_UNKNOWN; |
136 } | 146 } |
137 | 147 |
138 bool BluetoothDevice::IsSupported() const { | 148 bool BluetoothDevice::IsSupported() const { |
139 DeviceType device_type = GetDeviceType(); | 149 DeviceType device_type = GetDeviceType(); |
140 return (device_type == DEVICE_KEYBOARD || | 150 return (device_type == DEVICE_JOYSTICK || |
| 151 device_type == DEVICE_GAMEPAD || |
| 152 device_type == DEVICE_KEYBOARD || |
141 device_type == DEVICE_MOUSE || | 153 device_type == DEVICE_MOUSE || |
142 device_type == DEVICE_TABLET || | 154 device_type == DEVICE_TABLET || |
143 device_type == DEVICE_KEYBOARD_MOUSE_COMBO); | 155 device_type == DEVICE_KEYBOARD_MOUSE_COMBO); |
144 } | 156 } |
145 | 157 |
146 string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const { | 158 string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const { |
147 string16 address = UTF8ToUTF16(address_); | 159 string16 address = UTF8ToUTF16(address_); |
148 DeviceType device_type = GetDeviceType(); | 160 DeviceType device_type = GetDeviceType(); |
149 switch (device_type) { | 161 switch (device_type) { |
150 case DEVICE_COMPUTER: | 162 case DEVICE_COMPUTER: |
151 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_COMPUTER, | 163 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_COMPUTER, |
152 address); | 164 address); |
153 case DEVICE_PHONE: | 165 case DEVICE_PHONE: |
154 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_PHONE, | 166 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_PHONE, |
155 address); | 167 address); |
156 case DEVICE_MODEM: | 168 case DEVICE_MODEM: |
157 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MODEM, | 169 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MODEM, |
158 address); | 170 address); |
| 171 case DEVICE_JOYSTICK: |
| 172 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_JOYSTICK, |
| 173 address); |
| 174 case DEVICE_GAMEPAD: |
| 175 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_GAMEPAD, |
| 176 address); |
159 case DEVICE_KEYBOARD: | 177 case DEVICE_KEYBOARD: |
160 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_KEYBOARD, | 178 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_KEYBOARD, |
161 address); | 179 address); |
162 case DEVICE_MOUSE: | 180 case DEVICE_MOUSE: |
163 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MOUSE, | 181 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MOUSE, |
164 address); | 182 address); |
165 case DEVICE_TABLET: | 183 case DEVICE_TABLET: |
166 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_TABLET, | 184 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_TABLET, |
167 address); | 185 address); |
168 case DEVICE_KEYBOARD_MOUSE_COMBO: | 186 case DEVICE_KEYBOARD_MOUSE_COMBO: |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // static | 644 // static |
627 BluetoothDevice* BluetoothDevice::CreateUnbound( | 645 BluetoothDevice* BluetoothDevice::CreateUnbound( |
628 BluetoothAdapter* adapter, | 646 BluetoothAdapter* adapter, |
629 const BluetoothDeviceClient::Properties* properties) { | 647 const BluetoothDeviceClient::Properties* properties) { |
630 BluetoothDevice* device = new BluetoothDevice(adapter); | 648 BluetoothDevice* device = new BluetoothDevice(adapter); |
631 device->Update(properties, false); | 649 device->Update(properties, false); |
632 return device; | 650 return device; |
633 } | 651 } |
634 | 652 |
635 } // namespace chromeos | 653 } // namespace chromeos |
OLD | NEW |