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

Search This thread

noname81

Senior Member
Jun 28, 2009
1,806
6,870
Google Pixel 7 Pro
A lower level multitouch approach: As iperov said, the multitouch values can be retrieved via PenTrac.dll. The touch driver touch.dll loads a dll called PenTrac.dll if the reg value “MultiTouchDemo” changes from “0” to “1”. If PenTrac.dll exports the function gMultiPointHook(), this function will be called for every touch on the screen. PenTrac.dll can now e.g. post the touch values via win messages to the foreground window.

I tested this approach with a little MultiTouchDemo-App:

+ the fingers can touch the screen separately
- still auto alignment
- touch.dll can recognize, that more than 2 fingers are on the screen but delivers only the values for 2 fingers to gMultiPointHook()
 

Eoinoc

Senior Member
Dec 21, 2008
85
3
www.accountkiller.com
Hello noname81, any chance you post or link that Demo app you've mentioned . I'm eager to get hacking on multi touch myself.

Code quality or language irrevelent :D I'm just interested to read the source to get an overview of the process. Would be hugely appreciated :)
 

noname81

Senior Member
Jun 28, 2009
1,806
6,870
Google Pixel 7 Pro
Hi Eoinoc,

sorry for my late response. Attached you'll find PenTrac.dll (and the source code) and my little DemoApp. To test this multitouch approach:

- copy PenTrac.dll to /windows
- set reg value "HKLM\HARDWARE\DEVICEMAP\TOUCH\MultiTouchDemo" to "1"

touch.dll now loads PenTrac.dll and you'll see the following debug output (NKDbgPrintfW()):

[PenTrac] DllMain()
[PenTrac] Initialize...

- copy MultiTouchDemo.exe to the target and start it

The last days I tried to "find" the 3rd finger :). Internally touch.dll can recognize 3 fingers on the screen, but I didn't find the values for the 3rd pos. When 3 fingers are on the screen, touch.dll forces this to a 2 finger input.
Auto alignment is also a problem. It seems that touch.dll gets the aligned values from the psoc. I tried to manipulate this behaviour with the reg value "HWMode". If bit 4 is, set the psoc changes to another mode where x-axis alignment is different (the values are swapped - you can test it with the DemoApp), but auto alignment is still activated. :-( Do you have another idea?
Interesting is also the reg value "PsocDebugMode". When activated, the driver prints the following messages:

[D:TP] tp_debug: [15]6400;[16]3097;[37]8707;[58]8959;[61]65535;[70]65535;[82]65535;[105]65535;[126]65535;[129]65535;[151]65535;[152]65535.
[D:TP] tp_debug: [15]8704;[16]3874;[37]8707;[58]8959;[61]65535;[70]65535;[82]65535;[105]65535;[126]65535;[129]65535;[151]65535;[152]65535.

The output changes with different finger positions, but how to interpret these values?

Another question: Is in the new TMOB ROM 2.01 a new touch.dll integrated? And are there different reg values under

"HKLM\HARDWARE\DEVICEMAP\TOUCH\" or
"HKLM\HARDWARE\Setting\TouchPanel?
 

Attachments

  • MultiTouchDemo.zip
    220.6 KB · Views: 57
  • PenTrac.zip
    3.7 KB · Views: 39

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
Hi Eoinoc,

sorry for my late response. Attached you'll find PenTrac.dll (and the source code) and my little DemoApp. To test this multitouch approach:

- copy PenTrac.dll to /windows
- set reg value "HKLM\HARDWARE\DEVICEMAP\TOUCH\MultiTouchDemo" to "1"

touch.dll now loads PenTrac.dll and you'll see the following debug output (NKDbgPrintfW()):

[PenTrac] DllMain()
[PenTrac] Initialize...

- copy MultiTouchDemo.exe to the target and start it

The last days I tried to "find" the 3rd finger :). Internally touch.dll can recognize 3 fingers on the screen, but I didn't find the values for the 3rd pos. When 3 fingers are on the screen, touch.dll forces this to a 2 finger input.
Auto alignment is also a problem. It seems that touch.dll gets the aligned values from the psoc. I tried to manipulate this behaviour with the reg value "HWMode". If bit 4 is, set the psoc changes to another mode where x-axis alignment is different (the values are swapped - you can test it with the DemoApp), but auto alignment is still activated. :-( Do you have another idea?
Interesting is also the reg value "PsocDebugMode". When activated, the driver prints the following messages:

[D:TP] tp_debug: [15]6400;[16]3097;[37]8707;[58]8959;[61]65535;[70]65535;[82]65535;[105]65535;[126]65535;[129]65535;[151]65535;[152]65535.
[D:TP] tp_debug: [15]8704;[16]3874;[37]8707;[58]8959;[61]65535;[70]65535;[82]65535;[105]65535;[126]65535;[129]65535;[151]65535;[152]65535.

The output changes with different finger positions, but how to interpret these values?

Another question: Is in the new TMOB ROM 2.01 a new touch.dll integrated? And are there different reg values under

"HKLM\HARDWARE\DEVICEMAP\TOUCH\" or
"HKLM\HARDWARE\Setting\TouchPanel?

Nice to know you are working hard on it :)
Thank you for your reply! (I will take a look later I am busy)

Interpreting: LoWord/HiWord may do it?! Try to change only x or y then you will see
 
Last edited:

yngvebn

Senior Member
May 13, 2008
235
0
Oslo
Regarding the CatchWndProc method, it only accepts that one construct... With the X and Y...

Alright, here's my code:



Code:
public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();

            

        }

        public struct MouseState
        {
            public Point Position;
            public bool MouseDown;
        }
        public MouseState[] Fingers = new MouseState[3];

        public void frmMain_MouseDown(object sender, MouseEventArgs e)
        {
            label1.Text = "MouseDown!";
            int ButtonID = (int)(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 frmMain_MouseMove(object sender, MouseEventArgs e)
        {
            label1.Text = "Moving";
            int ButtonID = (int)(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 frmMain_MouseUp(object sender, MouseEventArgs e)
        {
            label1.Text = "Up!";
            int ButtonID = (int)(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;
        }

        

        private void Form1_Load(object sender, EventArgs e)
        {
            
           
            SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();
            myMultiTouch.CatchWndProc(this, 0, 0);
            
            myMultiTouch.MouseDown+=new SciLorsMultiTouch.SciLorsMultiTouch.MouseDownEventHandler(frmMain_MouseDown);
            myMultiTouch.MouseMove += new SciLorsMultiTouch.SciLorsMultiTouch.MouseMoveEventHandler(frmMain_MouseMove);
            myMultiTouch.MouseUp += new SciLorsMultiTouch.SciLorsMultiTouch.MouseUpEventHandler(frmMain_MouseUp);
        }

    }
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
Do you press both Fingers on the Screen at the same time(Put them down at the same time)?

I do not know if the attaching of the events is right, I have just translated that with a tool. Maybe there is a problem?

Edit:
Code:
SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();
cannot be in the load procedure. the declaration of "myMultitouch" must be like " public MouseState[] Fingers = new MouseState[3];" outside of the procedures. Otherwise the "myMultiTouch"-Class gets disposed automaticly!
 
Last edited:

yngvebn

Senior Member
May 13, 2008
235
0
Oslo
Do you press both Fingers on the Screen at the same time(Put them down at the same time)?

I do not know if the attaching of the events is right, I have just translated that with a tool. Maybe there is a problem?

Edit:
Code:
SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();
cannot be in the load procedure. the declaration of "myMultitouch" must be like " public MouseState[] Fingers = new MouseState[3];" outside of the procedures. Otherwise the "myMultiTouch"-Class gets disposed automaticly!

Changed the event back to the one in your example, and after realizing I had to actually hook them up to the form-events too, it get some response.. However only for one finger at the time...

I only get the "Left button" activated no matter what I do...

(Oh, I also moved the constructor out from the class. that was a stupid mistake... :))
 

yngvebn

Senior Member
May 13, 2008
235
0
Oslo
Got it! Did another soft reset, and somehow it worked :)

Anyway, I notice you really have to place both fingers down at the very same time... Why is that?
 

noname81

Senior Member
Jun 28, 2009
1,806
6,870
Google Pixel 7 Pro
Hi yngvebn,

"Is it possible for an app using this dll to run in the background and listen for gestures in general?"

You can do this with the "Pentrac.dll" approach: The dll is already a background listener for the touch values. You could extend the dll to recognize/process gestures...
 

yngvebn

Senior Member
May 13, 2008
235
0
Oslo
Hi yngvebn,

"Is it possible for an app using this dll to run in the background and listen for gestures in general?"

You can do this with the "Pentrac.dll" approach: The dll is already a background listener for the touch values. You could extend the dll to recognize/process gestures...

Hmm... sounds like a good idea, but since I'm working on another rather large project, I think I'm gonna pause the multi-touch programming on hold for a while.. This is the reason I ask:

http://xdaforums.com/showthread.php?t=622028

I think that would be pretty cool :)
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
Ok, I have just saw a project which used decompiled code of my very own software... Very bad that I decompiled that project by fun and found out my own lines in there ;)

Just do not do this... Or I will blame you in front of the whole xda-developers community ;)
 
Last edited:

marbalon

Senior Member
Dec 21, 2007
461
7
Hi,
First of all thanks Scilor for all of your work. I have some question about this library. What license have this library? Can be used with commercial project ?

And the second about MT functionality on HD2. If i understand it is para-MT because you need to tap two fingers at the same time to initialize MT and then one finger and MT is active until one of fingers is on the screen. But if I want to catch MT events when I tap one finger and then second this library will not catch MT events, correct ?

Best regards,
Marcin.
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
The multitouch works as you said, also you must know there is some auto aligning. To see it just downcload my multioch demo from my website.

You are the first one asking for a commercial license. Just lets talk about the project, what it is for etc. over ICQ. There I can also may answer further Questions. Just PM me your icq.

SciLor
 
Last edited:

Som30ne

Senior Member
Nov 22, 2009
244
8
Hi.

I downloaded the Zip with the DLL to support multitouch on HD2.

The Zip file contains a 3MB text file, named KillMe.txt.
The content of this file is pretty much "garbage" text.

Im curious about why it is there . . .
Why make a 3 MB file when you could save the space with uploading a much smaller file.
 

scilor

Senior Member
Jan 5, 2008
1,270
36
@scilor.com
www.scilor.com
Hi.

I downloaded the Zip with the DLL to support multitouch on HD2.

The Zip file contains a 3MB text file, named KillMe.txt.
The content of this file is pretty much "garbage" text.

Im curious about why it is there . . .
Why make a 3 MB file when you could save the space with uploading a much smaller file.

Do not mind about it, it is just therefore that I can gain some points on that uploading service(So everybody who uses my software, give something back to me). Just ignore it :)
 
Last edited:

Som30ne

Senior Member
Nov 22, 2009
244
8
Do not mind about it, it is just therefore that I can gain some points on that uploading service(So everybody who uses my software, give something back to me). Just ignore it :)

Thanks for the quick reply.
The reason you mentioned is a totally legitimate reason :)

I tried using it with a simple app.
and I have some questions:
I get many many mouse move events even when there was no actual movement (even if I just hold the fingers on the same place)

So if I keep my fingers a sec. on the same place and then start moving them,
there is a (sometimes long) delay until the movement is reflected.

Maybe Im doind something wrong ?

(the (C#) sorce and the compiled app are attached in the file)
 

Attachments

  • MultyTouchTestB.zip
    37 KB · Views: 23