forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sending IrDA Data

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
maxx



Joined: 26 Jul 2007
Posts: 7

PostPosted: Thu Jul 26, 2007 2:40 am    Post subject: Sending IrDA Data Reply with quote

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.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Thu Jul 26, 2007 1:04 pm    Post subject: Reply with quote

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

Straight out of samples:
Code:

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 (len == 1) {
         if (otherPad & PSP_CTRL_CIRCLE) printf ("CIRCLE pressed\n");
         if (otherPad & PSP_CTRL_CROSS) printf ("CROSS pressed\n");
         if (otherPad & PSP_CTRL_SQUARE) printf ("SQUARE pressed\n");
         if (otherPad & PSP_CTRL_TRIANGLE) printf ("TRIANGLE pressed\n");
      }
      
      sceDisplayWaitVblankStart();
   }

   return 0;
}

// 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?
Back to top
View user's profile Send private message
maxx



Joined: 26 Jul 2007
Posts: 7

PostPosted: Thu Jul 26, 2007 11:05 pm    Post subject: Reply with quote

Yes, looked on the iR port in a black room with a digital camera.
Thnaks for the code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group