Synaptics SDK 找不到设备

Synaptics SDK can't find device

我正在尝试使用 Synaptics SDK 在 Synaptics 触摸板上获取设备句柄,特别是使用 SYNCTRLLib 中的方法。 但是,SYNCTRL方法找不到,返回-1.

Syn.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SYNCOMLib;
using SYNCTRLLib;

namespace TP_Test1
{
    class Syn
    {
        SynAPICtrl SynTP_API = new SynAPICtrl();
        SynDeviceCtrl SynTP_Dev = new SynDeviceCtrl();
        SynPacketCtrl SynTP_Pack = new SynPacketCtrl();
        int DeviceHandle;

        //Constructor
        public Syn ()
        {
            SynTP_API.Initialize();
            SynTP_API.Activate();

            //DeviceHandle == -1 ? Can't find device?
            DeviceHandle = SynTP_API.FindDevice(new SynConnectionType(), new SynDeviceType(), 0);
            //Below line causing Unhandled Exception
            SynTP_Dev.Select(DeviceHandle);
            SynTP_Dev.Activate();
            SynTP_Dev.OnPacket += SynTP_Dev_OnPacket;
        }

        public void SynTP_Dev_OnPacket()
        {
                Console.WriteLine(SynTP_Pack.FingerState);
                Console.WriteLine(SynTP_Pack.X);
                Console.WriteLine(SynTP_Pack.Y);
        }
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SYNCOMLib;
using SYNCTRLLib;

namespace TP_Test1
{
    class Program
    {
        static void Main(string[] args)
        {
            Syn mySyn = new Syn();
            mySyn.SynTP_Dev_OnPacket();
        }
    }
}

我看到您正在使用 Synaptics SDK 的 C# 包装器。尽管 CPP 代码对您来说可能并不简单,但您可能想要查看文件 Samples/ComTest.cpp。它包含一些用于查找设备的示例逻辑,更具体地说是在第 66-76 行:

  // Find a device, preferentially a TouchPad or Styk.
  ISynDevice *pDevice = 0;
  long lHandle = -1;
  if ((pAPI->FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, &lHandle) &&
       pAPI->FindDevice(SE_ConnectionAny, SE_DeviceStyk, &lHandle) &&
       pAPI->FindDevice(SE_ConnectionAny, SE_DeviceAny, &lHandle)) || 
      pAPI->CreateDevice(lHandle, &pDevice))
  {
    printf("Unable to find a Synaptics Device.\n");
    exit(-1);
  }

此外,请确保您已注册 dlls。根据 ReadSynSDK.txt 文件:

For certain purposes it may be necessary to register the dlls that are provided with the SDK. This can be done with the windows regsvr32 utility.