Commit e4548b72 authored by Jacob DeWitt's avatar Jacob DeWitt Committed by Commit Bot

Change Gamepad.index to signed int to match spec.

This hasn't been an issue since Gamepads on the navigator array should
always have index >= 0. However, WebXR Gamepads that are not on the
navigator array must have an index of -1.

Bug: 950202
Change-Id: Ia3abd606ae491cbdc738fc7a0c8fbde9eaf57e43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1721057Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681885}
parent 8c4810e0
......@@ -34,7 +34,7 @@
namespace blink {
Gamepad::Gamepad(Client* client,
unsigned index,
int index,
base::TimeTicks time_origin,
base::TimeTicks time_floor)
: client_(client),
......
......@@ -52,7 +52,7 @@ class MODULES_EXPORT Gamepad final : public ScriptWrappable {
};
Gamepad(Client* client,
unsigned index,
int index,
base::TimeTicks time_origin,
base::TimeTicks time_floor);
~Gamepad() override;
......@@ -64,7 +64,7 @@ class MODULES_EXPORT Gamepad final : public ScriptWrappable {
const String& id() const { return id_; }
void SetId(const String& id) { id_ = id; }
unsigned index() const { return index_; }
int index() const { return index_; }
bool connected() const { return connected_; }
void SetConnected(bool val) { connected_ = val; }
......@@ -109,7 +109,7 @@ class MODULES_EXPORT Gamepad final : public ScriptWrappable {
String id_;
// The index of this gamepad within the GamepadList.
const unsigned index_;
const int index_;
// True if this gamepad was still connected when gamepad state was captured.
bool connected_;
......
......@@ -43,7 +43,7 @@ enum GamepadMappingType {
// https://w3c.github.io/gamepad/#gamepad-interface
interface Gamepad {
readonly attribute DOMString id;
readonly attribute unsigned long index;
readonly attribute long index;
readonly attribute boolean connected;
readonly attribute DOMHighResTimeStamp timestamp;
readonly attribute GamepadMappingType mapping;
......
......@@ -149,11 +149,12 @@ GamepadHapticActuator* NavigatorGamepad::GetVibrationActuatorForGamepad(
return nullptr;
}
uint32_t pad_index = gamepad.index();
if (!gamepad.HasVibrationActuator()) {
return nullptr;
}
int pad_index = gamepad.index();
DCHECK_GE(pad_index, 0);
if (!vibration_actuators_[pad_index]) {
ExecutionContext* context =
DomWindow() ? DomWindow()->GetExecutionContext() : nullptr;
......
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