FreePIE

Programmable Input Emulator

This project is maintained by AndersMalmgren and zelmon64

Script examples

FreePIE uses Python as the scripting language of choice since v0.4.211.0. Here follows a collection of simple script examples to get you started.

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

PPJoy joystick emulation

def update():
    x = math.degrees(freeTrack.yaw) * ratio
    y = math.degrees(freeTrack.pitch) * ratio

    ppJoy[0].setAxis(AxisTypes.X, x)
    ppJoy[0].setAxis(AxisTypes.Y, y)

if starting:
    maxAngle = 180
    axisRange = 1000
    ratio = axisRange / maxAngle
    freeTrack.update += update
        

Android > Freetrack

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

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