Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 0f31e18

Browse files
author
Raphael Kubo da Costa
committed
Merge pull request #313 from astojilj/gamepad
XWALK-4992 [windows] App does not support gamepad
2 parents dce3262 + b34d261 commit 0f31e18

File tree

6 files changed

+23
-42
lines changed

6 files changed

+23
-42
lines changed

chrome/installer/mini_installer/chrome.release

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ natives_blob.bin: %(VersionDir)s\
3939
resources.pak: %(VersionDir)s\
4040
snapshot_blob.bin: %(VersionDir)s\
4141
syzyasan_rtl.dll: %(VersionDir)s\
42-
xinput1_3.dll: %(VersionDir)s\
4342
#
4443
# Sub directories living in the version dir
4544
#

chrome/tools/build/win/FILES.cfg

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,6 @@ FILES = [
382382
'buildtype': ['dev', 'official'],
383383
'filegroup': ['default', 'symsrc'],
384384
},
385-
# XInput files:
386-
{
387-
'filename': 'xinput1_3.dll',
388-
'buildtype': ['dev', 'official'],
389-
},
390385
# Native Client plugin files:
391386
{
392387
'filename': 'nacl_irt_x86_32.nexe',

content/browser/gamepad/gamepad_platform_data_fetcher_win.cc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,22 @@ const WebUChar* const GamepadSubTypeName(BYTE sub_type) {
5050
}
5151
}
5252

53+
const WebUChar* XInputDllFileName() {
54+
// Xinput.h defines filenames on different versions.
55+
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
56+
return FILE_PATH_LITERAL("xinput1_4.dll");
57+
} else if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
58+
return FILE_PATH_LITERAL("xinput9_1_0.dll");
59+
} else {
60+
// Vista and before use DirectX redistributable.
61+
return FILE_PATH_LITERAL("xinput1_3.dll");
62+
}
63+
}
64+
5365
} // namespace
5466

5567
GamepadPlatformDataFetcherWin::GamepadPlatformDataFetcherWin()
56-
: xinput_dll_(base::FilePath(FILE_PATH_LITERAL("xinput1_3.dll"))),
68+
: xinput_dll_(base::FilePath(XInputDllFileName())),
5769
xinput_available_(GetXInputDllFunctions()) {
5870
for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) {
5971
platform_pad_state_[i].status = DISCONNECTED;
@@ -314,10 +326,8 @@ void GamepadPlatformDataFetcherWin::GetRawInputPadData(
314326
bool GamepadPlatformDataFetcherWin::GetXInputDllFunctions() {
315327
xinput_get_capabilities_ = NULL;
316328
xinput_get_state_ = NULL;
317-
xinput_enable_ = reinterpret_cast<XInputEnableFunc>(
329+
XInputEnableFunc xinput_enable = reinterpret_cast<XInputEnableFunc>(
318330
xinput_dll_.GetFunctionPointer("XInputEnable"));
319-
if (!xinput_enable_)
320-
return false;
321331
xinput_get_capabilities_ = reinterpret_cast<XInputGetCapabilitiesFunc>(
322332
xinput_dll_.GetFunctionPointer("XInputGetCapabilities"));
323333
if (!xinput_get_capabilities_)
@@ -326,7 +336,10 @@ bool GamepadPlatformDataFetcherWin::GetXInputDllFunctions() {
326336
xinput_dll_.GetFunctionPointer("XInputGetState"));
327337
if (!xinput_get_state_)
328338
return false;
329-
xinput_enable_(true);
339+
if (xinput_enable) {
340+
// XInputEnable is unavailable before Win8 and deprecated in Win10.
341+
xinput_enable(true);
342+
}
330343
return true;
331344
}
332345

content/browser/gamepad/gamepad_platform_data_fetcher_win.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class GamepadPlatformDataFetcherWin : public GamepadDataFetcher {
4949
typedef DWORD (WINAPI *XInputGetStateFunc)(
5050
DWORD dwUserIndex, XINPUT_STATE* pState);
5151

52-
// Get functions from dynamically loaded xinput1_3.dll. We don't use
53-
// DELAYLOAD because the import library for Win8 SDK pulls xinput1_4 which
54-
// isn't redistributable. Returns true if loading was successful. We include
55-
// xinput1_3.dll with Chrome.
52+
// Get functions from dynamically loaded xinputX_Y.dll. We don't use
53+
// DELAYLOAD because XInputEnable is not available on all versions (it is
54+
// marked as deprecated on Win10) and thus the symbol is resolved in runtime.
55+
// Returns true if loading was successful.
5656
bool GetXInputDllFunctions();
5757

5858
// Scan for connected XInput and DirectInput gamepads.
@@ -71,7 +71,6 @@ class GamepadPlatformDataFetcherWin : public GamepadDataFetcher {
7171

7272
// Function pointers to XInput functionality, retrieved in
7373
// |GetXinputDllFunctions|.
74-
XInputEnableFunc xinput_enable_;
7574
XInputGetCapabilitiesFunc xinput_get_capabilities_;
7675
XInputGetStateFunc xinput_get_state_;
7776

content/content_common.gypi

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,30 +1042,6 @@
10421042
'<(DEPTH)/third_party/khronos',
10431043
],
10441044
}],
1045-
['OS=="win" and directxsdk_exists=="True"', {
1046-
'actions': [
1047-
{
1048-
'action_name': 'extract_xinput',
1049-
'variables': {
1050-
'input': 'APR2007_xinput_<(winsdk_arch).cab',
1051-
'output': 'xinput1_3.dll',
1052-
},
1053-
'inputs': [
1054-
'../third_party/directxsdk/files/Redist/<(input)',
1055-
],
1056-
'outputs': [
1057-
'<(PRODUCT_DIR)/<(output)',
1058-
],
1059-
'action': [
1060-
'python',
1061-
'../build/extract_from_cab.py',
1062-
'..\\third_party\\directxsdk\\files\\Redist\\<(input)',
1063-
'<(output)',
1064-
'<(PRODUCT_DIR)',
1065-
],
1066-
},
1067-
]
1068-
}],
10691045
['use_seccomp_bpf==0', {
10701046
'sources!': [
10711047
'common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc',

tools/checkbins/checkbins.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
# Windows guru for advice.
3131
EXCLUDED_FILES = ['chrome_frame_mini_installer.exe',
3232
'mini_installer.exe',
33-
'wow_helper.exe',
34-
'xinput1_3.dll' # Microsoft DirectX redistributable.
33+
'wow_helper.exe'
3534
]
3635

3736
def IsPEFile(path):

0 commit comments

Comments
 (0)