diff --git a/garrysmod/garrysmod/lua/autorun/TrackIR.lua b/garrysmod/garrysmod/lua/autorun/TrackIR.lua index fb34a09..f07ba92 100644 --- a/garrysmod/garrysmod/lua/autorun/TrackIR.lua +++ b/garrysmod/garrysmod/lua/autorun/TrackIR.lua @@ -1,9 +1,4 @@ if CLIENT then - if not file.Exists("garrysmod/lua/bin/gmcl_TrackIR_win32.dll", "BASE_PATH") then - print("no trackir m8") - return - end - local DPS = 66 -- tickrate local draw = draw local math = math @@ -12,8 +7,6 @@ if CLIENT then local data1 local data2 - - local function RotateVector(vector, angle) local _vector = vector local _angle = angle @@ -22,6 +15,8 @@ if CLIENT then return _vector end + + -- no ugly view like 'max is 130, min is 130, more like max is 130 but every ° over 130 is reducted (1/exp function) local function Nicerlimit(var, minu, maxi) local _maxi = maxi + 0.2 * maxi -- +20% local _minu = minu + 0.2 * minu @@ -47,7 +42,8 @@ if CLIENT then var = math.min(math.max(_minu, var), _maxi) return var - end -- no ugly view like 'max is 130, min is 130, more like max is 130 but every ° over 130 is reducted (1/exp function) + end + local function TrackIR_View(ply, origin, angles, fov, znear, zfar) local vehicle = LocalPlayer():GetVehicle() @@ -60,12 +56,10 @@ if CLIENT then return end - if LocalPlayer():GetNWEntity("ScriptedVehicle", NULL) ~= NULL and string.StartWith(LocalPlayer():GetNetworkedEntity("ScriptedVehicle", NULL):GetClass(), "sent_") then return end - local ang1 = Angle(Nicerlimit(TrackIR.Pitch / 90, -70, 70), 0, 0) local ang2 = Angle(0, Nicerlimit(TrackIR.Yaw / 90, -130, 130), 0) local ang3 = Angle(0, 0, Nicerlimit(-1 * TrackIR.Roll / 90 + -2 * TrackIR.X / 900, -70, 70)) @@ -81,9 +75,9 @@ if CLIENT then view.drawviewer = false return view - end -- for the players + end - local function TrackIR_View2(ply, origin, angles, fov, znear, zfar) + local function TrackIR_View2(ply, origin, angles, fov, znear, zfar) local ang1 = Angle(Nicerlimit(TrackIR.Pitch / 90, -70, 70) + angles[1], 0, 0) local ang2 = Angle(0, Nicerlimit(TrackIR.Yaw / 90, -130, 130) + angles[2], 0) local ang3 = Angle(0, 0, Nicerlimit(-1 * TrackIR.Roll / 90 + -2 * TrackIR.X / 900, -70, 70)) @@ -99,9 +93,11 @@ if CLIENT then view.drawviewer = false return view - end -- for the players + end + local function TrackIR_Timer() + -- the best way would be to make it 60/120 times per sec. (i mean, not 60-120, it's 60 OR 120 (depending of the trackir device)) TrackIR.Update() TrackIR.Pitch = TrackIR.get_Pitch() or 0 TrackIR.Yaw = TrackIR.get_Yaw() or 0 @@ -113,33 +109,32 @@ if CLIENT then Var_TrackIR_Angle_APIRAW = Angle(Nicerlimit(TrackIR.Pitch / 90, -70, 70), Nicerlimit(TrackIR.Yaw / 90, -130, 130), Nicerlimit(-1 * TrackIR.Roll / 90 + -2 * TrackIR.X / 900, -70, 70)) data1 = Angle(Nicerlimit(TrackIR.Roll / 90 + TrackIR.X / 900, -70, 70), -1 * Nicerlimit(TrackIR.Pitch / 90, -70, 70), Nicerlimit(TrackIR.Yaw / 90, -130, 130)) data2 = -1 * TrackIR.X / 500 - end -- the best way would be to make it 60/120 times per sec. (i mean, not 60-120, it's 60 OR 120 (depending of the trackir device)) + end + hook.Add("HUDPaint", "TrackIr real aiming", function() + -- don't get lost my friend, know where you're aiming ;) local tr = (util.TraceLine(util.GetPlayerTrace(LocalPlayer())).HitPos):ToScreen() draw.RoundedBox(0, tr.x - 6, tr.y - 6, 12, 12, Color(0, 0, 0, 105)) draw.RoundedBox(4, tr.x - 5, tr.y - 5, 10, 10, Color(64, 134, 195, 170)) - end) -- don't get lost my friend, know where you're aiming ;) + end) + hook.Add("Tick", "fix *AfxGetMainWnd()", function() + -- wait until gmod has focus, else *AfxGetMainWnd() from the module will return NULL (0x0) if not system.HasFocus() then return end require("TrackIR") -- no shit sherlock - TrackIR.Pitch = 0 TrackIR.Roll = 0 TrackIR.Yaw = 0 TrackIR.X = 0 TrackIR.Y = 0 TrackIR.Z = 0 - - local _data1 local _data2 - - hook.Add("Think", "TrackIRupdate", TrackIR_Timer) timer.Create("TrackIR_Net", 1 / DPS, 0, function() @@ -165,7 +160,8 @@ if CLIENT then end hook.Remove("Tick", "fix *AfxGetMainWnd()") -- everything has been executed, don't let it get executed twice - end) -- wait until gmod has focus, else *AfxGetMainWnd() from the module will return NULL (0x0) + end) + end if SERVER then diff --git a/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win32.dll b/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win32.dll index c0ee04f..0eded94 100644 Binary files a/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win32.dll and b/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win32.dll differ diff --git a/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win64.dll b/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win64.dll new file mode 100644 index 0000000..e6f3e02 Binary files /dev/null and b/garrysmod/garrysmod/lua/bin/gmcl_TrackIR_win64.dll differ