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

Commit

Permalink
Merge pull request #313 from astojilj/gamepad
Browse files Browse the repository at this point in the history
XWALK-4992 [windows] App does not support gamepad
  • Loading branch information
Raphael Kubo da Costa committed Jan 29, 2016
2 parents dce3262 + b34d261 commit 0f31e18
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 42 deletions.
1 change: 0 additions & 1 deletion chrome/installer/mini_installer/chrome.release
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ natives_blob.bin: %(VersionDir)s\
resources.pak: %(VersionDir)s\
snapshot_blob.bin: %(VersionDir)s\
syzyasan_rtl.dll: %(VersionDir)s\
xinput1_3.dll: %(VersionDir)s\
#
# Sub directories living in the version dir
#
Expand Down
5 changes: 0 additions & 5 deletions chrome/tools/build/win/FILES.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,6 @@ FILES = [
'buildtype': ['dev', 'official'],
'filegroup': ['default', 'symsrc'],
},
# XInput files:
{
'filename': 'xinput1_3.dll',
'buildtype': ['dev', 'official'],
},
# Native Client plugin files:
{
'filename': 'nacl_irt_x86_32.nexe',
Expand Down
23 changes: 18 additions & 5 deletions content/browser/gamepad/gamepad_platform_data_fetcher_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ const WebUChar* const GamepadSubTypeName(BYTE sub_type) {
}
}

const WebUChar* XInputDllFileName() {
// Xinput.h defines filenames on different versions.
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
return FILE_PATH_LITERAL("xinput1_4.dll");
} else if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
return FILE_PATH_LITERAL("xinput9_1_0.dll");
} else {
// Vista and before use DirectX redistributable.
return FILE_PATH_LITERAL("xinput1_3.dll");
}
}

} // namespace

GamepadPlatformDataFetcherWin::GamepadPlatformDataFetcherWin()
: xinput_dll_(base::FilePath(FILE_PATH_LITERAL("xinput1_3.dll"))),
: xinput_dll_(base::FilePath(XInputDllFileName())),
xinput_available_(GetXInputDllFunctions()) {
for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) {
platform_pad_state_[i].status = DISCONNECTED;
Expand Down Expand Up @@ -314,10 +326,8 @@ void GamepadPlatformDataFetcherWin::GetRawInputPadData(
bool GamepadPlatformDataFetcherWin::GetXInputDllFunctions() {
xinput_get_capabilities_ = NULL;
xinput_get_state_ = NULL;
xinput_enable_ = reinterpret_cast<XInputEnableFunc>(
XInputEnableFunc xinput_enable = reinterpret_cast<XInputEnableFunc>(
xinput_dll_.GetFunctionPointer("XInputEnable"));
if (!xinput_enable_)
return false;
xinput_get_capabilities_ = reinterpret_cast<XInputGetCapabilitiesFunc>(
xinput_dll_.GetFunctionPointer("XInputGetCapabilities"));
if (!xinput_get_capabilities_)
Expand All @@ -326,7 +336,10 @@ bool GamepadPlatformDataFetcherWin::GetXInputDllFunctions() {
xinput_dll_.GetFunctionPointer("XInputGetState"));
if (!xinput_get_state_)
return false;
xinput_enable_(true);
if (xinput_enable) {
// XInputEnable is unavailable before Win8 and deprecated in Win10.
xinput_enable(true);
}
return true;
}

Expand Down
9 changes: 4 additions & 5 deletions content/browser/gamepad/gamepad_platform_data_fetcher_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class GamepadPlatformDataFetcherWin : public GamepadDataFetcher {
typedef DWORD (WINAPI *XInputGetStateFunc)(
DWORD dwUserIndex, XINPUT_STATE* pState);

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

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

// Function pointers to XInput functionality, retrieved in
// |GetXinputDllFunctions|.
XInputEnableFunc xinput_enable_;
XInputGetCapabilitiesFunc xinput_get_capabilities_;
XInputGetStateFunc xinput_get_state_;

Expand Down
24 changes: 0 additions & 24 deletions content/content_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1042,30 +1042,6 @@
'<(DEPTH)/third_party/khronos',
],
}],
['OS=="win" and directxsdk_exists=="True"', {
'actions': [
{
'action_name': 'extract_xinput',
'variables': {
'input': 'APR2007_xinput_<(winsdk_arch).cab',
'output': 'xinput1_3.dll',
},
'inputs': [
'../third_party/directxsdk/files/Redist/<(input)',
],
'outputs': [
'<(PRODUCT_DIR)/<(output)',
],
'action': [
'python',
'../build/extract_from_cab.py',
'..\\third_party\\directxsdk\\files\\Redist\\<(input)',
'<(output)',
'<(PRODUCT_DIR)',
],
},
]
}],
['use_seccomp_bpf==0', {
'sources!': [
'common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc',
Expand Down
3 changes: 1 addition & 2 deletions tools/checkbins/checkbins.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
# Windows guru for advice.
EXCLUDED_FILES = ['chrome_frame_mini_installer.exe',
'mini_installer.exe',
'wow_helper.exe',
'xinput1_3.dll' # Microsoft DirectX redistributable.
'wow_helper.exe'
]

def IsPEFile(path):
Expand Down

0 comments on commit 0f31e18

Please sign in to comment.