Chris Chris - 13 days ago 6
C# Question

Synaptics Touchpad Signature

I want to use the Synaptics SDK to use the Touchpad to capture a signature. I am trying to capture the absolute X and Y positions of the touch so that I can track people lifting their finger and putting it down somewhere else. I know that I'm able to access the Touchpad because I can disable it and access the dimensions of the Touchpad.

The next step would be to get the absolute X and Y coordinates. According to the Synaptics PS/2 TouchPad Interfacing Guide (page 22) there is an "Absolute Mode" where I can get this information. So far I can't seem to access it. I don't know how to set it to that mode.

I'm developing in Visual Studio Express 2012 using C#.

Also, I can't seem to activate any of the events whatsoever. I'm trying to register the events like this:

using SYNCOMLib;
using SYNCTRLLib;

SYNCTRLLib.SynAPICtrl SynAPICtrl1 = new SynAPICtrl();
SYNCTRLLib.SynDeviceCtrl SynDeviceCtrl1 = new SynDeviceCtrl();
SYNCTRLLib.SynDisplayCtrl SynDisplayCtrl1 = new SynDisplayCtrl();

SynAPICtrl1.OnNotify += SynAPICtrl1_OnNotify;
SynDeviceCtrl1.OnPacket += SynDeviceCtrl1_OnPacket;
SynDisplayCtrl1.OnMessage += SynDisplayCtrl1_OnMessage;


I have functions which just log the function name to the console:

private void SynDisplayCtrl1_OnMessage(SynDisplayMessage eMessage)
{
Console.WriteLine("SynDisplayCtrl1_OnMessage");
}

private void SynAPICtrl1_OnNotify(SynNotificationReason eReason)
{
Console.WriteLine("SynAPICtrl1_OnNotify");
}

private void SynDeviceCtrl1_OnPacket()
{
Console.WriteLine("SynDeviceCtrl1_OnPacket");
}


None of these functions ever get called (or at least nothing ever gets logged in the console). I'm fairly new to Visual Studio and C#, so the solution may be a very simple fix.

Thanks in advance!

Edit: Here's the link to the Synaptics SDK in case you want it.

Answer

I followed the info on this site and converted it into the following C#.

At the top of my code:

using SYNCOMLib;
using SYNCTRLLib;

Outside of my functions so they're global

SynAPICtrl SynTP_API = new SynAPICtrl();
SynDeviceCtrl SynTP_Dev = new SynDeviceCtrl();
SynPacketCtrl SynTP_Pack = new SynPacketCtrl();
int DeviceHandle;

Inside my constructor

SynTP_API.Initialize();
SynTP_API.Activate();
DeviceHandle = SynTP_API.FindDevice(new SynConnectionType(), new SynDeviceType(), 0);
SynTP_Dev.Select(DeviceHandle);
SynTP_Dev.Activate();  
SynTP_Dev.OnPacket += SynTP_Dev_OnPacket;

Finally, the function to handle the event

private void SynTP_Dev_OnPacket()
{
    if (SynTP_Dev.LoadPacket(SynTP_Pack) == 1)
    {
        Console.WriteLine(SynTP_Pack.FingerState);
        Console.WriteLine(SynTP_Pack.X);
        Console.WriteLine(SynTP_Pack.Y);
    }
}

I'm going to change some variable names to make them a bit more intuitive, but this code works just fine.

Comments