Created
July 5, 2018 18:24
-
-
Save NanoPi/ddceb17a50884d7b3500e21f9c0e522b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| mw = 0.0 | |
| mm = 0.0 | |
| [jx,jy] = [xbox360[0].leftStickX,-xbox360[0].leftStickY] | |
| ku=cross([jx,jy],[kx,ky]) | |
| kv=dot([jx,jy],[kx,ky]) | |
| kw=atan2(ku,kv) | |
| kz=sqrt(pow(jx,2)+pow(jy,2)) | |
| [kx,ky]=[jx,jy] | |
| #diagnostics.watch(filters.simple(kw*500,0.9)) | |
| #if kw!=0.0: | |
| if kz>0.0001: | |
| mm = filters.simple(kw*500,0.95) | |
| #diagnostics.watch(mm*1) | |
| if abs(mm) < 2:#5: | |
| mm = 0 | |
| mw += kw*500 | |
| if abs(mw) >= 1.0: | |
| mouse.wheel = int(mw) | |
| mw -= int(mw) | |
| else: | |
| #diagnostics.watch(mm) | |
| mm*=0.975 | |
| if abs(mm)<0.01: | |
| mm=0 | |
| mw+=mm | |
| if abs(mw) >= 1.0: | |
| mouse.wheel = int(mw) | |
| mw -= int(mw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment