| View previous topic :: View next topic |
| Author |
Message |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Mon Jul 14, 2008 12:59 am Post subject: Odd plugin |
|
|
This is very odd...
The plugin loads IRDA.PRX fine in VSH, a Game150 mode however it fails in Game mode.
Why is this?
| Code: | #include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdio.h>
#include <string.h>
#include <pspirkeyb.h>
#include <pspirkeyb_rawkeys.h>
#include "../sdk/inputdriver.h"
#include "../sdk/inputframework.h"
PSP_MODULE_INFO("piKeyIR", 0x1000, 1, 1);
PSP_NO_CREATE_MAIN_THREAD();
#define DRIVERVER "1"
#define REQUIREDVER 1
SceUID irthread;
int gcurrmode;
int getDriverInfo(DRIVERINFO *infostruct) {
strcpy(infostruct->driverVersion, DRIVERVER);
if(infostruct->apiVersion < REQUIREDVER) return PIKEY_ERROR_VERSION;
else {
strcpy(infostruct->driverName, "IR");
infostruct->apiVersion = PIKEY_THIS_VERSION;
infostruct->unicodeSupported = FALSE;
return PIKEY_SUCCESS;
}
}
#define CONFIG_FILE "ms0:/seplugins/pikey/pspirkeyb.ini"
SceUID threadid;
void *buffer;
SIrKeybScanCodeData scancodebuffer[255];
unsigned char vt100buffer[255];
SceUID load_module(const char *path, int flags, int type)
{
SceKernelLMOption option;
SceUID mpid;
/* If the type is 0, then load the module in the kernel partition, otherwise load it
in the user partition. */
if (type == 0) {
mpid = 1;
} else {
mpid = 2;
}
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
return sceKernelLoadModule(path, flags, type > 0 ? &option : NULL);
}
int main_thread(SceSize args, void *argp) {
int ret;
int status;
// We have to load the IRDA PRX if we're in VSH mode.
if (!waitForModule("sceSIRCS_IrDA_Driver"))
{
sioPrint("Need to load IRDA\r\n");
// load the IRDA module.
SceUID modid = load_module("flash0:/kd/irda.prx", 0, 0);
if (modid > 0)
{
ret = sceKernelStartModule(modid, 0, NULL, &status, NULL);
if (ret < 0)
{
sioPrint("failed to start IRDA: ");
sioPrintWord(ret);
sioPrint("\r\n");
return ret;
}
}
else
{
sioPrint("failed to load IRDA: ");
sioPrintWord(ret);
sioPrint("\r\n");
return 4;
}
}
sioPrint("Starting libpspirkeyb\r\n");
ret = pspIrKeybInit( CONFIG_FILE, 1 );
if( ret != PSP_IRKBD_RESULT_OK )
{
sioPrint("!! libpspirkeyb failed !!\r\n");
return 0;
}
sioPrint("IR in ready.\r\n");
gcurrmode = -1;
for(;;) {
// avoid tight loops
sceKernelDelayThread(1000);
// check which mode the framework is in, and switch the IR lib accordingly
int lmode = getMode();
if (lmode != gcurrmode)
{
if (lmode == PIKEY_KEYMODE_VT100STREAM)
{
pspIrKeybOutputMode( PSP_IRKBD_OUTPUT_MODE_VT100 );
buffer = vt100buffer;
}
else if (lmode == PIKEY_KEYMODE_KEYPRESS)
{
pspIrKeybOutputMode( PSP_IRKBD_OUTPUT_MODE_SCANCODE );
buffer = scancodebuffer;
}
gcurrmode = lmode;
}
int length, ii;
ret = pspIrKeybReadinput(buffer, &length);
// returns 0 for success, all errors are negative
if((ret >= 0) && (length > 0))
{
for (ii = 0; ii < length; ii++)
{
if (gcurrmode == PIKEY_KEYMODE_VT100STREAM)
{
putNextChar(vt100buffer[ii]);
}
else if (gcurrmode == PIKEY_KEYMODE_KEYPRESS)
{
sendKeyPress(scancodebuffer[ii].raw,
scancodebuffer[ii].pressed,
scancodebuffer[ii].shift,
scancodebuffer[ii].ctrl,
scancodebuffer[ii].alt);
}
}
}
}
return 0;
}
// called by module_start
int main(void) {
threadid = sceKernelCreateThread("IRumode", main_thread, 16, 0xA000, 0, NULL);
if (threadid >= 0) sceKernelStartThread(threadid, 0, NULL);
else return threadid;
return 0;
}
SceSize sceKernelMaxFreeMemSize()
{
return 0x4000;
}
|
|
|
| Back to top |
|
 |
Smong
Joined: 04 Sep 2007 Posts: 82
|
Posted: Mon Jul 14, 2008 9:58 pm Post subject: |
|
|
One reason why something would work in game150 and not game would be an incorrect use of kernel mode. _________________ (+[__]%) |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Tue Jul 15, 2008 1:42 am Post subject: Thanks... |
|
|
Thanks for that but that doesn't actually help!
I can feel that it's only a small change but I can't see where!
Help please?
Angelo |
|
| Back to top |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Tue Jul 15, 2008 2:25 am Post subject: |
|
|
what is your firmware version?
could you provide the makefile? _________________ --pspZorba--
NO to K1.5 ! |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Tue Jul 15, 2008 2:37 am Post subject: |
|
|
I'm on the latest M33 firmware 4.01 M33... no 1.50 addon kernel but I know this works in 1.50 mode.
Makefile:
| Code: | TARGET = piKeyIR
OBJS = main.o
BUILD_PRX=1
PRX_EXPORTS=exports.exp
USE_KERNEL_LIBS = 1
USE_PSPSDK_LIBC = 0
INCDIR =
CFLAGS = -O0 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
PSPSDK=$(shell psp-config --pspsdk-path)
LIBS=-lpspirkeyb
include $(PSPSDK)/lib/build.mak
LIBS += ../sdk/framework_stub.o -lpsppower_driver -lpspkernel -lpsphprm_driver
|
|
|
| Back to top |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Tue Jul 15, 2008 4:43 am Post subject: |
|
|
I wasn't able to compile your code ( I miss some file like "../sdk/inputdriver.h" and "../sdk/inputframework.h" )
But I made a simple test:
A prx in kernel mode with one function that loads and starts irda.prx, using your code: SceUID load_module(const char *path, int flags, int type) .
and an eboot in user mode that loads my prx and call the function that loads "flash0:/kd/irda.prx"
well this returns me a valid handle meaning that irda.prx has been loaded and started....
what are the code returned by either load_module and sceKernelStartModule by your HB? _________________ --pspZorba--
NO to K1.5 ! |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Tue Jul 15, 2008 6:44 am Post subject: |
|
|
This is a PRX. I know it works fine, it works perfectly in VSH and Game150, just just not Game3.XX/4.XX.
It's very odd! |
|
| Back to top |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Tue Jul 15, 2008 6:56 am Post subject: |
|
|
I know it is a prx, my quick test was a prx too and it works under GAME.
So what are the error codes ? _________________ --pspZorba--
NO to K1.5 ! |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Wed Jul 16, 2008 2:17 am Post subject: |
|
|
It compiles fine! It just doesn't load IRDA when in Game mode!
The plugin will only work if I add IRDA in SEPlugins/Game.txt
Very odd!
Thanks for the help!
Angelo |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Fri Aug 01, 2008 8:07 pm Post subject: |
|
|
So what's stopping it from loading irda.prx in Game4.XX mode?
Anybody got any ideas? |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Fri Aug 01, 2008 8:19 pm Post subject: |
|
|
Nothing, didn't read well :)
Anyways, can you post what loadmodule and startmodule are returning when loading irda.prx? |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Sat Aug 02, 2008 2:39 am Post subject: Nothing! |
|
|
It doesn't return with anything!
Just to keep in mind this module is loaded by the main engine piKey.PRX.
Actually I'll change the SIO output to displayStatusText and I'll have another look when I get a chance.
Thanks Moonlight!
Angelo |
|
| Back to top |
|
 |
angelo
Joined: 29 Aug 2007 Posts: 168
|
Posted: Sun Aug 03, 2008 8:25 am Post subject: Interesting |
|
|
OK here's some intersting facts:
- piKey will not load at all when in GAME 4.XX mode. No debug messages appear... nothing.
- When "flash0:/kd/irda.prx" is added to Game.txt, piKey works in game and all messages appear.
Moonlight, how do your Game, VSH, POPS and Game150 work? My plugin works when I force start the module into a txt file.
Any ideas please?
Angelo |
|
| Back to top |
|
 |
|