05-19-2011 05:27 PM
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
http://www.blackberry.com/developers/docs/webworks
06-02-2011 08:42 PM
Im also trying to use rotationRate but cant seem to get it to work as well
06-03-2011 12:07 PM
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.
06-03-2011 12:25 PM
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
06-03-2011 01:20 PM
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.
06-03-2011 01:37 PM
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
10-24-2012 08:57 PM - edited 10-25-2012 07:01 PM
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...
10-29-2012 11:51 AM
Sensor APIs for WebWorks are coming very soon! Without making any promises they should arrive before the end of the year.
12-24-2012 01:27 AM
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/acceler
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/is
12-25-2012 04:05 AM
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);