From ca52f695ffd9d2826b8af04a79fcfd789b5a1f88 Mon Sep 17 00:00:00 2001 From: Clive Galway Date: Sun, 20 Feb 2022 16:58:16 +0000 Subject: [PATCH] TestDevice no longer news up a manager to get DeviceId --- C#/TestApp/Helpers/TestDevices.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/C#/TestApp/Helpers/TestDevices.cs b/C#/TestApp/Helpers/TestDevices.cs index 44c051e..2b369b5 100644 --- a/C#/TestApp/Helpers/TestDevices.cs +++ b/C#/TestApp/Helpers/TestDevices.cs @@ -1,4 +1,5 @@ using AutoHotInterception; +using AutoHotInterception.Helpers; using System; using System.Collections.Generic; using System.Linq; @@ -17,6 +18,8 @@ namespace TestApp public class TestDevice { + private static readonly IntPtr _deviceContext = ManagedWrapper.CreateContext(); + public bool IsMouse { get; set; } public int? Vid { get; set; } public int? Pid { get; set; } @@ -25,15 +28,13 @@ namespace TestApp public int GetDeviceId() { - var im = new Manager(); - if (Vid != null && Pid != null) { - return im.GetDeviceId(IsMouse, (int)Vid, (int)Pid, Instance); + return HelperFunctions.GetDeviceId(_deviceContext, IsMouse, (int)Vid, (int)Pid, Instance); } else { - return im.GetDeviceIdFromHandle(IsMouse, Handle, Instance); + return HelperFunctions.GetDeviceIdFromHandle(_deviceContext, IsMouse, Handle, Instance); } }