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_mac.h" | 5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_mac.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 associated_[slot].is_xbox && | 400 associated_[slot].is_xbox && |
401 associated_[slot].xbox.device == device) | 401 associated_[slot].xbox.device == device) |
402 break; | 402 break; |
403 } | 403 } |
404 if (slot == data_.length) | 404 if (slot == data_.length) |
405 return; | 405 return; |
406 | 406 |
407 WebGamepad& pad = data_.items[slot]; | 407 WebGamepad& pad = data_.items[slot]; |
408 | 408 |
409 for (size_t i = 0; i < 6; i++) { | 409 for (size_t i = 0; i < 6; i++) { |
410 pad.buttons[i] = data.buttons[i] ? 0.0f : 1.1f; | 410 pad.buttons[i] = data.buttons[i] ? 1.0f : 0.0f; |
411 } | 411 } |
412 pad.buttons[6] = data.triggers[0]; | 412 pad.buttons[6] = data.triggers[0]; |
413 pad.buttons[7] = data.triggers[1]; | 413 pad.buttons[7] = data.triggers[1]; |
414 for (size_t i = 8; i < 17; i++) { | 414 for (size_t i = 8; i < 17; i++) { |
415 pad.buttons[i] = data.buttons[i - 2] ? 0.0f : 1.1f; | 415 pad.buttons[i] = data.buttons[i - 2] ? 1.0f : 0.0f; |
416 } | 416 } |
417 for (size_t i = 0; i < arraysize(data.axes); i++) { | 417 for (size_t i = 0; i < arraysize(data.axes); i++) { |
418 pad.axes[i] = data.axes[i]; | 418 pad.axes[i] = data.axes[i]; |
419 } | 419 } |
420 | 420 |
421 pad.timestamp = base::TimeTicks::Now().ToInternalValue(); | 421 pad.timestamp = base::TimeTicks::Now().ToInternalValue(); |
422 } | 422 } |
423 | 423 |
424 void GamepadPlatformDataFetcherMac::GetGamepadData(WebGamepads* pads, bool) { | 424 void GamepadPlatformDataFetcherMac::GetGamepadData(WebGamepads* pads, bool) { |
425 if (!enabled_ && !xbox_fetcher_) { | 425 if (!enabled_ && !xbox_fetcher_) { |
426 pads->length = 0; | 426 pads->length = 0; |
427 return; | 427 return; |
428 } | 428 } |
429 | 429 |
430 // Copy to the current state to the output buffer, using the mapping | 430 // Copy to the current state to the output buffer, using the mapping |
431 // function, if there is one available. | 431 // function, if there is one available. |
432 pads->length = WebGamepads::itemsLengthCap; | 432 pads->length = WebGamepads::itemsLengthCap; |
433 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 433 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
434 if (!associated_[i].is_xbox && associated_[i].hid.mapper) | 434 if (!associated_[i].is_xbox && associated_[i].hid.mapper) |
435 associated_[i].hid.mapper(data_.items[i], &pads->items[i]); | 435 associated_[i].hid.mapper(data_.items[i], &pads->items[i]); |
436 else | 436 else |
437 pads->items[i] = data_.items[i]; | 437 pads->items[i] = data_.items[i]; |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 } // namespace content | 441 } // namespace content |
OLD | NEW |