Commit 65f77d1f authored by Jacob DeWitt's avatar Jacob DeWitt Committed by Commit Bot

Remove GvrGamepadDataFetcher

That class is specific to the Gamepad API integration that was used by
WebVR, so we can remove it now.

Bug: 1017848
Change-Id: I8b3022fbf59bd12ead6678b39b744efb2e57f428
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888120
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711473}
parent 2ff69e37
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "device/vr/android/gvr/cardboard_gamepad_data_fetcher.h" #include "device/vr/android/gvr/cardboard_gamepad_data_fetcher.h"
#include "device/vr/android/gvr/gvr_device.h" #include "device/vr/android/gvr/gvr_device.h"
#include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
#include "gpu/command_buffer/common/mailbox.h" #include "gpu/command_buffer/common/mailbox.h"
#include "services/device/public/mojom/constants.mojom.h" #include "services/device/public/mojom/constants.mojom.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -438,15 +437,11 @@ void VrShell::ToggleGvrGamepad(bool enabled) { ...@@ -438,15 +437,11 @@ void VrShell::ToggleGvrGamepad(bool enabled) {
device::GvrDevice* gvr_device = delegate_provider_->GetGvrDevice(); device::GvrDevice* gvr_device = delegate_provider_->GetGvrDevice();
if (!gvr_device) if (!gvr_device)
return; return;
device::GamepadDataFetcherManager::GetInstance()->AddFactory(
new device::GvrGamepadDataFetcher::Factory(this, gvr_device->GetId()));
gvr_gamepad_source_active_ = true; gvr_gamepad_source_active_ = true;
} else { } else {
DCHECK(gvr_gamepad_source_active_); DCHECK(gvr_gamepad_source_active_);
device::GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( device::GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
device::GAMEPAD_SOURCE_GVR); device::GAMEPAD_SOURCE_GVR);
gvr_gamepad_data_fetcher_ = nullptr;
gvr_gamepad_source_active_ = false; gvr_gamepad_source_active_ = false;
} }
} }
...@@ -1105,15 +1100,6 @@ void VrShell::ProcessDialogGesture(std::unique_ptr<InputEvent> event) { ...@@ -1105,15 +1100,6 @@ void VrShell::ProcessDialogGesture(std::unique_ptr<InputEvent> event) {
void VrShell::UpdateGamepadData(device::GvrGamepadData pad) { void VrShell::UpdateGamepadData(device::GvrGamepadData pad) {
if (gvr_gamepad_source_active_ != pad.connected) if (gvr_gamepad_source_active_ != pad.connected)
ToggleGvrGamepad(pad.connected); ToggleGvrGamepad(pad.connected);
if (gvr_gamepad_data_fetcher_)
gvr_gamepad_data_fetcher_->SetGamepadData(pad);
}
void VrShell::RegisterGvrGamepadDataFetcher(
device::GvrGamepadDataFetcher* fetcher) {
DVLOG(1) << __FUNCTION__ << "(" << fetcher << ")";
gvr_gamepad_data_fetcher_ = fetcher;
} }
void VrShell::RegisterCardboardGamepadDataFetcher( void VrShell::RegisterCardboardGamepadDataFetcher(
......
...@@ -259,7 +259,6 @@ class VrShell : device::GvrGamepadDataProvider, ...@@ -259,7 +259,6 @@ class VrShell : device::GvrGamepadDataProvider,
// device::GvrGamepadDataProvider implementation. // device::GvrGamepadDataProvider implementation.
void UpdateGamepadData(device::GvrGamepadData) override; void UpdateGamepadData(device::GvrGamepadData) override;
void RegisterGvrGamepadDataFetcher(device::GvrGamepadDataFetcher*) override;
// device::CardboardGamepadDataProvider implementation. // device::CardboardGamepadDataProvider implementation.
void RegisterCardboardGamepadDataFetcher( void RegisterCardboardGamepadDataFetcher(
...@@ -383,7 +382,6 @@ class VrShell : device::GvrGamepadDataProvider, ...@@ -383,7 +382,6 @@ class VrShell : device::GvrGamepadDataProvider,
// Registered fetchers, must remain alive for UpdateGamepadData calls. // Registered fetchers, must remain alive for UpdateGamepadData calls.
// That's ok since the fetcher is only destroyed from VrShell's destructor. // That's ok since the fetcher is only destroyed from VrShell's destructor.
device::GvrGamepadDataFetcher* gvr_gamepad_data_fetcher_ = nullptr;
device::CardboardGamepadDataFetcher* cardboard_gamepad_data_fetcher_ = device::CardboardGamepadDataFetcher* cardboard_gamepad_data_fetcher_ =
nullptr; nullptr;
int64_t cardboard_gamepad_timer_ = 0; int64_t cardboard_gamepad_timer_ = 0;
......
...@@ -68,8 +68,6 @@ if (enable_vr) { ...@@ -68,8 +68,6 @@ if (enable_vr) {
"android/gvr/gvr_device.h", "android/gvr/gvr_device.h",
"android/gvr/gvr_device_provider.cc", "android/gvr/gvr_device_provider.cc",
"android/gvr/gvr_device_provider.h", "android/gvr/gvr_device_provider.h",
"android/gvr/gvr_gamepad_data_fetcher.cc",
"android/gvr/gvr_gamepad_data_fetcher.h",
"android/gvr/gvr_gamepad_data_provider.h", "android/gvr/gvr_gamepad_data_provider.h",
"android/gvr/gvr_utils.cc", "android/gvr/gvr_utils.cc",
"android/gvr/gvr_utils.h", "android/gvr/gvr_utils.h",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "device/gamepad/public/cpp/gamepads.h"
#include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
#include "ui/gfx/geometry/quaternion.h"
namespace device {
GvrGamepadDataFetcher::Factory::Factory(GvrGamepadDataProvider* data_provider,
mojom::XRDeviceId display_id)
: data_provider_(data_provider), display_id_(display_id) {
DVLOG(1) << __FUNCTION__ << "=" << this;
}
GvrGamepadDataFetcher::Factory::~Factory() {
DVLOG(1) << __FUNCTION__ << "=" << this;
}
std::unique_ptr<GamepadDataFetcher>
GvrGamepadDataFetcher::Factory::CreateDataFetcher() {
return std::make_unique<GvrGamepadDataFetcher>(data_provider_, display_id_);
}
GamepadSource GvrGamepadDataFetcher::Factory::source() {
return GAMEPAD_SOURCE_GVR;
}
GvrGamepadDataFetcher::GvrGamepadDataFetcher(
GvrGamepadDataProvider* data_provider,
mojom::XRDeviceId display_id)
: display_id_(display_id) {
// Called on UI thread.
DVLOG(1) << __FUNCTION__ << "=" << this;
data_provider->RegisterGvrGamepadDataFetcher(this);
}
GvrGamepadDataFetcher::~GvrGamepadDataFetcher() {
DVLOG(1) << __FUNCTION__ << "=" << this;
}
GamepadSource GvrGamepadDataFetcher::source() {
return GAMEPAD_SOURCE_GVR;
}
void GvrGamepadDataFetcher::OnAddedToProvider() {
PauseHint(false);
}
void GvrGamepadDataFetcher::SetGamepadData(GvrGamepadData data) {
// Called from UI thread.
gamepad_data_ = data;
}
void GvrGamepadDataFetcher::GetGamepadData(bool devices_changed_hint) {
// Called from gamepad polling thread.
PadState* state = GetPadState(0);
if (!state)
return;
// Take a snapshot of the asynchronously updated gamepad data.
// TODO(bajones): ensure consistency?
GvrGamepadData provided_data = gamepad_data_;
Gamepad& pad = state->data;
if (!state->is_initialized) {
state->is_initialized = true;
// This is the first time we've seen this device, so do some one-time
// initialization
pad.mapping = GamepadMapping::kNone;
pad.SetID(base::UTF8ToUTF16("Daydream Controller"));
pad.buttons_length = 1;
pad.axes_length = 2;
pad.display_id = static_cast<unsigned int>(display_id_);
pad.is_xr = true;
pad.hand =
provided_data.right_handed ? GamepadHand::kRight : GamepadHand::kLeft;
}
pad.connected = provided_data.connected;
pad.timestamp = CurrentTimeInMicroseconds();
if (provided_data.is_touching) {
gfx::Vector2dF touch_position = provided_data.touch_pos;
pad.axes[0] = (touch_position.x() * 2.0f) - 1.0f;
pad.axes[1] = (touch_position.y() * 2.0f) - 1.0f;
} else {
pad.axes[0] = 0.0f;
pad.axes[1] = 0.0f;
}
pad.buttons[0].touched = provided_data.is_touching;
pad.buttons[0].pressed = provided_data.controller_button_pressed;
pad.buttons[0].value = pad.buttons[0].pressed ? 1.0f : 0.0f;
pad.pose.not_null = true;
pad.pose.has_orientation = true;
pad.pose.has_position = false;
gfx::Quaternion orientation = provided_data.orientation;
pad.pose.orientation.not_null = true;
pad.pose.orientation.x = orientation.x();
pad.pose.orientation.y = orientation.y();
pad.pose.orientation.z = orientation.z();
pad.pose.orientation.w = orientation.w();
gfx::Vector3dF accel = provided_data.accel;
pad.pose.linear_acceleration.not_null = true;
pad.pose.linear_acceleration.x = accel.x();
pad.pose.linear_acceleration.y = accel.y();
pad.pose.linear_acceleration.z = accel.z();
gfx::Vector3dF gyro = provided_data.gyro;
pad.pose.angular_velocity.not_null = true;
pad.pose.angular_velocity.x = gyro.x();
pad.pose.angular_velocity.y = gyro.y();
pad.pose.angular_velocity.z = gyro.z();
}
void GvrGamepadDataFetcher::PauseHint(bool paused) {}
} // namespace device
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_FETCHER_H_
#define DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_FETCHER_H_
#include <string>
#include "device/gamepad/gamepad_data_fetcher.h"
#include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_export.h"
namespace device {
class DEVICE_VR_EXPORT GvrGamepadDataFetcher : public GamepadDataFetcher {
public:
class Factory : public GamepadDataFetcherFactory {
public:
Factory(GvrGamepadDataProvider*, mojom::XRDeviceId display_id);
~Factory() override;
std::unique_ptr<GamepadDataFetcher> CreateDataFetcher() override;
GamepadSource source() override;
private:
GvrGamepadDataProvider* data_provider_;
mojom::XRDeviceId display_id_;
};
GvrGamepadDataFetcher(GvrGamepadDataProvider*, mojom::XRDeviceId display_id);
~GvrGamepadDataFetcher() override;
GamepadSource source() override;
void GetGamepadData(bool devices_changed_hint) override;
void PauseHint(bool paused) override;
void OnAddedToProvider() override;
// Called from GvrGamepadDataProvider
void SetGamepadData(GvrGamepadData);
private:
mojom::XRDeviceId display_id_;
GvrGamepadData gamepad_data_;
DISALLOW_COPY_AND_ASSIGN(GvrGamepadDataFetcher);
};
} // namespace device
#endif // DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_FETCHER_H_
...@@ -65,11 +65,6 @@ class GvrGamepadDataProvider { ...@@ -65,11 +65,6 @@ class GvrGamepadDataProvider {
// GamepadDataFetcherFactory with the GamepadDataFetcherManager as // GamepadDataFetcherFactory with the GamepadDataFetcherManager as
// needed. // needed.
virtual void UpdateGamepadData(GvrGamepadData data) = 0; virtual void UpdateGamepadData(GvrGamepadData data) = 0;
// Called by the gamepad data fetcher constructor to register itself
// for receiving data via SetGamepadData. The fetcher must remain
// alive while the provider is calling SetGamepadData on it.
virtual void RegisterGvrGamepadDataFetcher(GvrGamepadDataFetcher*) = 0;
}; };
} // namespace device } // namespace device
......
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