Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: device/gamepad/gamepad_platform_data_fetcher_win.h

Issue 2081583002: Migrating majority of gamepad from content/browser/ to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final tweaks Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ 6 #define DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 11
12 #ifndef WIN32_LEAN_AND_MEAN 12 #ifndef WIN32_LEAN_AND_MEAN
13 #define WIN32_LEAN_AND_MEAN 13 #define WIN32_LEAN_AND_MEAN
14 #endif 14 #endif
15 #include <stdlib.h>
16 #include <Unknwn.h> 15 #include <Unknwn.h>
17 #include <WinDef.h> 16 #include <WinDef.h>
17 #include <XInput.h>
18 #include <stdlib.h>
18 #include <windows.h> 19 #include <windows.h>
19 #include <XInput.h>
20 20
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
24 #include "base/message_loop/message_loop.h" 24 #include "base/message_loop/message_loop.h"
25 #include "base/scoped_native_library.h" 25 #include "base/scoped_native_library.h"
26 #include "content/browser/gamepad/gamepad_data_fetcher.h" 26 #include "device/gamepad/gamepad_data_fetcher.h"
27 #include "content/browser/gamepad/gamepad_standard_mappings.h" 27 #include "device/gamepad/gamepad_standard_mappings.h"
28 #include "content/browser/gamepad/raw_input_data_fetcher_win.h" 28 #include "device/gamepad/raw_input_data_fetcher_win.h"
29 #include "third_party/WebKit/public/platform/WebGamepads.h" 29 #include "third_party/WebKit/public/platform/WebGamepads.h"
30 30
31 namespace content { 31 namespace device {
32 32
33 class GamepadPlatformDataFetcherWin : public GamepadDataFetcher { 33 class GamepadPlatformDataFetcherWin : public GamepadDataFetcher {
34 public: 34 public:
35 GamepadPlatformDataFetcherWin(); 35 GamepadPlatformDataFetcherWin();
36 ~GamepadPlatformDataFetcherWin() override; 36 ~GamepadPlatformDataFetcherWin() override;
37 void GetGamepadData(blink::WebGamepads* pads, 37 void GetGamepadData(blink::WebGamepads* pads,
38 bool devices_changed_hint) override; 38 bool devices_changed_hint) override;
39 void PauseHint(bool paused) override; 39 void PauseHint(bool paused) override;
40 40
41 private: 41 private:
42 // XInput-specific implementation for GetGamepadData. 42 // XInput-specific implementation for GetGamepadData.
43 bool GetXInputGamepadData(blink::WebGamepads* pads, 43 bool GetXInputGamepadData(blink::WebGamepads* pads,
44 bool devices_changed_hint); 44 bool devices_changed_hint);
45 45
46 // The three function types we use from xinput1_3.dll. 46 // The three function types we use from xinput1_3.dll.
47 typedef void (WINAPI *XInputEnableFunc)(BOOL enable); 47 typedef void(WINAPI* XInputEnableFunc)(BOOL enable);
48 typedef DWORD (WINAPI *XInputGetCapabilitiesFunc)( 48 typedef DWORD(WINAPI* XInputGetCapabilitiesFunc)(
49 DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities); 49 DWORD dwUserIndex,
50 typedef DWORD (WINAPI *XInputGetStateFunc)( 50 DWORD dwFlags,
51 DWORD dwUserIndex, XINPUT_STATE* pState); 51 XINPUT_CAPABILITIES* pCapabilities);
52 typedef DWORD(WINAPI* XInputGetStateFunc)(DWORD dwUserIndex,
53 XINPUT_STATE* pState);
52 54
53 // Get functions from dynamically loading the xinput dll. 55 // Get functions from dynamically loading the xinput dll.
54 // Returns true if loading was successful. 56 // Returns true if loading was successful.
55 bool GetXInputDllFunctions(); 57 bool GetXInputDllFunctions();
56 58
57 // Scan for connected XInput and DirectInput gamepads. 59 // Scan for connected XInput and DirectInput gamepads.
58 void EnumerateDevices(); 60 void EnumerateDevices();
59 bool GetXInputPadConnectivity(int i, blink::WebGamepad* pad) const; 61 bool GetXInputPadConnectivity(int i, blink::WebGamepad* pad) const;
60 62
61 void GetXInputPadData(int i, blink::WebGamepad* pad); 63 void GetXInputPadData(int i, blink::WebGamepad* pad);
(...skipping 13 matching lines...) Expand all
75 77
76 enum PadConnectionStatus { 78 enum PadConnectionStatus {
77 DISCONNECTED, 79 DISCONNECTED,
78 XINPUT_CONNECTED, 80 XINPUT_CONNECTED,
79 RAWINPUT_CONNECTED 81 RAWINPUT_CONNECTED
80 }; 82 };
81 83
82 struct PlatformPadState { 84 struct PlatformPadState {
83 PadConnectionStatus status; 85 PadConnectionStatus status;
84 86
85 int xinput_index; // XInput-only 87 int xinput_index; // XInput-only
86 HANDLE raw_input_handle; // RawInput-only fields. 88 HANDLE raw_input_handle; // RawInput-only fields.
87 }; 89 };
88 PlatformPadState platform_pad_state_[blink::WebGamepads::itemsLengthCap]; 90 PlatformPadState platform_pad_state_[blink::WebGamepads::itemsLengthCap];
89 91
90 std::unique_ptr<RawInputDataFetcher> raw_input_fetcher_; 92 std::unique_ptr<RawInputDataFetcher> raw_input_fetcher_;
91 93
92 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin); 94 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin);
93 }; 95 };
94 96
95 } // namespace content 97 } // namespace device
96 98
97 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ 99 #endif // DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
OLDNEW
« no previous file with comments | « device/gamepad/gamepad_platform_data_fetcher_mac.mm ('k') | device/gamepad/gamepad_platform_data_fetcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698