Bug 1559843 - Replace VR code endling to LF. r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Tue, 02 Jul 2019 23:40:27 +0000
changeset 540696 043e8cb3c865fbbf9c43afa3d8c592bd2d5082a5
parent 540695 0cc6906b460a158f84c340442dd94d0ddd572763
child 540697 2fbb1aab6c33d6d1d537676307b8dd467beccb7e
push id11529
push userarchaeopteryx@coole-files.de
push dateThu, 04 Jul 2019 15:22:33 +0000
treeherdermozilla-beta@ebb510a784b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1559843
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559843 - Replace VR code endling to LF. r=kip Differential Revision: https://phabricator.services.mozilla.com/D36673
gfx/vr/VRPuppetCommandBuffer.cpp
gfx/vr/VRPuppetCommandBuffer.h
gfx/vr/service/PuppetSession.cpp
gfx/vr/service/PuppetSession.h
gfx/vr/service/binding/OpenVRKnucklesBinding.h
gfx/vr/service/binding/OpenVRViveBinding.h
gfx/vr/service/binding/OpenVRWMRBinding.h
--- a/gfx/vr/VRPuppetCommandBuffer.cpp
+++ b/gfx/vr/VRPuppetCommandBuffer.cpp
@@ -1,512 +1,512 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "VRPuppetCommandBuffer.h"
-#include "prthread.h"
-#include "mozilla/ClearOnShutdown.h"
-
-namespace mozilla {
-namespace gfx {
-
-static StaticRefPtr<VRPuppetCommandBuffer> sVRPuppetCommandBufferSingleton;
-
-VRPuppetCommandBuffer& VRPuppetCommandBuffer::Get() {
-  if (sVRPuppetCommandBufferSingleton == nullptr) {
-    sVRPuppetCommandBufferSingleton = new VRPuppetCommandBuffer();
-    ClearOnShutdown(&sVRPuppetCommandBufferSingleton);
-  }
-  return *sVRPuppetCommandBufferSingleton;
-}
-
-VRPuppetCommandBuffer::VRPuppetCommandBuffer()
-    : mMutex("VRPuppetCommandBuffer::mMutex") {
-  MOZ_COUNT_CTOR(VRPuppetCommandBuffer);
-  MOZ_ASSERT(sVRPuppetCommandBufferSingleton == nullptr);
-  Reset();
-}
-
-VRPuppetCommandBuffer::~VRPuppetCommandBuffer() {
-  MOZ_COUNT_DTOR(VRPuppetCommandBuffer);
-}
-
-void VRPuppetCommandBuffer::Submit(const InfallibleTArray<uint64_t>& aBuffer) {
-  MutexAutoLock lock(mMutex);
-  mBuffer.AppendElements(aBuffer);
-  mEnded = false;
-  mEndedWithTimeout = false;
-}
-
-bool VRPuppetCommandBuffer::HasEnded() {
-  MutexAutoLock lock(mMutex);
-  return mEnded;
-}
-
-void VRPuppetCommandBuffer::Reset() {
-  MutexAutoLock lock(mMutex);
-  memset(&mPendingState, 0, sizeof(VRSystemState));
-  memset(&mCommittedState, 0, sizeof(VRSystemState));
-  for (int iControllerIdx = 0; iControllerIdx < kVRControllerMaxCount;
-       iControllerIdx++) {
-    for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
-      mHapticPulseRemaining[iControllerIdx][iHaptic] = 0.0f;
-      mHapticPulseIntensity[iControllerIdx][iHaptic] = 0.0f;
-    }
-  }
-  mDataOffset = 0;
-  mPresentationRequested = false;
-  mFrameSubmitted = false;
-  mFrameAccepted = false;
-  mTimeoutDuration = 10.0f;
-  mWaitRemaining = 0.0f;
-  mBlockedTime = 0.0f;
-  mTimerElapsed = 0.0f;
-  mEnded = true;
-  mEndedWithTimeout = false;
-  mLastRunTimestamp = TimeStamp();
-  mTimerSamples.Clear();
-  mBuffer.Clear();
-}
-
-bool VRPuppetCommandBuffer::RunCommand(uint64_t aCommand, double aDeltaTime) {
-  /**
-   * Run a single command.  If the command is blocking on a state change and
-   * can't be executed, return false.
-   *
-   * VRPuppetCommandBuffer::RunCommand is only called by
-   *VRPuppetCommandBuffer::Run(), which is already holding the mutex.
-   *
-   * Note that VRPuppetCommandBuffer::RunCommand may potentially be called >1000
-   *times per frame. It might not hurt to add an assert here, but we should
-   *avoid adding code which may potentially malloc (eg string handling) even for
-   *debug builds here.  This function will need to be reasonably fast, even in
-   *debug builds which will be using it during tests.
-   **/
-  switch ((VRPuppet_Command)(aCommand & 0xff00000000000000)) {
-    case VRPuppet_Command::VRPuppet_End:
-      CompleteTest(false);
-      break;
-    case VRPuppet_Command::VRPuppet_ClearAll:
-      memset(&mPendingState, 0, sizeof(VRSystemState));
-      memset(&mCommittedState, 0, sizeof(VRSystemState));
-      mPresentationRequested = false;
-      mFrameSubmitted = false;
-      mFrameAccepted = false;
-      break;
-    case VRPuppet_Command::VRPuppet_ClearController: {
-      uint8_t controllerIdx = aCommand & 0x00000000000000ff;
-      if (controllerIdx < kVRControllerMaxCount) {
-        mPendingState.controllerState[controllerIdx].Clear();
-      }
-    } break;
-    case VRPuppet_Command::VRPuppet_Timeout:
-      mTimeoutDuration = (double)(aCommand & 0x00000000ffffffff) / 1000.0f;
-      break;
-    case VRPuppet_Command::VRPuppet_Wait:
-      if (mWaitRemaining == 0.0f) {
-        mWaitRemaining = (double)(aCommand & 0x00000000ffffffff) / 1000.0f;
-        // Wait timer started, block
-        return false;
-      }
-      mWaitRemaining -= aDeltaTime;
-      if (mWaitRemaining > 0.0f) {
-        // Wait timer still running, block
-        return false;
-      }
-      // Wait timer has elapsed, unblock
-      mWaitRemaining = 0.0f;
-      break;
-    case VRPuppet_Command::VRPuppet_WaitSubmit:
-      if (!mFrameSubmitted) {
-        return false;
-      }
-      break;
-    case VRPuppet_Command::VRPuppet_CaptureFrame:
-      // TODO - Capture the frame and record the output (Bug 1555180)
-      break;
-    case VRPuppet_Command::VRPuppet_AcknowledgeFrame:
-      mFrameSubmitted = false;
-      mFrameAccepted = true;
-      break;
-    case VRPuppet_Command::VRPuppet_RejectFrame:
-      mFrameSubmitted = false;
-      mFrameAccepted = false;
-      break;
-    case VRPuppet_Command::VRPuppet_WaitPresentationStart:
-      if (!mPresentationRequested) {
-        return false;
-      }
-      break;
-    case VRPuppet_Command::VRPuppet_WaitPresentationEnd:
-      if (mPresentationRequested) {
-        return false;
-      }
-      break;
-    case VRPuppet_Command::VRPuppet_WaitHapticIntensity: {
-      // 0x0800cchhvvvvvvvv - VRPuppet_WaitHapticIntensity(c, h, v)
-      uint8_t iControllerIdx = (aCommand & 0x0000ff0000000000) >> 40;
-      if (iControllerIdx >= kVRControllerMaxCount) {
-        // Puppet test is broken, ensure it fails
-        return false;
-      }
-      uint8_t iHapticIdx = (aCommand & 0x000000ff00000000) >> 32;
-      if (iHapticIdx >= kNumPuppetHaptics) {
-        // Puppet test is broken, ensure it fails
-        return false;
-      }
-      uint32_t iHapticIntensity =
-          aCommand & 0x00000000ffffffff;  // interpreted as 16.16 fixed point
-
-      SimulateHaptics(aDeltaTime);
-      uint64_t iCurrentIntensity =
-          round(mHapticPulseIntensity[iControllerIdx][iHapticIdx] *
-                (1 << 16));  // convert to 16.16 fixed point
-      if (iCurrentIntensity > 0xffffffff) {
-        iCurrentIntensity = 0xffffffff;
-      }
-      if (iCurrentIntensity != iHapticIntensity) {
-        return false;
-      }
-    } break;
-
-    case VRPuppet_Command::VRPuppet_StartTimer:
-      mTimerElapsed = 0.0f;
-      break;
-    case VRPuppet_Command::VRPuppet_StopTimer:
-      mTimerSamples.AppendElements(mTimerElapsed);
-      // TODO - Return the timer samples to Javascript once the command buffer
-      // is complete (Bug 1555182)
-      break;
-
-    case VRPuppet_Command::VRPuppet_UpdateDisplay:
-      mDataOffset = (uint8_t*)&mPendingState.displayState -
-                    (uint8_t*)&mPendingState + (aCommand & 0x00000000ffffffff);
-      break;
-    case VRPuppet_Command::VRPuppet_UpdateSensor:
-      mDataOffset = (uint8_t*)&mPendingState.sensorState -
-                    (uint8_t*)&mPendingState + (aCommand & 0x00000000ffffffff);
-      break;
-    case VRPuppet_Command::VRPuppet_UpdateControllers:
-      mDataOffset = (uint8_t*)&mPendingState
-                        .controllerState[aCommand & 0x00000000000000ff] -
-                    (uint8_t*)&mPendingState + (aCommand & 0x00000000ffffffff);
-      break;
-    case VRPuppet_Command::VRPuppet_Commit:
-      memcpy(&mCommittedState, &mPendingState, sizeof(VRSystemState));
-      break;
-
-    case VRPuppet_Command::VRPuppet_Data7:
-      WriteData((aCommand & 0x00ff000000000000) >> 48);
-      MOZ_FALLTHROUGH;
-      // Purposefully, no break
-    case VRPuppet_Command::VRPuppet_Data6:
-      WriteData((aCommand & 0x0000ff0000000000) >> 40);
-      MOZ_FALLTHROUGH;
-      // Purposefully, no break
-    case VRPuppet_Command::VRPuppet_Data5:
-      WriteData((aCommand & 0x000000ff00000000) >> 32);
-      MOZ_FALLTHROUGH;
-      // Purposefully, no break
-    case VRPuppet_Command::VRPuppet_Data4:
-      WriteData((aCommand & 0x00000000ff000000) >> 24);
-      MOZ_FALLTHROUGH;
-      // Purposefully, no break
-    case VRPuppet_Command::VRPuppet_Data3:
-      WriteData((aCommand & 0x0000000000ff0000) >> 16);
-      MOZ_FALLTHROUGH;
-      // Purposefully, no break
-    case VRPuppet_Command::VRPuppet_Data2:
-      WriteData((aCommand & 0x000000000000ff00) >> 8);
-      MOZ_FALLTHROUGH;
-      // Purposefully, no break
-    case VRPuppet_Command::VRPuppet_Data1:
-      WriteData(aCommand & 0x00000000000000ff);
-      break;
-  }
-  return true;
-}
-
-void VRPuppetCommandBuffer::WriteData(uint8_t aData) {
-  if (mDataOffset && mDataOffset < sizeof(VRSystemState)) {
-    ((uint8_t*)&mPendingState)[mDataOffset++] = aData;
-  }
-}
-
-void VRPuppetCommandBuffer::Run() {
-  MutexAutoLock lock(mMutex);
-  TimeStamp now = TimeStamp::Now();
-  double deltaTime = 0.0f;
-  if (!mLastRunTimestamp.IsNull()) {
-    deltaTime = (now - mLastRunTimestamp).ToSeconds();
-  }
-  mLastRunTimestamp = now;
-  mTimerElapsed += deltaTime;
-  size_t transactionLength = 0;
-  while (transactionLength < mBuffer.Length() && !mEnded) {
-    if (RunCommand(mBuffer[transactionLength], deltaTime)) {
-      mBlockedTime = 0.0f;
-      transactionLength++;
-    } else {
-      mBlockedTime += deltaTime;
-      if (mBlockedTime > mTimeoutDuration) {
-        CompleteTest(true);
-      }
-      // If a command is blocked, we don't increment transactionLength,
-      // allowing the command to be retried on the next cycle
-      break;
-    }
-  }
-  mBuffer.RemoveElementsAt(0, transactionLength);
-}
-
-void VRPuppetCommandBuffer::Run(VRSystemState& aState) {
-  Run();
-  // We don't want to stomp over some members
-  bool bEnumerationCompleted = aState.enumerationCompleted;
-  bool bShutdown = aState.displayState.shutdown;
-  uint32_t minRestartInterval = aState.displayState.minRestartInterval;
-
-  // Overwrite it all
-  memcpy(&aState, &mCommittedState, sizeof(VRSystemState));
-
-  // Restore the members
-  aState.enumerationCompleted = bEnumerationCompleted;
-  aState.displayState.shutdown = bShutdown;
-  aState.displayState.minRestartInterval = minRestartInterval;
-}
-
-void VRPuppetCommandBuffer::StartPresentation() {
-  mPresentationRequested = true;
-  Run();
-}
-
-void VRPuppetCommandBuffer::StopPresentation() {
-  mPresentationRequested = false;
-  Run();
-}
-
-bool VRPuppetCommandBuffer::SubmitFrame() {
-  // Emulate blocking behavior of various XR API's as
-  // described by puppet script
-  mFrameSubmitted = true;
-  mFrameAccepted = false;
-  while (true) {
-    Run();
-    if (!mFrameSubmitted || mEnded) {
-      break;
-    }
-    PR_Sleep(PR_INTERVAL_NO_WAIT);  // Yield
-  }
-
-  return mFrameAccepted;
-}
-
-void VRPuppetCommandBuffer::VibrateHaptic(uint32_t aControllerIdx,
-                                          uint32_t aHapticIndex,
-                                          float aIntensity, float aDuration) {
-  if (aHapticIndex >= kNumPuppetHaptics ||
-      aControllerIdx >= kVRControllerMaxCount) {
-    return;
-  }
-
-  // We must Run() before and after updating haptic state to avoid script
-  // deadlocks
-  // The deadlocks would be caused by scripts that include two
-  // VRPuppet_WaitHapticIntensity commands.  If
-  // VRPuppetCommandBuffer::VibrateHaptic() is called twice without advancing
-  // through the command buffer with VRPuppetCommandBuffer::Run() in between,
-  // the first VRPuppet_WaitHapticInensity may not see the transient value that
-  // it is waiting for, thus blocking forever and deadlocking the script.
-  Run();
-  mHapticPulseRemaining[aControllerIdx][aHapticIndex] = aDuration;
-  mHapticPulseIntensity[aControllerIdx][aHapticIndex] = aIntensity;
-  Run();
-}
-
-void VRPuppetCommandBuffer::StopVibrateHaptic(uint32_t aControllerIdx) {
-  if (aControllerIdx >= kVRControllerMaxCount) {
-    return;
-  }
-  // We must Run() before and after updating haptic state to avoid script
-  // deadlocks
-  Run();
-  for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
-    mHapticPulseRemaining[aControllerIdx][iHaptic] = 0.0f;
-    mHapticPulseIntensity[aControllerIdx][iHaptic] = 0.0f;
-  }
-  Run();
-}
-
-void VRPuppetCommandBuffer::StopAllHaptics() {
-  // We must Run() before and after updating haptic state to avoid script
-  // deadlocks
-  Run();
-  for (int iControllerIdx = 0; iControllerIdx < kVRControllerMaxCount;
-       iControllerIdx++) {
-    for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
-      mHapticPulseRemaining[iControllerIdx][iHaptic] = 0.0f;
-      mHapticPulseIntensity[iControllerIdx][iHaptic] = 0.0f;
-    }
-  }
-  Run();
-}
-
-void VRPuppetCommandBuffer::SimulateHaptics(double aDeltaTime) {
-  for (int iControllerIdx = 0; iControllerIdx < kVRControllerMaxCount;
-       iControllerIdx++) {
-    for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
-      if (mHapticPulseIntensity[iControllerIdx][iHaptic] > 0.0f) {
-        mHapticPulseRemaining[iControllerIdx][iHaptic] -= aDeltaTime;
-        if (mHapticPulseRemaining[iControllerIdx][iHaptic] <= 0.0f) {
-          mHapticPulseRemaining[iControllerIdx][iHaptic] = 0.0f;
-          mHapticPulseIntensity[iControllerIdx][iHaptic] = 0.0f;
-        }
-      }
-    }
-  }
-}
-
-void VRPuppetCommandBuffer::CompleteTest(bool aTimedOut) {
-  mEndedWithTimeout = aTimedOut;
-  mEnded = true;
-}
-
-/**
- *  Generates a sequence of VRPuppet_Data# commands, as described
- *  in VRPuppetCommandBuffer.h, to encode the changes to be made to
- *  a "destination" structure to match the "source" structure.
- *  As the commands are encoded, the destination structure is updated
- *  to match the source.
- *
- * @param aBuffer
- *     The buffer in which the commands will be appended.
- * @param aSrcStart
- *     Byte pointer to the start of the structure that
- *     will be copied from.
- * @param aDstStart
- *     Byte pointer to the start of the structure that
- *     will be copied to.
- * @param aLength
- *     Length of the structure that will be copied.
- * @param aUpdateCommand
- *     VRPuppet_... command indicating which structure is being
- *     copied:
- *     VRPuppet_Command::VRPuppet_UpdateDisplay:
- *         A single VRDisplayState struct
- *     VRPuppet_Command::VRPuppet_UpdateSensor:
- *         A single VRHMDSensorState struct
- *     VRPuppet_Command::VRPuppet_UpdateControllers:
- *         An array of VRControllerState structs with a
- *         count of kVRControllerMaxCount
- */
-void VRPuppetCommandBuffer::EncodeStruct(nsTArray<uint64_t>& aBuffer,
-                                         uint8_t* aSrcStart, uint8_t* aDstStart,
-                                         size_t aLength,
-                                         VRPuppet_Command aUpdateCommand) {
-  // Naive implementation, but will not be executed in realtime, so will not
-  // affect test timer results. Could be improved to avoid unaligned reads and
-  // to use SSE.
-
-  // Pointer to source byte being compared+copied
-  uint8_t* src = aSrcStart;
-
-  // Pointer to destination byte being compared+copied
-  uint8_t* dst = aDstStart;
-
-  // Number of bytes packed into bufData
-  uint8_t bufLen = 0;
-
-  // 64-bits to be interpreted as up to 7 separate bytes
-  // This will form the lower 56 bits of the command
-  uint64_t bufData = 0;
-
-  // purgebuffer takes the bytes stored in bufData and generates a VRPuppet
-  // command representing those bytes as "VRPuppet Data".
-  // VRPUppet_Data1 encodes 1 byte
-  // VRPuppet_Data2 encodes 2 bytes
-  // and so on, until..
-  // VRPuppet_Data7 encodes 7 bytes
-  // This command is appended to aBuffer, then bufLen and bufData are reset
-  auto purgeBuffer = [&]() {
-    // Only emit a command if there are data bytes in bufData
-    if (bufLen > 0) {
-      MOZ_ASSERT(bufLen <= 7);
-      uint64_t command = (uint64_t)VRPuppet_Command::VRPuppet_Data1;
-      command += ((uint64_t)VRPuppet_Command::VRPuppet_Data2 -
-                  (uint64_t)VRPuppet_Command::VRPuppet_Data1) *
-                 (bufLen - 1);
-      command |= bufData;
-      aBuffer.AppendElement(command);
-      bufLen = 0;
-      bufData = 0;
-    }
-  };
-
-  // Loop through the bytes of the structs.
-  // While copying the struct at aSrcStart to aDstStart,
-  // the differences are encoded as VRPuppet commands and
-  // appended to aBuffer.
-  for (size_t i = 0; i < aLength; i++) {
-    if (*src != *dst) {
-      // This byte is different
-
-      // Copy the byte to the destination
-      *dst = *src;
-
-      if (bufLen == 0) {
-        // This is the start of a new span of changed bytes
-
-        // Output a command to specify the offset of the
-        // span.
-        aBuffer.AppendElement((uint64_t)aUpdateCommand + i);
-
-        // Store this first byte in bufData.
-        // We will batch up to 7 bytes in one VRPuppet_DataXX
-        // command, so we won't emit it yet.
-        bufLen = 1;
-        bufData = *src;
-      } else if (bufLen <= 6) {
-        // This is the continuation of a span of changed bytes.
-        // There is room to add more bytes to bufData.
-
-        // Store the next byte in bufData.
-        // We will batch up to 7 bytes in one VRPuppet_DataXX
-        // command, so we won't emit it yet.
-        bufData = (bufData << 8) | *src;
-        bufLen++;
-      } else {
-        MOZ_ASSERT(bufLen == 7);
-        // This is the continuation of a span of changed bytes.
-        // There are already 7 bytes in bufData, so we must emit
-        // the VRPuppet_Data7 command for the prior bytes before
-        // starting a new command.
-        aBuffer.AppendElement((uint64_t)VRPuppet_Command::VRPuppet_Data7 +
-                              bufData);
-
-        // Store this byte to be included in the next VRPuppet_DataXX
-        // command.
-        bufLen = 1;
-        bufData = *src;
-      }
-    } else {
-      // This byte is the same.
-      // If there are bytes in bufData, the span has now ended and we must
-      // emit a VRPuppet_DataXX command for the accumulated bytes.
-      // purgeBuffer will not emit any commands if there are no bytes
-      // accumulated.
-      purgeBuffer();
-    }
-    // Advance to the next source and destination byte.
-    ++src;
-    ++dst;
-  }
-  // In the event that the very last byte of the structs differ, we must
-  // ensure that the accumulated bytes are emitted as a VRPuppet_DataXX
-  // command.
-  purgeBuffer();
-}
-
-}  // namespace gfx
-}  // namespace mozilla
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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 "VRPuppetCommandBuffer.h"
+#include "prthread.h"
+#include "mozilla/ClearOnShutdown.h"
+
+namespace mozilla {
+namespace gfx {
+
+static StaticRefPtr<VRPuppetCommandBuffer> sVRPuppetCommandBufferSingleton;
+
+VRPuppetCommandBuffer& VRPuppetCommandBuffer::Get() {
+  if (sVRPuppetCommandBufferSingleton == nullptr) {
+    sVRPuppetCommandBufferSingleton = new VRPuppetCommandBuffer();
+    ClearOnShutdown(&sVRPuppetCommandBufferSingleton);
+  }
+  return *sVRPuppetCommandBufferSingleton;
+}
+
+VRPuppetCommandBuffer::VRPuppetCommandBuffer()
+    : mMutex("VRPuppetCommandBuffer::mMutex") {
+  MOZ_COUNT_CTOR(VRPuppetCommandBuffer);
+  MOZ_ASSERT(sVRPuppetCommandBufferSingleton == nullptr);
+  Reset();
+}
+
+VRPuppetCommandBuffer::~VRPuppetCommandBuffer() {
+  MOZ_COUNT_DTOR(VRPuppetCommandBuffer);
+}
+
+void VRPuppetCommandBuffer::Submit(const InfallibleTArray<uint64_t>& aBuffer) {
+  MutexAutoLock lock(mMutex);
+  mBuffer.AppendElements(aBuffer);
+  mEnded = false;
+  mEndedWithTimeout = false;
+}
+
+bool VRPuppetCommandBuffer::HasEnded() {
+  MutexAutoLock lock(mMutex);
+  return mEnded;
+}
+
+void VRPuppetCommandBuffer::Reset() {
+  MutexAutoLock lock(mMutex);
+  memset(&mPendingState, 0, sizeof(VRSystemState));
+  memset(&mCommittedState, 0, sizeof(VRSystemState));
+  for (int iControllerIdx = 0; iControllerIdx < kVRControllerMaxCount;
+       iControllerIdx++) {
+    for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
+      mHapticPulseRemaining[iControllerIdx][iHaptic] = 0.0f;
+      mHapticPulseIntensity[iControllerIdx][iHaptic] = 0.0f;
+    }
+  }
+  mDataOffset = 0;
+  mPresentationRequested = false;
+  mFrameSubmitted = false;
+  mFrameAccepted = false;
+  mTimeoutDuration = 10.0f;
+  mWaitRemaining = 0.0f;
+  mBlockedTime = 0.0f;
+  mTimerElapsed = 0.0f;
+  mEnded = true;
+  mEndedWithTimeout = false;
+  mLastRunTimestamp = TimeStamp();
+  mTimerSamples.Clear();
+  mBuffer.Clear();
+}
+
+bool VRPuppetCommandBuffer::RunCommand(uint64_t aCommand, double aDeltaTime) {
+  /**
+   * Run a single command.  If the command is blocking on a state change and
+   * can't be executed, return false.
+   *
+   * VRPuppetCommandBuffer::RunCommand is only called by
+   *VRPuppetCommandBuffer::Run(), which is already holding the mutex.
+   *
+   * Note that VRPuppetCommandBuffer::RunCommand may potentially be called >1000
+   *times per frame. It might not hurt to add an assert here, but we should
+   *avoid adding code which may potentially malloc (eg string handling) even for
+   *debug builds here.  This function will need to be reasonably fast, even in
+   *debug builds which will be using it during tests.
+   **/
+  switch ((VRPuppet_Command)(aCommand & 0xff00000000000000)) {
+    case VRPuppet_Command::VRPuppet_End:
+      CompleteTest(false);
+      break;
+    case VRPuppet_Command::VRPuppet_ClearAll:
+      memset(&mPendingState, 0, sizeof(VRSystemState));
+      memset(&mCommittedState, 0, sizeof(VRSystemState));
+      mPresentationRequested = false;
+      mFrameSubmitted = false;
+      mFrameAccepted = false;
+      break;
+    case VRPuppet_Command::VRPuppet_ClearController: {
+      uint8_t controllerIdx = aCommand & 0x00000000000000ff;
+      if (controllerIdx < kVRControllerMaxCount) {
+        mPendingState.controllerState[controllerIdx].Clear();
+      }
+    } break;
+    case VRPuppet_Command::VRPuppet_Timeout:
+      mTimeoutDuration = (double)(aCommand & 0x00000000ffffffff) / 1000.0f;
+      break;
+    case VRPuppet_Command::VRPuppet_Wait:
+      if (mWaitRemaining == 0.0f) {
+        mWaitRemaining = (double)(aCommand & 0x00000000ffffffff) / 1000.0f;
+        // Wait timer started, block
+        return false;
+      }
+      mWaitRemaining -= aDeltaTime;
+      if (mWaitRemaining > 0.0f) {
+        // Wait timer still running, block
+        return false;
+      }
+      // Wait timer has elapsed, unblock
+      mWaitRemaining = 0.0f;
+      break;
+    case VRPuppet_Command::VRPuppet_WaitSubmit:
+      if (!mFrameSubmitted) {
+        return false;
+      }
+      break;
+    case VRPuppet_Command::VRPuppet_CaptureFrame:
+      // TODO - Capture the frame and record the output (Bug 1555180)
+      break;
+    case VRPuppet_Command::VRPuppet_AcknowledgeFrame:
+      mFrameSubmitted = false;
+      mFrameAccepted = true;
+      break;
+    case VRPuppet_Command::VRPuppet_RejectFrame:
+      mFrameSubmitted = false;
+      mFrameAccepted = false;
+      break;
+    case VRPuppet_Command::VRPuppet_WaitPresentationStart:
+      if (!mPresentationRequested) {
+        return false;
+      }
+      break;
+    case VRPuppet_Command::VRPuppet_WaitPresentationEnd:
+      if (mPresentationRequested) {
+        return false;
+      }
+      break;
+    case VRPuppet_Command::VRPuppet_WaitHapticIntensity: {
+      // 0x0800cchhvvvvvvvv - VRPuppet_WaitHapticIntensity(c, h, v)
+      uint8_t iControllerIdx = (aCommand & 0x0000ff0000000000) >> 40;
+      if (iControllerIdx >= kVRControllerMaxCount) {
+        // Puppet test is broken, ensure it fails
+        return false;
+      }
+      uint8_t iHapticIdx = (aCommand & 0x000000ff00000000) >> 32;
+      if (iHapticIdx >= kNumPuppetHaptics) {
+        // Puppet test is broken, ensure it fails
+        return false;
+      }
+      uint32_t iHapticIntensity =
+          aCommand & 0x00000000ffffffff;  // interpreted as 16.16 fixed point
+
+      SimulateHaptics(aDeltaTime);
+      uint64_t iCurrentIntensity =
+          round(mHapticPulseIntensity[iControllerIdx][iHapticIdx] *
+                (1 << 16));  // convert to 16.16 fixed point
+      if (iCurrentIntensity > 0xffffffff) {
+        iCurrentIntensity = 0xffffffff;
+      }
+      if (iCurrentIntensity != iHapticIntensity) {
+        return false;
+      }
+    } break;
+
+    case VRPuppet_Command::VRPuppet_StartTimer:
+      mTimerElapsed = 0.0f;
+      break;
+    case VRPuppet_Command::VRPuppet_StopTimer:
+      mTimerSamples.AppendElements(mTimerElapsed);
+      // TODO - Return the timer samples to Javascript once the command buffer
+      // is complete (Bug 1555182)
+      break;
+
+    case VRPuppet_Command::VRPuppet_UpdateDisplay:
+      mDataOffset = (uint8_t*)&mPendingState.displayState -
+                    (uint8_t*)&mPendingState + (aCommand & 0x00000000ffffffff);
+      break;
+    case VRPuppet_Command::VRPuppet_UpdateSensor:
+      mDataOffset = (uint8_t*)&mPendingState.sensorState -
+                    (uint8_t*)&mPendingState + (aCommand & 0x00000000ffffffff);
+      break;
+    case VRPuppet_Command::VRPuppet_UpdateControllers:
+      mDataOffset = (uint8_t*)&mPendingState
+                        .controllerState[aCommand & 0x00000000000000ff] -
+                    (uint8_t*)&mPendingState + (aCommand & 0x00000000ffffffff);
+      break;
+    case VRPuppet_Command::VRPuppet_Commit:
+      memcpy(&mCommittedState, &mPendingState, sizeof(VRSystemState));
+      break;
+
+    case VRPuppet_Command::VRPuppet_Data7:
+      WriteData((aCommand & 0x00ff000000000000) >> 48);
+      MOZ_FALLTHROUGH;
+      // Purposefully, no break
+    case VRPuppet_Command::VRPuppet_Data6:
+      WriteData((aCommand & 0x0000ff0000000000) >> 40);
+      MOZ_FALLTHROUGH;
+      // Purposefully, no break
+    case VRPuppet_Command::VRPuppet_Data5:
+      WriteData((aCommand & 0x000000ff00000000) >> 32);
+      MOZ_FALLTHROUGH;
+      // Purposefully, no break
+    case VRPuppet_Command::VRPuppet_Data4:
+      WriteData((aCommand & 0x00000000ff000000) >> 24);
+      MOZ_FALLTHROUGH;
+      // Purposefully, no break
+    case VRPuppet_Command::VRPuppet_Data3:
+      WriteData((aCommand & 0x0000000000ff0000) >> 16);
+      MOZ_FALLTHROUGH;
+      // Purposefully, no break
+    case VRPuppet_Command::VRPuppet_Data2:
+      WriteData((aCommand & 0x000000000000ff00) >> 8);
+      MOZ_FALLTHROUGH;
+      // Purposefully, no break
+    case VRPuppet_Command::VRPuppet_Data1:
+      WriteData(aCommand & 0x00000000000000ff);
+      break;
+  }
+  return true;
+}
+
+void VRPuppetCommandBuffer::WriteData(uint8_t aData) {
+  if (mDataOffset && mDataOffset < sizeof(VRSystemState)) {
+    ((uint8_t*)&mPendingState)[mDataOffset++] = aData;
+  }
+}
+
+void VRPuppetCommandBuffer::Run() {
+  MutexAutoLock lock(mMutex);
+  TimeStamp now = TimeStamp::Now();
+  double deltaTime = 0.0f;
+  if (!mLastRunTimestamp.IsNull()) {
+    deltaTime = (now - mLastRunTimestamp).ToSeconds();
+  }
+  mLastRunTimestamp = now;
+  mTimerElapsed += deltaTime;
+  size_t transactionLength = 0;
+  while (transactionLength < mBuffer.Length() && !mEnded) {
+    if (RunCommand(mBuffer[transactionLength], deltaTime)) {
+      mBlockedTime = 0.0f;
+      transactionLength++;
+    } else {
+      mBlockedTime += deltaTime;
+      if (mBlockedTime > mTimeoutDuration) {
+        CompleteTest(true);
+      }
+      // If a command is blocked, we don't increment transactionLength,
+      // allowing the command to be retried on the next cycle
+      break;
+    }
+  }
+  mBuffer.RemoveElementsAt(0, transactionLength);
+}
+
+void VRPuppetCommandBuffer::Run(VRSystemState& aState) {
+  Run();
+  // We don't want to stomp over some members
+  bool bEnumerationCompleted = aState.enumerationCompleted;
+  bool bShutdown = aState.displayState.shutdown;
+  uint32_t minRestartInterval = aState.displayState.minRestartInterval;
+
+  // Overwrite it all
+  memcpy(&aState, &mCommittedState, sizeof(VRSystemState));
+
+  // Restore the members
+  aState.enumerationCompleted = bEnumerationCompleted;
+  aState.displayState.shutdown = bShutdown;
+  aState.displayState.minRestartInterval = minRestartInterval;
+}
+
+void VRPuppetCommandBuffer::StartPresentation() {
+  mPresentationRequested = true;
+  Run();
+}
+
+void VRPuppetCommandBuffer::StopPresentation() {
+  mPresentationRequested = false;
+  Run();
+}
+
+bool VRPuppetCommandBuffer::SubmitFrame() {
+  // Emulate blocking behavior of various XR API's as
+  // described by puppet script
+  mFrameSubmitted = true;
+  mFrameAccepted = false;
+  while (true) {
+    Run();
+    if (!mFrameSubmitted || mEnded) {
+      break;
+    }
+    PR_Sleep(PR_INTERVAL_NO_WAIT);  // Yield
+  }
+
+  return mFrameAccepted;
+}
+
+void VRPuppetCommandBuffer::VibrateHaptic(uint32_t aControllerIdx,
+                                          uint32_t aHapticIndex,
+                                          float aIntensity, float aDuration) {
+  if (aHapticIndex >= kNumPuppetHaptics ||
+      aControllerIdx >= kVRControllerMaxCount) {
+    return;
+  }
+
+  // We must Run() before and after updating haptic state to avoid script
+  // deadlocks
+  // The deadlocks would be caused by scripts that include two
+  // VRPuppet_WaitHapticIntensity commands.  If
+  // VRPuppetCommandBuffer::VibrateHaptic() is called twice without advancing
+  // through the command buffer with VRPuppetCommandBuffer::Run() in between,
+  // the first VRPuppet_WaitHapticInensity may not see the transient value that
+  // it is waiting for, thus blocking forever and deadlocking the script.
+  Run();
+  mHapticPulseRemaining[aControllerIdx][aHapticIndex] = aDuration;
+  mHapticPulseIntensity[aControllerIdx][aHapticIndex] = aIntensity;
+  Run();
+}
+
+void VRPuppetCommandBuffer::StopVibrateHaptic(uint32_t aControllerIdx) {
+  if (aControllerIdx >= kVRControllerMaxCount) {
+    return;
+  }
+  // We must Run() before and after updating haptic state to avoid script
+  // deadlocks
+  Run();
+  for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
+    mHapticPulseRemaining[aControllerIdx][iHaptic] = 0.0f;
+    mHapticPulseIntensity[aControllerIdx][iHaptic] = 0.0f;
+  }
+  Run();
+}
+
+void VRPuppetCommandBuffer::StopAllHaptics() {
+  // We must Run() before and after updating haptic state to avoid script
+  // deadlocks
+  Run();
+  for (int iControllerIdx = 0; iControllerIdx < kVRControllerMaxCount;
+       iControllerIdx++) {
+    for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
+      mHapticPulseRemaining[iControllerIdx][iHaptic] = 0.0f;
+      mHapticPulseIntensity[iControllerIdx][iHaptic] = 0.0f;
+    }
+  }
+  Run();
+}
+
+void VRPuppetCommandBuffer::SimulateHaptics(double aDeltaTime) {
+  for (int iControllerIdx = 0; iControllerIdx < kVRControllerMaxCount;
+       iControllerIdx++) {
+    for (int iHaptic = 0; iHaptic < kNumPuppetHaptics; iHaptic++) {
+      if (mHapticPulseIntensity[iControllerIdx][iHaptic] > 0.0f) {
+        mHapticPulseRemaining[iControllerIdx][iHaptic] -= aDeltaTime;
+        if (mHapticPulseRemaining[iControllerIdx][iHaptic] <= 0.0f) {
+          mHapticPulseRemaining[iControllerIdx][iHaptic] = 0.0f;
+          mHapticPulseIntensity[iControllerIdx][iHaptic] = 0.0f;
+        }
+      }
+    }
+  }
+}
+
+void VRPuppetCommandBuffer::CompleteTest(bool aTimedOut) {
+  mEndedWithTimeout = aTimedOut;
+  mEnded = true;
+}
+
+/**
+ *  Generates a sequence of VRPuppet_Data# commands, as described
+ *  in VRPuppetCommandBuffer.h, to encode the changes to be made to
+ *  a "destination" structure to match the "source" structure.
+ *  As the commands are encoded, the destination structure is updated
+ *  to match the source.
+ *
+ * @param aBuffer
+ *     The buffer in which the commands will be appended.
+ * @param aSrcStart
+ *     Byte pointer to the start of the structure that
+ *     will be copied from.
+ * @param aDstStart
+ *     Byte pointer to the start of the structure that
+ *     will be copied to.
+ * @param aLength
+ *     Length of the structure that will be copied.
+ * @param aUpdateCommand
+ *     VRPuppet_... command indicating which structure is being
+ *     copied:
+ *     VRPuppet_Command::VRPuppet_UpdateDisplay:
+ *         A single VRDisplayState struct
+ *     VRPuppet_Command::VRPuppet_UpdateSensor:
+ *         A single VRHMDSensorState struct
+ *     VRPuppet_Command::VRPuppet_UpdateControllers:
+ *         An array of VRControllerState structs with a
+ *         count of kVRControllerMaxCount
+ */
+void VRPuppetCommandBuffer::EncodeStruct(nsTArray<uint64_t>& aBuffer,
+                                         uint8_t* aSrcStart, uint8_t* aDstStart,
+                                         size_t aLength,
+                                         VRPuppet_Command aUpdateCommand) {
+  // Naive implementation, but will not be executed in realtime, so will not
+  // affect test timer results. Could be improved to avoid unaligned reads and
+  // to use SSE.
+
+  // Pointer to source byte being compared+copied
+  uint8_t* src = aSrcStart;
+
+  // Pointer to destination byte being compared+copied
+  uint8_t* dst = aDstStart;
+
+  // Number of bytes packed into bufData
+  uint8_t bufLen = 0;
+
+  // 64-bits to be interpreted as up to 7 separate bytes
+  // This will form the lower 56 bits of the command
+  uint64_t bufData = 0;
+
+  // purgebuffer takes the bytes stored in bufData and generates a VRPuppet
+  // command representing those bytes as "VRPuppet Data".
+  // VRPUppet_Data1 encodes 1 byte
+  // VRPuppet_Data2 encodes 2 bytes
+  // and so on, until..
+  // VRPuppet_Data7 encodes 7 bytes
+  // This command is appended to aBuffer, then bufLen and bufData are reset
+  auto purgeBuffer = [&]() {
+    // Only emit a command if there are data bytes in bufData
+    if (bufLen > 0) {
+      MOZ_ASSERT(bufLen <= 7);
+      uint64_t command = (uint64_t)VRPuppet_Command::VRPuppet_Data1;
+      command += ((uint64_t)VRPuppet_Command::VRPuppet_Data2 -
+                  (uint64_t)VRPuppet_Command::VRPuppet_Data1) *
+                 (bufLen - 1);
+      command |= bufData;
+      aBuffer.AppendElement(command);
+      bufLen = 0;
+      bufData = 0;
+    }
+  };
+
+  // Loop through the bytes of the structs.
+  // While copying the struct at aSrcStart to aDstStart,
+  // the differences are encoded as VRPuppet commands and
+  // appended to aBuffer.
+  for (size_t i = 0; i < aLength; i++) {
+    if (*src != *dst) {
+      // This byte is different
+
+      // Copy the byte to the destination
+      *dst = *src;
+
+      if (bufLen == 0) {
+        // This is the start of a new span of changed bytes
+
+        // Output a command to specify the offset of the
+        // span.
+        aBuffer.AppendElement((uint64_t)aUpdateCommand + i);
+
+        // Store this first byte in bufData.
+        // We will batch up to 7 bytes in one VRPuppet_DataXX
+        // command, so we won't emit it yet.
+        bufLen = 1;
+        bufData = *src;
+      } else if (bufLen <= 6) {
+        // This is the continuation of a span of changed bytes.
+        // There is room to add more bytes to bufData.
+
+        // Store the next byte in bufData.
+        // We will batch up to 7 bytes in one VRPuppet_DataXX
+        // command, so we won't emit it yet.
+        bufData = (bufData << 8) | *src;
+        bufLen++;
+      } else {
+        MOZ_ASSERT(bufLen == 7);
+        // This is the continuation of a span of changed bytes.
+        // There are already 7 bytes in bufData, so we must emit
+        // the VRPuppet_Data7 command for the prior bytes before
+        // starting a new command.
+        aBuffer.AppendElement((uint64_t)VRPuppet_Command::VRPuppet_Data7 +
+                              bufData);
+
+        // Store this byte to be included in the next VRPuppet_DataXX
+        // command.
+        bufLen = 1;
+        bufData = *src;
+      }
+    } else {
+      // This byte is the same.
+      // If there are bytes in bufData, the span has now ended and we must
+      // emit a VRPuppet_DataXX command for the accumulated bytes.
+      // purgeBuffer will not emit any commands if there are no bytes
+      // accumulated.
+      purgeBuffer();
+    }
+    // Advance to the next source and destination byte.
+    ++src;
+    ++dst;
+  }
+  // In the event that the very last byte of the structs differ, we must
+  // ensure that the accumulated bytes are emitted as a VRPuppet_DataXX
+  // command.
+  purgeBuffer();
+}
+
+}  // namespace gfx
+}  // namespace mozilla
--- a/gfx/vr/VRPuppetCommandBuffer.h
+++ b/gfx/vr/VRPuppetCommandBuffer.h
@@ -1,235 +1,235 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef GFX_VR_SERVICE_VRPUPPETCOMMANDBUFFER_H
-#define GFX_VR_SERVICE_VRPUPPETCOMMANDBUFFER_H
-
-#include <inttypes.h>
-#include "mozilla/Mutex.h"
-#include "nsTArray.h"
-#include "moz_external_vr.h"
-#include "mozilla/TimeStamp.h"
-
-namespace mozilla {
-namespace gfx {
-
-/**
- * A Puppet Device command buffer consists of a stream of 64-bit
- * commands.
- * The first 8 bits identifies the command and informs format of
- * the remaining 56 bits.
- *
- * These commands will be streamed into a buffer until
- * VRPuppet_End (0x0000000000000000) has been received.
- *
- * When VRPuppet_End is received, this command buffer will
- * be executed asynchronously, collecting the timer results
- * requested.
- *
- * In addition to the effects seen through the WebXR/VR API, tests
- * can get further feedback from the Puppet device.
- * Command buffers can be constructed such that when expected states
- * are not reached, the timeout timer will expire.
- * Data recorded with timer commands is returned when the command
- * buffer is completed, to validate against accepted ranges and to
- * quantify performance regressions.
- * Images submitted to the Puppet display are rendered with the
- * 2d browser output in order to enable reftests to validate
- * output against reference images.
- *
- * The state of the virtual puppet device is expressed to the VR service
- * in the same manner as physical devices -- using the VRDisplayState,
- * VRHMDSensorState and VRControllerState structures.
- *
- * By enabling partial updates of these structures, the command buffer
- * size is reduced to the values that change each frame.  This enables
- * realtime capture of a session, with physical hardware, for
- * replay in automated tests and benchmarks.
- *
- * All updates to the state structures are atomically updated in the
- * VR session thread, triggered by VRPuppet_Commit (0x1500000000000000).
- *
- * Command buffers are expected to be serialized to a human readable,
- * ascii format if stored on disk.  The binary representation is not
- * guaranteed to be consistent between versions or target platforms.
- * They should be re-constructed with the VRServiceTest DOM api at
- * runtime.
- *
- * The command set:
- *
- * 0x0000000000000000 - VRPuppet_End()
- * - End of stream, resolve promise returned by VRServiceTest::Play()
- *
- * 0x0100000000000000 - VRPuppet_ClearAll()
- * - Clear all structs
- *
- * 0x02000000000000nn - VRPuppet_ClearController(n)
- * - Clear a single controller struct
- *
- * 0x03000000nnnnnnnn - VRPuppet_Timeout(n)
- * - Reset the timeout timer to n milliseconds
- * - Initially the timeout timer starts at 10 seconds
- *
- * 0x04000000nnnnnnnn - VRPuppet_Wait(n)
- * - Wait n milliseconds before advancing to next command
- *
- * 0x0500000000000000 - VRPuppet_WaitSubmit()
- * - Wait until a frame has been submitted before advancing to the next command
- *
- * 0x0600000000000000 - VRPuppet_WaitPresentationStart()
- * - Wait until a presentation becomes active
- *
- * 0x0700000000000000 - VRPuppet_WaitPresentationEnd()
- * - Wait until a presentation ends
- *
- * 0x0800cchhvvvvvvvv - VRPuppet_WaitHapticIntensity(c, h, v)
- * - Wait until controller at index c's haptic actuator at index h reaches value
- * v.
- * - v is a 16.16 fixed point value, with 1.0f being the highest intensity and
- * 0.0f indicating that the haptic actuator is not running
- *
- * 0x0900000000000000 - VRPuppet_CaptureFrame()
- * - Captures the submitted frame.  Must later call
- *   VRPuppet_AcknowledgeFrame or VRPuppet_RejectFrame
- *   to unblock
- *
- * 0x0900000000000000 - VRPuppet_AcknowledgeFrame()
- * - Acknowledge the submitted frame, unblocking the Submit call.
- *
- * 0x0a00000000000000 - VRPuppet_RejectFrame()
- * - Reject the submitted frame, unblocking the Submit call.
- *
- * 0x0b00000000000000 - VRPuppet_StartTimer()
- * - Starts the timer
- *
- * 0x0c00000000000000 - VRPuppet_StopTimer()
- * - Stops the timer, the elapsed duration is recorded for access after the end
- *   of stream
- *
- * 0x0d000000aaaaaaaa - VRPuppet_UpdateDisplay(a)
- * - Start writing data to the VRDisplayState struct, at offset a
- *
- * 0x0e000000aaaaaaaa - VRPuppet_UpdateSensor(a)
- * - Start writing data to the VRHMDSensorState struct, at offset a
- *
- * 0x0f000000aaaaaaaa - VRPuppet_UpdateControllers(a)
- * - Start writing data to the VRControllerState array, at offset a
- *
- * 0x100000000000000 - VRPuppet_Commit
- * - Atomically commit the VRPuppet_Data updates to VRDisplayState,
- *   VRHMDSensorState and VRControllerState.
- *
- * 0xf0000000000000dd - VRPuppet_Data(d)
- * - 1 byte of data
- *
- * 0xf10000000000dddd - VRPuppet_Data(d)
- * - 2 bytes of data
- *
- * 0xf200000000dddddd - VRPuppet_Data(d)
- * - 3 bytes of data
- *
- * 0xf3000000dddddddd - VRPuppet_Data(d)
- * - 4 bytes of data
- *
- * 0xf40000dddddddddd - VRPuppet_Data(d)
- * - 5 bytes of data
- *
- * 0xf500dddddddddddd - VRPuppet_Data(d)
- * - 6 bytes of data
- *
- * 0xf6dddddddddddddd - VRPuppet_Data(d)
- * - 7 bytes of data
- *
- */
-enum class VRPuppet_Command : uint64_t {
-  VRPuppet_End = 0x0000000000000000,
-  VRPuppet_ClearAll = 0x0100000000000000,
-  VRPuppet_ClearController = 0x0200000000000000,
-  VRPuppet_Timeout = 0x0300000000000000,
-  VRPuppet_Wait = 0x0400000000000000,
-  VRPuppet_WaitSubmit = 0x0500000000000000,
-  VRPuppet_WaitPresentationStart = 0x0600000000000000,
-  VRPuppet_WaitPresentationEnd = 0x0700000000000000,
-  VRPuppet_WaitHapticIntensity = 0x0800000000000000,
-  VRPuppet_CaptureFrame = 0x0900000000000000,
-  VRPuppet_AcknowledgeFrame = 0x0a00000000000000,
-  VRPuppet_RejectFrame = 0x0b00000000000000,
-  VRPuppet_StartTimer = 0x0c00000000000000,
-  VRPuppet_StopTimer = 0x0d00000000000000,
-  VRPuppet_UpdateDisplay = 0x0e00000000000000,
-  VRPuppet_UpdateSensor = 0x0f00000000000000,
-  VRPuppet_UpdateControllers = 0x1000000000000000,
-  VRPuppet_Commit = 0x1100000000000000,
-  VRPuppet_Data1 = 0xf000000000000000,
-  VRPuppet_Data2 = 0xf100000000000000,
-  VRPuppet_Data3 = 0xf200000000000000,
-  VRPuppet_Data4 = 0xf300000000000000,
-  VRPuppet_Data5 = 0xf400000000000000,
-  VRPuppet_Data6 = 0xf500000000000000,
-  VRPuppet_Data7 = 0xf600000000000000,
-};
-
-static const int kNumPuppetHaptics = 8;
-
-class VRPuppetCommandBuffer {
- public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::gfx::VRPuppetCommandBuffer)
-  static VRPuppetCommandBuffer& Get();
-
-  // Interface to VRTestSystem
-  void Submit(const InfallibleTArray<uint64_t>& aBuffer);
-  void Reset();
-  bool HasEnded();
-
-  // Interface to PuppetSession
-  void Run(VRSystemState& aState);
-  void StartPresentation();
-  void StopPresentation();
-  bool SubmitFrame();
-  void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
-                     float aIntensity, float aDuration);
-  void StopVibrateHaptic(uint32_t aControllerIdx);
-  void StopAllHaptics();
-
-  static void EncodeStruct(nsTArray<uint64_t>& aBuffer, uint8_t* aSrcStart,
-                           uint8_t* aDstStart, size_t aLength,
-                           gfx::VRPuppet_Command aUpdateCommand);
-
- private:
-  VRPuppetCommandBuffer();
-  ~VRPuppetCommandBuffer();
-  void Run();
-  bool RunCommand(uint64_t aCommand, double aDeltaTime);
-  void WriteData(uint8_t aData);
-  void SimulateHaptics(double aDeltaTime);
-  void CompleteTest(bool aTimedOut);
-  nsTArray<uint64_t> mBuffer;
-  mozilla::Mutex mMutex;
-  VRSystemState mPendingState;
-  VRSystemState mCommittedState;
-  double mHapticPulseRemaining[kVRControllerMaxCount][kNumPuppetHaptics];
-  float mHapticPulseIntensity[kVRControllerMaxCount][kNumPuppetHaptics];
-
-  size_t mDataOffset;
-  bool mPresentationRequested;
-  bool mFrameSubmitted;
-  bool mFrameAccepted;
-  double mTimeoutDuration;  // Seconds
-  double mWaitRemaining;    // Seconds
-  double mBlockedTime;      // Seconds
-  double mTimerElapsed;     // Seconds
-  TimeStamp mLastRunTimestamp;
-
-  // Test Results:
-  bool mEnded;
-  bool mEndedWithTimeout;
-  nsTArray<double> mTimerSamples;
-};
-
-}  // namespace gfx
-}  // namespace mozilla
-
-#endif  // GFX_VR_SERVICE_VRPUPPETCOMMANDBUFFER_H
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef GFX_VR_SERVICE_VRPUPPETCOMMANDBUFFER_H
+#define GFX_VR_SERVICE_VRPUPPETCOMMANDBUFFER_H
+
+#include <inttypes.h>
+#include "mozilla/Mutex.h"
+#include "nsTArray.h"
+#include "moz_external_vr.h"
+#include "mozilla/TimeStamp.h"
+
+namespace mozilla {
+namespace gfx {
+
+/**
+ * A Puppet Device command buffer consists of a stream of 64-bit
+ * commands.
+ * The first 8 bits identifies the command and informs format of
+ * the remaining 56 bits.
+ *
+ * These commands will be streamed into a buffer until
+ * VRPuppet_End (0x0000000000000000) has been received.
+ *
+ * When VRPuppet_End is received, this command buffer will
+ * be executed asynchronously, collecting the timer results
+ * requested.
+ *
+ * In addition to the effects seen through the WebXR/VR API, tests
+ * can get further feedback from the Puppet device.
+ * Command buffers can be constructed such that when expected states
+ * are not reached, the timeout timer will expire.
+ * Data recorded with timer commands is returned when the command
+ * buffer is completed, to validate against accepted ranges and to
+ * quantify performance regressions.
+ * Images submitted to the Puppet display are rendered with the
+ * 2d browser output in order to enable reftests to validate
+ * output against reference images.
+ *
+ * The state of the virtual puppet device is expressed to the VR service
+ * in the same manner as physical devices -- using the VRDisplayState,
+ * VRHMDSensorState and VRControllerState structures.
+ *
+ * By enabling partial updates of these structures, the command buffer
+ * size is reduced to the values that change each frame.  This enables
+ * realtime capture of a session, with physical hardware, for
+ * replay in automated tests and benchmarks.
+ *
+ * All updates to the state structures are atomically updated in the
+ * VR session thread, triggered by VRPuppet_Commit (0x1500000000000000).
+ *
+ * Command buffers are expected to be serialized to a human readable,
+ * ascii format if stored on disk.  The binary representation is not
+ * guaranteed to be consistent between versions or target platforms.
+ * They should be re-constructed with the VRServiceTest DOM api at
+ * runtime.
+ *
+ * The command set:
+ *
+ * 0x0000000000000000 - VRPuppet_End()
+ * - End of stream, resolve promise returned by VRServiceTest::Play()
+ *
+ * 0x0100000000000000 - VRPuppet_ClearAll()
+ * - Clear all structs
+ *
+ * 0x02000000000000nn - VRPuppet_ClearController(n)
+ * - Clear a single controller struct
+ *
+ * 0x03000000nnnnnnnn - VRPuppet_Timeout(n)
+ * - Reset the timeout timer to n milliseconds
+ * - Initially the timeout timer starts at 10 seconds
+ *
+ * 0x04000000nnnnnnnn - VRPuppet_Wait(n)
+ * - Wait n milliseconds before advancing to next command
+ *
+ * 0x0500000000000000 - VRPuppet_WaitSubmit()
+ * - Wait until a frame has been submitted before advancing to the next command
+ *
+ * 0x0600000000000000 - VRPuppet_WaitPresentationStart()
+ * - Wait until a presentation becomes active
+ *
+ * 0x0700000000000000 - VRPuppet_WaitPresentationEnd()
+ * - Wait until a presentation ends
+ *
+ * 0x0800cchhvvvvvvvv - VRPuppet_WaitHapticIntensity(c, h, v)
+ * - Wait until controller at index c's haptic actuator at index h reaches value
+ * v.
+ * - v is a 16.16 fixed point value, with 1.0f being the highest intensity and
+ * 0.0f indicating that the haptic actuator is not running
+ *
+ * 0x0900000000000000 - VRPuppet_CaptureFrame()
+ * - Captures the submitted frame.  Must later call
+ *   VRPuppet_AcknowledgeFrame or VRPuppet_RejectFrame
+ *   to unblock
+ *
+ * 0x0900000000000000 - VRPuppet_AcknowledgeFrame()
+ * - Acknowledge the submitted frame, unblocking the Submit call.
+ *
+ * 0x0a00000000000000 - VRPuppet_RejectFrame()
+ * - Reject the submitted frame, unblocking the Submit call.
+ *
+ * 0x0b00000000000000 - VRPuppet_StartTimer()
+ * - Starts the timer
+ *
+ * 0x0c00000000000000 - VRPuppet_StopTimer()
+ * - Stops the timer, the elapsed duration is recorded for access after the end
+ *   of stream
+ *
+ * 0x0d000000aaaaaaaa - VRPuppet_UpdateDisplay(a)
+ * - Start writing data to the VRDisplayState struct, at offset a
+ *
+ * 0x0e000000aaaaaaaa - VRPuppet_UpdateSensor(a)
+ * - Start writing data to the VRHMDSensorState struct, at offset a
+ *
+ * 0x0f000000aaaaaaaa - VRPuppet_UpdateControllers(a)
+ * - Start writing data to the VRControllerState array, at offset a
+ *
+ * 0x100000000000000 - VRPuppet_Commit
+ * - Atomically commit the VRPuppet_Data updates to VRDisplayState,
+ *   VRHMDSensorState and VRControllerState.
+ *
+ * 0xf0000000000000dd - VRPuppet_Data(d)
+ * - 1 byte of data
+ *
+ * 0xf10000000000dddd - VRPuppet_Data(d)
+ * - 2 bytes of data
+ *
+ * 0xf200000000dddddd - VRPuppet_Data(d)
+ * - 3 bytes of data
+ *
+ * 0xf3000000dddddddd - VRPuppet_Data(d)
+ * - 4 bytes of data
+ *
+ * 0xf40000dddddddddd - VRPuppet_Data(d)
+ * - 5 bytes of data
+ *
+ * 0xf500dddddddddddd - VRPuppet_Data(d)
+ * - 6 bytes of data
+ *
+ * 0xf6dddddddddddddd - VRPuppet_Data(d)
+ * - 7 bytes of data
+ *
+ */
+enum class VRPuppet_Command : uint64_t {
+  VRPuppet_End = 0x0000000000000000,
+  VRPuppet_ClearAll = 0x0100000000000000,
+  VRPuppet_ClearController = 0x0200000000000000,
+  VRPuppet_Timeout = 0x0300000000000000,
+  VRPuppet_Wait = 0x0400000000000000,
+  VRPuppet_WaitSubmit = 0x0500000000000000,
+  VRPuppet_WaitPresentationStart = 0x0600000000000000,
+  VRPuppet_WaitPresentationEnd = 0x0700000000000000,
+  VRPuppet_WaitHapticIntensity = 0x0800000000000000,
+  VRPuppet_CaptureFrame = 0x0900000000000000,
+  VRPuppet_AcknowledgeFrame = 0x0a00000000000000,
+  VRPuppet_RejectFrame = 0x0b00000000000000,
+  VRPuppet_StartTimer = 0x0c00000000000000,
+  VRPuppet_StopTimer = 0x0d00000000000000,
+  VRPuppet_UpdateDisplay = 0x0e00000000000000,
+  VRPuppet_UpdateSensor = 0x0f00000000000000,
+  VRPuppet_UpdateControllers = 0x1000000000000000,
+  VRPuppet_Commit = 0x1100000000000000,
+  VRPuppet_Data1 = 0xf000000000000000,
+  VRPuppet_Data2 = 0xf100000000000000,
+  VRPuppet_Data3 = 0xf200000000000000,
+  VRPuppet_Data4 = 0xf300000000000000,
+  VRPuppet_Data5 = 0xf400000000000000,
+  VRPuppet_Data6 = 0xf500000000000000,
+  VRPuppet_Data7 = 0xf600000000000000,
+};
+
+static const int kNumPuppetHaptics = 8;
+
+class VRPuppetCommandBuffer {
+ public:
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::gfx::VRPuppetCommandBuffer)
+  static VRPuppetCommandBuffer& Get();
+
+  // Interface to VRTestSystem
+  void Submit(const InfallibleTArray<uint64_t>& aBuffer);
+  void Reset();
+  bool HasEnded();
+
+  // Interface to PuppetSession
+  void Run(VRSystemState& aState);
+  void StartPresentation();
+  void StopPresentation();
+  bool SubmitFrame();
+  void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
+                     float aIntensity, float aDuration);
+  void StopVibrateHaptic(uint32_t aControllerIdx);
+  void StopAllHaptics();
+
+  static void EncodeStruct(nsTArray<uint64_t>& aBuffer, uint8_t* aSrcStart,
+                           uint8_t* aDstStart, size_t aLength,
+                           gfx::VRPuppet_Command aUpdateCommand);
+
+ private:
+  VRPuppetCommandBuffer();
+  ~VRPuppetCommandBuffer();
+  void Run();
+  bool RunCommand(uint64_t aCommand, double aDeltaTime);
+  void WriteData(uint8_t aData);
+  void SimulateHaptics(double aDeltaTime);
+  void CompleteTest(bool aTimedOut);
+  nsTArray<uint64_t> mBuffer;
+  mozilla::Mutex mMutex;
+  VRSystemState mPendingState;
+  VRSystemState mCommittedState;
+  double mHapticPulseRemaining[kVRControllerMaxCount][kNumPuppetHaptics];
+  float mHapticPulseIntensity[kVRControllerMaxCount][kNumPuppetHaptics];
+
+  size_t mDataOffset;
+  bool mPresentationRequested;
+  bool mFrameSubmitted;
+  bool mFrameAccepted;
+  double mTimeoutDuration;  // Seconds
+  double mWaitRemaining;    // Seconds
+  double mBlockedTime;      // Seconds
+  double mTimerElapsed;     // Seconds
+  TimeStamp mLastRunTimestamp;
+
+  // Test Results:
+  bool mEnded;
+  bool mEndedWithTimeout;
+  nsTArray<double> mTimerSamples;
+};
+
+}  // namespace gfx
+}  // namespace mozilla
+
+#endif  // GFX_VR_SERVICE_VRPUPPETCOMMANDBUFFER_H
--- a/gfx/vr/service/PuppetSession.cpp
+++ b/gfx/vr/service/PuppetSession.cpp
@@ -1,114 +1,114 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "PuppetSession.h"
-
-#include "nsString.h"
-#include "VRPuppetCommandBuffer.h"
-#include "mozilla/StaticPrefs.h"
-
-#if defined(XP_WIN)
-#  include <d3d11.h>
-#  include "mozilla/gfx/DeviceManagerDx.h"
-#elif defined(XP_MACOSX)
-#  include "mozilla/gfx/MacIOSurface.h"
-#endif
-
-using namespace mozilla::gfx;
-
-namespace mozilla {
-namespace gfx {
-
-PuppetSession::PuppetSession() : VRSession() {}
-
-PuppetSession::~PuppetSession() { Shutdown(); }
-
-bool PuppetSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) {
-  if (!StaticPrefs::dom_vr_enabled() || !StaticPrefs::dom_vr_puppet_enabled()) {
-    return false;
-  }
-  VRPuppetCommandBuffer::Get().Run(aSystemState);
-  if (!aSystemState.displayState.isConnected) {
-    return false;
-  }
-#if defined(XP_WIN)
-  if (!CreateD3DObjects()) {
-    Shutdown();
-    return false;
-  }
-#endif
-
-  // Succeeded
-  return true;
-}
-
-#if defined(XP_WIN)
-bool PuppetSession::CreateD3DObjects() {
-  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetVRDevice();
-  if (!device) {
-    return false;
-  }
-  if (!CreateD3DContext(device)) {
-    return false;
-  }
-  return true;
-}
-#endif
-
-void PuppetSession::Shutdown() {}
-
-void PuppetSession::StartFrame(mozilla::gfx::VRSystemState& aSystemState) {
-  VRPuppetCommandBuffer::Get().Run(aSystemState);
-}
-
-void PuppetSession::ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) {
-  VRPuppetCommandBuffer& puppet = VRPuppetCommandBuffer::Get();
-  puppet.Run(aSystemState);
-  if (!aSystemState.displayState.isConnected) {
-    mShouldQuit = true;
-  }
-}
-
-#if defined(XP_WIN)
-bool PuppetSession::SubmitFrame(
-    const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
-    ID3D11Texture2D* aTexture) {
-  return VRPuppetCommandBuffer::Get().SubmitFrame();
-}
-#elif defined(XP_MACOSX)
-bool PuppetSession::SubmitFrame(
-    const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
-    const VRLayerTextureHandle& aTexture) {
-  return VRPuppetCommandBuffer::Get().SubmitFrame();
-}
-#endif
-
-void PuppetSession::StopPresentation() {
-  VRPuppetCommandBuffer::Get().StopPresentation();
-}
-
-bool PuppetSession::StartPresentation() {
-  VRPuppetCommandBuffer::Get().StartPresentation();
-  return true;
-}
-
-void PuppetSession::VibrateHaptic(uint32_t aControllerIdx,
-                                  uint32_t aHapticIndex, float aIntensity,
-                                  float aDuration) {
-  VRPuppetCommandBuffer::Get().VibrateHaptic(aControllerIdx, aHapticIndex,
-                                             aIntensity, aDuration);
-}
-
-void PuppetSession::StopVibrateHaptic(uint32_t aControllerIdx) {
-  VRPuppetCommandBuffer::Get().StopVibrateHaptic(aControllerIdx);
-}
-
-void PuppetSession::StopAllHaptics() {
-  VRPuppetCommandBuffer::Get().StopAllHaptics();
-}
-
-}  // namespace gfx
-}  // namespace mozilla
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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 "PuppetSession.h"
+
+#include "nsString.h"
+#include "VRPuppetCommandBuffer.h"
+#include "mozilla/StaticPrefs.h"
+
+#if defined(XP_WIN)
+#  include <d3d11.h>
+#  include "mozilla/gfx/DeviceManagerDx.h"
+#elif defined(XP_MACOSX)
+#  include "mozilla/gfx/MacIOSurface.h"
+#endif
+
+using namespace mozilla::gfx;
+
+namespace mozilla {
+namespace gfx {
+
+PuppetSession::PuppetSession() : VRSession() {}
+
+PuppetSession::~PuppetSession() { Shutdown(); }
+
+bool PuppetSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) {
+  if (!StaticPrefs::dom_vr_enabled() || !StaticPrefs::dom_vr_puppet_enabled()) {
+    return false;
+  }
+  VRPuppetCommandBuffer::Get().Run(aSystemState);
+  if (!aSystemState.displayState.isConnected) {
+    return false;
+  }
+#if defined(XP_WIN)
+  if (!CreateD3DObjects()) {
+    Shutdown();
+    return false;
+  }
+#endif
+
+  // Succeeded
+  return true;
+}
+
+#if defined(XP_WIN)
+bool PuppetSession::CreateD3DObjects() {
+  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetVRDevice();
+  if (!device) {
+    return false;
+  }
+  if (!CreateD3DContext(device)) {
+    return false;
+  }
+  return true;
+}
+#endif
+
+void PuppetSession::Shutdown() {}
+
+void PuppetSession::StartFrame(mozilla::gfx::VRSystemState& aSystemState) {
+  VRPuppetCommandBuffer::Get().Run(aSystemState);
+}
+
+void PuppetSession::ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) {
+  VRPuppetCommandBuffer& puppet = VRPuppetCommandBuffer::Get();
+  puppet.Run(aSystemState);
+  if (!aSystemState.displayState.isConnected) {
+    mShouldQuit = true;
+  }
+}
+
+#if defined(XP_WIN)
+bool PuppetSession::SubmitFrame(
+    const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
+    ID3D11Texture2D* aTexture) {
+  return VRPuppetCommandBuffer::Get().SubmitFrame();
+}
+#elif defined(XP_MACOSX)
+bool PuppetSession::SubmitFrame(
+    const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
+    const VRLayerTextureHandle& aTexture) {
+  return VRPuppetCommandBuffer::Get().SubmitFrame();
+}
+#endif
+
+void PuppetSession::StopPresentation() {
+  VRPuppetCommandBuffer::Get().StopPresentation();
+}
+
+bool PuppetSession::StartPresentation() {
+  VRPuppetCommandBuffer::Get().StartPresentation();
+  return true;
+}
+
+void PuppetSession::VibrateHaptic(uint32_t aControllerIdx,
+                                  uint32_t aHapticIndex, float aIntensity,
+                                  float aDuration) {
+  VRPuppetCommandBuffer::Get().VibrateHaptic(aControllerIdx, aHapticIndex,
+                                             aIntensity, aDuration);
+}
+
+void PuppetSession::StopVibrateHaptic(uint32_t aControllerIdx) {
+  VRPuppetCommandBuffer::Get().StopVibrateHaptic(aControllerIdx);
+}
+
+void PuppetSession::StopAllHaptics() {
+  VRPuppetCommandBuffer::Get().StopAllHaptics();
+}
+
+}  // namespace gfx
+}  // namespace mozilla
--- a/gfx/vr/service/PuppetSession.h
+++ b/gfx/vr/service/PuppetSession.h
@@ -1,57 +1,57 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef GFX_VR_SERVICE_PUPPETSESSION_H
-#define GFX_VR_SERVICE_PUPPETSESSION_H
-
-#include "VRSession.h"
-
-#include "mozilla/TimeStamp.h"
-#include "moz_external_vr.h"
-
-#if defined(XP_WIN)
-#  include <d3d11_1.h>
-#endif
-class nsITimer;
-
-namespace mozilla {
-namespace gfx {
-
-class PuppetSession : public VRSession {
- public:
-  PuppetSession();
-  virtual ~PuppetSession();
-
-  bool Initialize(mozilla::gfx::VRSystemState& aSystemState) override;
-  void Shutdown() override;
-  void ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) override;
-  void StartFrame(mozilla::gfx::VRSystemState& aSystemState) override;
-  bool StartPresentation() override;
-  void StopPresentation() override;
-  void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
-                     float aIntensity, float aDuration) override;
-  void StopVibrateHaptic(uint32_t aControllerIdx) override;
-  void StopAllHaptics() override;
-
- protected:
-#if defined(XP_WIN)
-  bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
-                   ID3D11Texture2D* aTexture) override;
-#elif defined(XP_MACOSX)
-  bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
-                   const VRLayerTextureHandle& aTexture) override;
-#endif
-
- private:
-#if defined(XP_WIN)
-  bool CreateD3DObjects();
-#endif
-};
-
-}  // namespace gfx
-}  // namespace mozilla
-
-#endif  // GFX_VR_SERVICE_PUPPETSESSION_H
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef GFX_VR_SERVICE_PUPPETSESSION_H
+#define GFX_VR_SERVICE_PUPPETSESSION_H
+
+#include "VRSession.h"
+
+#include "mozilla/TimeStamp.h"
+#include "moz_external_vr.h"
+
+#if defined(XP_WIN)
+#  include <d3d11_1.h>
+#endif
+class nsITimer;
+
+namespace mozilla {
+namespace gfx {
+
+class PuppetSession : public VRSession {
+ public:
+  PuppetSession();
+  virtual ~PuppetSession();
+
+  bool Initialize(mozilla::gfx::VRSystemState& aSystemState) override;
+  void Shutdown() override;
+  void ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) override;
+  void StartFrame(mozilla::gfx::VRSystemState& aSystemState) override;
+  bool StartPresentation() override;
+  void StopPresentation() override;
+  void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
+                     float aIntensity, float aDuration) override;
+  void StopVibrateHaptic(uint32_t aControllerIdx) override;
+  void StopAllHaptics() override;
+
+ protected:
+#if defined(XP_WIN)
+  bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
+                   ID3D11Texture2D* aTexture) override;
+#elif defined(XP_MACOSX)
+  bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
+                   const VRLayerTextureHandle& aTexture) override;
+#endif
+
+ private:
+#if defined(XP_WIN)
+  bool CreateD3DObjects();
+#endif
+};
+
+}  // namespace gfx
+}  // namespace mozilla
+
+#endif  // GFX_VR_SERVICE_PUPPETSESSION_H
--- a/gfx/vr/service/binding/OpenVRKnucklesBinding.h
+++ b/gfx/vr/service/binding/OpenVRKnucklesBinding.h
@@ -1,300 +1,300 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef GFX_VR_BLINDING_OPENVRKNUCKLESBINDING_H
-#define GFX_VR_BLINDING_OPENVRKNUCKLESBINDING_H
-
-namespace mozilla {
-namespace gfx {
-
-struct OpenVRKnucklesBinding {
-  const char* binding =
-      // clang-format off
-  "{\n"
-    "  \"version\" : \"0.1\", \n"
-    "  \"controller_type\" : \"knuckles\", \n"
-    "  \"description\" : \"Bindings for Firefox OpenVR for the Knuckles controller\", \n"
-    "  \"name\" : \"Firefox bindings for Knuckles Controller\", \n"
-    "  \"bindings\" : { \n"
-    "     \"/actions/firefox\" : { \n"
-    "         \"poses\" : [        \n"
-    "           {                \n"
-    "             \"output\" : \"/actions/firefox/in/LHand_pose\", \n"
-    "              \"path\" : \"/user/hand/left/pose/raw\"     \n"
-    "            },\n"
-    "            {                                             \n"
-    "              \"output\" : \"/actions/firefox/in/RHand_pose\", \n"
-    "              \"path\" : \"/user/hand/right/pose/raw\"    \n"
-    "            }\n"
-    "         ],\n"
-    "         \"haptics\" : [ \n"
-    "            {\n"
-    "              \"output\" : \"/actions/firefox/out/LHand_haptic\",  \n"
-    "              \"path\" : \"/user/hand/left/output/haptic\"     \n"
-    "            },\n"
-    "            { \n"
-    "              \"output\" : \"/actions/firefox/out/RHand_haptic\", \n"
-    "              \"path\" : \"/user/hand/right/output/haptic\"    \n"
-    "            }\n"
-    "		  ],\n"
-    "       \"sources\" : [ \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"position\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_analog\" \n"
-    "               }, \n"
-    "               \"click\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_pressed\" \n"
-    "               }, \n"
-    "               \"touch\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_touched\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trackpad\", \n"
-    "             \"path\" : \"/user/hand/left/input/trackpad\" \n"
-    "           },\n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"position\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_analog\" \n"
-    "               }, \n"
-    "               \"click\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_pressed\" \n"
-    "               }, \n"
-    "               \"touch\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_touched\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trackpad\", \n"
-    "             \"path\" : \"/user/hand/right/input/trackpad\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"pull\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_trigger_value\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/left/input/trigger\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"pull\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_trigger_value\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/right/input/trigger\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"click\" : { \n"
-    "                \"output\" : \"/actions/firefox/in/LHand_grip_pressed\" \n"
-    "              }, \n"
-    "               \"touch\" : { \n"
-    "                \"output\" : \"/actions/firefox/in/LHand_grip_touched\" \n"
-    "              } \n"
-    "             }, \n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/left/input/grip\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"click\" : { \n"
-    "                \"output\" : \"/actions/firefox/in/RHand_grip_pressed\" \n"
-    "              }, \n"
-    "               \"touch\" : { \n"
-    "                 \"output\" : \"/actions/firefox/in/RHand_grip_touched\" \n"
-    "              } \n"
-    "           }, \n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/right/input/grip\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"click\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_system_pressed\"  \n"
-    "                   }, \n"
-    "                 \"touch\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_system_touched\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/left/input/system\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"click\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_system_pressed\"  \n"
-    "                   }, \n"
-    "                 \"touch\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_system_touched\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/right/input/system\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"click\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_a_pressed\"  \n"
-    "                   }, \n"
-    "                 \"touch\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_a_touched\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/left/input/a\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"click\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_a_pressed\"  \n"
-    "                   }, \n"
-    "                 \"touch\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_a_touched\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/right/input/a\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"click\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_b_pressed\"  \n"
-    "                   }, \n"
-    "                 \"touch\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/LHand_b_touched\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/left/input/b\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "                 \"click\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_b_pressed\"  \n"
-    "                   }, \n"
-    "                 \"touch\" : { \n"
-    "                    \"output\" : \"/actions/firefox/in/RHand_b_touched\"  \n"
-    "                   } \n"
-    "              },\n"
-    "             \"mode\" : \"button\", \n"
-    "             \"path\" : \"/user/hand/right/input/b\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"position\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_analog\" \n"
-    "               }, \n"
-    "               \"click\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_pressed\" \n"
-    "               }, \n"
-    "               \"touch\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_touched\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"joystick\", \n"
-    "             \"path\" : \"/user/hand/left/input/thumbstick\" \n"
-    "           },\n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"position\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_analog\" \n"
-    "               }, \n"
-    "               \"click\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_pressed\" \n"
-    "               }, \n"
-    "               \"touch\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_touched\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"joystick\", \n"
-    "             \"path\" : \"/user/hand/right/input/thumbstick\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_finger_index_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/left/input/finger/index\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_finger_index_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/right/input/finger/index\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_finger_middle_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/left/input/finger/middle\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_finger_middle_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/right/input/finger/middle\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_finger_ring_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/left/input/finger/ring\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_finger_ring_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/right/input/finger/ring\" \n"
-    "           }, \n"
-      "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/LHand_finger_pinky_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/left/input/finger/pinky\" \n"
-    "           }, \n"
-    "           {\n"
-    "             \"inputs\" : { \n"
-    "               \"pull\" : { \n"
-    "                   \"output\" : \"/actions/firefox/in/RHand_finger_pinky_value\" \n"
-    "               } \n"
-    "             }, \n"
-    "             \"mode\" : \"trigger\", \n"
-    "             \"path\" : \"/user/hand/right/input/finger/pinky\" \n"
-    "           } \n"
-    "         ]\n"
-    "     }\n"
-    "  }\n"
-    "}";
-  // clang-format on
-};
-
-}  // namespace gfx
-}  // namespace mozilla
-
-#endif  // GFX_VR_BLINDING_OPENVRKNUCKLESBINDING_H
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef GFX_VR_BLINDING_OPENVRKNUCKLESBINDING_H
+#define GFX_VR_BLINDING_OPENVRKNUCKLESBINDING_H
+
+namespace mozilla {
+namespace gfx {
+
+struct OpenVRKnucklesBinding {
+  const char* binding =
+      // clang-format off
+  "{\n"
+    "  \"version\" : \"0.1\", \n"
+    "  \"controller_type\" : \"knuckles\", \n"
+    "  \"description\" : \"Bindings for Firefox OpenVR for the Knuckles controller\", \n"
+    "  \"name\" : \"Firefox bindings for Knuckles Controller\", \n"
+    "  \"bindings\" : { \n"
+    "     \"/actions/firefox\" : { \n"
+    "         \"poses\" : [        \n"
+    "           {                \n"
+    "             \"output\" : \"/actions/firefox/in/LHand_pose\", \n"
+    "              \"path\" : \"/user/hand/left/pose/raw\"     \n"
+    "            },\n"
+    "            {                                             \n"
+    "              \"output\" : \"/actions/firefox/in/RHand_pose\", \n"
+    "              \"path\" : \"/user/hand/right/pose/raw\"    \n"
+    "            }\n"
+    "         ],\n"
+    "         \"haptics\" : [ \n"
+    "            {\n"
+    "              \"output\" : \"/actions/firefox/out/LHand_haptic\",  \n"
+    "              \"path\" : \"/user/hand/left/output/haptic\"     \n"
+    "            },\n"
+    "            { \n"
+    "              \"output\" : \"/actions/firefox/out/RHand_haptic\", \n"
+    "              \"path\" : \"/user/hand/right/output/haptic\"    \n"
+    "            }\n"
+    "		  ],\n"
+    "       \"sources\" : [ \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"position\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_analog\" \n"
+    "               }, \n"
+    "               \"click\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_pressed\" \n"
+    "               }, \n"
+    "               \"touch\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_touched\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trackpad\", \n"
+    "             \"path\" : \"/user/hand/left/input/trackpad\" \n"
+    "           },\n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"position\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_analog\" \n"
+    "               }, \n"
+    "               \"click\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_pressed\" \n"
+    "               }, \n"
+    "               \"touch\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_touched\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trackpad\", \n"
+    "             \"path\" : \"/user/hand/right/input/trackpad\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"pull\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_trigger_value\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/left/input/trigger\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"pull\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_trigger_value\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/right/input/trigger\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"click\" : { \n"
+    "                \"output\" : \"/actions/firefox/in/LHand_grip_pressed\" \n"
+    "              }, \n"
+    "               \"touch\" : { \n"
+    "                \"output\" : \"/actions/firefox/in/LHand_grip_touched\" \n"
+    "              } \n"
+    "             }, \n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/left/input/grip\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"click\" : { \n"
+    "                \"output\" : \"/actions/firefox/in/RHand_grip_pressed\" \n"
+    "              }, \n"
+    "               \"touch\" : { \n"
+    "                 \"output\" : \"/actions/firefox/in/RHand_grip_touched\" \n"
+    "              } \n"
+    "           }, \n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/right/input/grip\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"click\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_system_pressed\"  \n"
+    "                   }, \n"
+    "                 \"touch\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_system_touched\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/left/input/system\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"click\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_system_pressed\"  \n"
+    "                   }, \n"
+    "                 \"touch\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_system_touched\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/right/input/system\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"click\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_a_pressed\"  \n"
+    "                   }, \n"
+    "                 \"touch\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_a_touched\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/left/input/a\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"click\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_a_pressed\"  \n"
+    "                   }, \n"
+    "                 \"touch\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_a_touched\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/right/input/a\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"click\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_b_pressed\"  \n"
+    "                   }, \n"
+    "                 \"touch\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/LHand_b_touched\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/left/input/b\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "                 \"click\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_b_pressed\"  \n"
+    "                   }, \n"
+    "                 \"touch\" : { \n"
+    "                    \"output\" : \"/actions/firefox/in/RHand_b_touched\"  \n"
+    "                   } \n"
+    "              },\n"
+    "             \"mode\" : \"button\", \n"
+    "             \"path\" : \"/user/hand/right/input/b\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"position\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_analog\" \n"
+    "               }, \n"
+    "               \"click\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_pressed\" \n"
+    "               }, \n"
+    "               \"touch\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_touched\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"joystick\", \n"
+    "             \"path\" : \"/user/hand/left/input/thumbstick\" \n"
+    "           },\n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"position\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_analog\" \n"
+    "               }, \n"
+    "               \"click\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_pressed\" \n"
+    "               }, \n"
+    "               \"touch\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_touched\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"joystick\", \n"
+    "             \"path\" : \"/user/hand/right/input/thumbstick\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_finger_index_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/left/input/finger/index\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_finger_index_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/right/input/finger/index\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_finger_middle_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/left/input/finger/middle\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_finger_middle_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/right/input/finger/middle\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_finger_ring_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/left/input/finger/ring\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_finger_ring_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/right/input/finger/ring\" \n"
+    "           }, \n"
+      "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/LHand_finger_pinky_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/left/input/finger/pinky\" \n"
+    "           }, \n"
+    "           {\n"
+    "             \"inputs\" : { \n"
+    "               \"pull\" : { \n"
+    "                   \"output\" : \"/actions/firefox/in/RHand_finger_pinky_value\" \n"
+    "               } \n"
+    "             }, \n"
+    "             \"mode\" : \"trigger\", \n"
+    "             \"path\" : \"/user/hand/right/input/finger/pinky\" \n"
+    "           } \n"
+    "         ]\n"
+    "     }\n"
+    "  }\n"
+    "}";
+  // clang-format on
+};
+
+}  // namespace gfx
+}  // namespace mozilla
+
+#endif  // GFX_VR_BLINDING_OPENVRKNUCKLESBINDING_H
--- a/gfx/vr/service/binding/OpenVRViveBinding.h
+++ b/gfx/vr/service/binding/OpenVRViveBinding.h
@@ -1,174 +1,174 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef GFX_VR_BLINDING_OPENVRVIVEBINDING_H
-#define GFX_VR_BLINDING_OPENVRVIVEBINDING_H
-
-namespace mozilla {
-namespace gfx {
-
-struct OpenVRViveBinding {
-  const char* binding =
-      // clang-format off
-  "{\n"
-  "  \"version\" : \"0.1\", \n"
-  "  \"controller_type\" : \"vive_controller\", \n"
-  "  \"description\" : \"Bindings for Firefox OpenVR for the Vive controller\", \n"
-  "  \"name\" : \"Firefox bindings for Vive Controller\", \n"
-  "  \"bindings\" : { \n"
-  "     \"/actions/firefox\" : { \n"
-  "         \"poses\" : [        \n"
-  "           {                \n"
-  "             \"output\" : \"/actions/firefox/in/LHand_pose\", \n"
-  "              \"path\" : \"/user/hand/left/pose/raw\"     \n"
-  "            },\n"
-  "            {                                             \n"
-  "              \"output\" : \"/actions/firefox/in/RHand_pose\", \n"
-  "              \"path\" : \"/user/hand/right/pose/raw\"    \n"
-  "            }\n"
-  "         ],\n"
-  "         \"haptics\" : [ \n"
-  "            {\n"
-  "              \"output\" : \"/actions/firefox/out/LHand_haptic\",  \n"
-  "              \"path\" : \"/user/hand/left/output/haptic\"     \n"
-  "            },\n"
-  "            { \n"
-  "              \"output\" : \"/actions/firefox/out/RHand_haptic\", \n"
-  "              \"path\" : \"/user/hand/right/output/haptic\"    \n"
-  "            }\n"
-  "		  ],\n"
-  "       \"sources\" : [ \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"position\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_analog\" \n"
-  "               }, \n"
-  "               \"click\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_pressed\" \n"
-  "               }, \n"
-  "               \"touch\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_touched\" \n"
-  "               } \n"
-  "             }, \n"
-  "             \"mode\" : \"trackpad\", \n"
-  "             \"path\" : \"/user/hand/left/input/trackpad\" \n"
-  "           },\n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"position\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_analog\" \n"
-  "               }, \n"
-  "               \"click\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_pressed\" \n"
-  "               }, \n"
-  "               \"touch\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_touched\" \n"
-  "               } \n"
-  "             }, \n"
-  "             \"mode\" : \"trackpad\", \n"
-  "             \"path\" : \"/user/hand/right/input/trackpad\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"pull\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_trigger_value\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"trigger\", \n"
-  "             \"path\" : \"/user/hand/left/input/trigger\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"pull\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_trigger_value\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"trigger\", \n"
-  "             \"path\" : \"/user/hand/right/input/trigger\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"click\" : { \n"
-  "                \"output\" : \"/actions/firefox/in/LHand_grip_pressed\" \n"
-  "              }, \n"
-  "               \"touch\" : { \n"
-  "                 \"output\" : \"/actions/firefox/in/LHand_grip_touched\" \n"
-  "              } \n"
-  "             }, \n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/left/input/grip\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"click\" : { \n"
-  "               \"output\" : \"/actions/firefox/in/RHand_grip_pressed\" \n"
-  "              }, \n"
-  "               \"touch\" : { \n"
-  "                \"output\" : \"/actions/firefox/in/RHand_grip_touched\" \n"
-  "              } \n"
-  "           }, \n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/right/input/grip\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_menu_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_menu_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/left/input/application_menu\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_menu_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_menu_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/right/input/application_menu\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_system_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_system_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/left/input/system\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_system_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_system_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/right/input/system\" \n"
-  "           } \n"
-  "         ]\n"
-  "     }\n"
-  "  }\n"
-  "}";
-  // clang-format on
-};
-
-}  // namespace gfx
-}  // namespace mozilla
-
-#endif  // GFX_VR_BLINDING_OPENVRVIVEBINDING_H
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef GFX_VR_BLINDING_OPENVRVIVEBINDING_H
+#define GFX_VR_BLINDING_OPENVRVIVEBINDING_H
+
+namespace mozilla {
+namespace gfx {
+
+struct OpenVRViveBinding {
+  const char* binding =
+      // clang-format off
+  "{\n"
+  "  \"version\" : \"0.1\", \n"
+  "  \"controller_type\" : \"vive_controller\", \n"
+  "  \"description\" : \"Bindings for Firefox OpenVR for the Vive controller\", \n"
+  "  \"name\" : \"Firefox bindings for Vive Controller\", \n"
+  "  \"bindings\" : { \n"
+  "     \"/actions/firefox\" : { \n"
+  "         \"poses\" : [        \n"
+  "           {                \n"
+  "             \"output\" : \"/actions/firefox/in/LHand_pose\", \n"
+  "              \"path\" : \"/user/hand/left/pose/raw\"     \n"
+  "            },\n"
+  "            {                                             \n"
+  "              \"output\" : \"/actions/firefox/in/RHand_pose\", \n"
+  "              \"path\" : \"/user/hand/right/pose/raw\"    \n"
+  "            }\n"
+  "         ],\n"
+  "         \"haptics\" : [ \n"
+  "            {\n"
+  "              \"output\" : \"/actions/firefox/out/LHand_haptic\",  \n"
+  "              \"path\" : \"/user/hand/left/output/haptic\"     \n"
+  "            },\n"
+  "            { \n"
+  "              \"output\" : \"/actions/firefox/out/RHand_haptic\", \n"
+  "              \"path\" : \"/user/hand/right/output/haptic\"    \n"
+  "            }\n"
+  "		  ],\n"
+  "       \"sources\" : [ \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"position\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_analog\" \n"
+  "               }, \n"
+  "               \"click\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_pressed\" \n"
+  "               }, \n"
+  "               \"touch\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_touched\" \n"
+  "               } \n"
+  "             }, \n"
+  "             \"mode\" : \"trackpad\", \n"
+  "             \"path\" : \"/user/hand/left/input/trackpad\" \n"
+  "           },\n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"position\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_analog\" \n"
+  "               }, \n"
+  "               \"click\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_pressed\" \n"
+  "               }, \n"
+  "               \"touch\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_touched\" \n"
+  "               } \n"
+  "             }, \n"
+  "             \"mode\" : \"trackpad\", \n"
+  "             \"path\" : \"/user/hand/right/input/trackpad\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"pull\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_trigger_value\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"trigger\", \n"
+  "             \"path\" : \"/user/hand/left/input/trigger\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"pull\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_trigger_value\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"trigger\", \n"
+  "             \"path\" : \"/user/hand/right/input/trigger\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"click\" : { \n"
+  "                \"output\" : \"/actions/firefox/in/LHand_grip_pressed\" \n"
+  "              }, \n"
+  "               \"touch\" : { \n"
+  "                 \"output\" : \"/actions/firefox/in/LHand_grip_touched\" \n"
+  "              } \n"
+  "             }, \n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/left/input/grip\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"click\" : { \n"
+  "               \"output\" : \"/actions/firefox/in/RHand_grip_pressed\" \n"
+  "              }, \n"
+  "               \"touch\" : { \n"
+  "                \"output\" : \"/actions/firefox/in/RHand_grip_touched\" \n"
+  "              } \n"
+  "           }, \n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/right/input/grip\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_menu_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_menu_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/left/input/application_menu\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_menu_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_menu_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/right/input/application_menu\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_system_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_system_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/left/input/system\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_system_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_system_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/right/input/system\" \n"
+  "           } \n"
+  "         ]\n"
+  "     }\n"
+  "  }\n"
+  "}";
+  // clang-format on
+};
+
+}  // namespace gfx
+}  // namespace mozilla
+
+#endif  // GFX_VR_BLINDING_OPENVRVIVEBINDING_H
--- a/gfx/vr/service/binding/OpenVRWMRBinding.h
+++ b/gfx/vr/service/binding/OpenVRWMRBinding.h
@@ -1,192 +1,192 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef GFX_VR_BLINDING_OPENVRWMRBINDING_H
-#define GFX_VR_BLINDING_OPENVRWMRBINDING_H
-
-namespace mozilla {
-namespace gfx {
-
-struct OpenVRWMRBinding {
-  const char* binding =
-      // clang-format off
-  "{\n"
-  "  \"version\" : \"0.1\", \n"
-  "  \"controller_type\" : \"holographic_controller\", \n"
-  "  \"description\" : \"Bindings for Firefox OpenVR for the Windows Mixed Reality controller\", \n"
-  "  \"name\" : \"Firefox bindings for Mixed Reality Controller\", \n"
-  "  \"bindings\" : { \n"
-  "     \"/actions/firefox\" : { \n"
-  "         \"poses\" : [        \n"
-  "           {                \n"
-  "             \"output\" : \"/actions/firefox/in/LHand_pose\", \n"
-  "              \"path\" : \"/user/hand/left/pose/raw\"     \n"
-  "            },\n"
-  "            {                                             \n"
-  "              \"output\" : \"/actions/firefox/in/RHand_pose\", \n"
-  "              \"path\" : \"/user/hand/right/pose/raw\"    \n"
-  "            }\n"
-  "         ],\n"
-  "         \"haptics\" : [ \n"
-  "            {\n"
-  "              \"output\" : \"/actions/firefox/out/LHand_haptic\",  \n"
-  "              \"path\" : \"/user/hand/left/output/haptic\"     \n"
-  "            },\n"
-  "            { \n"
-  "              \"output\" : \"/actions/firefox/out/RHand_haptic\", \n"
-  "              \"path\" : \"/user/hand/right/output/haptic\"    \n"
-  "            }\n"
-  "		  ],\n"
-  "       \"sources\" : [ \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"position\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_analog\" \n"
-  "               }, \n"
-  "               \"click\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_pressed\" \n"
-  "               }, \n"
-  "               \"touch\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_touched\" \n"
-  "               } \n"
-  "             }, \n"
-  "             \"mode\" : \"trackpad\", \n"
-  "             \"path\" : \"/user/hand/left/input/trackpad\" \n"
-  "           },\n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"position\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_analog\" \n"
-  "               }, \n"
-  "               \"click\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_pressed\" \n"
-  "               }, \n"
-  "               \"touch\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_touched\" \n"
-  "               } \n"
-  "             }, \n"
-  "             \"mode\" : \"trackpad\", \n"
-  "             \"path\" : \"/user/hand/right/input/trackpad\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"pull\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_trigger_value\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"trigger\", \n"
-  "             \"path\" : \"/user/hand/left/input/trigger\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"pull\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_trigger_value\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"trigger\", \n"
-  "             \"path\" : \"/user/hand/right/input/trigger\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"click\" : { \n"
-  "                \"output\" : \"/actions/firefox/in/LHand_grip_pressed\" \n"
-  "              }, \n"
-  "               \"touch\" : { \n"
-  "                 \"output\" : \"/actions/firefox/in/LHand_grip_touched\" \n"
-  "              } \n"
-  "             }, \n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/left/input/grip\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"click\" : { \n"
-  "                \"output\" : \"/actions/firefox/in/RHand_grip_pressed\" \n"
-  "              }, \n"
-  "               \"touch\" : { \n"
-  "                 \"output\" : \"/actions/firefox/in/RHand_grip_touched\" \n"
-  "              } \n"
-  "             }, \n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/right/input/grip\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_menu_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_menu_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/left/input/application_menu\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_menu_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_menu_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/right/input/application_menu\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_system_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/LHand_system_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/left/input/system\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "                 \"click\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_system_pressed\"  \n"
-  "                   }, \n"
-  "                 \"touch\" : { \n"
-  "                    \"output\" : \"/actions/firefox/in/RHand_system_touched\"  \n"
-  "                   } \n"
-  "              },\n"
-  "             \"mode\" : \"button\", \n"
-  "             \"path\" : \"/user/hand/right/input/system\" \n"
-  "           }, \n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"position\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_analog\" \n"
-  "               } \n"
-  "             }, \n"
-  "             \"mode\" : \"joystick\", \n"
-  "             \"path\" : \"/user/hand/left/input/joystick\" \n"
-  "           },\n"
-  "           {\n"
-  "             \"inputs\" : { \n"
-  "               \"position\" : { \n"
-  "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_analog\" \n"
-  "               } \n"
-  "             }, \n"
-  "             \"mode\" : \"joystick\", \n"
-  "             \"path\" : \"/user/hand/right/input/joystick\" \n"
-  "           } \n"
-  "         ]\n"
-  "     }\n"
-  "  }\n"
-  "}";
-  // clang-format on
-};
-
-}  // namespace gfx
-}  // namespace mozilla
-
-#endif  // GFX_VR_BLINDING_OPENVRWMRBINDING_H
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef GFX_VR_BLINDING_OPENVRWMRBINDING_H
+#define GFX_VR_BLINDING_OPENVRWMRBINDING_H
+
+namespace mozilla {
+namespace gfx {
+
+struct OpenVRWMRBinding {
+  const char* binding =
+      // clang-format off
+  "{\n"
+  "  \"version\" : \"0.1\", \n"
+  "  \"controller_type\" : \"holographic_controller\", \n"
+  "  \"description\" : \"Bindings for Firefox OpenVR for the Windows Mixed Reality controller\", \n"
+  "  \"name\" : \"Firefox bindings for Mixed Reality Controller\", \n"
+  "  \"bindings\" : { \n"
+  "     \"/actions/firefox\" : { \n"
+  "         \"poses\" : [        \n"
+  "           {                \n"
+  "             \"output\" : \"/actions/firefox/in/LHand_pose\", \n"
+  "              \"path\" : \"/user/hand/left/pose/raw\"     \n"
+  "            },\n"
+  "            {                                             \n"
+  "              \"output\" : \"/actions/firefox/in/RHand_pose\", \n"
+  "              \"path\" : \"/user/hand/right/pose/raw\"    \n"
+  "            }\n"
+  "         ],\n"
+  "         \"haptics\" : [ \n"
+  "            {\n"
+  "              \"output\" : \"/actions/firefox/out/LHand_haptic\",  \n"
+  "              \"path\" : \"/user/hand/left/output/haptic\"     \n"
+  "            },\n"
+  "            { \n"
+  "              \"output\" : \"/actions/firefox/out/RHand_haptic\", \n"
+  "              \"path\" : \"/user/hand/right/output/haptic\"    \n"
+  "            }\n"
+  "		  ],\n"
+  "       \"sources\" : [ \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"position\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_analog\" \n"
+  "               }, \n"
+  "               \"click\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_pressed\" \n"
+  "               }, \n"
+  "               \"touch\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_trackpad_touched\" \n"
+  "               } \n"
+  "             }, \n"
+  "             \"mode\" : \"trackpad\", \n"
+  "             \"path\" : \"/user/hand/left/input/trackpad\" \n"
+  "           },\n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"position\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_analog\" \n"
+  "               }, \n"
+  "               \"click\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_pressed\" \n"
+  "               }, \n"
+  "               \"touch\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_trackpad_touched\" \n"
+  "               } \n"
+  "             }, \n"
+  "             \"mode\" : \"trackpad\", \n"
+  "             \"path\" : \"/user/hand/right/input/trackpad\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"pull\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_trigger_value\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"trigger\", \n"
+  "             \"path\" : \"/user/hand/left/input/trigger\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"pull\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_trigger_value\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"trigger\", \n"
+  "             \"path\" : \"/user/hand/right/input/trigger\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"click\" : { \n"
+  "                \"output\" : \"/actions/firefox/in/LHand_grip_pressed\" \n"
+  "              }, \n"
+  "               \"touch\" : { \n"
+  "                 \"output\" : \"/actions/firefox/in/LHand_grip_touched\" \n"
+  "              } \n"
+  "             }, \n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/left/input/grip\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"click\" : { \n"
+  "                \"output\" : \"/actions/firefox/in/RHand_grip_pressed\" \n"
+  "              }, \n"
+  "               \"touch\" : { \n"
+  "                 \"output\" : \"/actions/firefox/in/RHand_grip_touched\" \n"
+  "              } \n"
+  "             }, \n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/right/input/grip\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_menu_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_menu_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/left/input/application_menu\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_menu_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_menu_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/right/input/application_menu\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_system_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/LHand_system_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/left/input/system\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "                 \"click\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_system_pressed\"  \n"
+  "                   }, \n"
+  "                 \"touch\" : { \n"
+  "                    \"output\" : \"/actions/firefox/in/RHand_system_touched\"  \n"
+  "                   } \n"
+  "              },\n"
+  "             \"mode\" : \"button\", \n"
+  "             \"path\" : \"/user/hand/right/input/system\" \n"
+  "           }, \n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"position\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/LHand_thumbstick_analog\" \n"
+  "               } \n"
+  "             }, \n"
+  "             \"mode\" : \"joystick\", \n"
+  "             \"path\" : \"/user/hand/left/input/joystick\" \n"
+  "           },\n"
+  "           {\n"
+  "             \"inputs\" : { \n"
+  "               \"position\" : { \n"
+  "                   \"output\" : \"/actions/firefox/in/RHand_thumbstick_analog\" \n"
+  "               } \n"
+  "             }, \n"
+  "             \"mode\" : \"joystick\", \n"
+  "             \"path\" : \"/user/hand/right/input/joystick\" \n"
+  "           } \n"
+  "         ]\n"
+  "     }\n"
+  "  }\n"
+  "}";
+  // clang-format on
+};
+
+}  // namespace gfx
+}  // namespace mozilla
+
+#endif  // GFX_VR_BLINDING_OPENVRWMRBINDING_H