[HELP] Mouse emulation code! for PC

Official forum for open source FreePIE discussion and development.
Post Reply
MaximousHD
One Eyed Hopeful
Posts: 1
Joined: Thu Oct 02, 2014 5:22 pm

[HELP] Mouse emulation code! for PC

Post by MaximousHD »

Hello everyone, as you can probably tell I am new here, I came for assistance of being able to use oculus rift demos with my android device, Here is what I have so far for my set up: I have a galaxy s4, I bought Google cardboard(I am trying to set this up before I get it so when I get it I am still not messing with the programs so much) I have the Freepie IMU and splashtop(Will probably switch to Kainy) and all of the mouse emulation codes I have tried have not worked, recently I have combined some Freetrack Android Gyroscope code with some Android mouse emulation code to mix and match until I have been able to actually make my mouse respond to the movement of my Device, I got it working but it is not very "accurate" like when I move my phone up, it moves diagonal, when I move my phone to the left, it will send the mouse in some random direction, heres the code(By the layout of it you can probably tell I have never worked with python before.)



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

if starting:
centerYaw = 0
centerPitch = 0
centerRoll = 0

yaw = 0
pitch = 0
roll = 0
android[0].update += update

freeTrack.yaw = yaw - centerYaw
freeTrack.pitch = pitch - centerPitch
freeTrack.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll

if starting:
global yaw
global roll
global pitch
yaw = -android[0].googleYaw
roll = -android[0].googleRoll
pitch = android[0].googlePitch

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

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

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.M)

if toggle:
enabled = not enabled




EDIT: I found the reason why the movements were so weird, it is because my phone needs to be facing the screen in a way that I cannot put it in the cardboard, Does anyone know how to change this so I can have it be horizontal instead of vertical? if you do, please edit my script and paste it below.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [HELP] Mouse emulation code! for PC

Post by CyberVillain »

Try android[0].googleYaw its more suited for your use case

FreePIE does not support to emulate oculus sadly
Post Reply

Return to “FreePIE”