Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synaptics SDK can't find device

Tags:

c#

touchpad

I'm attempting to grab a device handle on the Synaptics Touchpad using the Synaptics SDK, specifically using methods in the SYNCTRLLib. However, the SYNCTRL method failed to find it, returning -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();
        }
    }
}
like image 225
jerryh91 Avatar asked Sep 24 '15 17:09

jerryh91


1 Answers

I see that you are using the C# wrappers for Synaptics SDK. Even though CPP code might be not trivial to you, you might want to take a look at the file Samples/ComTest.cpp. It contains some example logic in order to find devices, more specifically at lines 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);
  }

Also, make sure you have registered the dlls. According to the ReadSynSDK.txt file:

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.

like image 141
marcelovca90 Avatar answered Oct 13 '22 07:10

marcelovca90