Commit d3ea2db9 authored by Matt Reynolds's avatar Matt Reynolds Committed by Commit Bot

Add a feature to enable gamepad button/axis events

This CL adds a command line switch and Feature entry for enabling
event listeners to listen for gamepad button and axis inputs.

Intent to implement thread:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/9cfRxXx5Cis

BUG=856290

Change-Id: I5323ff7692ffb235fc3759b1305216085ed6460c
Reviewed-on: https://chromium-review.googlesource.com/1139092
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580361}
parent 1103662b
...@@ -33,11 +33,32 @@ size_t OverrideIntervalIfValid(base::StringPiece param_value, ...@@ -33,11 +33,32 @@ size_t OverrideIntervalIfValid(base::StringPiece param_value,
} // namespace } // namespace
// Enables gamepadbuttondown, gamepadbuttonup, gamepadbuttonchange,
// gamepadaxismove non-standard gamepad events.
const base::Feature kEnableGamepadButtonAxisEvents{
"EnableGamepadButtonAxisEvents", base::FEATURE_DISABLED_BY_DEFAULT};
// Overrides the gamepad polling interval.
const base::Feature kGamepadPollingInterval{"GamepadPollingInterval", const base::Feature kGamepadPollingInterval{"GamepadPollingInterval",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const char kGamepadPollingIntervalParamKey[] = "interval-ms"; const char kGamepadPollingIntervalParamKey[] = "interval-ms";
bool AreGamepadButtonAxisEventsEnabled() {
// Check if button and axis events are enabled by a field trial.
if (base::FeatureList::IsEnabled(kEnableGamepadButtonAxisEvents))
return true;
// Check if button and axis events are enabled by a command-line flag.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line &&
command_line->HasSwitch(switches::kEnableGamepadButtonAxisEvents)) {
return true;
}
return false;
}
size_t GetGamepadPollingInterval() { size_t GetGamepadPollingInterval() {
size_t polling_interval = kPollingIntervalMillisecondsMax; size_t polling_interval = kPollingIntervalMillisecondsMax;
......
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
namespace features { namespace features {
extern const base::Feature kEnableGamepadButtonAxisEvents;
extern const base::Feature kGamepadPollingInterval; extern const base::Feature kGamepadPollingInterval;
extern const char kGamepadPollingIntervalParamKey[]; extern const char kGamepadPollingIntervalParamKey[];
bool AreGamepadButtonAxisEventsEnabled();
size_t GetGamepadPollingInterval(); size_t GetGamepadPollingInterval();
} // namespace features } // namespace features
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
namespace switches { namespace switches {
// Enables gamepadbuttondown, gamepadbuttonup, gamepadbuttonchange,
// gamepadaxismove non-standard gamepad events.
const char kEnableGamepadButtonAxisEvents[] =
"enable-gamepad-button-axis-events";
// Overrides the gamepad polling interval. Decreasing the interval improves // Overrides the gamepad polling interval. Decreasing the interval improves
// input latency of buttons and axes but may negatively affect performance due // input latency of buttons and axes but may negatively affect performance due
// to more CPU time spent in the input polling thread. // to more CPU time spent in the input polling thread.
......
...@@ -9,6 +9,7 @@ namespace switches { ...@@ -9,6 +9,7 @@ namespace switches {
// All switches in alphabetical order. The switches should be documented // All switches in alphabetical order. The switches should be documented
// alongside the definition of their values in the .cc file. // alongside the definition of their values in the .cc file.
extern const char kEnableGamepadButtonAxisEvents[];
extern const char kGamepadPollingInterval[]; extern const char kGamepadPollingInterval[];
} // namespace switches } // namespace switches
......
...@@ -555,6 +555,10 @@ ...@@ -555,6 +555,10 @@
settable_from_internals: true, settable_from_internals: true,
status: "experimental", status: "experimental",
}, },
{
name: "GamepadButtonAxisEvents",
status: "experimental",
},
{ {
name: "GamepadExtensions", name: "GamepadExtensions",
status: "experimental", status: "experimental",
......
...@@ -27647,9 +27647,11 @@ from previous Chrome versions. ...@@ -27647,9 +27647,11 @@ from previous Chrome versions.
<int value="-1961497025" label="tint-gl-composited-content"/> <int value="-1961497025" label="tint-gl-composited-content"/>
<int value="-1961062505" label="VrBrowsingInCustomTab:disabled"/> <int value="-1961062505" label="VrBrowsingInCustomTab:disabled"/>
<int value="-1960567385" label="KeepPrefetchedContentSuggestions:enabled"/> <int value="-1960567385" label="KeepPrefetchedContentSuggestions:enabled"/>
<int value="-1958315092" label="EnableGamepadButtonAxisEvents:disabled"/>
<int value="-1957328398" label="MacSystemShareMenu:disabled"/> <int value="-1957328398" label="MacSystemShareMenu:disabled"/>
<int value="-1956747298" label="LayeredAPI:enabled"/> <int value="-1956747298" label="LayeredAPI:enabled"/>
<int value="-1956349722" label="disable-smooth-scrolling"/> <int value="-1956349722" label="disable-smooth-scrolling"/>
<int value="-1955923385" label="EnableGamepadButtonAxisEvents:enabled"/>
<int value="-1948540128" label="disable-webrtc-hw-encoding (deprecated)"/> <int value="-1948540128" label="disable-webrtc-hw-encoding (deprecated)"/>
<int value="-1946595906" label="enable-push-api-background-mode"/> <int value="-1946595906" label="enable-push-api-background-mode"/>
<int value="-1946522787" label="VrCustomTabBrowsing:disabled"/> <int value="-1946522787" label="VrCustomTabBrowsing:disabled"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment