Andorid>Mouse script aleatory jumps! :S

Official forum for open source FreePIE discussion and development.
Post Reply
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Andorid>Mouse script aleatory jumps! :S

Post 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).
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Andorid>Mouse script aleatory jumps! :S

Post by RescueGamer »

anyone? :(
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Andorid>Mouse script aleatory jumps! :S

Post 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?
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Andorid>Mouse script aleatory jumps! :S

Post 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
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Andorid>Mouse script aleatory jumps! :S

Post 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
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Andorid>Mouse script aleatory jumps! :S

Post 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
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Andorid>Mouse script aleatory jumps! :S

Post 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
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Andorid>Mouse script aleatory jumps! :S

Post 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 :)
Post Reply

Return to “FreePIE”