Page 1 of 1

Andorid>Mouse script aleatory jumps! :S

Posted: Thu May 23, 2013 3:56 pm
by RescueGamer
Hi, i'm using a script to emulate the mouse with the android sensors, it works really well, but it makes jumps in some aleatory positions(I think is aleatory beacuse it changes every time i close freepie, or it depends on how close is the cursor from the end of the desktop at the moment the program start runing or somethin like that), that happen when you try to rotate or looking too up/down (even if you only rotate a few, it works better with the phone turned back)

This is the script:

Code: Select all

def update():
   yaw = -android.googleYaw
   pitch = android.googlePitch
    
   deltaYaw = filters.delta(yaw)
   deltaPitch = filters.delta(pitch)   
    
   mouse.deltaX = deltaYaw*multiply
   mouse.deltaY = deltaPitch*multiply

if starting:
   multiply = 200
   android.update += update
Any ideas of what is causing this?, because other than that the script is really good, I get a better tracking than other scripts as freetrack or vireioSMT (the latter works great too, but loses calibration and have some latency).

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Tue May 28, 2013 9:00 am
by RescueGamer
anyone? :(

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Tue May 28, 2013 9:36 am
by CyberVillain
If it was only yaw then I would say the problem is when the compass goes from +180 to -180 the delta value sent to mouse will be huge at this point. But you say its also a problem with pitch? Same problem both with Google yaw and yaw?

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Tue May 28, 2013 10:11 am
by RescueGamer
I don't know for sure if the pitch jumps too, it simly does something strange on the edges, but not that aleatory jumps which unables me to turn around in yaw. I only can use the google yaw, for some reason if I use only yaw etc I never get good results, the last time i tested with only yaw,pitch and roll (without google) the pitch and roll fusion their valors, i mean, if i move the smartphone for pitch it change a bit the roll valor too :S

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Tue May 28, 2013 4:57 pm
by CyberVillain
Please check if the jump happens at the magnetic north only. I helped another user with this problem, but cant find that script.
If it only happens when passing the magnetic north its becasue the value goes from +180 to -180 the delta value sent into the mouse emulation will then be 360 degress making it jump

edit: look here http://www.mtbs3d.com/phpBB/viewtopic.p ... lta#p99613

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Tue May 28, 2013 5:28 pm
by RescueGamer
seems to be the solution, but i get "expected an indented block" with this:
def update():
global yaw
global roll
global pitch
yaw = android.googleYaw + math.pi
roll = android.googleRoll
pitch = android.googlePitch


if starting:
yaw = 0
roll = 0
pitch = 0
enabled = False
android.update += update

deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
deltaRoll = filters.delta(roll)

if math.fabs(deltaYaw) >= math.pi:
deltaYaw = 0

if (enabled):
mouse.deltaX = -deltaYaw*600
mouse.deltaY = -deltaRoll*1000


toggle = keyboard.getPressed(Key.Z)

if toggle:
enabled = not enabled

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Wed May 29, 2013 2:30 am
by CyberVillain
Python is picky about indention you need to keep the tabs for it to work

Code: Select all

def update():
	global yaw
	global roll
	global pitch
	yaw = android.googleYaw + math.pi
	roll = android.googleRoll
	pitch = android.googlePitch


if starting:
	yaw = 0
	roll = 0
	pitch = 0
	enabled = False
	android.update += update

deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
deltaRoll = filters.delta(roll)

if math.fabs(deltaYaw) >= math.pi:
	deltaYaw = 0

if (enabled):
	mouse.deltaX = -deltaYaw*600
	mouse.deltaY = -deltaRoll*1000


toggle = keyboard.getPressed(Key.Z)

if toggle:
	enabled = not enabled

Re: Andorid>Mouse script aleatory jumps! :S

Posted: Wed May 29, 2013 4:55 am
by RescueGamer
Thanks! that works really well, now i changed it to use te pitch as "Y" and added a line for use the roll with vireio shared memory, now i have a realy good script, with this i had a very functional head tracking for my future DIY rift (it has very low lag, not perfect but very good latency) with my smartphone, thanks a lot for all, you do a huge work for this community :)