Skip to content

Instantly share code, notes, and snippets.

@NanoPi
NanoPi / DSUServer_mouse-gyro-min.py
Last active February 18, 2023 08:59
FreePIE script, experimental DSU Server that always has a single DS4 controller that does nothing except output IMU data. Converts raw mouse movements to the gyroscope's Yaw and Pitch with a little bit of smoothing.
import socket
import struct
import select
import time
import random
from binascii import crc32
DSUC_VersionReq = 0x100000
DSUS_VersionRsp = 0x100000
DSUC_ListPorts = 0x100001
@NanoPi
NanoPi / showcursor.ahk
Last active February 13, 2022 20:47
Small demo to test Steam Controller config Action Set switching.
Gui, Show, w640 h360
OnMessage(0x100, "WM_KEYDOWN")
Return
;C::DllCall("ShowCursor", UInt,0)
;V::DllCall("ShowCursor", UInt,1)
GuiClose:
{
ExitApp
}
from math import atan2, sqrt, pow
#import numpy
import operator
def cross(a, b):
return a[0]*b[1]-a[1]*b[0]
def dot(a,b):
return sum(map( operator.mul, a, b))
if starting:
kx = 0.0
ky = 0.0
@NanoPi
NanoPi / joymouse.PIE
Created August 24, 2014 05:47
GlovePIE joystick mouse script
//pie.framerate = screen.RefreshRate
pie.framerate = 120
var.f = removeunits(pie.framerate)
var.x = deadzone(joy.X,0.03)
var.y = deadzone(joy.Y,0.03)
var.scale = 60
var.x = ensuremaprange(var.x,-1,1,-var.scale,var.scale)
var.y = ensuremaprange(var.y,-1,1,-var.scale,var.scale)
var.dial = EnsureMapRange(joy.dial, -0.62, 1, -1, 1)
@NanoPi
NanoPi / mouse.py
Last active March 17, 2025 08:34
FreePIE joystick mouse script
# https://github.com/AndersMalmgren/FreePIE/wiki/Sign
def sign(val): #Returns -1 for negatives, 0 for zero and 1 for positives
return (1 * (val > 0)) + (-1 * (val < 0))
# https://github.com/AndersMalmgren/FreePIE/wiki/ScaledDeadzone
# (modified)
def ScaledDeadzone(val, mini, maxi, dz): #Paremeters are Value, Minimum, Maximum and Deadzone Size.
scaled = filters.mapRange(val,mini,maxi, -1.0,1.0)
output = 0.0
if abs(scaled) > dz: