Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Controlling Synaptics Touchpad using COM API


  • Please log in to reply
50 replies to this topic
jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
:? - you deleted your post about CPU usage & data lagging. The reason this was happening was because of the massive number of OnPacket Events that were occurring. This might be a better approach:
[color=#107095]#NoTrayIcon[/color]

[color=#107095]Loop[/color], 4 {

	[color=#107095]Gui[/color], Add, Text, % [color=#666666]"x12 y"[/color] 20*[color=brown]A_Index[/color]-10 [color=#666666]" w60 h20"[/color], % [color=#107095]Chr[/color](86+[color=brown]A_Index[/color]) [color=#666666]":"[/color]

	[color=#107095]Gui[/color], Add, [color=#107095]Edit[/color], % [color=#666666]"x30 y"[/color] 20*[color=brown]A_Index[/color]-10 [color=#666666]" w60 h20 v"[/color] [color=#107095]Chr[/color](86+[color=brown]A_Index[/color])

}

[color=#107095]Gui[/color], Show, x0 y0 w100 h100

Com_Init()

SynAPI := Com_CreateObject([color=#666666]"SynCtrl.SynAPICtrl"[/color])

SynDev := Com_CreateObject([color=#666666]"SynCtrl.SynDeviceCtrl"[/color])

SynPac := Com_CreateObject([color=#666666]"SynCtrl.SynPacketCtrl"[/color])

Com_Invoke(SynAPI, [color=#666666]"Initialize"[/color])

DeviceHandle := Com_Invoke(SynAPI, [color=#666666]"FindDevice"[/color], 0,2,-1)

Com_Invoke(SynDev, [color=#666666]"Select"[/color], DeviceHandle) ; is DeviceHandle always zero?

[color=#107095]while[/color], Not stop

	[color=#107095]GoSub[/color], OnPacket

[color=#107095]Gui[/color], Destroy

Com_Release(SynApi)

Com_Release(SynDev)

Com_Release(SynPac)

Com_Term()

[color=#107095]ExitApp[/color]



GuiClose:

	stop := true

	[color=#107095]return[/color]

OnPacket:

	Com_Invoke(SynDev, [color=#666666]"LoadPacket"[/color], [color=#666666]"+"[/color] SynPac)

	[color=#107095]Loop[/color], 4

		[color=#107095]GuiControl[/color], , % [color=#107095]Chr[/color](86+[color=brown]A_Index[/color]), % Com_Invoke(SynPac, [color=#107095]Chr[/color](86+[color=brown]A_Index[/color]))

	[color=#107095]return[/color]


j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011

:? - you deleted your post about CPU usage & data lagging. The reason this was happening was because of the massive number of OnPacket Events that were occurring.

My bad, my bad :oops:, well actually your previous code work pretty well that spike was cause by Tooltip, so i delete my post, sorry about that.

Glad that you've read my post earlier though, this latest approach is better (much more accurate now), thank you very much....

Now that we can detect W,X,Y,Z, we could make a custom gesture using combination of the W,X,Y,Z value, for example:
Strong Z value (above 100) accompanied by W Value of 4 or 15 would make a Palm gesture
Strong Z value (above 100) combined with Strong W Value (9 to 12) would indicate Thumb gesture

And also if we add FingerState we could detect more gesture, eg. (2 Finger Tap, 3 Finger Tap), but interpretation of FingerStateFlags is a bit tricky

What do you think?

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
some proof of concept/demo:

Based on jethrow's script, i add some parameters so it will show some message on tooltips if it's detect Palm/Thumbnail on touchpad.

#Persistent
CoordMode, Tooltip, Screen
OnExit, Cleanup
Com_Init()
SynAPI := Com_CreateObject("SynCtrl.SynAPICtrl")
SynDev := Com_CreateObject("SynCtrl.SynDeviceCtrl")
Com_Invoke(SynAPI, "Initialize")
DeviceHandle := Com_Invoke(SynAPI, "FindDevice", 0,2,-1)
Com_Invoke(SynDev, "Select", DeviceHandle) ; is DeviceHandle always zero?
sink := Com_ConnectObject(SynDev, "SynDev_")
return

Cleanup:
   Com_DisconnectObject(sink)
   Com_Release(SynApi)
   Com_Release(SynDev)
   Com_Release(SynPac)
   Com_Term()
   ExitApp

SynDev_OnPacket() {
   global SynPac, SynDev
   if Not SynPac
      SynPac := Com_CreateObject("SynCtrl.SynPacketCtrl")
   Com_Invoke(SynDev, "LoadPacket", "+" SynPac)
   TP_W := Com_Invoke(SynPac, "W")
   TP_Z := Com_Invoke(SynPac, "Z")

If TP_W > 8
{
Gesture:= "Thumbnail Detected"
}

If (TP_W = 4 OR TP_W > 13) AND TP_Z > 110
{
Gesture:= "Palm Detected"
}

ToolTip, W:%TP_W% Z:%TP_Z% %Gesture%
}


Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Just for fun: Absolute movement. Its shows how inacurate the pads are when used raw.
Uses AHK_L. Press ESCAPE to exit when done. It's the only way to exit...
#Persistent
CoordMode, Tooltip, Screen
CoordMode, Mouse, Screen
SynAPI := ComObjCreate("SynCtrl.SynAPICtrl")
SynDev := ComObjCreate("SynCtrl.SynDeviceCtrl")
SynAPI.Initialize
SynDev.Select( SynAPI.FindDevice(0,2,-1) )
SynPac := ComObjCreate("SynCtrl.SynPacketCtrl")
Loop
{
	SynDev.LoadPacket(SynPac)
	MouseMove(SynPac.XRaw, SynPac.YRaw)
	Sleep 0
}
return

MouseMove(X, Y)
{
	MinX := 1268
	MaxX := 5888
	MinY := 1026
	MaxY := 4864
	If (X > MaxX)
		X := MaxX
	If (X < MinX)
		X := MinX
	If (Y > MaxY)
		Y := MaxY
	If (Y < MinY)
		Y := MinY
	
	Percent_X := (X-MinX) / (MaxX-MinX)
	Percent_Y := (Y-MinY) / (MaxY-MinY)
	New_X := Percent_X*A_ScreenWidth
	New_Y := A_ScreenHeight - Percent_Y*A_ScreenHeight
	ToolTip,
	(
	%Percent_X%`t%Percent_Y%
	(%New_X%, %New_Y%)
	), 0, 0
	
	MouseMove, New_X, New_Y, 0
	Sleep 0
}
	
Esc::ExitApp

aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011

Just for fun: Absolute movement. Its shows how inacurate the pads are when used raw.

I can't test your code since AHK_L always crash here, but i think jethrow have pointed out that:

The reason this was happening was because of the massive number of OnPacket Events that were occurring.

Code below is in AHK Basic :
For example if i use jethrow's previous code I got high CPU usage (70%-90%) & some lag on monitored W,X,Y,Z value.
#Persistent
CoordMode, Tooltip, Screen
OnExit, Cleanup
Com_Init()
SynAPI := Com_CreateObject("SynCtrl.SynAPICtrl")
SynDev := Com_CreateObject("SynCtrl.SynDeviceCtrl")
Com_Invoke(SynAPI, "Initialize")
DeviceHandle := Com_Invoke(SynAPI, "FindDevice", 0,2,-1)
Com_Invoke(SynDev, "Select", DeviceHandle) ; is DeviceHandle always zero?
sink := Com_ConnectObject(SynDev, "SynDev_")
return

Cleanup:
   Com_DisconnectObject(sink)
   Com_Release(SynApi)
   Com_Release(SynDev)
   Com_Release(SynPac)
   Com_Term()
   ExitApp

SynDev_OnPacket() {
   global SynPac, SynDev
   if Not SynPac
      SynPac := Com_CreateObject("SynCtrl.SynPacketCtrl")
   Com_Invoke(SynDev, "LoadPacket", "+" SynPac)
   data .=   "XRaw:`t" Com_Invoke(SynPac, "XRaw")
      .   "`nYRaw:`t" Com_Invoke(SynPac, "YRaw")
      .   "`nZRaw:`t" Com_Invoke(SynPac, "ZRaw")
      .   "`nWidth:`t" Com_Invoke(SynPac, "W")
   ToolTip, %data%, 0, 0
}
But if i use this (jethrow's script) I got moderate CPU usage (40%) and better result on monitored W,X,Y,Z
#NoTrayIcon
Loop, 4 {
   Gui, Add, Text, % "x12 y" 20*A_Index-10 " w60 h20", % Chr(86+A_Index) ":"
   Gui, Add, Edit, % "x30 y" 20*A_Index-10 " w60 h20 v" Chr(86+A_Index)
}
Gui, Show, x0 y0 w100 h100
Com_Init()
SynAPI := Com_CreateObject("SynCtrl.SynAPICtrl")
SynDev := Com_CreateObject("SynCtrl.SynDeviceCtrl")
SynPac := Com_CreateObject("SynCtrl.SynPacketCtrl")
Com_Invoke(SynAPI, "Initialize")
DeviceHandle := Com_Invoke(SynAPI, "FindDevice", 0,2,-1)
Com_Invoke(SynDev, "Select", DeviceHandle) ; is DeviceHandle always zero?
while, Not stop
   GoSub, OnPacket
Gui, Destroy
Com_Release(SynApi)
Com_Release(SynDev)
Com_Release(SynPac)
Com_Term()
ExitApp

GuiClose:
   stop := true
   return
OnPacket:
   Com_Invoke(SynDev, "LoadPacket", "+" SynPac)
   Loop, 4
      GuiControl, , % Chr(86+A_Index), % Com_Invoke(SynPac, Chr(86+A_Index))
   return

PS: Turning GUI/Tooltips Off on both code will get the CPU went down to Low usage (3%-6%)

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
I was getting crashes at first, until I changed it from the packets function to the while loop like jethrow said. It should work fine now.

I'll see what else I can do with it tomorrow if I have some free time. I'm not sure how popular this brand of trackpads is, but there could be some cool scripts made from this API.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
SYNAPTICS is the most common touchpad you would find, second is ALPS, so i think it's quite popular :wink:

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
Attention : This code need AutoHotkey_L, to work. AHK_Basic is possible to use, with some adjustment.
SynAPICtrl (Synaptics API control) reference
Provides a global interface for managing the Synaptics COM subsystem.
Methods & Description :
Initialize : Initialize instances of ISynAPICtrl.
FindDevice : Find devices known to the Synaptics COM subsystem.
GetLongProperty : Obtain machine global properties.
SetLongProperty : Set machine global properties.
GetStringProperty : Obtain machine global strings.
HardwareBroadcast : Broadcast a configuration command to all devices known to the Synaptics COM subsystem.
PersistState : Save the state of the Synaptics COM subsystem to the system registry.
RestoreState : Load the state of the Synaptics COM subsystem from the system registry.
Activate : Allow posting of ISynAPICtrl related events.
Deactivate : Disallow posting of ISynAPICtrl related events.
Properties/Enumeration:
Available Enumerated value for FindDevice:
Syntax : FindDevice(lConnectionType, lDeviceType, plHandle)
; lConnectionType
SE_ConnectionAny      := 0
SE_ConnectionCOM      := 1
SE_ConnectionPS2      := 2
SE_ConnectionUSB      := 3
SE_ConnectionUnknown  := 0
; lDeviceType
SE_DeviceAny                      := 0
SE_DeviceUnknown                  := 0
SE_DeviceMouse                    := 1
SE_DeviceTouchPad                 := 2
SE_DeviceWheelMouse               := 3
SE_DeviceIBMCompatibleStick       := 4
SE_DeviceStyk                     := 5
SE_DeviceFiveButtonWheelMouse     := 6
SE_DevicecPad                     := 7
SE_DeviceControlBar               := 8
SE_DeviceRGBControlBar            := 9
SE_DeviceUnAuthenticatedTouchPad  := 10
SE_DeviceTouchDisplay             := 7
SE_DeviceTouchScreen              := 2
Available Property for GetLongProperty/SetLongProperty:
Syntax:
GetLongProperty(lSynAPIProperty)
SetLongProperty(lSynAPIProperty, lAssignedValue)
; lSynAPIProperty
SP_SynComDllVersion       := 268435457 ; The version of the Synaptics COM DLL.
SP_MaxDevices             := 268435458 ; The maximum no. of devices that may be controlled simultaneously.
SP_DevicesPresent         := 268435459 ; The number of devices currently known to the Synaptics COM DLL.
SP_DriverVersion          := 268435460 ; The runtime version of the Synaptics Driver.
SP_RequiredDriverVersion  := 268435461 ; The minimum required driver version supported by Synaptics COM API.
SP_ForeignDevicesPresent  := 268435462 ; Non Synaptics devices detect by driver.
Available Property for GetStringProperty:
Syntax:
GetStringProperty(lSynAPIProperty)
; lSynAPIProperty
SP_VersionString := 268436737 ; The version of the Synaptics COM DLL in string form.

Usage:
;standard initialization
SynAPI := ComObjCreate("SynCtrl.SynAPICtrl")
SynAPI.Initialize
;using get method to retrieve value :
Syn_DeviceFound := SynAPI.GetLongProperty(268436737)   ; retrieve number of detected Synaptics devices
Syn_Version     := SynAPI.GetStringProperty(268436737) ; retrieve driver version
DeviceHandle    := SynAPI.FindDevice(0, 2, -1) ; obtain devicehandle to be used by SynDeviceCtrl
Using integer value directly make the code less readable, but i would allow more flexibility. If you prefer more readable form, you have to define it first (Or just copy above value).
;define some variable
SP_VersionString   := 268436737 ; The version of the Synaptics COM DLL in string form.
SP_DevicesPresent  := 268435459 ; The number of devices currently known to the Synaptics COM DLL.
SE_ConnectionAny   := 0
SE_DeviceTouchPad  := 2

;initialization
SynAPI := ComObjCreate("SynCtrl.SynAPICtrl")
SynAPI.Initialize

;using get method to retrieve value :
Syn_DeviceFound := SynAPI.GetLongProperty(SP_DevicesPresent)   ; retrieve number of detected Synaptics devices
Syn_Version     := SynAPI.GetStringProperty(SP_VersionString)  ; retrieve driver version
DeviceHandle    := SynAPI.FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, -1) ; obtain devicehandle to be used by SynDeviceCtrl

It is possible to use SetLongProperty to assign some value, but it would be pointless (and riddiculus) to use it on SynAPICtrl. But it would become handy on SynDeviceCtrl, since we could use it to control touchpad feature eg(disable/enable : touchpad, tapping, lockdrag, etc...).

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
SynDeviceCtrl (Synaptics Device control) reference
Provides an interface for managing Synaptics COM subsystem devices. We can control touchpad feature with this interface.
Methods &Description :
Select : Point an ISynDeviceCtrl instance to a particular hardware device.
GetLongProperty : Obtain device long properties.
SetLongProperty : Set device long properties.
GetStringProperty : Obtain device string properties.
LoadPacket : Load an ISynPacketCtrl instance with packet data.
ForceMotion : Force the device handler to report motion to the OS.
ForcePacket : Force a simulated packet through the device handler.
Acquire : Acquire exclusive access to the device.
Unacquire : Release exclusive device access.
Activate : Connect an ISynDeviceCtrl instance to device events.
Deactivate : Disconnect an ISynDeviceCtrl instance from device events.
Properties:
Available Property for GetLongProperty/SetLongProperty:
Syntax:
GetLongProperty(lSynDeviceProperty)
SetLongProperty(lSynDeviceProperty, lAssignedValue)
; lSynDeviceProperty
SP_Handle         := 268435713
SP_DeviceType     := 268435714
SP_ConnectionType := 268435715
SP_FWVersion      := 268435716
SP_Geometry       := 268435717
SP_SensorType     := 268435718
SP_ProductType    := 268435719

SP_ASICType := 268435721

SP_ReportRate                  := 268435725
SP_Gestures                    := 268435726
SP_SecondaryGestures           := 268435727
SP_EdgeMotionOptions           := 268435728
SP_EdgeMotionSpeed             := 268435729
SP_MotionRotationAngle         := 268435730
SP_XDPI                        := 268435731
SP_YDPI                        := 268435732
SP_XLoSensor                   := 268435733
SP_YLoSensor                   := 268435734
SP_XHiSensor                   := 268435735
SP_YHiSensor                   := 268435736
SP_XLoRim                      := 268435737
SP_YLoRim                      := 268435738
SP_XHiRim                      := 268435739
SP_YHiRim                      := 268435740
SP_XLoBorder                   := 268435741
SP_YLoBorder                   := 268435742
SP_XHiBorder                   := 268435743
SP_YHiBorder                   := 268435744
SP_YLoBorderVScroll            := 268435745
SP_YHiBorderVScroll            := 268435746
SP_XLoWideBorder               := 268435747
SP_YLoWideBorder               := 268435748
SP_XHiWideBorder               := 268435749
SP_YHiWideBorder               := 268435750
SP_ZMaximum                    := 268435751
SP_ZTouchThreshold             := 268435752
SP_TopLeftCornerWidth          := 268435753
SP_TopLeftCornerHeight         := 268435754
SP_TopRightCornerWidth         := 268435755
SP_TopRightCornerHeight        := 268435756
SP_BottomRightCornerWidth      := 268435757
SP_BottomRightCornerHeight     := 268435758
SP_BottomLeftCornerWidth       := 268435759
SP_BottomLeftCornerHeight      := 268435760
SP_TopLeftCornerAction         := 268435761
SP_TopRightCornerAction        := 268435762
SP_BottomRightCornerAction     := 268435763
SP_BottomLeftCornerAction      := 268435764
SP_LeftButtonAction            := 268435765
SP_RightButtonAction           := 268435766
SP_HasBothButtonFeature        := 268435767
SP_MiddleButtonAction          := 268435768
SP_UpButtonAction              := 268435769
SP_DownButtonAction            := 268435770
SP_Ex1ButtonAction             := 268435771
SP_Ex2ButtonAction             := 268435772
SP_Ex3ButtonAction             := 268435773
SP_Ex4ButtonAction             := 268435774
SP_Ex5ButtonAction             := 268435775
SP_Ex6ButtonAction             := 268435776
SP_Ex7ButtonAction             := 268435777
SP_Ex8ButtonAction             := 268435778
SP_ExtendedButtons             := 268435779
SP_HasMiddleButton             := 268435780
SP_HasUpDownButtons            := 268435781
SP_IsMultiFingerCapable        := 268435782
SP_IsPenCapable                := 268435783
SP_IsVScroll                   := 268435784
SP_IsHScroll                   := 268435785
SP_IsWEMode                    := 268435786
SP_IsLowReportRate             := 268435787
SP_IsHighReportRate            := 268435788
SP_IsTapEnabled                := 268435789
SP_IsDragEnabled               := 268435790
SP_IsDragLockEnabled           := 268435791
SP_IsCornerTapEnabled          := 268435792
SP_IsEdgeMotionEnabled         := 268435793
SP_IsEdgeMotionDragEnabled     := 268435794
SP_IsEdgeMotionMoveEnabled     := 268435795
SP_IsReleaseToSelectEnabled    := 268435796
SP_IsMiddleTapToHelpEnabled    := 268435797
SP_IsMiddleButtonBlockEnabled  := 268435798
SP_IsPressureDragEnabled       := 268435799
SP_Is3ButtonEnabled            := 268435800
SP_IsPressureEdgeMotionEnabled := 268435801
SP_IsMiddleButtonLock          := 268435802
SP_Button4Action               := 268435803
SP_Button5Action               := 268435804

SP_DisablePDIfExtPresent    := 268435820
SP_VerticalScrollingFlags   := 268435821
SP_HorizontalScrollingFlags := 268435822
SP_DisplayFlags             := 268435823
SP_ModelId                  := 268435824
SP_DisableState             := 268435825
SP_NumLEDs                  := 268435826
SP_Pid                      := 268435827
SP_IsBtnSensitivity         := 268435828
SP_BtnSensitivity           := 268435829
SP_IlluminationState        := 268435830
SP_HasMultiFingerReport     := 268435831

SP_IsMultiFingerReportEnabled   := 268435832
SP_IsClearPad                   := 268435833
SP_HasAdvancedGestures          := 268435834
SP_PinchFlags                   := 268435835
SP_Slider0Flags                 := 268435836
SP_Slider1Flags                 := 268435837
SP_VerticalScrollRegionWidth    := 268435838
SP_VerticalScrollSpeed          := 268435839
SP_HorizontalScrollRegionHeight := 268435840
SP_HorizontalScrollSpeed        := 268435841
SP_GlobalScrollingModes         := 268435842
SP_PalmThreshold                := 268435843
SP_2FVerticalScrollingFlags     := 268435844
SP_2FHorizontalScrollingFlags   := 268435845
SP_SuppressTapping              := 268435846
SP_2FingerVerticalScrollSpeed   := 268435847
SP_2FingerHorizontalScrollSpeed := 268435848
SP_HasCoverGesture              := 268435849
SP_IsFingerStateReportEnabled   := 268435850
SP_IsEdgeTapFilteringEnabled    := 268435851
SP_IsOriginationZoneEnabled     := 268435852
SP_IsButtonTapFilteringEnabled  := 268435853
SP_EdgeTapZoneTopLeft           := 268435854
SP_EdgeTapZoneWidthHeight       := 268435855
SP_ButtonTapZoneTopLeft         := 268435856
SP_ButtonTapZoneWidthHeight     := 268435857
SP_OriginationZoneTopLeft       := 268435858
SP_OriginationZoneWidthHeight   := 268435859
SP_IlluminationEnabledState     := 268435860
SP_IlluminationBrightnessState  := 268435861
SP_2FingerTapAction             := 268435862
SP_3FingerStrokeUp              := 268435863
SP_3FingerStrokeDown            := 268435864
SP_TwoFingerDoubleTapState      := 268435865
SP_HasTwoFingerDoubleTap        := 268435866
SP_ChiralScrolling              := 268435867
SP_1FingerPressButtonAction     := 268435868
SP_2FingerPressButtonAction     := 268435869
SP_3FingerPressButtonAction     := 268435870
SP_WorkspaceSwitch              := 268435871
SP_EnableActiveStick            := 268435872
SP_ActiveStickTimeOut           := 268435873
SP_IsTheaterPad                 := 268435874
SP_DeviceMode                   := 268435875
SP_TouchPadLightingEnabled      := 268435876
SP_ProfileDirtyFlag             := 268435877
SP_BoardNumber                  := 268435878

Available Property for GetStringProperty:
Syntax:
GetStringProperty(lSynDeviceStringProperty)
; lSynDeviceStringProperty
SP_ModelString              := 268436993
SP_PnPID                    := 268436994
SP_ShortName                := 268436995
SP_ProductSubclassConfigKey := 268436996

Usage :
; define some variable
; lSynAPIProperty
SE_ConnectionAny   := 0
SE_DeviceTouchPad  := 2
; lSynDeviceProperty
; Boolean:
SP_IsTapEnabled         := 268435789 ; tap enable/disable
SP_IsDragEnabled        := 268435790 ; drag disable/enable
SP_IsDragLockEnabled    := 268435791 ; draglock enable/disable
SP_IsCornerTapEnabled   := 268435792 ; tap zones enable/disable
SP_DisableState         := 268435825 ; touchpad disable/enable
; Integer:
SP_ZTouchThreshold      := 268435752 ; touchpad Sensitivity setting

; initialization
SynAPI := ComObjCreate("SynCtrl.SynAPICtrl")
SynDev := ComObjCreate("SynCtrl.SynDeviceCtrl")
SynAPI.Initialize
DeviceHandle    := SynAPI.FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, -1) ; obtain devicehandle to be used by SynDeviceCtrl
SynDev.Select(DeviceHandle) ; must be call first, before the use of other SynDeviceCtrl Function

; now we can modify touchpad setting/feature
; Example :
; Enable/disable touchpad:
;   SynDev.SetLongProperty(SP_DisableState, 1) ; disable touchpad
;   SynDev.SetLongProperty(SP_DisableState, 0) ; enable touchpad
;
; Enable/disable tapping:
;   SynDev.SetLongProperty(SP_IsTapEnabled, 0) ; disable tapping
;
; Modify touchpad sensitivity setting (it range between 22-62)
;   SynDev.SetLongProperty(SP_ZTouchThreshold, 22) ; lightest touch
;   SynDev.SetLongProperty(SP_ZTouchThreshold, 42) ; moderate touch
;   SynDev.SetLongProperty(SP_ZTouchThreshold, 62) ; heaviest touch, 


j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
[Reserved] for SynDev (Synaptics Device control) reference

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
SynPacketCtrl (Synaptics Packet control) reference
Provides an interface for managing pointing device packet data.
Methods & Description :
GetLongProperty : Obtain packet related properties.
SetLongProperty : Set packet related properties.
Copy : Copy data from one packet to another.
Property:
Available Property for GetLongProperty:
Syntax:
GetLongProperty(lSynPacketProperty)
; lSynPacketProperty
SP_AssociatedDeviceHandle  := 268436225 ; The query handle of the device that reported the packet. 
SP_SequenceNumber          := 268436226 ; The sequence number assigned to the device packet. Sequence numbers start from zero at boot and increment sequentially on each device report. 
SP_TimeStamp               := 268436227 ; The number of milliseconds that have elapsed from an arbitrary time in the past until the time when packet was received from the device. 
SP_XRaw                    := 268436228 ; The raw X coordinate reported by the device. 
SP_ZXRaw                   := 268436228 ; The X axis contribution to the reported Z value. Applies to TouchScreens only. 
SP_YRaw                    := 268436229 ; The raw Y coordinate reported by the device. 
SP_ZYaw                    := 268436230 ; The Y axis contribution to the reported Z value. Applies to TouchScreens only. 
SP_ZRaw                    := 268436231 ; The raw Z value reported by the device. 
SP_W                       := 268436232 ; The W value reported by the device. On a TouchPad W corresponds roughly to the "width" of the object touching the pad. 
SP_X                       := 268436233 ; A low-pass filtered X coordinate. 
SP_Y                       := 268436234 ; A low-pass filtered Y coordinate. 
SP_Z                       := 268436235 ; A low-pass filtered Z value. 
SP_XDelta                  := 268436236 ; The difference between the filtered X coordinates of the current device packet and the previous device packet. 
SP_YDelta                  := 268436237 ; The difference between the filtered Y coordinates of the current device packet and the previous device packet. 
SP_ZDelta                  := 268436238 ; The difference between the filtered Z values of the current device packet and the previous device packet. 
SP_XMickeys                := 268436239 ; The number of X Mickeys that will be reported to the OS as a result of this device packet. 
SP_YMickeys                := 268436240 ; The number of Y Mickeys that will be reported to the OS as a result of this device packet. 
SP_AnachronisticState      := 268436241 ; Undocumented, detect FingerState & ButtonState at the same time
SP_FingerState             := 268436242 ; Specifies the device finger state at the time that the packet was generated. Must be a combination of the SynFingerFlags enumeration. 
SP_ExtendedState           := 268436243 ; Undocumented, for internal Synaptics use. 
SP_ButtonState             := 268436244 ; Specifies the device button state at the time that the packet was generated. Must be a combination of the SynButtonFlags enumeration 
SP_ExtraFingerState        := 268436245 ; Undocumented, for internal Synaptics use. Detect MultiFinger
Alternative syntax (shorthand) :
COMobject.XRaw :arrow: the equivalent of COMobject.GetLongProperty(SP_XRaw)
Possible shorthand:

[*:iygrfjbn] AssociatedDeviceHandle
[*:iygrfjbn] SequenceNumber
[*:iygrfjbn] TimeStamp
[*:iygrfjbn] XRaw
[*:iygrfjbn] ZXRaw
[*:iygrfjbn] YRaw
[*:iygrfjbn] ZRaw
[*:iygrfjbn] ZYRaw
[*:iygrfjbn] W
[*:iygrfjbn] X
[*:iygrfjbn] Y
[*:iygrfjbn] Z
[*:iygrfjbn] XDelta
[*:iygrfjbn] YDelta
[*:iygrfjbn] ZDelta
[*:iygrfjbn] XMickeys
[*:iygrfjbn] YMickeys
[*:iygrfjbn] FingerState
[*:iygrfjbn] ExtendedState
[*:iygrfjbn] ButtonState
Usage:
; Create COM Object
SynAPI := ComObjCreate("SynCtrl.SynAPICtrl")
SynDev := ComObjCreate("SynCtrl.SynDeviceCtrl")
; Initialize ISynAPICtrl instance
SynAPI.Initialize
; Finding Synaptics Touchpad to be used by ISynDeviceCtrl
DeviceHandle := SynAPI.FindDevice(0,2,-1)
; Pointing DeviceHandle to ISynDeviceCtrl instance
SynDev.Select(DeviceHandle)

; Connects SynDeviceCtrl related events with the prefix "SynDev_". So we could
; use SynDeviceCtrl_OnPacket events to obtain synchronous reports of Synaptics
; device data
ComObjConnect(SynDev, "SynDev_")
;-------------------------------------------------------------------------------

<- Put Your Code HERE

;-------------------------------------------------------------------------------
SynDev_OnPacket(SynDev) {
 ; Create SynPacketCtrl (Synaptics Packet Control) COM Object
   static SynPac := ComObjCreate("SynCtrl.SynPacketCtrl")
 ; read the device packet queue and export packet data to an ISynPacketCtrl instance
   SynDev.LoadPacket(SynPac)
 ; set Global variable so we can use it outside this function
   global GetAssociatedDeviceHandle, GetSequenceNumber, GetTimeStamp, GetXRaw, GetYRaw, GetZRaw, GetZYRaw, GetW, GetX, GetY, GetZ, GetXDelta, GetYDelta, GetZDelta, GetXMickeys, GetYMickeys, GetAnachronisticState, GetFingerState, GetExtendedState, GetButtonState, GetExtraFingerState, GetWheelDelta, GetFingerIndex
 ; retrieve packet value
			GetAssociatedDeviceHandle := SynPac.GetLongProperty(268436225)
			GetSequence               := SynPac.GetLongProperty(268436226)
			GetTime                   := SynPac.GetLongProperty(268436227)
			GetXRaw                   := SynPac.GetLongProperty(268436228)
			GetYRaw                   := SynPac.GetLongProperty(268436229)
			GetZRaw                   := SynPac.GetLongProperty(268436230)
			GetZYRaw                  := SynPac.GetLongProperty(268436231)
			GetW                      := SynPac.GetLongProperty(268436232)
			GetX                      := SynPac.GetLongProperty(268436233)
			GetY                      := SynPac.GetLongProperty(268436234)
			GetZ                      := SynPac.GetLongProperty(268436235)
			GetXDelta                 := SynPac.GetLongProperty(268436236)
			GetYDelta                 := SynPac.GetLongProperty(268436237)
			GetZDelta                 := SynPac.GetLongProperty(268436238)
			GetXMickeys               := SynPac.GetLongProperty(268436239)
			GetYMickeys               := SynPac.GetLongProperty(268436240)
			GetAnachronisticState     := SynPac.GetLongProperty(268436241)
			GetFingerState            := SynPac.GetLongProperty(268436242)
			GetExtendedState          := SynPac.GetLongProperty(268436243)
			GetButtonState            := SynPac.GetLongProperty(268436244)
			GetExtraFingerState       := SynPac.GetLongProperty(268436245)
			GetWheelDelta             := SynPac.GetLongProperty(268436246)
			GetFingerIndex            := SynPac.GetLongProperty(268436247)
}


j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
Code Sample :

; :: NotePAD ::  musical Note on touchPAD
;
; This plain script demonstrate Synaptics COM usage to retrieve raw input from
; touchpad. It detect finger presence on x,y coordinate and match match them
; with predefined zone, and play some musical note (SoundBeep) accordingly.
;
; The predefined zone in this script was harcoded but actually it's calculated as follow:
;
;        4864+-----------+-----+-----+-----------+ <-- SP_YHiSensor
;            |           |           |           |
;            |           |           |           |
;            |           |           |           |
;            |           |           |           |
;            |           |           |           |
;            +-----------+-----+-----+-----------+ <-- SP_YLoSensor+((SP_YHiSensor-SP_YLoSensor)/2) = 2944
;            |           |           |           |
;            |           |           |           |
;            |           |           |           |
;            |           |           |           |
;            |           |           |           |
;        1024+-----------+-----+-----+-----------+ <-- SP_YLoSensor
;            1024        ^           ^           5888
;            ^           |           |            ^
;            SP_XLoSensor|           |           SP_XHiSensor
;                        |           |
;                        |           SP_X_LoSensor+(((SP_YLoSensor-SP_YLoSensor)/3)*2) = 4267
;                        |
;                        SP_X_LoSensor+(((SP_YLoSensor-SP_YLoSensor)/3)*1) = 2646
;
; the upper/lower limit of reportable x&y might varies, but for typical model its 
; (1024,1024) to (5888,4864), you can use getlongproperty to find its value:
;    - YourVar := SynDev.GetLongProperty(268435733) ; SP_XLoSensor <-- LowerX Limit
;    - YourVar := SynDev.GetLongProperty(268435734) ; SP_YLoSensor <-- LowerY Limit
;    - YourVar := SynDev.GetLongProperty(268435735) ; SP_XHiSensor <-- UpperX Limit
;    - YourVar := SynDev.GetLongProperty(268435736) ; SP_YHiSensor <-- UpperY Limit
;
;
;-------------------------------------------------------------------------------
; Create COM Object
SynAPI := ComObjCreate("SynCtrl.SynAPICtrl")
SynDev := ComObjCreate("SynCtrl.SynDeviceCtrl")

; Initialize ISynAPICtrl instance
SynAPI.Initialize

; Finding Synaptics Touchpad to be used by ISynDeviceCtrl
DeviceHandle := SynAPI.FindDevice(0,2,-1)

; Pointing DeviceHandle to ISynDeviceCtrl instance
SynDev.Select(DeviceHandle)

; Connects SynDeviceCtrl related events with the prefix "SynDev_". So we could
; use SynDeviceCtrl_OnPacket events to obtain synchronous reports of Synaptics
; device data
ComObjConnect(SynDev, "SynDev_")

; Startup Message...
MsgBox, Custom TapZone DEMO. Press Ctrl+6/Ctrl+9 to start, Press Ctrl+ESC to exit.
;-------------------------------------------------------------------------------
; <------ Routine Started ........
Loop {
;-------------------------------------------------------------------------------
; CustomTapZone (6 Area)
;
;        4864+-----------+-----------+-----------+
;            |           |           |           |
;            |           |           |           |
;            |     4     |     5     |     6     |
;            |           |           |           |
;            |           |           |           |
;        2944+-----------+-----------+-----------+
;            |           |           |           |
;            |           |           |           |
;            |     1     |     2     |     3     |
;            |           |           |           |
;            |           |           |           |
;        1024+-----------+-----------+-----------+
;            1024        2646        4267        5888
;

If 6TapZone=1
{
	If GetY between 1024 and 2944
	{
		If GetX between 1024 and 2645			; TapZone Area 1
		{
		  SoundBeep, 523, 150
		}
		If GetX between 2646 and 4266			; TapZone Area 2
		{
		  SoundBeep, 587, 150
		}
		If GetX between 4267 and 5888			; TapZone Area 3
		{
		  SoundBeep, 659, 150
		}
	}
	If GetY between 2945 and 4864
	{
		If GetX between 1024 and 2645			; TapZone Area 4
		{
		  SoundBeep, 699, 150
		}
		If GetX between 2646 and 4266			; TapZone Area 5
		{
		  SoundBeep, 784, 150
		}
		If GetX between 4267 and 5888			; TapZone Area 6
		{
		  SoundBeep, 880, 150
		}
	}
}

;-------------------------------------------------------------------------------
; CustomTapZone (9 Area)
;
;        4864+-----------+-----------+-----------+
;            |           |           |           |
;            |     7     |     8     |     9     |
;            |           |           |           |
;        3584+-----------+-----------+-----------+
;            |           |           |           |
;            |     4     |     5     |     6     |
;            |           |           |           |
;        2304+-----------+-----------+-----------+
;            |           |           |           |
;            |     1     |     2     |     3     |
;            |           |           |           |
;        1024+-----------+-----------+-----------+
;            1024        2646        4267        5888
;

If 9TapZone=1
{
		If GetY between 1024 and 2304
		{
			If GetX between 1024 and 2645			; TapZone Area 1
			{
			  SoundBeep, 523, 150
			}
			If GetX between 2646 and 4266			; TapZone Area 2
			{
		    SoundBeep, 587, 150
			}
			If GetX between 4267 and 5888			; TapZone Area 3
			{
		    SoundBeep, 659, 150
			}
		}
		If GetY between 2305 and 3584
		{
			If GetX between 1024 and 2645			; TapZone Area 4
			{
			  SoundBeep, 699, 150
			}
			If GetX between 2646 and 4266			; TapZone Area 5
			{
			  SoundBeep, 784, 150
			}
			If GetX between 4267 and 5888			; TapZone Area 6
			{
			  SoundBeep, 880, 150
			}
		}
		If GetY between 3585 and 4864
		{
			If GetX between 1024 and 2645			; TapZone Area 7
			{
			  SoundBeep, 988, 150
			}
			If GetX between 2646 and 4266			; TapZone Area 8
			{
			  SoundBeep, 1047, 150
			}
			If GetX between 4267 and 5888			; TapZone Area 9
			{
			  SoundBeep, 1175, 150
			}
		}
}

Sleep, 1
}
; <------ End Of Routine ........
; <-----------------------------------------------------------------------------


;-------------------------------------------------------------------------------
; HotKey

; Toogle 6 Tapzone mode
^6::
If 6TapZone<>1
{
	9TapZone:=0
	MsgBox, 6 TapZone are now ACTIVE. Press Ctrl+6 again to De-activate or press Ctrl+9 to switch to 9 TapZone.
	6TapZone:=1
	Return
}
6TapZone:=0
MsgBox, 6TapZone Deactivated
Return

; Toogle 9 Tapzone mode
^9::
If 9TapZone<>1
{
	6TapZone:=0
	MsgBox, 9 TapZone are now ACTIVE. Press Ctrl+9 again to De-activate or press Ctrl+6 to switch to 6 TapZone.
	9TapZone:=1
	Return
}
9TapZone:=0
MsgBox, 9TapZone Deactivated
Return

; Exit !DEMO!
^Esc::
  MsgBox, Exit DEMO
  ComObjConnect(SynDev)
  Gui, Destroy
  ExitApp

;-------------------------------------------------------------------------------
; Function

; Receives synchronous notification of Synaptics pointing device reports.
SynDev_OnPacket(SynDev) {
 ; Create SynPacketCtrl (Synaptics Packet Control) COM Object
   static SynPac := ComObjCreate("SynCtrl.SynPacketCtrl")

 ; read the device packet queue and export packet data to an ISynPacketCtrl instance
   SynDev.LoadPacket(SynPac)

 ; set Global variable so we can use it outside this function
   global GetAssociatedDeviceHandle, GetX, GetY

 ; retrieve packet value
			GetX                      := SynPac.GetLongProperty(268436233)
			GetY                      := SynPac.GetLongProperty(268436234)
}


j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
SynPacketCtrl (Synaptics Packet control) reference
Provides an interface for managing Synaptics cPad displays.
Synaptics cPad is an LCD-equipped TouchPad™ that utilizes Synaptics transparent capacitive technology. The cPad serves as both a navigation device for cursor control, and a platform for interactive input. cPad integrates a clear, capacitive touch sensor with a LCD, EL backlight, and the required electronics, drivers, and support software. The result is a unique interface solution that allows notebook users to directly interact with the cPad display to control applications without disturbing the primary display.

Methods & Description

[*:2oaca1up]GetProperty : Obtain display long properties.
[*:2oaca1up]SetProperty : Set display long properties.
[*:2oaca1up]PixelToTouch : Convert a display pixel location to underlying TouchPad coordinates.
[*:2oaca1up]TouchToPixel : Convert underlying TouchPad coordinates to a display pixel location.
[*:2oaca1up]GetDC : Get a Windows GDI device context for drawing on the display.
[*:2oaca1up]FlushDC : Flush changes in the display device context to the actual display.
[*:2oaca1up]Acquire : Acquire shared access to the display.
[*:2oaca1up]Unacquire : Release previously acquired shared access.
[*:2oaca1up]Select : Point an ISynDisplay instance to a particular hardware device.
[*:2oaca1up]SetEventNotification : Register an event to receive display arbitration notifications.
[*:2oaca1up]GetEventParameter : Obtain additional information about an arbitration notification.
[*:2oaca1up]SetSynchronousNotification : Setup a routine to be called upon display ownership changes.

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
[Reserved] for SynDis (Synaptics Display control) reference

j--hn
  • Members
  • 176 posts
  • Last active: Oct 26 2011 02:42 PM
  • Joined: 16 Apr 2011
[Reserved] for SynAbs (Synaptics Absolute Mode Touchpad Class) reference