Bug 1305890 - Part 1: Oculus Touch button inputs support; r=kip

MozReview-Commit-ID: CJmSW00e8Ov

--HG--
extra : rebase_source : f27abcda43cd3c02eb7f31cece07ef7ad26899d9
This commit is contained in:
Daosheng Mu 2017-01-04 11:30:49 +08:00
Родитель 8d57237a09
Коммит 32f7b8390b
2 изменённых файлов: 34 добавлений и 6 удалений

Просмотреть файл

@ -192,7 +192,9 @@ VRManager::NotifyVsync(const TimeStamp& aVsyncTimestamp)
TimeDuration duration = TimeStamp::Now() - mLastRefreshTime;
if (duration.ToMilliseconds() > kVRDisplayRefreshMaxDuration) {
RefreshVRDisplays();
RefreshVRControllers();
if (bHaveControllerListener) {
RefreshVRControllers();
}
mLastRefreshTime = TimeStamp::Now();
}
}

Просмотреть файл

@ -122,15 +122,15 @@ static pfn_ovr_GetMirrorTextureBufferGL ovr_GetMirrorTextureBufferGL = nullptr;
#define OVR_MINOR_VERSION 10
static const ovrButton kOculusTouchLButton[] = {
ovrButton_LThumb,
ovrButton_X,
ovrButton_Y,
ovrButton_LThumb
ovrButton_Y
};
static const ovrButton kOculusTouchRButton[] = {
ovrButton_RThumb,
ovrButton_A,
ovrButton_B,
ovrButton_RThumb
};
static const uint32_t kNumOculusButton = sizeof(kOculusTouchLButton) /
@ -939,7 +939,7 @@ VRSystemManagerOculus::GetHMDs(nsTArray<RefPtr<VRDisplayHost>>& aHMDResult)
void
VRSystemManagerOculus::HandleInput()
{
// mSession is available after VRDisplay is created
// mSession is available after VRDisplay is created
// at GetHMDs().
if (!mSession) {
return;
@ -964,7 +964,33 @@ void
VRSystemManagerOculus::HandleButtonPress(uint32_t aControllerIdx,
uint64_t aButtonPressed)
{
// TODO: Bug 1305890
MOZ_ASSERT(sizeof(kOculusTouchLButton) / sizeof(ovrButton) ==
sizeof(kOculusTouchRButton) / sizeof(ovrButton));
RefPtr<impl::VRControllerOculus> controller(mOculusController[aControllerIdx]);
MOZ_ASSERT(controller);
GamepadHand hand = controller->GetHand();
uint64_t diff = (controller->GetButtonPressed() ^ aButtonPressed);
uint32_t buttonMask = 0;
for (uint32_t i = 0; i < kNumOculusButton; ++i) {
switch (hand) {
case mozilla::dom::GamepadHand::Left:
buttonMask = kOculusTouchLButton[i];
break;
case mozilla::dom::GamepadHand::Right:
buttonMask = kOculusTouchRButton[i];
break;
default:
MOZ_ASSERT(false);
break;
}
if (diff & buttonMask) {
NewButtonEvent(aControllerIdx, i, diff & aButtonPressed);
}
}
controller->SetButtonPressed(aButtonPressed);
}
void