Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
ChanneledDan
Posts: 29
Registered: ‎02-25-2011
My Device: PlayBook
My Carrier: Rogers

deviceMotion event and 'acceleration', rotationRate'

Hi all,

 

I'm starting work on a PlayBook WebWorks app, and I can't quite get my event listener for devicemotion to work correctly. Specifically, the 'acceleration' and 'rotationRate' attributes.

 

accelerationIncludingGravity for x, y, and z works perfectly, giving me values. acceleration (the normal type, not including effects of gravity on the gyro) gives me an error. Same thing with rotationRate, which should have the attributes rotationRate.alpha, rotationRate.beta, and rotationRate.gamma, none of which seem to work (they don't seem to exist and when they get called it results in a JavaScript error).

 

Anyone get these to work correctly?

 

http://www.blackberry.com/developers/docs/webworks/api/DeviceMotionEvent.html

http://www.blackberry.com/developers/docs/webworks/api/RotationRate.html

--------------------------------------
PlayBook Apps: EveryDay Converter
Please use plain text.
New Member
Hindyo
Posts: 1
Registered: ‎06-02-2011
My Device: Blackberry Playbook
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'

Im also trying to use rotationRate but cant seem to get it to work as well

Please use plain text.
Developer
ChanneledDan
Posts: 29
Registered: ‎02-25-2011
My Device: PlayBook
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'

This is very confusing, since the documentation makes it appear as though these features are supported, but through some searching I found out that they are not supported (in WebWorks). Even thoguh the compatibility table shows the PlayBook as supporting it, it also says at the very top of the page that currently the hardware doesn't have a gyroscope (even though it does because it's accessible to Adobe AIR apps).

 

Odd.

--------------------------------------
PlayBook Apps: EveryDay Converter
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'

From the last I talked with the browser team, DeviceMotion is supported but DeviceOrientation is not supported.

 

I will double check to see if the RotationRate is not yet supported. and have the documentation updated accordingly

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'


ChanneledDan wrote:

This is very confusing, since the documentation makes it appear as though these features are supported, but through some searching I found out that they are not supported (in WebWorks). Even thoguh the compatibility table shows the PlayBook as supporting it, it also says at the very top of the page that currently the hardware doesn't have a gyroscope (even though it does because it's accessible to Adobe AIR apps).

 

Odd.


The text at the top of the page should read more that the Gyroscope hasn't been plumbed into the Browser yet, thus is not yet available.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'

It has been confirmed that the Gyroscope data is not supported on the PlayBook... The properties that are supported from the Device Motion Event are

 

- accelerationIncludingGravity

- interval

 

I have opened up a github Issue for the docs correction.. hopefully we can get this updated as part of the Delta release of the WebWorks SDK for Tablet OS due out mid June

 

https://github.com/blackberry/WebWorks-API-Docs/issues/150

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Trusted Contributor
lcocea
Posts: 117
Registered: ‎02-29-2012
My Device: PlayBook & Nexus 4

Re: deviceMotion event and 'acceleration', rotationRate'

[ Edited ]

I wonder what's taking so long (2 years and counting) to add the gyroscope, acceleration (without gravity), and magnetometer APIs to the WebWorks SDK...

Please use plain text.
BlackBerry Development Advisor (Retired)
aparco
Posts: 15
Registered: ‎10-11-2012
My Device: BlackBerry Z10
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'

Sensor APIs for WebWorks are coming very soon!  Without making any promises they should arrive before the end of the year.

Please use plain text.
Contributor
Andrew4Life
Posts: 41
Registered: ‎02-14-2012
My Device: Curve 8900 / Playbook
My Carrier: Rogers

Re: deviceMotion event and 'acceleration', rotationRate'

What is the status of this?

 

When trying to use Acceleration on the BB10 Dev Alpha, it seems that instead of getting 9.8 for gravity, it was normalized to 1. 

 

Where as the documentation says:

"Data Examples= A device lying flat on a horizontal surface with the screen upmost has an acceleration of zero and the following value for accelerationIncludingGravity="

https://developer.blackberry.com/html5/api/acceleration.html

 

It's still not clear what accleration does. (As opposed to accelerationwithgravity).

Seems like an issue was opened 6 months ago to update something, but it still is open.

https://github.com/blackberry/WebWorks-API-Docs/issues/323

 

 

Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: deviceMotion event and 'acceleration', rotationRate'

I've managed to get the kind of thing you seem to be after using the Accelerometer

 

The trick is to track it via the devicemotion event

 

The Community Sample 'KitchenSink' is very useful to see this in action without the hassle of debugging your own code

 

I only use two planes of movement in the code below but you can use the Z as well if you like

 

I used an expanded version of the following as a control system for a game we ditched - it's similar to the driving games where you 'steer' the device

 

 

Some code....

--------------------

function handleDeviceMotion(event)
    {
    ax = event.accelerationIncludingGravity.x;
    ay = event.accelerationIncludingGravity.y;

    if(ax > 2)
        {
        // Right
        }
    else
        {
        // Not right
        }
        
    if(ax < -2)
        {
        // Left
        }
    else
        {

        // Not left
        }
    
    }

window.addEventListener("devicemotion", handleDeviceMotion, false);




Click the like button if you find my posts useful!
Please use plain text.