 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
cyf505
Joined: 29 Jan 2007 Posts: 2
|
Posted: Mon Jan 29, 2007 11:00 am Post subject: IR TV Question |
|
|
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 |
|
 |
reefbarman
Joined: 08 Jan 2007 Posts: 87 Location: Australia
|
|
| Back to top |
|
 |
cyf505
Joined: 29 Jan 2007 Posts: 2
|
Posted: Mon Jan 29, 2007 1:05 pm Post subject: |
|
|
thanks reefbarman,i see that topic
but i want an example for that,
can you give me,thanks |
|
| Back to top |
|
 |
|
|
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
|