FreePie and HTC One M8

Official forum for open source FreePIE discussion and development.
Post Reply
tekolinooo
One Eyed Hopeful
Posts: 5
Joined: Sun Feb 15, 2015 4:43 pm

FreePie and HTC One M8

Post by tekolinooo »

Hello guys!
For some time i was trying to make my own "diy rift" for gaming.
I tried some tracking ways to emulate a mouse but all seem to be laggy and not so good.
I saw the features that freePie can give us and i tried to make it work with my phone. Sadly, no success at all.

I am using the android free pie imu apk installed on my htc one m8, freepie 1.8 installed on my pc and i tride the following codes:

Code: Select all

Android mouse emulation with deadband and continous yaw

def update():   
    #Apply deadband filter to avoid drift
    #And continousRotation filter to yaw axis to avoid jumps when passing tracker center
    x = filters.deadband(filters.delta(math.degrees(filters.continousRotation(android[0].yaw))), deadband)
    y = filters.deadband(filters.delta(math.degrees(android[0].pitch)), deadband)
      
    mouse.deltaX = x * multiply
    mouse.deltaY = y * multiply
   
if starting: 
    deadband = 0.01
    multiply = 5
    android[0].update += update
and

Code: Select all

TrackIR mouse emulation

#Use Z to toggle on/off and right mouse to activate head tracking 
#(Good for games like Battlefield 3)
def update():
    yaw = trackIR.yaw
    pitch = trackIR.pitch
   
    deltaYaw = filters.delta(yaw)
    deltaPitch = filters.delta(pitch)   
     
    if (enabled and hotkey):
        mouse.deltaX = deltaYaw*multiply
        mouse.deltaY = -deltaPitch*multiply

if starting:
    enabled = False
    multiply = 20
    trackIR.update += update

hotkey = mouse.rightButton
toggle = keyboard.getPressed(Key.Z)

if toggle:
    enabled = not enabled
I am pretty sure that i made some mistakes or i did not understand how to put them together.
Another thing i have to ask is about freetrack.
As soon as i use the python code from "script examples" android > freetrack i have to use the freetrack software to "catch" the readings from my phone? I have freetrack installed since i used it for the past way to track my movement.

Can anyone put a lil' "tutorial" on how to run this on my phone?

I would like to use the memory sharing track from vireio but the vireioSMT plugin seems not to work with this version of freepie. I cannot start it with vireioSMT plugin installed.

And another little thing, could i emulate the combined readings by my phone's sensors as a HMD? Some games which have native 3d support have to "detect" hmds for "full support".

I look forward for your answers!
Thank you very much!
tekolinooo
One Eyed Hopeful
Posts: 5
Joined: Sun Feb 15, 2015 4:43 pm

Re: FreePie and HTC One M8

Post by tekolinooo »

Hello guys ! I managed it to work now, its a very cool feature.
I tested it a little in portal 2 and some games and it works great. One thing that i like to add as a "feature" for my code is an autocenter when i stay for some time pointing forward. Some like when i stay in my 0,0,0 position for 5 seconds the pointer resets to center values.
I am kinda new to python and i don't know so much about it. It's cool and i will do my best to learn it.
As a way out if i can't implement this feature it would be a custom key that when is pressed it reset the cursor to center. Tell me if you have any ideas :)

Here is my code ( it's not made by me, i just removed and modified some values to make it work better for me )

Code: Select all

def update():
   global yaw
   global pitch
   
   yaw = android[0].googleYaw
   pitch = -android[0].googleRoll
   

   
   diagnostics.watch(yaw)
   diagnostics.watch(pitch)

def getRaw(z): #n is the denominator for the value
	rollRaw.append(math.degrees(-(android[index].googlePitch)) / z)
   
if starting:
   yawMult = 1000
   pitchMult = 1000
   rollMult = 5
   gaussMax = 35 #size of filter to gain stability, must be odd number
   index = 0 #which android device to use
   
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0
   
   yaw = 0
   pitch = 0
   roll = 0
   
   rollRaw = list()
   
   #calculate gauss matrix
   gaussMatrix = list()
   for x in xrange(gaussMax):
   		gaussMatrix.append(2.7182818284 ** (-(x-math.floor(gaussMax/2)) ** 2))
   		#example if gaussMax = 3, floor(3/2) = floor(1.5) = 1. x-1
   		#example if gaussMax = 5, floor(5/2) = floor(2.5) = 2. x-2
   print gaussMatrix
   
   #get raw data first
   for x in xrange(gaussMax):
    getRaw(rollMult) #call function raw values with divider as parameter 
   
   prevGauss = [0,0,0] #gauss values tracker, [yaw, pitch, roll]
   
   android[index].update += update
   enabled = True
   
   
#reset gauss values
gaussRoll = 0

#create new gauss values from the collected raw values
#will be updated into vireioSMT in update()
for x in xrange(gaussMax):
	gaussRoll += rollRaw[x] * gaussMatrix[x]

#mouse move code starts here
deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)

if (enabled):
	mouse.deltaX = deltaYaw*1000
	mouse.deltaY = deltaPitch*1000
#mouse move code ends here
	
#remove first values of raw lists
#list.remove takes out the first incident of the value in (x) 
rollRaw.remove(rollRaw[0])

#take new value at end of raw lists
getRaw(rollMult)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: FreePie and HTC One M8

Post by CyberVillain »

Sadly you cant tell whats the center with mouse emulation so there is not way to return to center :/
tekolinooo
One Eyed Hopeful
Posts: 5
Joined: Sun Feb 15, 2015 4:43 pm

Re: FreePie and HTC One M8

Post by tekolinooo »

Oh i understand, but could we "reset" the 0 values that android sends us? Just like when whe put the phone on a stable position, take the values that it sends and use them as "center values" for our code. Is that possible in any way?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: FreePie and HTC One M8

Post by CyberVillain »

But with a relative device as a mouse there is no center
tekolinooo
One Eyed Hopeful
Posts: 5
Joined: Sun Feb 15, 2015 4:43 pm

Re: FreePie and HTC One M8

Post by tekolinooo »

I managed it to work properly for now, the only thing that i would like to do is to emulate this " mouse " as oculus rift. Is there any "example script" for this? I saw on github page that freepie can do it :)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: FreePie and HTC One M8

Post by CyberVillain »

FreePIE can only read Oculus data, not simulate it. Its because there is not easy point of entry with their library (Which off course is a deliberate act on their part)
tekolinooo
One Eyed Hopeful
Posts: 5
Joined: Sun Feb 15, 2015 4:43 pm

Re: FreePie and HTC One M8

Post by tekolinooo »

I read some more about oculus and their libs, i understand now, hopefully the developers will publish the games I want without "direct oculus launcher" .
Thank you very much for your attention!
Post Reply

Return to “FreePIE”