2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-04-24 01:05:29 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/GamepadMonitoring.h"
|
2016-06-28 01:25:00 +03:00
|
|
|
#include "mozilla/dom/GamepadPlatformService.h"
|
|
|
|
#include "mozilla/ipc/BackgroundParent.h"
|
|
|
|
|
|
|
|
using namespace mozilla::ipc;
|
2015-04-24 01:05:29 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
void MaybeStopGamepadMonitoring() {
|
2016-06-28 01:25:00 +03:00
|
|
|
AssertIsOnBackgroundThread();
|
2016-06-28 01:27:00 +03:00
|
|
|
RefPtr<GamepadPlatformService> service =
|
2016-06-28 01:25:00 +03:00
|
|
|
GamepadPlatformService::GetParentService();
|
|
|
|
MOZ_ASSERT(service);
|
|
|
|
if (service->HasGamepadListeners()) {
|
|
|
|
return;
|
2015-04-24 01:05:29 +03:00
|
|
|
}
|
|
|
|
StopGamepadMonitoring();
|
2016-06-28 01:25:00 +03:00
|
|
|
service->ResetGamepadIndexes();
|
|
|
|
service->MaybeShutdown();
|
2015-04-24 01:05:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|