タッチスクリーン入力サンプル。


過去に書いたコードを少し直してアーカイブした。


devkitPro の example とあまり代わり映えしないが、
タッチパネルの抵抗値を実機確認するために
z1, z2 メンバまで表示するようにしたんだと思う。


touch input sample


ttp://page.freett.com/ntr/example/touch.zip

/*---------------------------------------------------------------------------------
	
	touch input sample
	
	version 0.02
	Mar 15, 2010
	
	By. REGEKATSU
	
---------------------------------------------------------------------------------*/
#include <nds.h>
#include <stdio.h>

//---------------------------------------------------------------------------------
int main(void){
//---------------------------------------------------------------------------------
	
	touchPosition touch;
	
	consoleDemoInit();
	iprintf("touch input sample\n\nversion 0.02\nMar 15, 2010\n\nBy REGEKATSU\n\n");
	
	while(1) {
		
		swiWaitForVBlank();
		
		//タッチスクリーンの入力状態を得る。
		scanKeys();
		
		if(keysDown() & KEY_TOUCH){
			iprintf("\x1b[8;0Htouch screen Down");
		}else if(keysHeld() & KEY_TOUCH){
			iprintf("\x1b[8;0Htouch screen Held");
		}else if(keysUp() & KEY_TOUCH){
			iprintf("\x1b[8;0Htouch screen Up  ");
		}else{
			iprintf("\x1b[8;0Htouch screen Free");
		}
		
		//タッチスクリーンの入力に対する詳細を得る。
		touchRead(&touch);
		
		iprintf("\x1b[10;0HtouchPosition.rawx = %04d", touch.rawx);
		iprintf("\x1b[11;0HtouchPosition.rawy = %04d", touch.rawy);
		iprintf("\x1b[12;0HtouchPosition.x    =  %03d", touch.px);
		iprintf("\x1b[13;0HtouchPosition.y    =  %03d", touch.py);
		iprintf("\x1b[14;0HtouchPosition.z1   = %04d", touch.z1);
		iprintf("\x1b[15;0HtouchPosition.z2   = %04d", touch.z2);
		
	}
	
}

//---------------------------------------------------------------------------------