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/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 return (2.f * (value - min) / static_cast<float>(max - min)) - 1.f; | 34 return (2.f * (value - min) / static_cast<float>(max - min)) - 1.f; |
35 } | 35 } |
36 | 36 |
37 // http://www.usb.org/developers/hidpage | 37 // http://www.usb.org/developers/hidpage |
38 const uint32_t kGenericDesktopUsagePage = 0x01; | 38 const uint32_t kGenericDesktopUsagePage = 0x01; |
39 const uint32_t kButtonUsagePage = 0x09; | 39 const uint32_t kButtonUsagePage = 0x09; |
40 const uint32_t kJoystickUsageNumber = 0x04; | 40 const uint32_t kJoystickUsageNumber = 0x04; |
41 const uint32_t kGameUsageNumber = 0x05; | 41 const uint32_t kGameUsageNumber = 0x05; |
42 const uint32_t kMultiAxisUsageNumber = 0x08; | 42 const uint32_t kMultiAxisUsageNumber = 0x08; |
43 const uint32_t kAxisMinimumUsageNumber = 0x30; | 43 const uint32_t kAxisMinimumUsageNumber = 0x30; |
44 const uint32_t kAxisMaximumUsageNumber = 0x35; | |
45 | 44 |
46 } // namespace | 45 } // namespace |
47 | 46 |
48 GamepadPlatformDataFetcherMac::GamepadPlatformDataFetcherMac() | 47 GamepadPlatformDataFetcherMac::GamepadPlatformDataFetcherMac() |
49 : enabled_(true) { | 48 : enabled_(true) { |
50 memset(associated_, 0, sizeof(associated_)); | 49 memset(associated_, 0, sizeof(associated_)); |
51 | 50 |
52 xbox_fetcher_.reset(new XboxDataFetcher(this)); | 51 xbox_fetcher_.reset(new XboxDataFetcher(this)); |
53 if (!xbox_fetcher_->RegisterForNotifications()) | 52 if (!xbox_fetcher_->RegisterForNotifications()) |
54 xbox_fetcher_.reset(); | 53 xbox_fetcher_.reset(); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 pads->length = WebGamepads::itemsLengthCap; | 431 pads->length = WebGamepads::itemsLengthCap; |
433 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 432 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
434 if (!associated_[i].is_xbox && associated_[i].hid.mapper) | 433 if (!associated_[i].is_xbox && associated_[i].hid.mapper) |
435 associated_[i].hid.mapper(data_.items[i], &pads->items[i]); | 434 associated_[i].hid.mapper(data_.items[i], &pads->items[i]); |
436 else | 435 else |
437 pads->items[i] = data_.items[i]; | 436 pads->items[i] = data_.items[i]; |
438 } | 437 } |
439 } | 438 } |
440 | 439 |
441 } // namespace content | 440 } // namespace content |
OLD | NEW |