Chromium Code Reviews| Index: components/exo/gamepad.cc |
| diff --git a/components/exo/gamepad.cc b/components/exo/gamepad.cc |
| index b997045dd5a4c665c6c3a9e15cb8e3c7959977d3..0b6820ac00f3b47576c05556e73543850ee705c5 100644 |
| --- a/components/exo/gamepad.cc |
| +++ b/components/exo/gamepad.cc |
| @@ -16,7 +16,8 @@ |
| #include "components/exo/shell_surface.h" |
| #include "components/exo/surface.h" |
| #include "device/gamepad/gamepad_data_fetcher.h" |
| -#include "device/gamepad/gamepad_platform_data_fetcher.h" |
| +#include "device/gamepad/gamepad_pad_state_provider.h" |
| +#include "device/gamepad/gamepad_platform_data_fetcher_linux.h" |
| #include "ui/aura/client/focus_client.h" |
| #include "ui/aura/window.h" |
| @@ -30,7 +31,7 @@ bool GamepadButtonValuesAreEqual(double a, double b) { |
| std::unique_ptr<device::GamepadDataFetcher> CreateGamepadPlatformDataFetcher() { |
| return std::unique_ptr<device::GamepadDataFetcher>( |
| - new device::GamepadPlatformDataFetcher()); |
| + new device::GamepadPlatformDataFetcherLinux()); |
| } |
| // Time between gamepad polls in milliseconds. |
| @@ -45,7 +46,8 @@ constexpr unsigned kPollingTimeIntervalMs = 16; |
| // This class is reference counted to allow it to shut down safely on the |
| // polling thread even if the Gamepad has been destroyed on the origin thread. |
| class Gamepad::ThreadSafeGamepadChangeFetcher |
| - : public base::RefCountedThreadSafe< |
| + : public device::GamepadPadStateProvider, |
| + public base::RefCountedThreadSafe< |
| Gamepad::ThreadSafeGamepadChangeFetcher> { |
| public: |
| using ProcessGamepadChangesCallback = |
| @@ -74,7 +76,7 @@ class Gamepad::ThreadSafeGamepadChangeFetcher |
| private: |
| friend class base::RefCountedThreadSafe<ThreadSafeGamepadChangeFetcher>; |
| - virtual ~ThreadSafeGamepadChangeFetcher() {} |
| + ~ThreadSafeGamepadChangeFetcher() override {} |
| // Enables or disables polling. |
| void EnablePollingOnPollingThread(bool enabled) { |
| @@ -84,6 +86,7 @@ class Gamepad::ThreadSafeGamepadChangeFetcher |
| if (is_enabled_) { |
| if (!fetcher_) { |
| fetcher_ = create_fetcher_callback_.Run(); |
| + InitializeDataFetcher(fetcher_.get()); |
| DCHECK(fetcher_); |
| } |
| SchedulePollOnPollingThread(); |
| @@ -119,7 +122,22 @@ class Gamepad::ThreadSafeGamepadChangeFetcher |
| DCHECK(fetcher_); |
| blink::WebGamepads new_state = state_; |
| - fetcher_->GetGamepadData(&new_state, false); |
| + fetcher_->GetGamepadData(false); |
|
reveman
2016/08/07 16:45:43
nit: not new to this patch but can you add (false
|
| + |
| + new_state.length = 0; |
| + device::PadState& pad_state = pad_states_.get()[0]; |
| + |
| + if (!pad_state.active_state && |
|
reveman
2016/08/07 16:45:43
nit: I don't really understand this part. Can you
|
| + pad_state.source != device::GAMEPAD_SOURCE_NONE) { |
| + ClearPadState(pad_state); |
| + } |
| + |
| + MapAndSanitizeGamepadData(&pad_state, &new_state.items[0], false); |
|
reveman
2016/08/07 16:45:43
nit: false /* name */ here too
|
| + |
| + if (pad_state.active_state) { |
|
reveman
2016/08/07 16:45:43
nit: also don't understand this. if active_state i
|
| + new_state.length++; |
| + pad_state.active_state = device::GAMEPAD_INACTIVE; |
| + } |
| if (std::max(new_state.length, state_.length) > 0) { |
| if (new_state.items[0].connected != state_.items[0].connected || |