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

Search This thread

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
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-dotNetCfMultiTouchDLL.html
 
Last edited:
P

pongothemagnificent

Guest
Exelent work you've done here mate, keep it up.
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
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 :)
 

iperov

Member
Feb 6, 2009
34
1
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
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
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.

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.
 

TrYde

Senior Member
Aug 8, 2007
183
5
Toulon
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.
 

iperov

Member
Feb 6, 2009
34
1
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?
 

CrazyDreads21

Member
Nov 18, 2009
35
0
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
 
Last edited:

CrazyDreads21

Member
Nov 18, 2009
35
0
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!
 

iperov

Member
Feb 6, 2009
34
1
Yup.
Try deblock checkings in Touch.dll wich will loading PenTrac.dll,
PenTrac.dll this will be ur driver.
Then define func gMultipointHook, and log it.

or

hook gMultipointHook in TouchGL :)

people waiting...
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
I already tried to hook a dll over .net but there seems to be impossible.
I have to stick to c++, but due to I am not very familiar with it, I will need much more time :D
 

VanKurt

Senior Member
Jun 5, 2009
130
0
Duisburg / Aachen / Böblingen
By the way: why isn't HTC publishing a powerfull and easy to use Multitouch SDK? :confused:
I think it would be in there own interest to have as many developers out there create cool games and apps using this technology. That would be a great advertisement for the HD2...
And since they have all the code at their hands it wouldn't be too much work either.

ARGH, how I hate this. On all other plattforms (iPhone, Android) EVERY feature of the phone (from Multitouch, GSensor, GPS etc.) is easily accessible and well documented... :mad:
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
By the way: why isn't HTC publishing a powerfull and easy to use Multitouch SDK? :confused:
I think it would be in there own interest to have as many developers out there create cool games and apps using this technology. That would be a great advertisement for the HD2...
And since they have all the code at their hands it wouldn't be too much work either.

ARGH, how I hate this. On all other plattforms (iPhone, Android) EVERY feature of the phone (from Multitouch, GSensor, GPS etc.) is easily accessible and well documented... :mad:

The Problem is that the "Multitouch" is implented by HTC and really hacked in...