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 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ | 5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ |
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ | 6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #ifndef WIN32_LEAN_AND_MEAN | 10 #ifndef WIN32_LEAN_AND_MEAN |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/browser/gamepad/gamepad_data_fetcher.h" | 24 #include "content/browser/gamepad/gamepad_data_fetcher.h" |
25 #include "content/browser/gamepad/gamepad_standard_mappings.h" | 25 #include "content/browser/gamepad/gamepad_standard_mappings.h" |
26 #include "third_party/WebKit/public/platform/WebGamepads.h" | 26 #include "third_party/WebKit/public/platform/WebGamepads.h" |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 class GamepadPlatformDataFetcherWin : public GamepadDataFetcher { | 30 class GamepadPlatformDataFetcherWin : public GamepadDataFetcher { |
31 public: | 31 public: |
32 GamepadPlatformDataFetcherWin(); | 32 GamepadPlatformDataFetcherWin(); |
33 virtual ~GamepadPlatformDataFetcherWin(); | 33 virtual ~GamepadPlatformDataFetcherWin(); |
34 virtual void GetGamepadData(WebKit::WebGamepads* pads, | 34 virtual void GetGamepadData(blink::WebGamepads* pads, |
35 bool devices_changed_hint) OVERRIDE; | 35 bool devices_changed_hint) OVERRIDE; |
36 private: | 36 private: |
37 // XInput-specific implementation for GetGamepadData. | 37 // XInput-specific implementation for GetGamepadData. |
38 bool GetXInputGamepadData(WebKit::WebGamepads* pads, | 38 bool GetXInputGamepadData(blink::WebGamepads* pads, |
39 bool devices_changed_hint); | 39 bool devices_changed_hint); |
40 bool GetDirectInputGamepadData(WebKit::WebGamepads* pads, | 40 bool GetDirectInputGamepadData(blink::WebGamepads* pads, |
41 bool devices_changed_hint); | 41 bool devices_changed_hint); |
42 | 42 |
43 // The three function types we use from xinput1_3.dll. | 43 // The three function types we use from xinput1_3.dll. |
44 typedef void (WINAPI *XInputEnableFunc)(BOOL enable); | 44 typedef void (WINAPI *XInputEnableFunc)(BOOL enable); |
45 typedef DWORD (WINAPI *XInputGetCapabilitiesFunc)( | 45 typedef DWORD (WINAPI *XInputGetCapabilitiesFunc)( |
46 DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities); | 46 DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities); |
47 typedef DWORD (WINAPI *XInputGetStateFunc)( | 47 typedef DWORD (WINAPI *XInputGetStateFunc)( |
48 DWORD dwUserIndex, XINPUT_STATE* pState); | 48 DWORD dwUserIndex, XINPUT_STATE* pState); |
49 | 49 |
50 // Get functions from dynamically loaded xinput1_3.dll. We don't use | 50 // Get functions from dynamically loaded xinput1_3.dll. We don't use |
51 // DELAYLOAD because the import library for Win8 SDK pulls xinput1_4 which | 51 // DELAYLOAD because the import library for Win8 SDK pulls xinput1_4 which |
52 // isn't redistributable. Returns true if loading was successful. We include | 52 // isn't redistributable. Returns true if loading was successful. We include |
53 // xinput1_3.dll with Chrome. | 53 // xinput1_3.dll with Chrome. |
54 bool GetXInputDllFunctions(); | 54 bool GetXInputDllFunctions(); |
55 | 55 |
56 // Scan for connected XInput and DirectInput gamepads. | 56 // Scan for connected XInput and DirectInput gamepads. |
57 void EnumerateDevices(WebKit::WebGamepads* pads); | 57 void EnumerateDevices(blink::WebGamepads* pads); |
58 bool GetXInputPadConnectivity(int i, WebKit::WebGamepad* pad) const; | 58 bool GetXInputPadConnectivity(int i, blink::WebGamepad* pad) const; |
59 | 59 |
60 void GetXInputPadData(int i, WebKit::WebGamepad* pad); | 60 void GetXInputPadData(int i, blink::WebGamepad* pad); |
61 void GetDirectInputPadData(int i, WebKit::WebGamepad* pad); | 61 void GetDirectInputPadData(int i, blink::WebGamepad* pad); |
62 | 62 |
63 int FirstAvailableGamepadId() const; | 63 int FirstAvailableGamepadId() const; |
64 bool HasXInputGamepad(int index) const; | 64 bool HasXInputGamepad(int index) const; |
65 bool HasDirectInputGamepad(const GUID &guid) const; | 65 bool HasDirectInputGamepad(const GUID &guid) const; |
66 | 66 |
67 base::ScopedNativeLibrary xinput_dll_; | 67 base::ScopedNativeLibrary xinput_dll_; |
68 bool xinput_available_; | 68 bool xinput_available_; |
69 bool directinput_available_; | 69 bool directinput_available_; |
70 | 70 |
71 // Function pointers to XInput functionality, retrieved in | 71 // Function pointers to XInput functionality, retrieved in |
(...skipping 11 matching lines...) Expand all Loading... |
83 }; | 83 }; |
84 | 84 |
85 struct PadState { | 85 struct PadState { |
86 PadConnectionStatus status; | 86 PadConnectionStatus status; |
87 int xinput_index; // XInput-only. | 87 int xinput_index; // XInput-only. |
88 // Fields below are for DirectInput devices only. | 88 // Fields below are for DirectInput devices only. |
89 GUID guid; | 89 GUID guid; |
90 IDirectInputDevice8* directinput_gamepad; | 90 IDirectInputDevice8* directinput_gamepad; |
91 GamepadStandardMappingFunction mapper; | 91 GamepadStandardMappingFunction mapper; |
92 }; | 92 }; |
93 PadState pad_state_[WebKit::WebGamepads::itemsLengthCap]; | 93 PadState pad_state_[blink::WebGamepads::itemsLengthCap]; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin); | 95 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin); |
96 }; | 96 }; |
97 | 97 |
98 } // namespace content | 98 } // namespace content |
99 | 99 |
100 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ | 100 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ |
OLD | NEW |