views:

47

answers:

2

I am looking at using the accelerometer as an input channel for controlling a game on the Blackberry. However, I only want to respond to it when the user makes a violent motion to the left or the right.

So my question is: what is the range of input to expect from a user holding the device in their hands and what threshold should I set to be sure I don't respond to normal movement during play?

+3  A: 

The API docs specify that the maximum G-force acceleration that the hardware can measure is usually 2G, so if you want "violent" shaking that would be a good number to shoot for.

However, I'd highly recommend writing up a quick test app that records the values from the accelerometer and shows you the actual values it is recording (either to a log file or just keep track of the current "maximum"). Then just play around with the device and determine the best thresholds for "normal" use and "violent shaking".

Marc Novakowski
+1  A: 

I did accordingly to Marc's answer and I wrote a test that gave me the range of input. Each x, y, and z axis can have a value of -1048 to 1048 (as fas as I can tell). There is additional information on how to use the AcceleratorSensor to read these values and what they mean in the 4.7 API documentation.

After further testing on the device I figure that a variation of +/- 1000 in any direction within 50ms was enough to separate normal movement from a shake.

ADB