I'm playing around with the IR port and seeing all the other demos that are flying about it looked pretty fun. I'm still slowly working my way through the PSP dev world.
Something that I thought would be fun and useful to make is an IRLearner. The idea is that you could place an IR remote infront of the psp it would be able to capture the information and then send out a duplicate of that information back out.
In theory, you could then expand it with profiles and other such stuff so that you'd be able to control multiple devices with the PSP, slap on a nice GUI and it'd be a simple yet handy app... anyway as this is my first attempt I'd like to ask a question:
This is my source so far (as you can see I've only been playing for an hour, and it's mainly a rip off of other code, like shines! thanks man! You've been so much help!):
Code: Select all
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - IrDA example
*
* Copyright (c) 2005 Frank Buss <[email protected]> (aka Shine)
*
* $Id$
*/
#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);
/* 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 main(void)
{
char buffer[10];
unsigned char data;
SceCtrlData pad;
u32 buttonsold = 0;
SetupCallbacks();
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
printf ("IrDA Learner Demo Energy\n");
printf ("-------------------------------------------------\n");
printf ("Get an IR device and press by the psp.\n\n");
printf ("Once you got a data sent message press the start button\n");
printf ("this should then repeat the command\n\n");
int fd = sceIoOpen("irda0:", PSP_O_RDWR, 0);
int q = 0;
while (q < 2)
{
// check for pad info from other PSP
int len = sceIoRead(fd, &data, 1);
int otherPad = data << 8;
if (len == 1)
{
printf("Got Data:");
printf("%c", data);
printf("\n\n");
q = q + 1;
}
sceDisplayWaitVblankStart();
}
while(1)
{
// read pad and send it
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_START)
{
sceIoWrite(fd, &data, 1);
printf("Sent Data:");
printf("%c", data);
printf("\n\n");
}
sceDisplayWaitVblankStart();
}
return 0;
}
Thanks for any help,
Energy