IR TV Question

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

Moderators: cheriff, TyRaNiD

Post Reply
cyf505
Posts: 2
Joined: Mon Jan 29, 2007 10:51 am

IR TV Question

Post by cyf505 »

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: Select all

#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&#40;"IRDA Learner", 0, 1, 1&#41;; 

/* Define the main thread's attribute value &#40;optional&#41; */ 
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;; 

unsigned char my_cmd&#91;37&#93;;

int a=1;

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

/* Exit callback */ 
int exit_callback&#40;void&#41; 
&#123; 
   sceKernelExitGame&#40;&#41;; 

   return 0; 
&#125; 

/* Callback thread */ 
void CallbackThread&#40;void *arg&#41; 
&#123; 
   int cbid; 

   cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;; 
   sceKernelRegisterExitCallback&#40;cbid&#41;; 

   sceKernelSleepThreadCB&#40;&#41;; 
&#125; 

/* Sets up the callback thread and returns its thread id */ 
int SetupCallbacks&#40;void&#41; 
&#123; 
   int thid = 0; 

   thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;; 
   if&#40;thid >= 0&#41; 
   &#123; 
      sceKernelStartThread&#40;thid, 0, 0&#41;; 
   &#125; 

   return thid; 
&#125; 


int irda_capture&#40;int irdafd, int filefd&#41; &#123;
        SceCtrlData pad;
        unsigned char data;
        int len;

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



int main&#40;void&#41; 
&#123; 
   char buffer&#91;10&#93;; 
   unsigned char data; 
   SceCtrlData pad; 
   u32 buttonsold = 0; 

   SetupCallbacks&#40;&#41;; 
   pspDebugScreenInit&#40;&#41;; 

   sceCtrlSetSamplingCycle&#40;0&#41;; 
   sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_DIGITAL&#41;; 

   printf &#40;"Wait for data...\n"&#41;; 

   int irdafd = sceIoOpen&#40;"irda0&#58;", PSP_O_RDWR, 0&#41;; 
   int filefd = sceIoOpen&#40;"irda0&#58;", PSP_O_RDWR, 0&#41;;


   while&#40;a==1&#41; 
   &#123; 
      // read pad and send it 
              sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
                if &#40;pad.Buttons & PSP_CTRL_START&#41;
                        irda_capture&#40;irdafd, filefd&#41;;        
   &#125; 
   
           sceIoClose&#40;irdafd&#41;;
        sceIoClose&#40;filefd&#41;;

   sceDisplayWaitVblankStart&#40;&#41;; 

   return 0; 
&#125; 
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

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
cyf505
Posts: 2
Joined: Mon Jan 29, 2007 10:51 am

Post by cyf505 »

thanks reefbarman,i see that topic

but i want an example for that,

can you give me,thanks
Post Reply