Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Accelerometer values in upside down — Gideros Forum

Accelerometer values in upside down

alexzhengalexzheng Guru
edited January 2013 in General questions
Since the value of Accelerometer will out auto rotate when the oritation changed.

when the iOS device is upside down, the +x is in the left side, and we can not get the oritation, so we can not decide which direct to move to.

Comments

  • atilimatilim Maintainer
    uh.. I see. Let me try to find a good solution to it.
  • ar2rsawseenar2rsawseen Maintainer
    edited January 2013
    Theoretically you can implement a low pass filter to get the gravity component and base your decision on it.
    -- get accelerometer values
    local x, y = accelerometer:getAcceleration()
     
    -- apply low pass filter
    self.fx = x * self.filter + self.fx * (1 - self.filter)
    self.fy = y * self.filter + self.fy * (1 - self.filter)
    Then can't remember from the top of my head, but you can check for absolute values which is higher x or y to determine is it portrait or landscape and then is it positive or negative to see if it's landscape left or landscape right
  • alexzhengalexzheng Guru
    edited January 2013
  • uh.. I see. Let me try to find a good solution to it.
    I suggest two solutions:
    1. dispatch the device rotation event, we can calculator the value ourselfs.
    2. rotate the value of accelerometer according to oritation in the api.


  • Is there any progress on this?
    When using autorotate values are negated if upside down, but this info is not passed on to the lua environment, so no way to correct behaviour.
    Do the rotate events get pushed to lua layer in any way?
  • I did some test with Application:getOrientation()
    and it seems Application:getOrientation() only returns what is set, and not the real "active" orientation of the device....
    I guess I will have to analyse the other accel values to understand the orientation myself
    I was only using y, and now I will have to consider x, and z to see which orientation the device is in and then correct the y values accordingly for interaction....
  • it seems Application:getOrientation() only returns what is set, and not the real "active" orientation of the device....

    yup 1jetly

    hijacking thread now

    long time ago i had made one game which uses accelerometer that works fine when device is in faceup mode (i dont know whether android has faceup and facedown but still for explanation) but when it come in facedown mode (play while sleeping on bed) it doesnt work i had lived that as it was but just wanted to know whether there is any solid solution for this or not

    :)

    Likes: ramose

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.