Hi @santiagoluib3,
You might consider running an “accelerometer” check for a few seconds and see if you get a response. For example, check the “event.deltaTime” and see if it changes. If you do get a response within this time, then you can assume there’s an accelerometer. If not, then assume it “timed out” without a response.
Something like this (I tested this on a device with an accelerometer, but not one without, so you’ll need to test it more yourself):
[lua]
local hasAccelerometer = false
local previousDeltaTime = 0
local timeoutTimer
local timesToCheck = 10
local function onAccelerate( event )
--print( event.deltaTime )
if ( event.deltaTime ~= previousDeltaTime ) then
hasAccelerometer = true
end
end
local function checkForTimeout( event )
if ( hasAccelerometer == true ) then
print( “THERE IS AN ACCELEROMETER” )
timer.cancel( timeoutTimer )
elseif ( event.count == timesToCheck and hasAccelerometer == false ) then
print( “NO ACCELEROMETER DETECTED” )
Runtime:removeEventListener( “accelerometer”, onAccelerate )
end
end
timeoutTimer = timer.performWithDelay( 1000, checkForTimeout, timesToCheck )
Runtime:addEventListener( “accelerometer”, onAccelerate )
[/lua]
Brent