Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devicemotion can't support remote controller of AppleTV #598

Open
finscn opened this issue Dec 28, 2015 · 4 comments
Open

devicemotion can't support remote controller of AppleTV #598

finscn opened this issue Dec 28, 2015 · 4 comments

Comments

@finscn
Copy link
Contributor

finscn commented Dec 28, 2015

is this feature in the roadmap?

@ericjbasti
Copy link

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.

@finscn
Copy link
Contributor Author

finscn commented Dec 29, 2015

@phoboslab , I implement this feature in my fork
finscn@597e1e7

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 .

@finscn
Copy link
Contributor Author

finscn commented Dec 30, 2015

I update my fork:
finscn@c6f1948

@finscn
Copy link
Contributor Author

finscn commented Jan 4, 2016

Update again: finscn@7bfc59c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants