FORUMS
Remove All Ads from XDA

[DLL] SciLor's HD2/Leo Multitouch .NET CF DLL

1,253 posts
Thanks Meter: 22
 
Post Reply Email Thread
Hello, XDA's

Due to the discovered HD2 Multitouch captilities I have developed a .net cf dll for easy use.

It converts the Multitouch events to normal Mouse events



SciLor's .NET CF MultiTouch DLL v0.1 adds MultiTouch-Support to your existing .NET CF software very easily (Currently only for the HD2):
If I release a new DLL, it WILL be fully compatible to the previous one!


First of all you will have to add your app to the PinchToZoom Whitelist in the registry:
Code:
[HKEY_LOCAL_MACHINE\Software\HTC\TouchGL\Pinch\WhiteList\YourApp]
"ProcName"="YouAppProcessName.exe"
After adding, soft reset!

Then add the "SciLors-MultiTouch.dll" as reference in your Visual Studio project. Beware, it is not allowed to change the assembly name! It must stay "SciLors-MultiTouch.dll" or it will not work!

Afterwards declare the MultiTouch Class:
VB.NET:
Code:
Dim myMultiTouch As New SciLorsMultiTouch.SciLorsMultiTouch
C#:
Code:
SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();
Then you add following to your Form_Load event:
VB.NET:
Code:
Call myMultiTouch.CatchWndProc(Me)
AddHandler myMultiTouch.MouseDown, AddressOf frmMain_MouseDown
AddHandler myMultiTouch.MouseMove, AddressOf frmMain_MouseMove
AddHandler myMultiTouch.MouseUp, AddressOf frmMain_MouseUp
C#:
Code:
myMultiTouch.CatchWndProc(this);
myMultiTouch.MouseDown += frmMain_MouseDown;
myMultiTouch.MouseMove += frmMain_MouseMove;
myMultiTouch.MouseUp += frmMain_MouseUp;
Now, at every MultiTouch Event it gets delegated to your frmMain_Mouse* procedures (There will be always 2 Events fired due to there existing 2 Fingers on the screen ). You can easily detect wheather the mouse event comes from a normal mouse-press or a multitouch finger.
Code:
Single Finger:
	Windows.Forms.MouseButtons.None or MouseButton = Windows.Forms.MouseButtons.Left
MultiTouch:
	Finger 1: Windows.Forms.MouseButtons.Middle
	Finger 2: Windows.Forms.MouseButtons.Right
Code Examples:
VB.NET:
Code:
Public Structure MouseState
	Dim Position As Point
	Dim MouseDown As Boolean
End Structure

Public Fingers(2) As MouseState

Public Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseDown
	Dim ButtonID As Byte = ButtonToID(e.Button)
	With Fingers(ButtonID)
		.Position.X = e.X
		.Position.Y = e.Y
		.MouseDown = True
	End With
End Sub

Public Sub frmMain_MouseMoveByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseMove
	Dim ButtonID As Byte = ButtonToID(e.Button)
	With Fingers(ButtonID)
		.Position.X = e.X
		.Position.Y = e.Y
		.MouseDown = True
	End With
End Sub

Public Sub frmMain_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseUp
	Dim ButtonID As Byte = ButtonToID(e.Button)
	With Fingers(ButtonID)
		.Position.X = e.X
		.Position.Y = e.Y
		.MouseDown = False
	End With
End Sub

Private Function ButtonToID(ByVal MouseButton As MouseButtons)
	If MouseButton = Windows.Forms.MouseButtons.None Or MouseButton = Windows.Forms.MouseButtons.Left Then
		Return 0
	ElseIf MouseButton = Windows.Forms.MouseButtons.Middle Then
		Return 1
	Else
		Return 2
	End If
End Function
C#:
Code:
public struct MouseState
{
	public Point Position;
	public bool MouseDown;
}
public MouseState[] Fingers = new MouseState[3];

public void pctDraw_MouseDown(object sender, MouseEventArgs e)
{
	int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));
	this.Fingers[ButtonID].Position.X = e.X;
	this.Fingers[ButtonID].Position.Y = e.Y;
	this.Fingers[ButtonID].MouseDown = true;
}

public void pctDraw_MouseMove(object sender, MouseEventArgs e)
{
	int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));
	this.Fingers[ButtonID].Position.X = e.X;
	this.Fingers[ButtonID].Position.Y = e.Y;
	this.Fingers[ButtonID].MouseDown = true;
}

public void pctDraw_MouseUp(object sender, MouseEventArgs e)
{
	int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));
	this.Fingers[ButtonID].Position.X = e.X;
	this.Fingers[ButtonID].Position.Y = e.Y;
	this.Fingers[ButtonID].MouseDown = false;
}

private object ButtonToID(MouseButtons MouseButton)
{
	if ((MouseButton == MouseButtons.None) | (MouseButton == MouseButtons.Left))
	{
		return 0;
	}
	if (MouseButton == MouseButtons.Middle)
	{
		return 1;
	}
	return 2;
}
-Multiple Instances are not supported and not needed (Multitouch events fire allways, everywhere on the form)!
-The Mouse-Coordinates are allways relative to the forms top-left corner.



Download at:
http://www.scilor.com/hd2-leo-dotNet...iTouchDLL.html
 
 
pongothemagnificent
8th December 2009, 12:04 AM |#2  
Guest
Thanks Meter: 0
 
More
Exelent work you've done here mate, keep it up.
8th December 2009, 03:40 PM |#3  
scilor's Avatar
OP Senior Member
Flag @scilor.com
Thanks Meter: 22
 
Donate to Me
More
I will update this to the best Multitouch solution I find
The dll will kept compatible to the previous versions so, if the author of a software forgets to update to the best DLL you can do it manually
8th December 2009, 06:50 PM |#4  
Member
Thanks Meter: 1
 
More
rofl author is newb,
dev need no external dlls to realize double touch.

Its called............. gestures.

Download Winmo 6.5 sdk for gesture.h and lib.

Gesture GID_DOUBLESELECT implement two finger tracking on screen.


So..... lets waiting Windows Mobile 7 sdk for pure multitouch support
8th December 2009, 06:56 PM |#5  
scilor's Avatar
OP Senior Member
Flag @scilor.com
Thanks Meter: 22
 
Donate to Me
More
Quote:
Originally Posted by iperov

rofl author is newb,
dev need no external dlls to realize double touch.

Its called............. gestures.

Download Winmo 6.5 sdk for gesture.h and lib.

Gesture GID_DOUBLESELECT implement two finger tracking on screen.


So..... lets waiting Windows Mobile 7 sdk for pure multitouch support

First of all you are the newb
According to http://msdn.microsoft.com/en-us/library/ee207148.aspx the GID_DOUBLESELECT is just for a double tap.

Quote:

A double tap represents the left double click of a mouse.
The application receives a GID_DOUBLESELECT gesture message when the finger–up events occur in a defined time period and within a specific distance of each other.

And has nothing to do with multitouch finger tracking

The dll should easily extent any .net program with a multitouch fingertracking very easily.
8th December 2009, 07:33 PM |#6  
Member
Thanks Meter: 1
 
More
GID_ZOOM 3 The zoom gesture.

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
8th December 2009, 07:42 PM |#7  
scilor's Avatar
OP Senior Member
Flag @scilor.com
Thanks Meter: 22
 
Donate to Me
More
Quote:
Originally Posted by iperov

GID_ZOOM 3 The zoom gesture.

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

This is for Window 7
Man please read before thinking knowing more
9th December 2009, 12:58 AM |#8  
Very nice, Scilor. I'll try it in my cover browser app that I am working on

Just a question, how do you handle the absence of HTC dll ? In my case I am making a generic application with enhanced functionality for HD2.
9th December 2009, 05:03 AM |#9  
Member
Thanks Meter: 1
 
More
so how enable multitouch without white-listing? i think HTC driver quering some interfaces, and translate double touch as windows messages to foregroung active window, if parent process is white-listed?
9th December 2009, 06:17 AM |#10  
Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by iperov

so how enable multitouch without white-listing? i think HTC driver quering some interfaces, and translate double touch as windows messages to foregroung active window, if parent process is white-listed?

lolololol, you totally got owned, and you completely deserved it for trying to call someone out in a really douchebag way when you actually had no clue what you were talking about. Nice job trying to save face and be diplomatic NOW though...

SciLor, keep up the good work this is awesome
9th December 2009, 06:18 AM |#11  
Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by iperov

rofl author is newb,
dev need no external dlls to realize double touch.

Its called............. gestures.

Download Winmo 6.5 sdk for gesture.h and lib.

Gesture GID_DOUBLESELECT implement two finger tracking on screen.


So..... lets waiting Windows Mobile 7 sdk for pure multitouch support

P.S. are you still "rofl"? Cuz I am!
Post Reply Subscribe to Thread

Tags
hd2, multitouch, scilor

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes