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

Side by Side Diff: content/browser/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
7
8 #include <memory>
9
10 #include "build/build_config.h"
11
12 #ifndef WIN32_LEAN_AND_MEAN
13 #define WIN32_LEAN_AND_MEAN
14 #endif
15 #include <stdlib.h>
16 #include <Unknwn.h>
17 #include <WinDef.h>
18 #include <windows.h>
19 #include <XInput.h>
20
21 #include "base/compiler_specific.h"
22 #include "base/macros.h"
23 #include "base/memory/weak_ptr.h"
24 #include "base/message_loop/message_loop.h"
25 #include "base/scoped_native_library.h"
26 #include "content/browser/gamepad/gamepad_data_fetcher.h"
27 #include "content/browser/gamepad/gamepad_standard_mappings.h"
28 #include "content/browser/gamepad/raw_input_data_fetcher_win.h"
29 #include "third_party/WebKit/public/platform/WebGamepads.h"
30
31 namespace content {
32
33 class GamepadPlatformDataFetcherWin : public GamepadDataFetcher {
34 public:
35 GamepadPlatformDataFetcherWin();
36 ~GamepadPlatformDataFetcherWin() override;
37 void GetGamepadData(blink::WebGamepads* pads,
38 bool devices_changed_hint) override;
39 void PauseHint(bool paused) override;
40
41 private:
42 // XInput-specific implementation for GetGamepadData.
43 bool GetXInputGamepadData(blink::WebGamepads* pads,
44 bool devices_changed_hint);
45
46 // The three function types we use from xinput1_3.dll.
47 typedef void (WINAPI *XInputEnableFunc)(BOOL enable);
48 typedef DWORD (WINAPI *XInputGetCapabilitiesFunc)(
49 DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities);
50 typedef DWORD (WINAPI *XInputGetStateFunc)(
51 DWORD dwUserIndex, XINPUT_STATE* pState);
52
53 // Get functions from dynamically loading the xinput dll.
54 // Returns true if loading was successful.
55 bool GetXInputDllFunctions();
56
57 // Scan for connected XInput and DirectInput gamepads.
58 void EnumerateDevices();
59 bool GetXInputPadConnectivity(int i, blink::WebGamepad* pad) const;
60
61 void GetXInputPadData(int i, blink::WebGamepad* pad);
62 void GetRawInputPadData(int i, blink::WebGamepad* pad);
63
64 int FirstAvailableGamepadId() const;
65 bool HasXInputGamepad(int index) const;
66 bool HasRawInputGamepad(const HANDLE handle) const;
67
68 base::ScopedNativeLibrary xinput_dll_;
69 bool xinput_available_;
70
71 // Function pointers to XInput functionality, retrieved in
72 // |GetXinputDllFunctions|.
73 XInputGetCapabilitiesFunc xinput_get_capabilities_;
74 XInputGetStateFunc xinput_get_state_;
75
76 enum PadConnectionStatus {
77 DISCONNECTED,
78 XINPUT_CONNECTED,
79 RAWINPUT_CONNECTED
80 };
81
82 struct PlatformPadState {
83 PadConnectionStatus status;
84
85 int xinput_index; // XInput-only
86 HANDLE raw_input_handle; // RawInput-only fields.
87 };
88 PlatformPadState platform_pad_state_[blink::WebGamepads::itemsLengthCap];
89
90 std::unique_ptr<RawInputDataFetcher> raw_input_fetcher_;
91
92 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin);
93 };
94
95 } // namespace content
96
97 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698