#74872 - patroclus02 - Wed Mar 08, 2006 11:58 am
Hello,
I'm going through http://www.double.co.nz/nintendo_ds/index.html tutorial
I'm trying to understand how the demos work, though it is quite difficult to figure out everything, as there're lots of defines, procedure, and so on.
So far, I wonder how does first demo calculate pixel position touched.
It defines
and the calculates
so when you retrieve x and y positions (not given in pixels when calling touchRead), it computes the real pixel data doing:
I don't understand how this is done. why - 60? why - 28?...
As I read it is a calibrating routine or something like that.
But, if you use your own IRQ handler, you need to do this? or in latest NDSLIB you can just use IPC->touchXpx or touchRead without including the above code in the handler??
Thank you
I'm going through http://www.double.co.nz/nintendo_ds/index.html tutorial
I'm trying to understand how the demos work, though it is quite difficult to figure out everything, as there're lots of defines, procedure, and so on.
So far, I wonder how does first demo calculate pixel position touched.
It defines
Code: |
#define TOUCH_CAL_X1 (*(vs16*)0x027FFCD8) #define TOUCH_CAL_Y1 (*(vs16*)0x027FFCDA) #define TOUCH_CAL_X2 (*(vs16*)0x027FFCDE) #define TOUCH_CAL_Y2 (*(vs16*)0x027FFCE0) |
and the calculates
Code: |
s32 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1; s32 TOUCH_HEIGHT = TOUCH_CAL_Y2 - TOUCH_CAL_Y1; s32 TOUCH_OFFSET_X = ( ((SCREEN_WIDTH -60) * TOUCH_CAL_X1) / TOUCH_WIDTH ) - 28; s32 TOUCH_OFFSET_Y = ( ((SCREEN_HEIGHT-60) * TOUCH_CAL_Y1) / TOUCH_HEIGHT ) - 28; |
so when you retrieve x and y positions (not given in pixels when calling touchRead), it computes the real pixel data doing:
Code: |
xpx = ( ((SCREEN_WIDTH -60) * x) / TOUCH_WIDTH ) - TOUCH_OFFSET_X; ypx = ( ((SCREEN_HEIGHT-60) * y) / TOUCH_HEIGHT ) - TOUCH_OFFSET_Y; |
I don't understand how this is done. why - 60? why - 28?...
As I read it is a calibrating routine or something like that.
But, if you use your own IRQ handler, you need to do this? or in latest NDSLIB you can just use IPC->touchXpx or touchRead without including the above code in the handler??
Thank you