diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/gamepad/ipc/GamepadTestChannelParent.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/gamepad/ipc/GamepadTestChannelParent.cpp')
-rw-r--r-- | dom/gamepad/ipc/GamepadTestChannelParent.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/dom/gamepad/ipc/GamepadTestChannelParent.cpp b/dom/gamepad/ipc/GamepadTestChannelParent.cpp new file mode 100644 index 000000000..421447fe0 --- /dev/null +++ b/dom/gamepad/ipc/GamepadTestChannelParent.cpp @@ -0,0 +1,63 @@ +/* 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 "GamepadTestChannelParent.h" + +#include "mozilla/dom/GamepadPlatformService.h" +#include "mozilla/Unused.h" + +namespace mozilla { +namespace dom { + +bool +GamepadTestChannelParent::RecvGamepadTestEvent(const uint32_t& aID, + const GamepadChangeEvent& aEvent) +{ + mozilla::ipc::AssertIsOnBackgroundThread(); + RefPtr<GamepadPlatformService> service = + GamepadPlatformService::GetParentService(); + MOZ_ASSERT(service); + if (aEvent.type() == GamepadChangeEvent::TGamepadAdded) { + const GamepadAdded& a = aEvent.get_GamepadAdded(); + nsCString gamepadID; + LossyCopyUTF16toASCII(a.id(), gamepadID); + uint32_t index = service->AddGamepad(gamepadID.get(), + static_cast<GamepadMappingType>(a.mapping()), + a.num_buttons(), + a.num_axes()); + if (!mShuttingdown) { + Unused << SendReplyGamepadIndex(aID, index); + } + return true; + } + if (aEvent.type() == GamepadChangeEvent::TGamepadRemoved) { + const GamepadRemoved& a = aEvent.get_GamepadRemoved(); + service->RemoveGamepad(a.index()); + return true; + } + if (aEvent.type() == GamepadChangeEvent::TGamepadButtonInformation) { + const GamepadButtonInformation& a = aEvent.get_GamepadButtonInformation(); + service->NewButtonEvent(a.index(), a.button(), a.pressed(), a.value()); + return true; + } + if (aEvent.type() == GamepadChangeEvent::TGamepadAxisInformation) { + const GamepadAxisInformation& a = aEvent.get_GamepadAxisInformation(); + service->NewAxisMoveEvent(a.index(), a.axis(), a.value()); + return true; + } + + NS_WARNING("Unknown event type."); + return false; +} + +bool +GamepadTestChannelParent::RecvShutdownChannel() +{ + mShuttingdown = true; + Unused << Send__delete__(this); + return true; +} + +} // namespace dom +} // namespace mozilla |