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 "content/browser/gamepad/gamepad_platform_data_fetcher_linux.h" | 5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <libudev.h> | 8 #include <libudev.h> |
9 #include <linux/joystick.h> | 9 #include <linux/joystick.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 // Append the vendor and product information then convert the utf-8 | 182 // Append the vendor and product information then convert the utf-8 |
183 // id string to WebUChar. | 183 // id string to WebUChar. |
184 std::string id = name_string + base::StringPrintf( | 184 std::string id = name_string + base::StringPrintf( |
185 " (%sVendor: %s Product: %s)", | 185 " (%sVendor: %s Product: %s)", |
186 mapper ? "STANDARD GAMEPAD " : "", | 186 mapper ? "STANDARD GAMEPAD " : "", |
187 vendor_id, | 187 vendor_id, |
188 product_id); | 188 product_id); |
189 TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id); | 189 base::TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id); |
190 base::string16 tmp16 = UTF8ToUTF16(id); | 190 base::string16 tmp16 = UTF8ToUTF16(id); |
191 memset(pad.id, 0, sizeof(pad.id)); | 191 memset(pad.id, 0, sizeof(pad.id)); |
192 tmp16.copy(pad.id, arraysize(pad.id) - 1); | 192 tmp16.copy(pad.id, arraysize(pad.id) - 1); |
193 | 193 |
194 pad.connected = true; | 194 pad.connected = true; |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 void GamepadPlatformDataFetcherLinux::EnumerateDevices() { | 198 void GamepadPlatformDataFetcherLinux::EnumerateDevices() { |
199 udev_enumerate* enumerate = udev_enumerate_new(udev_->udev_handle()); | 199 udev_enumerate* enumerate = udev_enumerate_new(udev_->udev_handle()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 continue; | 248 continue; |
249 pad.buttons[item] = event.value ? 1.0 : 0.0; | 249 pad.buttons[item] = event.value ? 1.0 : 0.0; |
250 if (item >= pad.buttonsLength) | 250 if (item >= pad.buttonsLength) |
251 pad.buttonsLength = item + 1; | 251 pad.buttonsLength = item + 1; |
252 } | 252 } |
253 pad.timestamp = event.time; | 253 pad.timestamp = event.time; |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
257 } // namespace content | 257 } // namespace content |
OLD | NEW |