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 > DS touch screen Area detection

#129052 - SukiStrider - Fri May 18, 2007 3:51 pm

Please can someone show me in a small c/c++ code or explain to me how to detect a screen press area.

For example: If the centre of the DS's touch screen is pressed how do i write the code that detects the area pressed.

I normally write it like this:

[Please excuse the coding, I am at work, THIS IS NOT WORK RELATED]

This is to detect a small square area when pressed.

if ((screen_area > 5 && screen_area < 8) ||
(screen_area > 20 && screen_area < 23) ||
(screen_area > 35 && screen_area < 38) ||
(screen_area > 50 && screen_area < 53))

But this seems wrong, can you show me another way.

Thanks In Advance[/b]

#129055 - Lick - Fri May 18, 2007 4:10 pm

Code:
touchPosition tp = touchReadXY();

if (tp.py >= 32 && tp.py < 160 &&     // stylus.y = [32, 159]

    tp.px >= 32 && tp.px < 224)     // stylus.x = [32, 223]
{

    // code

}

_________________
http://licklick.wordpress.com

#129058 - keldon - Fri May 18, 2007 5:02 pm

SukiStrider wrote:
[/b]

Note that writing an entire post in bold or capitals will not make people read it more, they have already clicked the link into your thread and therefore want to read it [in case that was your intention].

#129125 - mml - Sat May 19, 2007 5:56 am

keldon wrote:
Note that writing an entire post in bold or capitals...


PhpBB is retarded and frequently decides to automatically close tags you open when you hit submit, even if you already closed or completely deleted those tags yourself. So I wouldn't read too much into a random trailing [/b], or any other tag really.

#129143 - tepples - Sat May 19, 2007 4:36 pm

Do you mean to detect whether the center of a touch is within a given area on the screen, or do you mean to detect the actual area of a single touch (e.g. finger covers more area than stylus)?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#129164 - Dood77 - Sun May 20, 2007 12:26 am

A small tech demo showing what data (graphed, not numbers) the DS actually receives from the touch screen (demonstrating how the calculated touch point changes with pressure and the instrument used) would be neat to see, there would be three modes:
One with a dot for showing the center of the actual touch point
One that would change the color of the background depending on what area the DS was calculating
And one that would have a dot that faded to different colors depending on the pressure calculated.

But I really don't know exactly the data that the DS receives.. so I could be wrong on what a program would/could do... I'm not a programmer, at least not for the DS.
_________________
If I use a term wrong or something then feel free to correct, I?m not much of a programmer.

Original DS Phat obtained on day of release + flashme v7
Supercard: miniSD, Kingston 1GB, Kingston 2GB
Ralink chipset PCI NIC

#129167 - SukiStrider - Sun May 20, 2007 12:50 am

Hi tepples,

yeah, I mean to detect the actual area of a single touch weather it be stylus or other wise, I think Lick's suggestion (thanks for that) is understandable and any more help is appreciated.

Lets say I have a screen image with a square icon of 4x4 pixels on the upper left of the screen how do i detect whether that icon's area has been press.

I don't want to use the method I mentioned in my first post (very Amateur coding)

I know of another way using pointers but that is just too complicated.

I appreciate your interest.

#129170 - SukiStrider - Sun May 20, 2007 1:16 am

keldon sorry if that typo offended you, but that was not my doing, when i clicked preview then clicked submit it just appeared.

Any-who, Dood77 you may not be a DS programmer but your suggestion is very close at least your first two points (finding the matrix of the area pressed if something as accurate as a stylus was used, then highlighting that circular area with an alternate colour, but that seemed too complicated so i settled for finding the area of a screen press be it a covered area (finger press) or something else.

Maybe it's my explanation.