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.
5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_
8 #include "build/build_config.h"
10 #ifndef WIN32_LEAN_AND_MEAN
11 #define WIN32_LEAN_AND_MEAN
16 #include "base/basictypes.h"
17 #include "base/compiler_specific.h"
18 #include "base/scoped_native_library.h"
19 #include "content/browser/gamepad/gamepad_data_fetcher.h"
23 class GamepadPlatformDataFetcherWin
: public GamepadDataFetcher
{
25 GamepadPlatformDataFetcherWin();
26 virtual ~GamepadPlatformDataFetcherWin();
27 virtual void GetGamepadData(WebKit::WebGamepads
* pads
,
28 bool devices_changed_hint
) OVERRIDE
;
30 // The three function types we use from xinput1_3.dll.
31 typedef void (WINAPI
*XInputEnableFunc
)(BOOL enable
);
32 typedef DWORD (WINAPI
*XInputGetCapabilitiesFunc
)(
33 DWORD dwUserIndex
, DWORD dwFlags
, XINPUT_CAPABILITIES
* pCapabilities
);
34 typedef DWORD (WINAPI
*XInputGetStateFunc
)(
35 DWORD dwUserIndex
, XINPUT_STATE
* pState
);
37 // Get functions from dynamically loaded xinput1_3.dll. We don't use
38 // DELAYLOAD because the import library for Win8 SDK pulls xinput1_4 which
39 // isn't redistributable. Returns true if loading was successful. We include
40 // xinput1_3.dll with Chrome.
41 bool GetXinputDllFunctions();
43 base::ScopedNativeLibrary xinput_dll_
;
44 bool xinput_available_
;
46 // Function pointers to XInput functionality, retrieved in
47 // |GetXinputDllFunctions|.
48 XInputEnableFunc xinput_enable_
;
49 XInputGetCapabilitiesFunc xinput_get_capabilities_
;
50 XInputGetStateFunc xinput_get_state_
;
52 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin
);
55 } // namespace content
57 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_