1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Option Explicit On
Public Class Form1
Public DeviceHandle As Integer, GetX As Integer, GetY As Integer, GetZ As Integer, ThirdXspan As Double, ThirdYspan As Double
Public Ydigits As Object = {7, 4, 1}, Xmin As Integer, Ymin As Integer, Xmax As Integer, Ymax As Integer, GetButtonState As Integer
Public ZTouchThreshold As Integer, dummy As Integer
Public Const SE_ConnectionAny As SYNCTRLLib.SynConnectionType = 0
Public Const SE_DeviceTouchPad As SYNCTRLLib.SynDeviceType = 2
Public Const SP_DisableState As SYNCTRLLib.SynDeviceProperty = 268435825
Public Const SP_IsTapEnabled As SYNCTRLLib.SynDeviceProperty = 268435789
Public Const SP_ZTouchThreshold As SYNCTRLLib.SynDeviceProperty = 268435752
Public Const SP_XLoSensor As SYNCTRLLib.SynDeviceProperty = 268435733
Public Const SP_XHiSensor As SYNCTRLLib.SynDeviceProperty = 268435735
Public Const SP_YLoSensor As SYNCTRLLib.SynDeviceProperty = 268435734
Public Const SP_YHiSensor As SYNCTRLLib.SynDeviceProperty = 268435736
Private Sub Form1_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
AxSynAPICtrl1.Initialize() 'initialize an ISynAPI instance
AxSynAPICtrl1.Activate() 'connect ISynAPICtrl events to the application's main message pump
DeviceHandle = AxSynAPICtrl1.FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, -1) 'query handle for a particular type of device or for a device connected
If DeviceHandle = -1 Then
MsgBox("Unable to find a Synaptics Touchpad")
End
End If
AxSynDeviceCtrl1.Select(DeviceHandle) 'point an ISynDeviceCtrl instance to a particular physical device
AxSynDeviceCtrl1.Activate() 'connect ISynDeviceCtrl events to the application's main message pump
AxSynDeviceCtrl1.Acquire(0) 'acquire exclusive access to the device
AxSynDeviceCtrl1.SetLongProperty(SP_DisableState, 0) 'enable Touchpad
AxSynDeviceCtrl1.SetLongProperty(SP_IsTapEnabled, 0) 'disable Tap as left button click
ZTouchThreshold = AxSynDeviceCtrl1.GetLongProperty(SP_ZTouchThreshold) + 20 'get Touchpad sensibility
Xmin = AxSynDeviceCtrl1.GetLongProperty(SP_XLoSensor)
Xmax = AxSynDeviceCtrl1.GetLongProperty(SP_XHiSensor)
Ymin = AxSynDeviceCtrl1.GetLongProperty(SP_YLoSensor)
Ymax = AxSynDeviceCtrl1.GetLongProperty(SP_YHiSensor)
ThirdXspan = ((Xmax - Xmin) / 3) + 10 ^ -10 'calculate 1/3 of X span
ThirdYspan = ((Ymax - Ymin) / 3) + 10 ^ -10 'calculate 1/3 of Y span
End Sub
Private Sub AxSynDeviceCtrl1_OnPacket(sender As System.Object, e As System.EventArgs) Handles AxSynDeviceCtrl1.OnPacket
Dim Result As Object
AxSynDeviceCtrl1.LoadPacket(AxSynPacketCtrl1) 'read the device packet queue and export packet data to an ISynPacketCtrl instance
GetX = AxSynPacketCtrl1.X
GetY = AxSynPacketCtrl1.Y
GetZ = AxSynPacketCtrl1.Z
GetButtonState = AxSynPacketCtrl1.ButtonState
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
AxSynDeviceCtrl1.Unacquire()
AxSynDeviceCtrl1.Deactivate()
AxSynDeviceCtrl1.SetLongProperty(SP_IsTapEnabled, 1)
Me.Close()
End Sub
End Class |
Partager