PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

touch simultaneously with 2 styluses?

Hi, is there a documentation on the touch pad API?

I want to work on PDA with 2 stylus simultaneously (at the same time). Is it something that touchscreen hardware / Win API can handle or it is restricted to a 1 touch point at a time?
angedelamort · 09 Sep 2004, 14:07 UTC
It's hardware dependant. I'm pretty sure all harware allow only one stylus at the time.
Asus 620

Could someone please post any directions where to find documentation of what is possible with hardware?
The touchscreen on most (if not all) PPC devices is a simple 2-axis device, capable of returning where a single stylus is positioned.

However I've been thinking about multiple stylus (styli?? hmm I'll stick with styluses) recently for handling two finger typing on a software keyboard, and think it'd be perfectly possible to get a good estimation of two styluses' positions in code, providing you're not expecting them both to move at the same time, and assmung that two presses, even very close togther in time, will not be exactly concurrent. With current touchscreens, two simultenous points of contact on the touchscreen simply returns the midpoint between them.

Just thinking outloud here... We get a sort-of state machine:

Start in "no stylus" mode:
- mousedown, treat this as the first stylus mousedown, and enter "one stylus" mode

In "one stylus" mode:
- mouseup, treat this as the first stylus mouseup
- mousemove, check if the speed of the move (i.e. distance/time between messages) is greater than a threshold value. If it's not, it's a regular single stylus mousemove. If it is, treat this as the second stylus' mousedown. To get the position, add double the distance from the fist stylus' position, and enter "two styluses" mode

In "two styluses" mode:
- Mouseup, mouseup for both styluses
- Mousemove, those below the speed threshold are treated as the second stylus' mousemoves, again doubling the distance from the first stylus' position. If one above the threshold is received, whichever stylus position it is nearest is treated as the single remaining stylus, the other stylus does its mouseup processing, and we return to "one stylus" mode.

This could be quite an interesting technique, I can probably think of a few applications other than just two-finger typing. You could even extend it to more than two presses, although there'd probably be too much movement, and it might be a bit fiddly on such small screens.
Styli and styluses are both <a href="http://dictionary.reference.com/search?r=2&q;=styli">correct plurals</a>.
This is kinda off-topic, but it always surprises me how small a Pocket PC screen actually is. It looks a reasonable size on the device, but when you look at a screen protector, you think, "Blimey, that's small!"
Refractor - yep I know, I did a dictionary.com before posting. Styli kind of looked pretentious.

Jesse - yep, it's funny that - they do look bigger than their same sized screen protectors.
"The touchscreen on most (if not all) PPC devices is a simple 2-axis device" - are u positive about that?
Can it be that it's just a software restriction?

Again if u touch it with finger, I am quite convienced that multiple elements are firing signals - but I am speculating here. Is there a hardware description?
Hi, yes it's a physical limitation. Here's a useful page with an overview of the different touchscreen technologies - I've never seen a PPC with anything but a resistive touchscreen.
http://www.manufacturing.net/ctl/articl ... 2F1%2F1998

Interestingly this article explains the little dots you can see if you look closely - they're to keep the two conductive layers separate except when pressed.

In addition to the article, I presume the hardware samples the resistance across the x axis then across the y axis in rapid succession to determine the coordinates.
In theory, it would be possible to write a massive hack that detects how much movement there is when you press a second item, however I've been told it's not a constant, especially across devices.

andyclap: On my 3955, in sunlight you can see the dots as clear as day.
sponge wrote:In theory, it would be possible to write a massive hack that detects how much movement there is when you press a second item, however I've been told it's not a constant, especially across devices.


Do you mean "mathematically estimate" the postion of the second stylus based on the standard, API defined "mouse movement"?

Is there any (detailed)documentation on harware, or drivers?

:(
Yes I can see the little dots in sunlight also (iPAQ 3970). Damn annoying.
andru123 wrote:
Do you mean "mathematically estimate" the postion of the second stylus based on the standard, API defined "mouse movement"?

Is there any (detailed)documentation on harware, or drivers?

:(


If you are having trouble getting the above descriptions. Try getting a PAINT like program putting it in pencil mode and use two styluses. It just averages the point if there are two styluses.

You get stylus co-ordinates in a message handling loop like WndProc. Called WM_LBUTTON, WM_LBUTTONUP, WM_MOUSEMOVE in game example code you will need anyway to get something on the screen to see what is happening.

If you haven't used one stylus probably not a great idea to start writing for two. :)

Actually I think this is great. I'm trying a little test game PONG like, just waste today on it. The funny idea is to make a limit area around the bat you can't leave. So when one player tries to muck you up by moving the stylus stupidly you take your stylus up confirming they are out of area and they loose. It's clear to me you must define areas the styluses are in or they would just clash. I'm also working on an assumption that if two styluses go in a straight line then an average between them is also a straight line. So as long as the average is straight you can do basic legal dual movement.
Nah, this is not possible. How do you expect to infer two coordinates from a single coordinate? Say Windows is reporting a mouse event in the the middle of the screen. Where are the two physical points at?
Code:

o
+
o


o
+
o


o
+
o


o+o

+ Cursor position returned by Windows
o Physical points of stylus on screen


Dan East
You assume one stylus hits before the other. Or in my game you'd wait. You need to add rules to make anything like it work.

As for some of the odd effects I'm thinking they make the game. :D

For example each player can only touch the screen for a certain amount of time, etc..

Anyway I'm playing!!

I have 6 doughnuts left and plenty of strong coffee.
I was about to make the same point, if the two points are moving at the same time, there's no way of working out their positions.

However it would be possible to create a pong like game if one person had the X axis, and one the Y, playing around the corner of the screen. Don't know if it'd be much fun, as PDA screens are probably far too small.
I was planning on putting the thing up as I think that is the best way to see what the problems are and what it can do. But working files into a release at 1:30 AM sounds like pain with no gain. And tommorow I'm on work catch up. :)

Anyway what happens with the math if you try. Is because you have pixel accuracy your projected points are over excited. It's like putting a repulse force in the middle. Everything moves away quicker than reality. Simply put after a few calculated iterations your points are crap.

I still think you could write a game with two styli. Because people are reactive and quick thinking. You get a feel for what is going on and can get your way. It's like everything is on ice and you just have to take the styli away when things go wrong for you. The sillyness is a game in itself.

However I don't think thumb taps which are supposed to be not moving will work. Because there is a small movement and due to the exponetial accuracy loss your projected point will slide. The sillyness would not be fun if you were typing.

Eat Doughnuts, do something silly and sleep = Good day. :)
If you had a game where each player could only select 2 buttons , it may work by setting one player's buttons close together and the other far apart...

Code:

| a b | top player buttons
| |
| |
| ac bc ad bd |
| |
| |
|c d| bottom player buttons


the offset buttons keep the diagonal midpoints from overlapping...

How about that ascii art. Done on a ppc no less.
The initial point estimation is quite good I can see it working. However if you trap all the WM_ messages you see little cresents and loci in the middle as the two styli are pressed at the same time. About 12 pixels diameter for loop cresent or 20 in length if straight.

I guess these screens have some kind of physical nature. I'm guessing there is a recordable analog voltage due to resisitivity in X,Y that is simply A to D converted into the raw co-ordinates.

If you want to do this you really need to set it up and have a real look. It is not clean maths, it wiggles its way over a fraction of a second to the mid point. So make sure you use big buttons.
I felt stupid building it on some unreleasable code. So I've kind of got it onto and old GXSample.

Get the GXSample.exe out of the zip and run it on a 240x320 PocketPC.(Not IPaq) sorry code is very basic.

D-Pad exits when you tap it down.
Older non IPaq computers may need to put gx.lib in the same directory.

You'll see it does stuff, and kind of get an idea inaccurate does not mean without use. :P
Attachments:
gxsample.zip (22 KB)
Weeee the hardware really does not support 2 pens :(
:
http://focus.ti.com/lit/ds/symlink/tsc2200.pdf

:cry:

If only they allowed reading first from X+ and then from X- areas separately ....

But they dont.
I don't think you ever said what application you were going to use it for.

Now I can at least refer to my example. You can see if someone keeps the stylus down you can still tap the screen to get yours where you want.

I don't see what the "Emoticon" crying is all about. It must of occured to you that no one had done it! :roll: