| View previous topic :: View next topic |
| Author |
Message |
pspwill
Joined: 17 Nov 2005 Posts: 51
|
Posted: Mon Sep 18, 2006 7:26 am Post subject: PSP Headphone Remote |
|
|
Is there any sample code around for using the headphone remote? I cant find any in the sdk so.
Thanks |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Mon Sep 18, 2006 7:56 am Post subject: |
|
|
| You don't really need it. The peek commands work like in sceCtrl, and the Is[...]Exist return only true/false when called... |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue Sep 19, 2006 4:07 am Post subject: |
|
|
| If you use SDL, the remote buttons show up as keyboard keys F10 through F15. You can see the corresponding source code in SDL/src/video/psp/SDL_pspevents.c. Also, in the pspware repository, PSPMediaCenter/gui/debug/gui.c uses the hprm. |
|
| Back to top |
|
 |
RasZilan
Joined: 27 Sep 2006 Posts: 2
|
Posted: Wed Sep 27, 2006 8:59 am Post subject: |
|
|
I used the PSPMediaCenter gui.c as an example to test a piece of code on the PSP which would detect if the PLAYPAUSE key was pressed however I get the following message from the PSP "The game could not be started (80020001)". I am using make kxploit as I have a 1.5fw PSP and dont get any errors when compiling.
main.c
| Code: |
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psphprm.h>
PSP_MODULE_INFO("Remote Code Display", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* 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() {
pspDebugScreenInit();
SetupCallbacks();
u32 remoteButtons;
printf("Please Press The Pause Key");
while(1) {
sceHprmPeekCurrentKey(&remoteButtons);
if(remoteButtons & PSP_HPRM_PLAYPAUSE){
break;
}
}
printf("Pause Key Pressed");
sceKernelSleepThread();
return 0;
}
|
makefile
| Code: |
TARGET = remote
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Remote Code Display
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
LIBS += -lpsphprm_driver
|
Any help would be appreciated I am scratching my head on this one and will probably go bald if I keep it up :) |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Wed Sep 27, 2006 4:01 pm Post subject: |
|
|
You are using the kernel version of hprm in your user mode program.
You can do two things:
Change the attributes of your app to 0x1000.
Or better: change the line of the libs in makefile to:
LIBS += -lpsphprm
To use the user mode version of hprm. |
|
| Back to top |
|
 |
RasZilan
Joined: 27 Sep 2006 Posts: 2
|
Posted: Thu Sep 28, 2006 3:47 am Post subject: |
|
|
Great, thanks that resolved the problem and prevented any more hair loss :)
I changed the line in the makefile from:
LIBS += -lpsphprm_driver
to
LIBS += -lpsphprm
and it works fine now.... |
|
| Back to top |
|
 |
|