mirror of https://github.com/axmolengine/axmol.git
fixed accelerometer for windows store apps device orientation
This commit is contained in:
parent
634fb98a5d
commit
ff172e0057
|
@ -100,6 +100,7 @@ void Device::setAccelerometerEnabled(bool isEnabled)
|
|||
|
||||
auto orientation = GLViewImpl::sharedOpenGLView()->getDeviceOrientation();
|
||||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
switch (orientation)
|
||||
{
|
||||
case DisplayOrientations::Portrait:
|
||||
|
@ -127,7 +128,36 @@ void Device::setAccelerometerEnabled(bool isEnabled)
|
|||
acc.y = reading->AccelerationY;
|
||||
break;
|
||||
}
|
||||
#else // Windows Store App
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/apps/dn440593
|
||||
switch (orientation)
|
||||
{
|
||||
case DisplayOrientations::Portrait:
|
||||
acc.x = reading->AccelerationY;
|
||||
acc.y = -reading->AccelerationX;
|
||||
break;
|
||||
|
||||
case DisplayOrientations::Landscape:
|
||||
acc.x = reading->AccelerationX;
|
||||
acc.y = reading->AccelerationY;
|
||||
break;
|
||||
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
acc.x = -reading->AccelerationY;
|
||||
acc.y = reading->AccelerationX;
|
||||
break;
|
||||
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
acc.x = -reading->AccelerationY;
|
||||
acc.y = reading->AccelerationX;
|
||||
break;
|
||||
|
||||
default:
|
||||
acc.x = reading->AccelerationY;
|
||||
acc.y = -reading->AccelerationX;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
std::shared_ptr<cocos2d::InputEvent> event(new AccelerometerEvent(acc));
|
||||
cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(event);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue