Well it sounded easy, but its not working. Can anybody see anything obviously wrong with it....
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 printf pspDebugScreenPrintf
PSP_MODULE_INFO("IrDA Relay", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
void delay_loop(int num) {
if (num <= 0) return;
for (; num > 0; num--)
sceDisplayWaitVblankStart();
}
int exit_callback(void)
{
sceKernelExitGame();
return 0;
}
void CallbackThread(void *arg)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
/*
*Main Function
*/
int main(int argc, char *argv[]) {
SceCtrlData pad;
SetupCallbacks();
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
printf("IrDA Relay\n-Will send the same signal back\n--several seconds after recieving it.\n\n");
int fd = sceIoOpen("irda0:", PSP_O_RDWR, 0);
if (fd < 0) {
printf("ERROR: Could not open irda device!\n");
printf("Press any button to exit...\n");
while (pad.Buttons == 0) {
delay_loop(2);
sceCtrlReadBufferPositive(&pad, 1);
}
return -1;
}
while (1) {
unsigned char data;
data = sceIoRead(fd, &data, 32);
if (data <= 32) {
delay_loop(50);
sceIoWrite(fd, &data, 32);
printf("%c", data);
}
sceDisplayWaitVblankStart();
}
sceIoClose(fd);
return 0;
}