New issue
Advanced search Search tips

Issue 749295 link

Starred by 15 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 27
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Feature


Show other hotlists

Hotlists containing this issue:
Gamepad


Sign in to add a comment

Vibrate (haptic feedback) API for gamepads

Project Member Reported by mattreynolds@chromium.org, Jul 26 2017

Issue description

The Gamepad API should support the haptic feedback motors found in popular modern videogame controllers like the XBox One and DualShock 4.

Related issues on the w3c/gamepad github:

Vibrate feature for Gamepad
https://github.com/w3c/gamepad/issues/19

Consider changing API to match SDL2's
https://github.com/w3c/gamepad/issues/24

Support Buffered Haptic Effects
https://github.com/w3c/gamepad/issues/39

The most common haptic feedback mechanism for standard gamepads uses two Eccentric Rotation Mass (ERM) motors positioned in the controller handles. These ERMs have different masses to provide both low-frequency and high-frequency rumble effects. ERMs are typically controlled by a sequence of intensity/duration pairs which tell the motor when to vibrate and how strong the effect should be.

Newer gamepads, including the Oculus Touch and HTC Vive VR controllers, use Linear Resonant Actuator (LRA) motors to provide haptic feedback. LRAs can provide a wider variety of effects, and can often be programmed by sending a buffer of samples that are played back by the LRA as vibration intensity.
 
I think we should consider three main use cases:

Simple vibration: One haptic device that takes duration/intensity pairs (or sequences of pairs). This would support gamepads with a single motor or more complex gamepads that don't fit the other categories but still support vibration. It will also be appropriate for mobile phones that expose themselves as a gamepad.

Left/Right vibration: Two haptic devices, a low-frequency motor on the left and a high-frequency motor on the right, which each take duration/intensity pairs or sequences of pairs. This would support most modern console gamepads including XBox 360, DualShock 3, and DualShock 4. Most other standard gamepads like the Steam Controller and VR gamepads have haptic devices that can create a low/high frequency rumble effect.

Linear resonant vibration: Two identical haptic devices in the left and right hands which take arrays of samples and play them back as vibration intensity. This would support the Oculus Touch which uses the OVRHaptics API. Other gamepads with LRA-based haptics may also be able to take advantage of this (Nintendo Switch joycons, XBox One rumble triggers, Steam Controller). We should also expect LRAs to become more common in the future.

This leaves out many devices that don't fall into the above categories. For instance, some devices have additional haptics beyond the standard Left/Right rumble. If we expose all haptic devices on the gamepad as an array, it will be difficult for developers to know how the user will experience haptic effects from those additional devices. So, we may want to extend the gamepad API's standard gamepad spec to specify indices for common haptic devices, or maybe add a way for the gamepad mapping to associate a haptic device with a particular button or axis to give developers a hint at what they are vibrating.

Some APIs (for instance, SDL2's haptics) also support force feedback devices like steering wheels and joysticks. These feedback effects rely on the current position, velocity, or acceleration of the input axes and require a fast control loop for a good user experience. Support for these devices is outside the scope of this API.

Fully supporting sending buffers of intensity samples to the LRA for custom effects will require a much more complex API than for simple left/right rumble effects. To keep it manageable, perhaps we can use Web Audio and MediaStreams to stream the data to the device. I think it's fine to leave this out of the initial version of the API and have LRA devices fall back to Left/Right for now.
Project Member

Comment 2 by bugdroid1@chromium.org, Oct 27 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/687970a2d6b323836c35bae8bb1922dcf833bcb5

commit 687970a2d6b323836c35bae8bb1922dcf833bcb5
Author: Matt Reynolds <mattreynolds@google.com>
Date: Fri Oct 27 22:11:28 2017

Add new IDL for gamepad vibration

To support rumble effects via the Gamepad API, a new
GamepadHapticActuator interface is added. The actuator member
will be used to issue haptics commands to the associated gamepad.

BUG= 749295 

Change-Id: Ic6b6ecdfd13c8d7c263ec6dc2a8b3e44becf66a1
Reviewed-on: https://chromium-review.googlesource.com/695817
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512319}
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/device/gamepad/public/cpp/gamepad.h
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/ppapi/shared_impl/ppb_gamepad_shared.h
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/BUILD.gn
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/Gamepad.cpp
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/Gamepad.h
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/Gamepad.idl
[add] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/GamepadEffectParameters.idl
[add] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/GamepadHapticActuator.cpp
[add] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/GamepadHapticActuator.h
[add] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/GamepadHapticActuator.idl
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.h
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/Source/modules/modules_idl_files.gni
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/third_party/WebKit/public/platform/web_feature.mojom
[modify] https://crrev.com/687970a2d6b323836c35bae8bb1922dcf833bcb5/tools/metrics/histograms/enums.xml

Project Member

Comment 3 by bugdroid1@chromium.org, Oct 30 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9b28722361e5ca64e63b00cada5c5a76e0260c1c

commit 9b28722361e5ca64e63b00cada5c5a76e0260c1c
Author: Matt Reynolds <mattreynolds@google.com>
Date: Mon Oct 30 22:52:23 2017

Add mojo pipe for gamepad haptics commands

A new mojo pipe is added from blink::GamepadDispatcher to
device::GamepadHapticsManager to communicate haptics commands (play
effect, reset vibration).

BUG= 749295 

Change-Id: I20400aaca30165133a4b892e900f171e3bd48eda
Reviewed-on: https://chromium-review.googlesource.com/723848
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512658}
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/content/browser/renderer_host/render_process_host_impl.cc
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/content/public/app/mojo/content_browser_manifest.json
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/BUILD.gn
[add] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/gamepad_haptics_manager.cc
[add] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/gamepad_haptics_manager.h
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/public/interfaces/gamepad.mojom
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/public/interfaces/gamepad.typemap
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/public/interfaces/gamepad_struct_traits.cc
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/device/gamepad/public/interfaces/gamepad_struct_traits.h
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/third_party/WebKit/Source/modules/gamepad/BUILD.gn
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/third_party/WebKit/Source/modules/gamepad/DEPS
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/third_party/WebKit/Source/modules/gamepad/GamepadDispatcher.cpp
[modify] https://crrev.com/9b28722361e5ca64e63b00cada5c5a76e0260c1c/third_party/WebKit/Source/modules/gamepad/GamepadDispatcher.h

Project Member

Comment 4 by bugdroid1@chromium.org, Oct 31 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1911f59616ff7bdcccf126fe8fb3af871bd12a8e

commit 1911f59616ff7bdcccf126fe8fb3af871bd12a8e
Author: Matt Reynolds <mattreynolds@google.com>
Date: Tue Oct 31 23:48:49 2017

Add haptics to GamepadDataFetcher

A GamepadDataFetcher represents a host interface for receiving gamepad
state and communicating commands to a gamepad connected over a
particular host interface.

This CL modifies GamepadDataFetcher to support haptics commands.
Haptics commands received by GamepadService are routed to the fetcher
corresponding to the gamepad's host interface.

BUG= 749295 

Change-Id: I82629d34494871ed59c574a9846c0b4ff088f229
Reviewed-on: https://chromium-review.googlesource.com/739926
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513009}
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_data_fetcher.cc
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_data_fetcher.h
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_haptics_manager.cc
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_pad_state_provider.cc
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_pad_state_provider.h
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_provider.cc
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_provider.h
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_service.cc
[modify] https://crrev.com/1911f59616ff7bdcccf126fe8fb3af871bd12a8e/device/gamepad/gamepad_service.h

Project Member

Comment 5 by bugdroid1@chromium.org, Nov 1 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f0f0ecac94a6bd832352a8fc8d2be46dbf0957a1

commit f0f0ecac94a6bd832352a8fc8d2be46dbf0957a1
Author: Matt Reynolds <mattreynolds@google.com>
Date: Wed Nov 01 01:05:18 2017

Implement GamepadHapticActuator

GamepadHapticActuator receives haptics commands and forwards them to
GamepadDispatcher, which dispatches them to the device service. It also
manages the state of promises which have been returned to the user as
the result of haptics commands.

Haptics commands include playEffect, which plays a vibration effect on
the target gamepad, and reset, which stops vibration and resets any
vibration-related state on the gamepad. Both commands return a promise
that is resolved with a result code once the command is completed.

BUG= 749295 

Change-Id: I457c4b0e024c88adcaecdf6695959e06acb20a8e
Reviewed-on: https://chromium-review.googlesource.com/747050
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513032}
[modify] https://crrev.com/f0f0ecac94a6bd832352a8fc8d2be46dbf0957a1/third_party/WebKit/Source/modules/gamepad/GamepadHapticActuator.cpp
[modify] https://crrev.com/f0f0ecac94a6bd832352a8fc8d2be46dbf0957a1/third_party/WebKit/Source/modules/gamepad/GamepadHapticActuator.h

Project Member

Comment 6 by bugdroid1@chromium.org, Nov 3 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a9ba8220705d3128a4f1c9b34335dc01a1b73801

commit a9ba8220705d3128a4f1c9b34335dc01a1b73801
Author: Matt Reynolds <mattreynolds@google.com>
Date: Fri Nov 03 18:51:41 2017

Split XboxControllerMac into its own file

XboxDataFetcher enumerates Xbox 360 and Xbox One gamepads connected over
USB. XboxController represents a connection to one Xbox gamepad through
this data fetcher. This CL moves the XboxController logic out of
XboxDataFetcher and into a separate file. The class is also renamed to
XboxControllerMac.

BUG= 749295 

Change-Id: If97c9f86a0e2bfa1dbf73438bc423c90450f2ba2
Reviewed-on: https://chromium-review.googlesource.com/752144
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513861}
[modify] https://crrev.com/a9ba8220705d3128a4f1c9b34335dc01a1b73801/device/gamepad/BUILD.gn
[add] https://crrev.com/a9ba8220705d3128a4f1c9b34335dc01a1b73801/device/gamepad/xbox_controller_mac.h
[add] https://crrev.com/a9ba8220705d3128a4f1c9b34335dc01a1b73801/device/gamepad/xbox_controller_mac.mm
[modify] https://crrev.com/a9ba8220705d3128a4f1c9b34335dc01a1b73801/device/gamepad/xbox_data_fetcher_mac.h
[modify] https://crrev.com/a9ba8220705d3128a4f1c9b34335dc01a1b73801/device/gamepad/xbox_data_fetcher_mac.mm

Project Member

Comment 7 by bugdroid1@chromium.org, Nov 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e88656fc09b1199c4feaaa8dd6fdca490799b2d2

commit e88656fc09b1199c4feaaa8dd6fdca490799b2d2
Author: Matt Reynolds <mattreynolds@google.com>
Date: Sat Nov 04 01:08:16 2017

Remove Objective-C calls from XboxDataFetcher

After moving XboxControllerMac out of xbox_data_fetcher_mac.mm, there are
only two Obj-C calls remaining, which are used for string conversions.
This CL replaces the string conversions with base/strings methods
and renames the file xbox_data_fetcher_mac.cc.

BUG= 749295 

Change-Id: I6456cc809f6d7ce365f397b2d1f9f22e57511c83
Reviewed-on: https://chromium-review.googlesource.com/753533
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514001}
[modify] https://crrev.com/e88656fc09b1199c4feaaa8dd6fdca490799b2d2/device/gamepad/BUILD.gn
[modify] https://crrev.com/e88656fc09b1199c4feaaa8dd6fdca490799b2d2/device/gamepad/xbox_controller_mac.h
[modify] https://crrev.com/e88656fc09b1199c4feaaa8dd6fdca490799b2d2/device/gamepad/xbox_controller_mac.mm
[rename] https://crrev.com/e88656fc09b1199c4feaaa8dd6fdca490799b2d2/device/gamepad/xbox_data_fetcher_mac.cc

Project Member

Comment 8 by bugdroid1@chromium.org, Nov 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/092c3d970b25fffb87299a2b5fbb35e1ebc36c3d

commit 092c3d970b25fffb87299a2b5fbb35e1ebc36c3d
Author: Matt Reynolds <mattreynolds@google.com>
Date: Mon Nov 13 21:12:57 2017

Add haptics for X360 and Xbox One gamepads on Mac

On Mac, Xbox gamepads connected over USB are supported by an internal
driver that is used when no OS-level driver is installed. This CL adds
haptics support for Xbox gamepads connected in this way.

BUG= 749295 

Change-Id: Ie674b0b832ad0f1922821c3f9ef1ce232ab2dcd0
Reviewed-on: https://chromium-review.googlesource.com/754366
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516047}
[modify] https://crrev.com/092c3d970b25fffb87299a2b5fbb35e1ebc36c3d/device/gamepad/xbox_controller_mac.h
[modify] https://crrev.com/092c3d970b25fffb87299a2b5fbb35e1ebc36c3d/device/gamepad/xbox_controller_mac.mm
[modify] https://crrev.com/092c3d970b25fffb87299a2b5fbb35e1ebc36c3d/device/gamepad/xbox_data_fetcher_mac.cc
[modify] https://crrev.com/092c3d970b25fffb87299a2b5fbb35e1ebc36c3d/device/gamepad/xbox_data_fetcher_mac.h

Project Member

Comment 9 by bugdroid1@chromium.org, Dec 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7c498e59105b72ba9986dd5d9b55e9a69e07c66d

commit 7c498e59105b72ba9986dd5d9b55e9a69e07c66d
Author: Matt Reynolds <mattreynolds@google.com>
Date: Wed Dec 06 22:06:24 2017

Add a base class for haptic gamepad functionality

AbstractHapticGamepad encapsulates the logic for translating haptic
effect descriptions into a sequence of vibration actuator commands.
Users of AbstractHapticGamepad should override SetVibration so that it
updates the vibration actuators on the device with the specified
intensities.

BUG= 749295 

Change-Id: I3744cd3b06efb7970bd87048996250e52c472919
Reviewed-on: https://chromium-review.googlesource.com/810006
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522221}
[modify] https://crrev.com/7c498e59105b72ba9986dd5d9b55e9a69e07c66d/device/BUILD.gn
[modify] https://crrev.com/7c498e59105b72ba9986dd5d9b55e9a69e07c66d/device/gamepad/BUILD.gn
[add] https://crrev.com/7c498e59105b72ba9986dd5d9b55e9a69e07c66d/device/gamepad/abstract_haptic_gamepad.cc
[add] https://crrev.com/7c498e59105b72ba9986dd5d9b55e9a69e07c66d/device/gamepad/abstract_haptic_gamepad.h
[add] https://crrev.com/7c498e59105b72ba9986dd5d9b55e9a69e07c66d/device/gamepad/abstract_haptic_gamepad_unittest.cc

Project Member

Comment 10 by bugdroid1@chromium.org, Jan 3 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3927f87f2cdf1d2184772a80114be5a9aaa064c6

commit 3927f87f2cdf1d2184772a80114be5a9aaa064c6
Author: Matt Reynolds <mattreynolds@google.com>
Date: Wed Jan 03 03:24:00 2018

Add a base Dualshock4 controller implementation

Haptics on Dualshock4 devices are typically not supported by OS-level
haptics APIs, so in order to support vibration effects on these devices
we issue device-specific reports using the raw HID protocol.
Dualshock4ControllerBase implements the common logic for creating the
report buffer from the vibration intensity values. Users should
implement WriteOutputReport to provide the OS-specific logic for sending
the report to the device.

BUG= 749295 

Change-Id: I742316f385235b44c0658dd9e571fa73cf4f496e
Reviewed-on: https://chromium-review.googlesource.com/810053
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526608}
[modify] https://crrev.com/3927f87f2cdf1d2184772a80114be5a9aaa064c6/device/gamepad/BUILD.gn
[add] https://crrev.com/3927f87f2cdf1d2184772a80114be5a9aaa064c6/device/gamepad/dualshock4_controller_base.cc
[add] https://crrev.com/3927f87f2cdf1d2184772a80114be5a9aaa064c6/device/gamepad/dualshock4_controller_base.h

Project Member

Comment 11 by bugdroid1@chromium.org, Jan 9 2018

Project Member

Comment 12 by bugdroid1@chromium.org, Jan 9 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9575621400edfc5dc1fb9ba94591dd5d8937961f

commit 9575621400edfc5dc1fb9ba94591dd5d8937961f
Author: Matt Reynolds <mattreynolds@google.com>
Date: Tue Jan 09 19:29:10 2018

Add haptics for evdev gamepads on Linux

Allow haptics commands to be sent to the platform data fetcher on Linux.
In order for a gamepad to support haptics, the gamepad must be enumerable
through the evdev input event interface. The evdev device must support
the EV_FF feature (force feedback) and FF_RUMBLE (rumble effects).

BUG= 749295 

Change-Id: If8a0af76a116289b3a8f39d0c4a10ee8e0dc0ba6
Reviewed-on: https://chromium-review.googlesource.com/748201
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528067}
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/BUILD.gn
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/abstract_haptic_gamepad.cc
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/abstract_haptic_gamepad.h
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/abstract_haptic_gamepad_unittest.cc
[add] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/gamepad_device_linux.cc
[add] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/gamepad_device_linux.h
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/gamepad_platform_data_fetcher_linux.cc
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/gamepad_platform_data_fetcher_linux.h
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/public/cpp/gamepad.h
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/device/gamepad/public/interfaces/gamepad_struct_traits.cc
[modify] https://crrev.com/9575621400edfc5dc1fb9ba94591dd5d8937961f/third_party/WebKit/Source/modules/gamepad/GamepadHapticActuator.cpp

Project Member

Comment 13 by bugdroid1@chromium.org, Jan 10 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f5b6747cb083223c931351a999be7e0ad25375d3

commit f5b6747cb083223c931351a999be7e0ad25375d3
Author: Matt Reynolds <mattreynolds@google.com>
Date: Wed Jan 10 22:19:13 2018

Add haptics for Dualshock4 gamepads on Linux

Haptics for Dualshock4 gamepads is not compatible with the force feedback
feature of the Linux input subsystem. To support vibration effects on
these devices, we enumerate the gamepad through the hidraw interface and
communicate haptics commands using the proprietary Dualshock4 USB protocol.

BUG= 749295 

Change-Id: I5d732a7502eaea5ad5b1e801825375a659d6fc29
Reviewed-on: https://chromium-review.googlesource.com/854984
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528444}
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/BUILD.gn
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/abstract_haptic_gamepad.h
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/dualshock4_controller_base.h
[add] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/dualshock4_controller_linux.cc
[add] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/dualshock4_controller_linux.h
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/gamepad_device_linux.cc
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/gamepad_device_linux.h
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/gamepad_platform_data_fetcher_linux.cc
[modify] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/gamepad_platform_data_fetcher_linux.h
[add] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/udev_gamepad_linux.cc
[add] https://crrev.com/f5b6747cb083223c931351a999be7e0ad25375d3/device/gamepad/udev_gamepad_linux.h

Project Member

Comment 15 by bugdroid1@chromium.org, Jan 11 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e0cf8e1b851449b628d17431943b7a6c6286b5c2

commit e0cf8e1b851449b628d17431943b7a6c6286b5c2
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Thu Jan 11 20:01:32 2018

Fix DCHECK failure on gamepad disconnect on Windows

AbstractHapticGamepad requires that callers call the Shutdown method
before destroying the gamepad object. This CL ensures that Shutdown is
called in GamepadPlatformDataFetcherWin when an XInput gamepad is
disconnected.

BUG= 749295 

Change-Id: Idae6d509144e2f09c8d1f6bb69f3b693920e6670
Reviewed-on: https://chromium-review.googlesource.com/861195
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528720}
[modify] https://crrev.com/e0cf8e1b851449b628d17431943b7a6c6286b5c2/device/gamepad/gamepad_platform_data_fetcher_win.cc

Project Member

Comment 16 by bugdroid1@chromium.org, Jan 12 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8f3484489f552b27cad8b6872c5e482091f6794c

commit 8f3484489f552b27cad8b6872c5e482091f6794c
Author: Matt Reynolds <mattreynolds@google.com>
Date: Fri Jan 12 20:27:53 2018

Add haptics for USB HID gamepads on Mac

This CL adds haptics support for USB HID devices through the
ForceFeedback framework. In order to support haptics through this API,
the device must have an appropriate driver installed.

BUG= 749295 

Change-Id: I3336801a7bae8c1231f550b6b610f725bf26896f
Reviewed-on: https://chromium-review.googlesource.com/753432
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529050}
[modify] https://crrev.com/8f3484489f552b27cad8b6872c5e482091f6794c/device/gamepad/BUILD.gn
[add] https://crrev.com/8f3484489f552b27cad8b6872c5e482091f6794c/device/gamepad/gamepad_device_mac.h
[add] https://crrev.com/8f3484489f552b27cad8b6872c5e482091f6794c/device/gamepad/gamepad_device_mac.mm
[modify] https://crrev.com/8f3484489f552b27cad8b6872c5e482091f6794c/device/gamepad/gamepad_platform_data_fetcher_mac.h
[modify] https://crrev.com/8f3484489f552b27cad8b6872c5e482091f6794c/device/gamepad/gamepad_platform_data_fetcher_mac.mm

Project Member

Comment 17 by bugdroid1@chromium.org, Jan 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/29be76624e607cb63e495d1cbf1481cb34e5c8f5

commit 29be76624e607cb63e495d1cbf1481cb34e5c8f5
Author: Matt Reynolds <mattreynolds@google.com>
Date: Wed Jan 17 20:33:56 2018

Don't clear devices during gamepad enumeration

In GamepadPlatformDataFetcherLinux, when enumerating devices with
EnumerateSubsystemDevices, we incorrectly clear the device list. Since
we enumerate multiple subsystems, this causes us to lose all devices
except those found in the last subsystem. This CL instead clears the
device list before enumeration begins.

This CL also combines some subsystem strings that were duplicated.

BUG= 749295 

Change-Id: I905b75ba37e1e53cbd67777ed7e07c2a66df4073
Reviewed-on: https://chromium-review.googlesource.com/865807
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529859}
[modify] https://crrev.com/29be76624e607cb63e495d1cbf1481cb34e5c8f5/device/gamepad/gamepad_platform_data_fetcher_linux.cc
[modify] https://crrev.com/29be76624e607cb63e495d1cbf1481cb34e5c8f5/device/gamepad/udev_gamepad_linux.cc
[modify] https://crrev.com/29be76624e607cb63e495d1cbf1481cb34e5c8f5/device/gamepad/udev_gamepad_linux.h

Project Member

Comment 18 by bugdroid1@chromium.org, Jan 18 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c712ffa49e86a653344716fa01cf863c4d18698c

commit c712ffa49e86a653344716fa01cf863c4d18698c
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Thu Jan 18 22:37:35 2018

Remove DLL management from RawInputDataFetcher

RawInputDataFetcher uses methods from hid.dll to enumerate and fetch
gamepad state for RawInput devices. The DLL is loaded as needed and
a handle is retained by the data fetcher.

This CL moves the DLL management logic and function pointers to a
separate object that can be shared between the data fetcher and
other classes.

BUG= 749295 

Change-Id: Ifbdf1d67a4577e91806e3e7ee5ee6e4cae621691
Reviewed-on: https://chromium-review.googlesource.com/871845
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530311}
[modify] https://crrev.com/c712ffa49e86a653344716fa01cf863c4d18698c/device/gamepad/BUILD.gn
[add] https://crrev.com/c712ffa49e86a653344716fa01cf863c4d18698c/device/gamepad/hid_dll_functions_win.cc
[add] https://crrev.com/c712ffa49e86a653344716fa01cf863c4d18698c/device/gamepad/hid_dll_functions_win.h
[modify] https://crrev.com/c712ffa49e86a653344716fa01cf863c4d18698c/device/gamepad/raw_input_data_fetcher_win.cc
[modify] https://crrev.com/c712ffa49e86a653344716fa01cf863c4d18698c/device/gamepad/raw_input_data_fetcher_win.h

Project Member

Comment 19 by bugdroid1@chromium.org, Jan 20 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e497ecf96965a1f99959ad1a7df748a94d89bf1e

commit e497ecf96965a1f99959ad1a7df748a94d89bf1e
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Sat Jan 20 00:25:41 2018

Factor out a device object for RawInput gamepads

RawInputDataFetcher previously stored information about each connected
gamepad in a RawGamepadInfo object internal to the data fetcher. This
CL renames the object to RawInputGamepadDeviceWin and moves more of the
capabilities and polling logic into that class.

BUG= 749295 

Change-Id: I9b2ad1f2712e3c14289a9d9a159a04c4cf952d4e
Reviewed-on: https://chromium-review.googlesource.com/875194
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530682}
[modify] https://crrev.com/e497ecf96965a1f99959ad1a7df748a94d89bf1e/device/gamepad/BUILD.gn
[modify] https://crrev.com/e497ecf96965a1f99959ad1a7df748a94d89bf1e/device/gamepad/raw_input_data_fetcher_win.cc
[modify] https://crrev.com/e497ecf96965a1f99959ad1a7df748a94d89bf1e/device/gamepad/raw_input_data_fetcher_win.h
[add] https://crrev.com/e497ecf96965a1f99959ad1a7df748a94d89bf1e/device/gamepad/raw_input_gamepad_device_win.cc
[add] https://crrev.com/e497ecf96965a1f99959ad1a7df748a94d89bf1e/device/gamepad/raw_input_gamepad_device_win.h

Project Member

Comment 20 by bugdroid1@chromium.org, Jan 24 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/be9f9f40f79fae8528cd9e5f5fc578c71dc2e545

commit be9f9f40f79fae8528cd9e5f5fc578c71dc2e545
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Wed Jan 24 22:18:10 2018

Avoid recreating haptics in GamepadPlatformDataFetcherWin

A gamepad may be enumerated twice while its active state is still
marked as GAMEPAD_NEWLY_ACTIVE. If this happens, a new
XInputHapticGamepadWin instance will be created without properly
shutting down the previous instance, causing a DCHECK failure.

This situation can occur when a gamepad is enumerated twice before
the polling thread polls the gamepad state, which resets all gamepads
to GAMEPAD_INACTIVE.

To avoid the DCHECK failure, this CL modifies the newly active gamepad
logic so the XInputHapticGamepadWin instance is only created if it was
previously null.

BUG= 749295 

Change-Id: I1afbe0f6e4f6757384dd37a3491ab6a9cd4313c5
Reviewed-on: https://chromium-review.googlesource.com/883780
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531712}
[modify] https://crrev.com/be9f9f40f79fae8528cd9e5f5fc578c71dc2e545/device/gamepad/gamepad_platform_data_fetcher_win.cc

Project Member

Comment 21 by bugdroid1@chromium.org, Jan 29 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a077c7a863a283118f746e7ac1254f163b167cac

commit a077c7a863a283118f746e7ac1254f163b167cac
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Mon Jan 29 21:00:04 2018

Add bus_type param to GetGamepadStandardMappingFunction

The Standard Gamepad spec lays out a standard configuration for gamepad
buttons and axes. The browser attempts to remap the buttons and axes
reported by connected devices to more closely match the standard. In
most cases, a suitable mapping function can be chosen from the vendor
and product IDs reported by the device.

In some cases this is not sufficient; for instance, some devices are
supported over both USB and Bluetooth and require different mapping
functions in either case. To help select a mapping function in these
cases, a |bus_type| parameter is added to
GetGamepadStandardMappingFunction to specify whether the device is
connected over USB or Bluetooth.

BUG= 749295 

Change-Id: I566e06f5d34eeac269a0a70e912f74a64ccd19f5
Reviewed-on: https://chromium-review.googlesource.com/887231
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532583}
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/gamepad_platform_data_fetcher_linux.cc
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/gamepad_platform_data_fetcher_mac.mm
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/gamepad_standard_mappings.h
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/gamepad_standard_mappings_linux.cc
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/gamepad_standard_mappings_mac.mm
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/gamepad_standard_mappings_win.cc
[modify] https://crrev.com/a077c7a863a283118f746e7ac1254f163b167cac/device/gamepad/raw_input_data_fetcher_win.cc

Project Member

Comment 22 by bugdroid1@chromium.org, Feb 5 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/acd7c7eaac795286ab4c46dfd11571705a4d2c4f

commit acd7c7eaac795286ab4c46dfd11571705a4d2c4f
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Mon Feb 05 22:14:06 2018

Split GamepadActiveState into separate flags

The Gamepad service allows gamepads to be enumerated by a number
of distinct data fetchers which feed into a central gamepad provider.
The provider is responsible for managing the state and ordering of
connected gamepads as well as issuing notifications when gamepads are
connected or disconnected.

PadState's |active_state| member indicates the gamepad's current
connection status as "inactive" (not receiving updates), "active"
(recently received an update), or "newly active" (just connected).
This state used for three tasks:

* A connection event is fired when the gamepad is first connected.
* A disconnection event is fired when the gamepad is no longer
  connected.
* The data fetcher performs some first-time initialization when the
  gamepad is first connected.

This CL splits |active_state| into separate flags to address each case.

* |is_active| is used to detect the current connection status. It is
  initialized to false for each polling cycle and set to true once
  the PadState is accessed. If this flag is false after a polling
  cycle, the gamepad is considered disconnected.
* |is_newly_active| is initialized to true when the PadState slot is
  allocated and set to false once the gamepad connection event has
  been issued.
* |is_initialized| is initialized to false when the PadState slot is
  allocated and may be set to true by the data fetcher to indicate
  that it has performed first-time initialization for this gamepad.

BUG= 749295 

Change-Id: I2c99e766c900c9c92a5bffecb12ec283739f2597
Reviewed-on: https://chromium-review.googlesource.com/896028
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534503}
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/game_controller_data_fetcher_mac.mm
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/gamepad_pad_state_provider.cc
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/gamepad_pad_state_provider.h
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/gamepad_platform_data_fetcher_android.cc
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/gamepad_platform_data_fetcher_win.cc
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/gamepad_provider.cc
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/gamepad/gamepad_provider.h
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/vr/android/gvr/cardboard_gamepad_data_fetcher.cc
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/vr/android/gvr/gvr_gamepad_data_fetcher.cc
[modify] https://crrev.com/acd7c7eaac795286ab4c46dfd11571705a4d2c4f/device/vr/oculus/oculus_gamepad_data_fetcher.cc

Project Member

Comment 23 by bugdroid1@chromium.org, Feb 6 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2d2b87e5f9c872902d8508f6377470a4a6fa87e1

commit 2d2b87e5f9c872902d8508f6377470a4a6fa87e1
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Tue Feb 06 01:02:23 2018

Add support for Switch Pro Controller on Linux

BUG= 749295 

Change-Id: I939cc7ab58cc9a8196fe728c926341f4ccebea20
Reviewed-on: https://chromium-review.googlesource.com/887253
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534563}
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/BUILD.gn
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_device_linux.cc
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_device_linux.h
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_platform_data_fetcher_linux.cc
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_platform_data_fetcher_linux.h
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_standard_mappings.cc
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_standard_mappings.h
[modify] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/gamepad_standard_mappings_linux.cc
[add] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/switch_pro_controller_linux.cc
[add] https://crrev.com/2d2b87e5f9c872902d8508f6377470a4a6fa87e1/device/gamepad/switch_pro_controller_linux.h

Project Member

Comment 24 by bugdroid1@chromium.org, Feb 6 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/babcfdda46cb068b1793d2c914e6d761d42f5ac4

commit babcfdda46cb068b1793d2c914e6d761d42f5ac4
Author: Thomas Anderson <thomasanderson@chromium.org>
Date: Tue Feb 06 01:26:48 2018

Revert "Add support for Switch Pro Controller on Linux"

This reverts commit 2d2b87e5f9c872902d8508f6377470a4a6fa87e1.

Reason for revert: Causes build failure on Google Chrome Linux x64:
https://ci.chromium.org/buildbot/chromium.chrome/Google%20Chrome%20Linux%20x64/27255

Original change's description:
> Add support for Switch Pro Controller on Linux
> 
> BUG= 749295 
> 
> Change-Id: I939cc7ab58cc9a8196fe728c926341f4ccebea20
> Reviewed-on: https://chromium-review.googlesource.com/887253
> Reviewed-by: Brandon Jones <bajones@chromium.org>
> Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#534563}

TBR=bajones@chromium.org,mattreynolds@chromium.org

Change-Id: Ie3b35357e131dd10291fec0b4ec06227b03f0c7b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  749295 
Reviewed-on: https://chromium-review.googlesource.com/903103
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534567}
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/BUILD.gn
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_device_linux.cc
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_device_linux.h
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_platform_data_fetcher_linux.cc
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_platform_data_fetcher_linux.h
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_standard_mappings.cc
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_standard_mappings.h
[modify] https://crrev.com/babcfdda46cb068b1793d2c914e6d761d42f5ac4/device/gamepad/gamepad_standard_mappings_linux.cc
[delete] https://crrev.com/f7ba8a52e2dd3e32b9a49e39237f7f7b38713343/device/gamepad/switch_pro_controller_linux.cc
[delete] https://crrev.com/f7ba8a52e2dd3e32b9a49e39237f7f7b38713343/device/gamepad/switch_pro_controller_linux.h

Project Member

Comment 25 by bugdroid1@chromium.org, Feb 9 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/14b157142ce0febc22c1bd836f7d8ccdc2931e81

commit 14b157142ce0febc22c1bd836f7d8ccdc2931e81
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Fri Feb 09 22:14:04 2018

Add haptics for Dualshock4 gamepads on Windows

Provide support for vendor-specific haptics commands. The Dualshock4
gamepad is usable on Windows as a generic HID device for button and
axis inputs, but haptics commands must be issued using proprietary
reports.

BUG= 749295 

Change-Id: I0de8101d624d89bc14cb3fb213dfb04da3b72165
Reviewed-on: https://chromium-review.googlesource.com/803673
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535849}
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/BUILD.gn
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/dualshock4_controller_base.cc
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/dualshock4_controller_base.h
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/dualshock4_controller_linux.cc
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/dualshock4_controller_linux.h
[add] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/dualshock4_controller_win.cc
[add] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/dualshock4_controller_win.h
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/raw_input_data_fetcher_win.cc
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/raw_input_data_fetcher_win.h
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/raw_input_gamepad_device_win.cc
[modify] https://crrev.com/14b157142ce0febc22c1bd836f7d8ccdc2931e81/device/gamepad/raw_input_gamepad_device_win.h

Project Member

Comment 27 by bugdroid1@chromium.org, Mar 23 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fc63d3995a0ebff5dad757e24077fb8c4ac5065b

commit fc63d3995a0ebff5dad757e24077fb8c4ac5065b
Author: Matt Reynolds <mattreynolds@google.com>
Date: Thu Mar 22 23:04:46 2018

[Mac] Fix long haptic effects on Xbox One gamepads

On Mac, Chrome includes an internal driver for Xbox 360 and Xbox One
gamepads connected over USB. Vibration effects are issued to these
devices over USB HID using a vendor-specific protocol.

The Xbox One rumble packet specifies a duration for the effect. Chrome
always sets this to the maximum value and instead issues a new rumble
packet to end the effect. However, the duration of an Xbox One effect
with the maximum duration is approximately 3 seconds, causing longer
effects to end earlier than intended.

To support longer effects, the internal driver will now issue a second
rumble packet when needed.

BUG= 749295 

Change-Id: I25313715912f1a77b6fabc9071d2e77b804e3d8f
Reviewed-on: https://chromium-review.googlesource.com/964991
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545281}
[modify] https://crrev.com/fc63d3995a0ebff5dad757e24077fb8c4ac5065b/device/gamepad/xbox_controller_mac.mm

Project Member

Comment 28 by bugdroid1@chromium.org, May 1 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/043469f886c8a475d19c707bd28c5b427cd06d8f

commit 043469f886c8a475d19c707bd28c5b427cd06d8f
Author: Matt Reynolds <mattreynolds@google.com>
Date: Tue May 01 22:56:58 2018

Add a GamepadVibration runtime feature flag

In previous versions, the vibration feature was enabled with the
GamepadExtensions runtime feature flag. This CL splits the vibration
functionality into a separate flag that is enabled by default. This
allows the vibration feature to be enabled independently of other
features that use the same runtime flag.

BUG= 749295 

Change-Id: Ia8017e8b0ecd9df4490e8b205ecd1f49509c687b
Reviewed-on: https://chromium-review.googlesource.com/1027996
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555211}
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/chrome/browser/about_flags.cc
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/chrome/browser/flag_descriptions.cc
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/chrome/browser/flag_descriptions.h
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/content/child/runtime_features.cc
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/content/public/common/content_features.cc
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/content/public/common/content_features.h
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/WebKit/LayoutTests/http/tests/origin_trials/webexposed/xr/webvr-gamepad-origin-trial-interfaces.html
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/blink/public/platform/web_runtime_features.h
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/blink/renderer/modules/gamepad/gamepad.idl
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/blink/renderer/modules/gamepad/gamepad_haptic_actuator.idl
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/blink/renderer/platform/exported/web_runtime_features.cc
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/third_party/blink/renderer/platform/runtime_enabled_features.json5
[modify] https://crrev.com/043469f886c8a475d19c707bd28c5b427cd06d8f/tools/metrics/histograms/enums.xml

Project Member

Comment 29 by bugdroid1@chromium.org, May 2 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6027dafffb5695f8e158fb72ba2abf006b7fe602

commit 6027dafffb5695f8e158fb72ba2abf006b7fe602
Author: Matt Reynolds <mattreynolds@chromium.org>
Date: Wed May 02 23:15:50 2018

Allow late initialization of gamepad haptics

Several fields of the blink::Gamepad object are only modified when
the device is first connected. This is done under the assumption that
these device properties cannot change while the device is connected.
However, in some cases we expose a gamepad to a page before we have
determined the haptic capabilities of the gamepad. Once the
capabilities are known, the gamepad object is updated but the new
value is not propagated. Instead, the page still sees the null value.

This changes the vibrationActuator caching behavior to allow a one-time
update from null to non-null after the gamepad is initially connected.

BUG= 749295 

Change-Id: I45eb23a02a26681617d9e0f769c01acfaed21135
Reviewed-on: https://chromium-review.googlesource.com/952221
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555605}
[modify] https://crrev.com/6027dafffb5695f8e158fb72ba2abf006b7fe602/third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc

I'm confused about the status of this - it looks like it just shipped enabled by default in Chrome 68, but as the gamepad.vibrationActuator property. However the MDN documentation and the spec (https://w3c.github.io/gamepad/extensions.html#partial-gamepad-interface) instead use an array at gamepad.hapticActuators. The feature was not listed on the release schedule (https://www.chromestatus.com/features/schedule), the platform status still indicates it's behind a flag (https://www.chromestatus.com/feature/5705158763741184), and this issue is not yet marked "fixed".

We'd like to implement code using this once it's released, but is it actually fully shipped now? It looks a bit like it got shipped accidentally...
@mattreynolds I'd also very much like to know the current status of this.

I can confirm that it works and is enabled by default using Chrome M68+ so if this wasn't an accidental release, I'd really appreciate if this could be marked as "fixed" and mentioned in the upcoming Chrome M69 stable release.
Status: Fixed (was: Started)
This is intentionally enabled by the commit in #28, I forgot to update the chromestatus entry. Sorry for the confusion!
Thanks a lot for the info and your work!

I'm sure that a lot of game developers will make use of this feature in their  HTML5 games.
mattreynolds@ - thanks for clarifying. However how do we actually use the API? There is no accurate documentation anywhere. The spec describes a different API, MDN describes a different API, etc. I can't find documentation on how to use the API and what the parameters to playEffect() should be anywhere. Any tips?
Here's the pull request on the github with the proposed spec changes but it hasn't been merged yet:

https://github.com/w3c/gamepad/pull/68/commits/8e65fbf6d84d70fbf11e504420b97e90c681ae72

canPlayEffectType is not yet implemented, but isn't very useful at this point anyway since there is only one effect type.

There's also a design doc with some examples:

https://docs.google.com/document/d/1jPKzVRNzzU4dUsvLpSXm1VXPQZ8FP-0lKMT-R_p-s6g/edit

And here are some interactive examples:

https://codepen.io/anon/pen/yKgYGz

I'll see if we can get better documentation on MDN.
Great, thanks, looks like there's enough to get going with there.

Sign in to add a comment