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 > touchX,touchY problem

#43288 - no0ne - Sat May 21, 2005 4:08 pm

Hey, i just got into this and I modified the Hello World program so that when you click on the screen a '*' will show up where you move the cursor (stylus), i dont really mind if the asterisk remain on the screen.

(Within the original While1-print touch pos...)
Code:
if(1)
{
int x = IPC->touchX;
int y = IPC->touchY;
consolePrintSet(x,y);
consolePrintf("*");
}


I have no clue how to convert the hex values into decimals, or if the NDS library already has a decimal Xpos and Ypos....can you guys help me out a bit?

-Thanks

#43292 - strager - Sat May 21, 2005 5:43 pm

What do you mean, hex to decimal? Be more specific and I may be able to answer your question.

Also, wrong forum.

#43301 - no0ne - Sat May 21, 2005 7:32 pm

Sorry about posting in the wrong forum.

I want the "IPC->touchX" value (example: 0A01) to be used as a value for "consolePrintSet(int,int)", or get an already decimal x and y position on the touchscreen so that when the user clicks/drags in a specific spot on the touch screen, it will print out an asterisk in that spot. sort of a really crappy paint program (just fooling around). I dont really know much C, i know C++ and java quite well and I cant find out how to do it.

#43302 - strager - Sat May 21, 2005 7:53 pm

Sorry, not the wrong forum. I was thinking was in the GBA Coding section...

An int is in binary, and only binary. Your C/C++ compiler will convert the hex, octal, or decimal values to binary for you.

Use the touch like this:
Code:
consolePrintSet((int)(IPC->touchX), (int)(IPC->touchY));


And it should do what you want.

#43303 - no0ne - Sat May 21, 2005 8:05 pm

thanks but i found out how to get it to work, i just converted the the hex value to decimal and it works! thanks though!

happy coding!

#43314 - no0ne - Sat May 21, 2005 9:36 pm

actually it still dosent convert the hex value to decimal, i meant it works if I convert it manually...what the hell...

#43317 - tepples - Sat May 21, 2005 10:08 pm

strager wrote:
Sorry, not the wrong forum. I was thinking was in the GBA Coding section...

D?j? vu is a glitch in the matrix, caused when a moderator moves a topic.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.