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 > Dodgy touchscreen readings at top corners

#56764 - Zapf_Bandit - Tue Oct 11, 2005 9:21 am

I am having very irritating issues with the touchscreen.

I am making a Maze game and I have the maze take the whole screen using tiles 8x8 to build it.

All is great when I am near the middle of the screen and the stylus position is nice and accurate.

Unfortunately it all falls to pieces when I try and use either of the top corners.

I can't even get within 8 pixels of the left hand side and the top right corner behaves differently if going upwards or coming down !!!

Has anyone else had similar problems such as this?

Before anyone asks I HAVE calibrated my stylus multiple times testing different offsets to no avail.

Thanks in Advance,
Zapf Bandit

#56765 - josath - Tue Oct 11, 2005 9:24 am

does this happen in other homebrew, or just the one you wrote?

try this, and see if it has the same problem: http://devkitpro.kicks-ass.org/devkitPro/touch_test.nds (by WinterMute)

#56769 - Onori - Tue Oct 11, 2005 10:16 am

I had the same problem using the method in old version of sdk example (IPC->touchX / IPC->touchY) that worked on emulator, then I used IPC->touchXpx IPC->touchYpx (that don't work on emulator like ideas) but it work quite fine on real DS

#56809 - Maverick - Tue Oct 11, 2005 7:10 pm

write a mini program that plots a white pixel at the touch screen coordinate and run some tests to see what the pixel plotting behaviour is

#56848 - cybereality - Tue Oct 11, 2005 11:14 pm

Its seems that other people have had those problems too. My DS seems to get the touch readings decent, just a little jittery (+-2) if you press nice and hard. If you just lightly graze the screen it gives horriblely inaccurate readings leaning toward the lower left hand corner (0,198). I heard that there were different touch screens produced for different models, so we may not even have the same exact hardware.

I put together this little test program that outputs touch readings. It gives the raw data and also some averaged values that are more accurate (but delayed because it is an average). It also displays a crosshair on screen so it is easy to see what it going wrong. I was going to fix it so it used the timer interupts to get the readings instead of the vblank, but I never got a chance to finish it. Anyway, I figured it might be useful to some people so here it is for download (source, nds & nds.gba included):

TOUCH SCREEN TEST PROGRAM
_________________
// cybereality

#56859 - headspin - Wed Oct 12, 2005 12:15 am

Check out the code at the end of this thread. It sounds like your not reading the calibration offsets.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#56895 - Zapf_Bandit - Wed Oct 12, 2005 5:14 am

Whoa, so many replies, you guys are great.

I am both happy and sad to say none of these things helped...

I tested with cyberreality's app and got exactly the same behaviours I experience. The top left corner gives me (9,0).

I implemented the code recommended by headspin since I was using hard coded constants for the calibration positions but this did nothing either.

I have already tried Mavrick's suggestion of ploting the pos and both the top corners are not reached.

I am really at a loss... With Nintendogs I can move my cursor anywhere... What am I doing wrong???

Zapf

#56907 - Defect - Wed Oct 12, 2005 6:03 am

I'm thinking it might be to do with the plastic cover on the touch screen, it may not flex enough to allow the stylus to get right into the corners?

#56928 - Dark Knight ez - Wed Oct 12, 2005 9:03 am

No. That can't be it.
Quote:
With Nintendogs I can move my cursor anywhere

#56939 - headspin - Wed Oct 12, 2005 11:46 am

We are aware that the touchscreen processing of homebrew is not as good as commerical games. We are still yet to figure out why. The fact that the other homebrew you tested does the same thing suggests that it's not your code that is at fault but the accuracy issues of the library itself.

To quote wintermute on the latest release of devkitARM r16..

Quote:
Touch code has been tidied and stabilised slightly. There is still some work to do on this.

_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#57018 - Zapf_Bandit - Thu Oct 13, 2005 1:19 am

I'm not sure but I think that the calibration is non-linear. When calibrating the DS asks for 3 points not 2. I am really going to try and improve this behaviour in my code since at the moment it is a quite big limitation on the game designs I want to make since I need to avoid certain areas on screen.

Is the value returned from the libnds "touchRead(TSC_MEASURE_X)" just a value of somewhere in memory of is some other processing done to it beforehand?

If it is processed where can I find the raw values?

Thanks,
Zapf Bandit

#57036 - josath - Thu Oct 13, 2005 4:45 am

Zapf_Bandit wrote:

Is the value returned from the libnds "touchRead(TSC_MEASURE_X)" just a value of somewhere in memory of is some other processing done to it beforehand?

If it is processed where can I find the raw values?


Did you even look at the code for touchRead()? It's fairly simple, like 15 lines, with a bunch of comments explaining each step. Right below that function is the one that takes all the calibration offsets into account, touchReadXY(), which is used in the arm7 template to store values into the IPC, which can be read on the arm9.

#57050 - cybereality - Thu Oct 13, 2005 9:43 am

headspin wrote:
We are aware that the touchscreen processing of homebrew is not as good as commerical games.


You'd actually be surprised. I was figuring the same thing, but I ran some tests and some commercial games have the same problems. They are probably doing some form of interpolation on the raw data. The game I noticed it a bunch on was Need for Speed, but it also was in Feel the Magic (which relies on the stylus). Try it out on your DS, you'll see.
_________________
// cybereality

#57060 - Didou - Thu Oct 13, 2005 12:28 pm

Hi,

It appeared to me on ReboNDS that using the good old IPC->touchX works fine both on hardware and emulator.
On the other side, using the touchRead () of libnds really give strange results.
So I decided to keep my own old way,usign the hard coded famous constants...

-- Didou

#57079 - Mollusk - Thu Oct 13, 2005 4:37 pm

the only problem with that is that some people don't have good stylus positions at all, depending on the touch screen !

I did some quick testing, and at one point I had a nearly perfect touch code for me (maximum 1-2 pixels off in the top corner, perfect everywhere), but for some people, it was... 20 pixels off ! So I went back to using the calibration, which isn't as good for me, but fairly good for everyone...
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#57097 - headspin - Thu Oct 13, 2005 7:28 pm

There have been various ideas thrown around this thread on how to improve the touchscreen readings.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game