Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,804,353 Members 40,462 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
l3v5y
Old
(Last edited by l3v5y; 2nd December 2009 at 10:03 PM.)
#1  
l3v5y's Avatar
Retired Senior Moderator - OP
Thanks Meter 38
Posts: 7,390
Join Date: Sep 2007
Location: Bristol

 
DONATE TO ME
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:
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)
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, 522 views)
File Type: zip MultiTouch Demo2.zip - [Click for QR Code] (12.2 KB, 431 views)
 
l3v5y
Old
(Last edited by l3v5y; 30th November 2009 at 02:56 PM.)
#2  
l3v5y's Avatar
Retired Senior Moderator - OP
Thanks Meter 38
Posts: 7,390
Join Date: Sep 2007
Location: Bristol

 
DONATE TO ME
A more robust way (and the correct way) to get the values for the messages is:
Quote:
Originally Posted by MilaCzeque View Post
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.
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.
 
tibursio
Old
(Last edited by tibursio; 29th November 2009 at 10:26 PM.)
#3  
Member
Thanks Meter 1
Posts: 87
Join Date: Nov 2008
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.
 
l3v5y
Old
#4  
l3v5y's Avatar
Retired Senior Moderator - OP
Thanks Meter 38
Posts: 7,390
Join Date: Sep 2007
Location: Bristol

 
DONATE TO ME
Quote:
Originally Posted by tibursio View Post
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.
What ain't perfect about it?

It might be HTCs fault, or it might be my fault...
 
scilor
Old
(Last edited by scilor; 29th November 2009 at 11:09 PM.)
#5  
scilor's Avatar
Senior Member
Thanks Meter 19
Posts: 1,230
Join Date: Jan 2008
Location: @scilor.com

 
DONATE TO ME
Mhh, I cannot get working Windows Messages in .Net
 
l3v5y
Old
#6  
l3v5y's Avatar
Retired Senior Moderator - OP
Thanks Meter 38
Posts: 7,390
Join Date: Sep 2007
Location: Bristol

 
DONATE TO ME
Quote:
Originally Posted by scilor View Post
Mhh, I cannot get working Windows Messages in .Net
Does http://social.msdn.microsoft.com/For...d-b47b6becf70d help?
 
Arktronic
Old
#7  
Arktronic's Avatar
Retired Recognized Developer
Thanks Meter 55
Posts: 810
Join Date: Dec 2006

 
DONATE TO ME
Quote:
Originally Posted by l3v5y View Post
That's for desktop .NET, not the same This, however, should help: http://msdn.microsoft.com/en-us/libr...agewindow.aspx
Phones: Nokia 6800 Typhoon (SMT5600) ► Hermes (TyTN) ► Raphael (Fuze) ► Samsung Focus Flash + Lumia 710
Tablets: B&N NOOKcolor
Tweet @Arktronic

Want to ping or do DNS and WHOIS lookups on WP7? Get my Network Suite app! Want to have self-updating code in your own WP7 apps? Check out LiveLibs.

"Ну, чумадан, погоди!"
 
the0ne
Old
(Last edited by the0ne; 30th November 2009 at 06:19 AM.)
#8  
the0ne's Avatar
Senior Member
Thanks Meter 52
Posts: 843
Join Date: Jan 2007
Location: Melbourne
cant wait to see the use of multitouch in WM games...Thanks for your effort and releasing the code for others.

EDIT : Have sent you beer money...
---

Windows Phone Apps || Windows Phone Games --- want to review apps and game for windows phone and get paid for it ? Get it touch



---
 
scilor
Old
#9  
scilor's Avatar
Senior Member
Thanks Meter 19
Posts: 1,230
Join Date: Jan 2008
Location: @scilor.com

 
DONATE TO ME
Quote:
Originally Posted by the0ne View Post
cant wait to see the use of multitouch in WM games...Thanks for your effort and releasing the code for others.

EDIT : Have sent you beer money...
If I manage Multitouch, A Pong Clone will be there
 
A_C
Old
#10  
A_C's Avatar
Senior Member
Thanks Meter 4
Posts: 1,364
Join Date: Jan 2007
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...
Cheers,
A_C
http://ac-s2.com

Tags
hd2, multitouch
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Share Your Thoughts Anonymously with A Minimalist Social Network

Nowadays, almost everyone has a second life onthe Internet. Among the best … more

Enable Heads Up Notifications For The Sprint Galaxy S3

Heads up notifications, in case you didn’t already know, are an experimental … more

Android One Goes Live in India!

Android One is a Google initiative set to bring an AOSP-like experience tosome emergingmarkets like India, … more

XDA and LeaseWeb: Win Free Server Trial and Moto 360

As you might recall from a previousBehind the Scenesarticle we wrote, XDA’s … more