What's happening is this :When I load my prx, the psp freezes, but when the prx is NOT loaded, none of the buttons I want (WLAN_UP, NOTE, SCREEN, HOME, VOL+, and VOL-)... ( I'm not sure if that's because the prx is not loading, or my code is incorrect, most likely is my code is incorrect ). Also no other buttons will work ( I tried with the cross button ).
KernelModePrx Stuff:
main.c :
Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
PSP_MODULE_INFO("buttons", 0x1000, 1, 1);
PSP_HEAP_SIZE_KB(32);
PSP_NO_CREATE_MAIN_THREAD();
unsigned int getbuttons()
{
u32 k1 = pspSdkGetK1();
pspSdkSetK1(0);
SceCtrlData pad;
sceCtrlPeekBufferPositive(&pad, 1);
pspSdkSetK1(k1);
return pad.Buttons;
}
int module_start()
{
return 0;
}
int module_stop()
{
return 0;
}
Code: Select all
TARGET = test
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = kstuff.exp
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
LIBDIR =
LDFLAGS = -mno-ctr0 -nostartfiles
LIBS=$(STDLIBS)$(YOURLIBS)
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Code: Select all
# Define the exports for the prx
PSP_BEGIN_EXPORTS
# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END
# Export our function
PSP_EXPORT_START(buttons, 0, 0x1001)
PSP_EXPORT_FUNC_HASH(getbuttons)
PSP_EXPORT_END
PSP_END_EXPORTS
Then I grab that .S file (buttons.S), here it is :
Code: Select all
.set noreorder
#include "pspstub.s"
STUB_START "buttons",0x10090000,0x00010005
STUB_FUNC 0xE2D9AF83,getbuttons
STUB_END
main.c
Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
PSP_MODULE_INFO("button", 0, 1, 1);
PSP_MAIN_THREAD_ATTR( PSP_THREAD_ATTR_USER | PSP_THREAD_ATTR_VFPU );
unsigned int getbuttons();
int main()
{
pspDebugScreenInit();
//pspSdkLoadStartModule("test.prx", PSP_MEMORY_PARTITION_KERNEL);
//Taken out for now, seems to be freezing my psp...
pspDebugScreenPrintf("Well it didn't freeze before the while loop...\n");
while(1)
{
unsigned int kernelButtons = getbuttons();
if(kernelButtons & PSP_CTRL_HOME)
{
pspDebugScreenPrintf("You are pressing home\n");
}
if(kernelButtons & PSP_CTRL_VOLUP)
{
pspDebugScreenPrintf("You are pressing vol+\n");
}
if(kernelButtons & PSP_CTRL_CROSS)
{
pspDebugScreenPrintf("You are pressing cross\n");
}
}
sceKernelSleepThread();
return 0;
}
Code: Select all
TARGET = Kmode_Buttons
OBJS = main.o buttons.o
BUILD_PRX = 1
INCDIR =
CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
STDLIBS= -losl -lpng -lz \
-lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspgum -lpspaudiolib -lpspaudio -lm -lpspaudiocodec -ljpeg -lpspmpeg -lpspdebug -lpspdisplay -lpspge -lpspctrl -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lpsphprm -lpspusb -lpspusbstor
LIBS=$(STDLIBS)$(YOURLIBS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = KmodeButtons
#PSP_EBOOT_ICON = resources/icon0.png
#PSP_EBOOT_PIC1 = resources/pic1.png
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak