OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_DATA_FETCHER_H_ | |
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_DATA_FETCHER_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "build/build_config.h" | |
11 #include "content/browser/gamepad/gamepad_standard_mappings.h" | |
12 #include "third_party/WebKit/public/platform/WebGamepads.h" | |
13 | |
14 namespace content { | |
15 | |
16 // Abstract interface for imlementing platform- (and test-) specific behaviro | |
17 // for getting the gamepad data. | |
18 class GamepadDataFetcher { | |
19 public: | |
20 virtual ~GamepadDataFetcher() {} | |
21 virtual void GetGamepadData(blink::WebGamepads* pads, | |
22 bool devices_changed_hint) = 0; | |
23 virtual void PauseHint(bool paused) {} | |
24 | |
25 #if !defined(OS_ANDROID) | |
26 struct PadState { | |
27 // Gamepad data, unmapped. | |
28 blink::WebGamepad data; | |
29 | |
30 // Functions to map from device data to standard layout, if available. May | |
31 // be null if no mapping is available. | |
32 GamepadStandardMappingFunction mapper; | |
33 | |
34 // Sanitization masks | |
35 // axis_mask and button_mask are bitfields that represent the reset state of | |
36 // each input. If a button or axis has ever reported 0 in the past the | |
37 // corresponding bit will be set to 1. | |
38 | |
39 // If we ever increase the max axis count this will need to be updated. | |
40 static_assert(blink::WebGamepad::axesLengthCap <= | |
41 std::numeric_limits<uint32_t>::digits, | |
42 "axis_mask is not large enough"); | |
43 uint32_t axis_mask; | |
44 | |
45 // If we ever increase the max button count this will need to be updated. | |
46 static_assert(blink::WebGamepad::buttonsLengthCap <= | |
47 std::numeric_limits<uint32_t>::digits, | |
48 "button_mask is not large enough"); | |
49 uint32_t button_mask; | |
50 }; | |
51 | |
52 void MapAndSanitizeGamepadData(PadState* pad_state, blink::WebGamepad* pad); | |
53 | |
54 protected: | |
55 PadState pad_state_[blink::WebGamepads::itemsLengthCap]; | |
56 #endif | |
57 }; | |
58 | |
59 } // namespace content | |
60 | |
61 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_DATA_FETCHER_H_ | |
OLD | NEW |