Orientation Change not working as expected (Kindle Fire)

Hello!

I’ve developed my game to work on landscape orientation and when I turn my device the entire scene changes as expected, but the controls get reversed (right is left, and left is right).

I’m using the yGravity to control that so I made a short function to detect the orientation and react accordingly, but I can’t get it to work.

The orientation is ‘STUCK’ on the orientation the app was launched in, but the orientation change doesn’t get detected.

Here is the code:
 

local myOrientation = system.orientation local function changeOrientation (event) myOrientation = event.type print("SWICHAROOOOOOOOOOOOOO: "..event.delta) end local function onTilt( event ) print("This is my orientation: "..myOrientation) local tilt = 0 --print("Running on Game:Tilt") local u,v = heli:getLinearVelocity() if "landscapeLeft" == myOrientation then print("I'm in landscapeLeft!!!") print("Event Gravity: "..event.yGravity) tilt = -event.yGravity elseif "landscapeRight" == myOrientation then print("I'm in landscapeRight !!!") print("Event Gravity: "..event.yGravity) tilt = event.yGravity end ----print("Tilt: "..tilt) local newDirection = 0 if math.abs(tilt) \> .1 then newDirection = tilt print("NewVelocity: "..-newDirection\*300) ----print("X Velocity: "..-newDirection\*300) heli:setLinearVelocity(-newDirection\*300,v) if heli.x\<=-100 then heli.x=-100 elseif heli.x\>=580 then heli.x=580 end else heli:setLinearVelocity(0,v) newDirection = 0 end direction = newDirection end function scene:enterScene(event) --Check Orientation myOrientation = system.orientation -- Add a orientation listener Runtime:addEventListener( "orientation", changeOrientation ) --Add tilt listener Runtime:addEventListener ("accelerometer", onTilt) end