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 

IR TV Question

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



Joined: 29 Jan 2007
Posts: 2

PostPosted: Mon Jan 29, 2007 11:00 am    Post subject: IR TV Question Reply with quote

this is my code ,i want capture the data from my TV Remote control ,then send it to my TV,but it's look like can't do it,please help me

Code:

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspsircs.h>
#include <stdlib.h>
#include <string.h>

/* Define the module info section */
PSP_MODULE_INFO("IRDA Learner", 0, 1, 1);

/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

unsigned char my_cmd[37];

int a=1;

/* Define printf, just to make typing easier */
#define printf   pspDebugScreenPrintf

/* Exit callback */
int exit_callback(void)
{
   sceKernelExitGame();

   return 0;
}

/* Callback thread */
void CallbackThread(void *arg)
{
   int cbid;

   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);

   sceKernelSleepThreadCB();
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
   int thid = 0;

   thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0)
   {
      sceKernelStartThread(thid, 0, 0);
   }

   return thid;
}


int irda_capture(int irdafd, int filefd) {
        SceCtrlData pad;
        unsigned char data;
        int len;

        printf("Press the START button to stop.\n");
        while (1) {
                /* Read a byte */
                len = sceIoRead(irdafd, &data, 1);
                if (len != 0) {
                        /* Print it out and put it in the file */
                        printf("%c", data);
                        len = sceIoWrite(filefd, &data, 1);
                }
                /* Check for the start button */
        }
        return 0;
}



int main(void)
{
   char buffer[10];
   unsigned char data;
   SceCtrlData pad;
   u32 buttonsold = 0;

   SetupCallbacks();
   pspDebugScreenInit();

   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

   printf ("Wait for data...\n");

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


   while(a==1)
   {
      // read pad and send it
              sceCtrlReadBufferPositive(&pad, 1);
                if (pad.Buttons & PSP_CTRL_START)
                        irda_capture(irdafd, filefd);       
   }
   
           sceIoClose(irdafd);
        sceIoClose(filefd);

   sceDisplayWaitVblankStart();

   return 0;
}
Back to top
View user's profile Send private message
reefbarman



Joined: 08 Jan 2007
Posts: 87
Location: Australia

PostPosted: Mon Jan 29, 2007 11:21 am    Post subject: Reply with quote

hey cyf,

i had exactly the same idea and found that this could be quite a hard exercise check out this thread for more information http://forums.ps2dev.org/viewtopic.php?t=7548
Back to top
View user's profile Send private message
cyf505



Joined: 29 Jan 2007
Posts: 2

PostPosted: Mon Jan 29, 2007 1:05 pm    Post subject: Reply with quote

thanks reefbarman,i see that topic

but i want an example for that,

can you give me,thanks
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