gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > PRoblem using the TouchPad

#63370 - dieudunet - Mon Dec 12, 2005 2:42 pm

Hello guys,
I devellop a homebrew game with DevKitPro and i use the fonction TouchReadXY() to capture the x and y position of the touch pad on my DS

I do test with the Supercard SD and Superpass and i got near 30 pixel of errors

this means that when my stylus is on the bottom right corner, the position is 224,172

and on the upper left corner is 28, 20

i don't understand why ? i try lot of code download on the net and all do the same problem on my DS...

Do you know fromp where come the erros ? is it my DS that have a problem or in the libray LIBNDS the code don not word ???

I try to calibrate the screen but nothing change..

Please help , i going to be crazy

#63372 - Tobin - Mon Dec 12, 2005 3:15 pm

This is a common problem, search the forum about this topic, but there is no real solution. The accuracy should be ok on the rest of the screen.

P.s.: Do you know Jean Dieudonne: Foundation of Modern Analysis?

#63373 - dieudunet - Mon Dec 12, 2005 3:23 pm

Tobin wrote:
This is a common problem, search the forum about this topic, but there is no real solution. The accuracy should be ok on the rest of the screen.

P.s.: Do you know Jean Dieudonne: Foundation of Modern Analysis?


Yeah i no him. it's a "Math?maticiens c?l?bres" :D

about touch pad, i don't find any good answer on the other topic. i copie lot of code to try diiferent way of capture for the Stylus but each time i got 30 pixels out....
and near the center of the screen. the x,y are correct, and when i leave the center of the screen i beagin to lose precision

What is the origine of the problem.....

hellllllllpppppppppppppppp

#63375 - FloFri - Mon Dec 12, 2005 3:49 pm

Do you use a screen protector? If yes remove it. The current code to access the touchscreen does not work correctly with a screen protector. I had the same problem.

#63376 - dieudunet - Mon Dec 12, 2005 3:58 pm

FloFri wrote:
Do you use a screen protector? If yes remove it. The current code to access the touchscreen does not work correctly with a screen protector. I had the same problem.


i got one, i will try to remove it but i'm a surprise....it don't do anything on commercial game so why we got problem./.....

#63377 - Mollusk - Mon Dec 12, 2005 4:08 pm

I'm surprised you didn't find any info doing a search... there are about 2 subjects like this each week, each ending up by 2 things :

1. The members telling you to remove the screen protector, because it works better without it

2. The guy who asked the question saying it does work better, but still not perfect, and adding that commercial games do not have that problem and that the touch code could be better...

It's a bit boring, I guess... why not put a sticky here ?
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#63379 - dieudunet - Mon Dec 12, 2005 4:19 pm

Nothing change,

i got 17 pixel lost , up down right and left

i do not understand why there is no answer

is that the hardware managing the Stylus so hard to code
i will try to precise the code in ARM7 main program

#63380 - Mollusk - Mon Dec 12, 2005 4:22 pm

It's that depending on the screen manufacturer (no idea how many there are !), the precisions are quite the same ! some codes produced perfect input on my DS and like 20 pixels off on others, some were the opposite...

The current code is the one that seems to work the best overall, meaning it's not as good for me, but much better for some people
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#63381 - dieudunet - Mon Dec 12, 2005 4:30 pm

i want to understand, i ,will not stop my quest of the perfect stylus until i found WHY commercial game works and not my code

i go now to work to nintendo office, i can 't sleep until i know


see you soon

:D

#63398 - FloFri - Mon Dec 12, 2005 7:15 pm

just do a rewrite of TouchReadXY , that would be enough to fix the problem ;) ;) ;)

#63408 - tepples - Mon Dec 12, 2005 8:56 pm

Has anybody tried to disassemble an official WMB demo's ARM7 binary to see exactly what it does with touch screen results?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#63432 - wintermute - Tue Dec 13, 2005 2:02 am

tepples wrote:
Has anybody tried to disassemble an official WMB demo's ARM7 binary to see exactly what it does with touch screen results?


yes, the answer is, not a lot really. The raw touch screen values are sent back to the arm9

#63548 - natrium42 - Wed Dec 14, 2005 4:44 am

wintermute wrote:
tepples wrote:
Has anybody tried to disassemble an official WMB demo's ARM7 binary to see exactly what it does with touch screen results?


yes, the answer is, not a lot really. The raw touch screen values are sent back to the arm9

WntrMute, I see that you added neimod's modification for touchscreen code to libnds. There is a small typo for yoffset calculation, though.

dieudunet, here is a test binary with the new code: http://www.natrium42.com/downloads/TouchTest.nds
_________________
www.natrium42.com

#63581 - dieudunet - Wed Dec 14, 2005 2:57 pm

natrium42 wrote:
wintermute wrote:
tepples wrote:
Has anybody tried to disassemble an official WMB demo's ARM7 binary to see exactly what it does with touch screen results?


yes, the answer is, not a lot really. The raw touch screen values are sent back to the arm9

WntrMute, I see that you added neimod's modification for touchscreen code to libnds. There is a small typo for yoffset calculation, though.

dieudunet, here is a test binary with the new code: http://www.natrium42.com/downloads/TouchTest.nds


Thanks a lot guy, i will test it now :D

#63601 - tepples - Wed Dec 14, 2005 11:37 pm

wintermute wrote:
tepples wrote:
Has anybody tried to disassemble an official WMB demo's ARM7 binary to see exactly what it does with touch screen results?

The raw touch screen values are sent back to the arm9

OK, has anybody tried to disassemble those parts of an official demo's ARM9 binary that deal with the touch screen?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#63624 - SeanMon - Thu Dec 15, 2005 2:54 am

The DS might store the calibration data in memory, and commercial games have access to this, but the homebrew community doesn't know where it is yet.

Possible?

#63625 - Sintax - Thu Dec 15, 2005 2:59 am

Most likely I'd say the code we use is simply not exactly right. I tried the new touchscreen demo posted and it works a lot better than the code from before. The outsides of the touchscreen register well, but there is still a pull when there is a light touch, although now it is towards the center of the screen as opposed to the bottom left, like before.

#63693 - YopYop - Thu Dec 15, 2005 4:49 pm

Hi,

Can you test this demo http://yopyop156.ifrance.com/TouchTest3.nds on your DS?

Thanks

yopyop

edit a little change.


Last edited by YopYop on Thu Dec 15, 2005 10:06 pm; edited 1 time in total

#63696 - Jasper_M - Thu Dec 15, 2005 5:13 pm

YopYop: YOur code doesn't work.

However, I have a solution that works 100% (!) on my ds. Here's part of the code from my WIP Minesweeper, adapt it to suit your needs....:

Code:
   touchPosition touchxy;//EDIT:ADDED AFTERWARDS
            bool wasClick = false;
         do{
            touchxy = touchReadXY();
            u32 pressure;
            pressure =    IPC->touchZ2 *touchxy.x;
            pressure /=    IPC->touchZ1;
            pressure -=touchxy.x;
            if(touchxy.y>48 && touchxy.x<144)
               pressure+=0x70;
            if(touchxy.y>16 && touchxy.x<176)
               pressure+=0x200;
               
         if(pressure<0x0D00 && touchxy.x!=0 &&touchxy.y !=0 &&IPC->touchZ2>10){   
            wasClick=true;
            tilex = touchxy.px;
            tiley = touchxy.py;
         }
            specialKeys = ~IPC->buttons;
         }
         while(specialKeys & (1<<6));
         if(wasClick)
                            //VALID CLICK HERE,COORDS ROCK DO SOMETHING


I may post the test code if someone is willing to host it.

#63723 - duencil - Thu Dec 15, 2005 9:07 pm

natrium42 wrote:
WntrMute, I see that you added neimod's modification for touchscreen code to libnds. There is a small typo for yoffset calculation, though.

The yoffset calculation looks okay.. What were you referring to? The only typo I saw was in the clipping, where
Code:
if ( py > (SCREEN_HEIGHT -1)) px = SCREEN_HEIGHT -1;

in touch.c should of course be changing py. Was that it?

#63726 - natrium42 - Thu Dec 15, 2005 9:24 pm

duencil wrote:

The yoffset calculation looks okay.. What were you referring to?

I was referring to this:

Code:
xoffset = ((PersonalData->calX1 + PersonalData->calX2) * xscale  - ((PersonalData->calX1px + PersonalData->calX2px) << 19) ) / 2;
yoffset = ((PersonalData->calY1 + PersonalData->calY2) * xscale  - ((PersonalData->calY1px + PersonalData->calY2px) << 19) ) / 2;

It should be yscale and not xscale for yoffset calculation.
_________________
www.natrium42.com

#63737 - duencil - Fri Dec 16, 2005 12:16 am

Oh right, thanks natrium42 for clarifying that. I didn't have the latest cvs. After making those modifications my touch readings continue to be way off, but I think the problem could be in the touchRead() function rather than touchReadXY(). Whether looking at the raw touch position values or the converted pixel position values, I see a great variation in X when I just move the stylus vertically from the top to the bottom of the screen.

Unless we need to consider the centre position that we mark when callibrating - could this be being stored in the personal data (maybe in the 4 reserved bytes before the calibration information we have now). It seems likely that the centre is needed for _something_ given that you have to mark it. And storing the centre along with 2 diagonal callibration points would be enough info for an app to work out how to compensate for a per row delta in x, or a per column delta in y.

#63738 - duencil - Fri Dec 16, 2005 12:26 am

duencil wrote:
could this be being stored in the personal data (maybe in the 4 reserved bytes before the calibration information we have now)


I just checked out those bytes, but they seem to be set to zero. I don't see any other likely candidate for the information.