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

Search This thread

l3v5y

Retired Senior Moderator
Sep 13, 2007
7,485
44
32
Bristol
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:
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:
#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:
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:
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)
 
Last edited:

l3v5y

Retired Senior Moderator
Sep 13, 2007
7,485
44
32
Bristol
A more robust way (and the correct way) to get the values for the messages is:
This is not true. Message numbers are assigned dynamically and you missed first message.

Right approach is:
Code:
int HTC_Zoom_Begin;
int HTC_Zooming;
int HTC_Zoom_End;

void register_messages()
{
	HTC_Zoom_Begin = RegisterWindowMessage(TEXT("HTC_Zoom_Begin"));
	HTC_Zoom_End = RegisterWindowMessage(TEXT("HTC_Zoom_End"));
	HTC_Zooming = RegisterWindowMessage(TEXT("HTC_Zooming"));
}

Fact that your application works after SR is just coincidence. But nice try anyway. :D
Also note the first message...

I've also realised there are a few different "modes" will find them all, and build a library with a few gestures for things like rotate, pinch zoom, two finger scrolling etc.
 
Last edited:

tibursio

Senior Member
Nov 21, 2008
87
1
saw your tweet & entry @ WMPU, gonna try it now. A huge thanks for this, well done!

Edit: its working, not perfect but it works and thats a good achievement.
 
Last edited:

the0ne

Senior Member
Jan 2, 2007
843
52
Melbourne
www.1800pocketpc.com
cant wait to see the use of multitouch in WM games...Thanks for your effort and releasing the code for others.
worshippy.gif


EDIT : Have sent you beer money... :)
 
Last edited:

A_C

Senior Member
Jan 5, 2007
1,364
4
www.ac-s2.com
l3v5y, thanks for the findings.

But does it mean that LEO has a dual-touch screen? not really a multi-touch?

How about the normal WM_MOUSE events? But even these exist, it means a tri-touch screen?

P.S. I'm still waiting impatiently for my damn carrier to have HD2 restock...
 
[REF] Multitouch on the HTC Leo

I don't want to hijack this thread, but my 5 year old laptop has multitouch now with ubuntu linux for scrolling. Could it just be a driver issue. I didn't want to start a new thread either, zo just ignore this if you think this is a useless post
 

MilaCzeque

Member
Sep 9, 2007
20
6
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:
#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

This is not true. Message numbers are assigned dynamically and you missed first message.

Right approach is:
Code:
int HTC_Zoom_Begin;
int HTC_Zooming;
int HTC_Zoom_End;

void register_messages()
{
	HTC_Zoom_Begin = RegisterWindowMessage(TEXT("HTC_Zoom_Begin"));
	HTC_Zoom_End = RegisterWindowMessage(TEXT("HTC_Zoom_End"));
	HTC_Zooming = RegisterWindowMessage(TEXT("HTC_Zooming"));
}

Fact that your application works after SR is just coincidence. But nice try anyway. :D
 

l3v5y

Retired Senior Moderator
Sep 13, 2007
7,485
44
32
Bristol
This is not true. Message numbers are assigned dynamically and you missed first message.

Right approach is:
Code:
int HTC_Zoom_Begin;
int HTC_Zooming;
int HTC_Zoom_End;

void register_messages()
{
	HTC_Zoom_Begin = RegisterWindowMessage(TEXT("HTC_Zoom_Begin"));
	HTC_Zoom_End = RegisterWindowMessage(TEXT("HTC_Zoom_End"));
	HTC_Zooming = RegisterWindowMessage(TEXT("HTC_Zooming"));
}

Fact that your application works after SR is just coincidence. But nice try anyway. :D

That makes a lot more sense, though I didn't think of that as the messages sent were always the same, so I assumed they were constants...

Will add what you have found to the first post :)
 

l3v5y

Retired Senior Moderator
Sep 13, 2007
7,485
44
32
Bristol
I've realised there are a few different "modes" which I'll investigate. I'm also building a library with a few gestures for things like rotate, pinch zoom, two finger scrolling etc. which I'll release the code for all :)
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
.Net is done :)

Edit:
Ok, works, but the Problem is that, PinchToZoom seem to have to BIG Problems:

If 2 Points nearly on one line (horizontal or vertical) they align,
Also the Points are not identifiable
 
Last edited:

10076757

Senior Member
Nov 11, 2008
304
14
i dont understand

is this proper multitouch or just double scrolling. if it is proper multitouch, will there be a way to have more than dual touch?:confused:
 

Noonski

Inactive Recognized Developer / Moderator Emeritus
Apr 18, 2005
5,326
150
Amsterdam
noonski.nl
As part of my never ending Weekly Develoment and hacking cleaning up i have moved this thread to Windows Software development.

Sorry L3V5Y for not Pm-ing, didn't want to disturb you since you are a busy guy :D