Default [REF] Multitouch on the HTC Leo [Updated, 2/12/09]

Firstly, this only works on the HTC Leo, and secondly, I can't be held responsible if your device catches fire or any other damages caused by using this...

This is probably easier for C++/Win32 devs to get to grips with and I don't know much .Net so I won't be porting this to .Net.

Registry settings
These register the window for multitouch messages

Under HKLM\Software\HTC\TouchGL\Pinch\WhiteList create a key with whatever you want. Within that, create a string called "ClassName" with the Class.

For example:
Code:
Select Code
HKLM\Software\HTC\TouchGL\Pinch\WhiteList\MultiTouch
ClassName="MULTITOUCH"
That should be all you need... For debugging, I cheated and set my application to have the class HTCAlbumClass. Don't do that if you want it to work on a real device though!

Code
The actual multitouch part is pretty easy to handle.
Your window will get sent two messages, one for multitouch move/begin and one for multitouch end, they're standard C++/Win32 window messages.

Code:
Select Code
#define WM_MT_BEGIN (WM_APP+16391) // begins multitouch, and is sent when either mouse position changes.
#define WM_MT_END (WM_APP+16392)   // ends multitouch
The messages are fairly similar to ones for other mouse events, except that instead of the LPARAM being the mouse co-ordinates, both the LPARAM and the WPARAM are.
Code:
Select Code
POINT pt,pt2;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
			
pt2.x=LOWORD(wParam);
pt2.y=HIWORD(wParam);
In the l3v5yMultiTouch.h file, I've added two functions
Code:
Select Code
POINT ParamToPoint(WPARAM); 
POINT ParamToPoint(LPARAM);
These make converting between window messages and useful data slightly easier...

I've also created a class for MultiTouch that I'm looking to extend with gestures and some neat things. For now, download the source code and give it a play with.

My class also swaps the two points if one goes to the left of the other, so there are no issues with the two points swapping over when you really don't want it to...

Also note that I've now changed the license to GPL v3. If you want to do anything with the code let me know and I'll probably say "yes". This is more to make sure the people that have put work in to this get recognised than anything else.

All you have to do is handle those two points, and handle those two events.

There are two videos of this in action here and I'm working on a paint like application using it...

Attached is a demo application (make sure that HTCAlbum is shut before running it as it uses the HTCAlbum class) and source code.

If you find this useful, please link back to here, and mention my name! (and if you feel really generous, donate as well, but that's completely optional)
Attached Files
File Type: zip MultiTouch Demo.zip - [Click for QR Code] (8.1 KB, 577 views)
File Type: zip MultiTouch Demo2 SRC.zip - [Click for QR Code] (51.6 KB, 521 views)
File Type: zip MultiTouch Demo2.zip - [Click for QR Code] (12.2 KB, 431 views)