Sending IrDA Data

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
maxx
Posts: 7
Joined: Thu Jul 26, 2007 2:19 am

Sending IrDA Data

Post by maxx »

I'd like to know what is the simplest method of sending data using the IrDA, just like if the PSP was a remote.
I tried sceIoWrite but it doesn't send anything.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

You've got to open the irda device first so you're writing to something.

Straight out of samples:

Code: Select all

int main(void)
{
	SceCtrlData pad;
	u32 buttonsold = 0;

	SetupCallbacks();
	pspDebugScreenInit();

	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

	int fd = sceIoOpen("irda0:", PSP_O_RDWR, 0);

	while (1) {
		// read pad and send it
		sceCtrlReadBufferPositive(&pad, 1);
		if (pad.Buttons != buttonsold) {
			unsigned char padHighbyte = pad.Buttons >> 8;
			sceIoWrite(fd, &padHighbyte, 1);
			buttonsold = pad.Buttons;
		}

		// check for pad info from other PSP
		unsigned char data;
		int len = sceIoRead(fd, &data, 1);
		int otherPad = data << 8;
		if &#40;len == 1&#41; &#123;
			if &#40;otherPad & PSP_CTRL_CIRCLE&#41; printf &#40;"CIRCLE pressed\n"&#41;;
			if &#40;otherPad & PSP_CTRL_CROSS&#41; printf &#40;"CROSS pressed\n"&#41;;
			if &#40;otherPad & PSP_CTRL_SQUARE&#41; printf &#40;"SQUARE pressed\n"&#41;;
			if &#40;otherPad & PSP_CTRL_TRIANGLE&#41; printf &#40;"TRIANGLE pressed\n"&#41;;
		&#125;
		
		sceDisplayWaitVblankStart&#40;&#41;; 
	&#125;

	return 0;
&#125;

// By Shine

How do you know nothing is being sent, rather than the possibility that
the rest of your program is crap?
Have you checked ir with a digital camera or webcam?
maxx
Posts: 7
Joined: Thu Jul 26, 2007 2:19 am

Post by maxx »

Yes, looked on the iR port in a black room with a digital camera.
Thnaks for the code.
Post Reply