10-24-2011 01:21 AM - edited 10-24-2011 06:16 AM
Greettings and salutations fellow developers. some quick specifics I use the blackberry JDE 5.0 on Eclipse Galileo, I have created a mouse method for trackpads and trackballs. Trying to expand my sale horizons, two possible setbacks are haunting my thoughts.
setback 1: The mouse works great until you roll it two directions at once, example left and up at the same time only moves it left or up not both.
setback 2: the track pad does not roll like the ball, this method will probably work great for the ball but not the pad.
this is the code from my navigationMovement() method
protected boolean navigationMovement(int dx,int dy,int status,int time)
{
super.navigationMovement(dx, dy, status, time);
if (!mouseOn) //places mouse on first run but doesnt repeat
{
mouses.addElement(new Sprite(Utility.SCREEN_WIDTH / 2, Utility.SCREEN_HEIGHT / 2));
mouseOn = true;
}
Sprite f = (Sprite) mouses.firstElement(); //sprite class updates x and y coordinates //Focussing on the x/y of the mouse(i know using a vector is silly here)
f.x+= (dx * 10);
f.y+= (dy * 10); //moves the mouse according to dx/dy input
if((f.x + mouse.getWidth()) > Utility.SCREEN_WIDTH) f.x = Utility.SCREEN_WIDTH - mouse.getWidth();
else if(f.x < 0) f.x = 0;
if((f.y + mouse.getHeight()) > Utility.SCREEN_HEIGHT) f.y = Utility.SCREEN_HEIGHT - mouse.getHeight();
else if(f.y < 0) f.y = 0; //keeps the mouse from scrolling off screen
invalidate(); //update screen
return true;
}
Is there a way to make the trackpad act like the trackball with this method or will it be slower and choppy? I know that trackpads have a magnitude and direction. So I'm hoping it won't be too bad, it seems to work on the simulator but I need a real phone or app tester willing to try this for me.
More importantly how can I get the mouse to move two directions if the trackball is going two directions? I have some Ideas on this maybe an if statement to check if two directions are going at once then run both directions. But it seems like both directions should be running.
Thanks in advance.
-Andy
Solved! Go to Solution.
10-30-2011 06:07 PM
I just realized this post was a little out of place, well thanks to the blackberry api I got this one figured out.