Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 151
Registered: ‎03-27-2009
My Device: Not Specified

multitouch mixup

I have a simple app that does nothing more than display an icon under up to two touchpoints on the screen. In my screen's touchevent I have:

 

    protected boolean touchEvent(TouchEvent touchEvent) {
    	synchronized (this) {
			if (touchEvent.getEvent() == TouchEvent.MOVE
					|| touchEvent.getEvent() == TouchEvent.DOWN) {
				GameModel.touchX = touchEvent.getX(1);
				GameModel.touchY = touchEvent.getY(1);

				GameModel.touch2X = touchEvent.getX(2);
				GameModel.touch2Y = touchEvent.getY(2);
			}
		}
		return true;
    }

 

Then I just draw the icon at touchx,touchy and touch2x,touch2y. 

 

When I run the app on my Storm I test by making circular motions with two fingers on different sides of the screen.  It works for a few seconds, but then it seems to get mixed up. Each icon has it's X and Y values controlled by separate fingers! I.E. icon 1's X value correctly matches finger 1's touch point, but it's Y value is driven by finger 2's Y point, and vice versa.

 

This confusion will switch back and forth seemingly at random.

 

Any ideas would be appreciated!

 

Regards,

Kallin Nagelberg

Random Axis

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: multitouch mixup

What BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  This was an issue with early releases of BlackBerry device software version 4.7.0.  An upgrade may resolve this issue with your BlackBerry Storm.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 151
Registered: ‎03-27-2009
My Device: Not Specified

Re: multitouch mixup

I reverted my phone to 4.7.0.75 because the firmware that came installed did not work well with my carrier. It was a Verizon Phone and I am using it unlocked on the rogers network.  The problems I had were outlined here: http://supportforums.blackberry.com/t5/Java-Development/Choking-Tunnel-open-due-to-max-tunnels/m-p/3...

 

Do you know what versions were affected? If I have to upgrade, could you tell me what to do about my networking troubles? I'm hoping 5.0 resolves that. Could I install it?

Developer
Posts: 151
Registered: ‎03-27-2009
My Device: Not Specified

Re: multitouch mixup

[ Edited ]

I have upgraded to the latest Verizon OS, 5.0.0.328 . Unfortunately multi-touch still doesn't work on this version. Here is what happens:

 

multitouch-glitch.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When one finger's X or Y coordinate crosses with another they may become confused. IE., in the picture above when the Y values of the touch points converge touch Point 1 is assigned touchpoint 2's Y value and vice versa. The X values do not switch and remain bound to the correct touch points. The same problem is observed on the X axis if touch points cross in that direction.

 

I tried using getX,getY, getGlobalX, getGlobalY, and touchpoint.getMovePoints functions and the problem was the same with all. In order to verify what I was seeing on the screen I logged the values in the arrays from touchPoint everytime a new touchEvent.move or touchevent.down event was triggered using the following code:

 

 

 for (int i = 0; i < oldPointsSize; i++) {
            int x1 = xArray1[i];
            int y1 = yArray1[i];

            int x2 = xArray2[i];
            int y2 = yArray2[i];


            System.out.println(x1 + "," + y1 + "   " + x2 + "," + y2);
}

 

The results show that the data in the arrays is bad:

 

 

New Touch Event
New Touch Event
New Touch Event
291,176   74,254

New Touch Event
291,176   74,254
290,199   73,199
New Touch Event
291,176   74,254
290,199   73,199
289,210   71,210
New Touch Event
291,176   74,254
290,199   73,199
289,210   71,210
290,190   60,249
New Touch Event
291,176   74,254
290,199   73,199
289,210   71,210
290,190   60,249
291,173   57,275
New Touch Event
291,176   74,254
290,199   73,199
289,210   71,210
290,190   60,249
291,173   57,275
291,162   56,288
New Touch Event
291,176   74,254
290,199   73,199
289,210   71,210
290,190   60,249
291,173   57,275
291,162   56,288
292,151   52,301
New Touch Event
291,176   74,254
290,199   73,199
289,210   71,210
290,190   60,249
291,173   57,275
291,162   56,288
292,151   52,301
292,151   50,313

 

 

 

In the final event log you can see the behavior described in the image:

 

The Y value of the first touch point increases from 176 to 210 as the first touchpoint moves down the screen.The Y value of the second point decreases from 254 to 210 as the second touchpoint moves up the screen. At this point the Y values of both are the same. After here they are incorrectly reported. touchpoint 1 receives touchpoint 2's Y values and vice versa. It may be that this only happens when an axis value is the same for both points.

 

If there is any suggestion on how to address this it would be appreciated. Otherwise it appears that multi-touch cannot be reliably implemented even on the latest OS versions.

 

Regards,

Kallin Nagelberg.

 

Developer
Posts: 151
Registered: ‎03-27-2009
My Device: Not Specified

Re: multitouch mixup

ping!

 

I want to make sure this issue isn't ignored. Multitouch support is critical to an app we have in development and we need to know whether or not the Storm actually supports it.

 

Thanks,

Kallin Nagelberg.

Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: multitouch mixup

I am also seeing this for os5.0.0.320.  What did you end up doing?  I am pretty shocked to see this as I would have thought that having little icons follow your fingers would have been one of the very first test for multitouch.

Highlighted
Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T

Re: multitouch mixup

I know this is an old topic - but is there any news on this?  Or has anyone found a workaround?



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.

Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: multitouch mixup

I filed a bug report.

Developer
Posts: 22
Registered: ‎04-09-2010
My Device: Storm
My Carrier: Just developing

Re: multitouch mixup

I'm developing for the Storm 1 and 2. I'm using the JRE 5.0.0.

This issue is not solved. On the simulator it seems to work, but on the device it exchanges 'y' values when the points meet at the horizontal axis.

 

 

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.util.MathUtilities;

public class MultiTouchTest extends UiApplication {
public static void main(String[] args) {
MultiTouchTest instance = new MultiTouchTest();
instance.enterEventDispatcher();

}
public MultiTouchTest(){
pushScreen(new MyScreen());
}
class MyScreen extends MainScreen{
int x1=-100,y1=-100,x2=-100,y2=-100;
int ang0=-1, ang1, angF;
int d0=0, d1=0;
double dR=0;
public MyScreen(){
Field f = new Field(){
protected boolean touchEvent(TouchEvent message) {
switch(message.getEvent()) {
case TouchEvent.MOVE:
if(message.getX(1) > 0 && message.getY(1) > 0) {
x1 = message.getX(1);
y1 = message.getY(1);
}
if(message.getX(2) > 0 && message.getY(2) > 0) {
x2 = message.getX(2);
y2 = message.getY(2);
}
if (ang0 == -1){
ang0 = (int)angle(x1, y1, x2, y2);
d0 = (int)distance(x1, y1, x2, y2);
}

ang1 = (int)angle(x1, y1, x2, y2);
angF = ang1-ang0;
if (angF < 0)
angF+=360;
d1 = (int)distance(x1, y1, x2, y2);

dR = (double)d1/(double)d0;

subpaint(getGraphics());
return true;
}
return false;
}

protected void layout(int width, int height) {
setExtent(360, 480);
}

protected void paint(Graphics graphics) {
graphics.clear();
graphics.drawLine(x1+10, y1+10, x2+10, y2+10);
graphics.drawText("1 ", x1, y1);
graphics.drawText("2 ", x2, y2);
graphics.drawText(""+ang0, 10, 5);
graphics.drawText(""+ang1, 10, 20);
graphics.drawText(""+ angF, 10, 35);

graphics.drawText(""+d0, 100, 5);
graphics.drawText(""+d1, 100, 20);
graphics.drawText(""+ dR, 100, 35);
}
public double angle(int x1, int y1, int x2, int y2) {

double dx = x2 - x1;
double dy = y2 - y1;
double angle = 0.0d;

if (dx == 0.0) {
if(dy == 0.0) angle = 0.0;
else if(dy > 0.0) angle = Math.PI / 2.0;
else angle = (Math.PI * 3.0) / 2.0;
}
else if(dy == 0.0) {
if(dx > 0.0) angle = 0.0;
else angle = Math.PI;
}
else {
if(dx < 0.0) angle = MathUtilities.atan(dy/dx) + Math.PI;
else if(dy < 0.0) angle = MathUtilities.atan(dy/dx) + (2*Math.PI);
else angle = MathUtilities.atan(dy/dx);
}
return (angle * 180) / Math.PI;
}
public double distance(int x1, int y1, int x2, int y2){
double dx = x2 - x1;
double dy = y2 - y1;
return Math.sqrt( dx*dx + dy*dy);
}
};
add(f);
}
}
}

 

 

Does anyone have a solution?

 

Regards,

Vitor Jesus

 

ps - copy the code to notepad to read it better.

 

 

 

Developer
Posts: 22
Registered: ‎04-09-2010
My Device: Storm
My Carrier: Just developing

Re: multitouch mixup

I just read the issue on the bug tracker. It seems it won't be fixed as it is a hardware limitation. It seems that the touch electronics report the points' coordinates, but not necessarely in the right order... this sure explains why I can't replicate the problem in the simulator.

 

I just want to throw my project to the bin....

 

How the hell is this possible? Somehow I find this so hard to believe.... such a major part of supporting multi-touch relies on correctly identifying where each finger is.... on the other hand it sure explains why the only multitouch feature that comes with the storm is the text selection.

 

I'll have to correct this in software. I'll post the solution here if and when I can fix this.