Accelerometer and orientation

So here is my issue,

I have a object that uses the accelerometer to move only left and right. On the orientation “landscapeRight” my object works perfectly, I tilt left the object moves right, just like it supposed to. On the orientation “landscapeLeft” things dont work right. I tilt left the object moves left, right moves it moves right. Can someone help me fix this? It feels unnatural for it to move the direction opposite I am tilting, plus it is inconsistent with the other orientation.

Here is my current code:

[lua]maxVisibleX = display.viewableContentWidth + -1* display.screenOriginX

local motionx = 0

local function onTilt( event )
motionx = (30 * event.yGravity) – Uses y gravity because it is in landscape orientation
end
Runtime:addEventListener( “accelerometer”, onTilt )

local function moveball (event)
if ((pail.x + motionx) < maxVisibleX) then
if ((pail.x + motionx) > display.screenOriginX) then
pail.x = pail.x + motionx + (motionx/2)
end
end
end
Runtime:addEventListener(“enterFrame”, moveball)[/lua] [import]uid: 104852 topic_id: 27466 reply_id: 327466[/import]

You need to detect the current orientation because, while the screen may auto rotate the display, the physical device is still either on it’s left or it’s right. [import]uid: 8271 topic_id: 27466 reply_id: 111613[/import]

I need to detect the screen orientation becouse the values become opposite what the were on the other rotation. [import]uid: 104852 topic_id: 27466 reply_id: 111672[/import]

You’re almost doing that already…

http://developer.anscamobile.com/content/events-and-listeners#orientation [import]uid: 8271 topic_id: 27466 reply_id: 111674[/import]