Open finscn opened 8 years ago
This is an interesting issue, because the only way to get the equivalent of device motion onto the atv requires the remote. The remote is a gamepad, and the current gamepad spec (which Dominic probably wants to stick to) doesn't support the required attributes.
It's easy to add in if you're looking to do so. In the EJBindingGamepad.m file you can add the gravity/acceleration attributes to the "microGamepad"
~ line 184 (EJBindingGamepad.m)
#if TARGET_OS_TV
// Provide the Remote's touch pad a axis in addition to the Up/Down/Left/Right buttons
else if( controller.microGamepad ) {
GCMicroGamepad *gamepad = controller.microGamepad;
JSObjectSetPropertyAtIndex(ctx, jsAxes, 0, JSValueMakeNumber(ctx, gamepad.dpad.xAxis.value), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 1, JSValueMakeNumber(ctx, -gamepad.dpad.yAxis.value), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 4, JSValueMakeNumber(ctx, controller.motion.gravity.x), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 5, JSValueMakeNumber(ctx, controller.motion.gravity.y), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 6, JSValueMakeNumber(ctx, controller.motion.gravity.z), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 7, JSValueMakeNumber(ctx, controller.motion.userAcceleration.x), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 8, JSValueMakeNumber(ctx, controller.motion.userAcceleration.y), NULL);
JSObjectSetPropertyAtIndex(ctx, jsAxes, 9, JSValueMakeNumber(ctx, controller.motion.userAcceleration.z), NULL);
}
#endif
return jsAxes;
You can then access this data the same way you would access the dpad info, just at the different array indexes. Not as nice as using the device motion api, but its not the same thing.
@phoboslab , I implement this feature in my fork
https://github.com/finscn/Ejecta/commit/597e1e77ff25189a23ee1db7897bb579731561fb
I hope it could help you.
In my version , the devicemotion event isn't invoked by [deviceMotionDelegate triggerDeviceMotionEvents];
.
It will be invoked when user call navigator.getGamepads(), I think 60FPS to hight .
is this feature in the roadmap?