PSP Headphone Remote

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
pspwill
Posts: 51
Joined: Thu Nov 17, 2005 8:07 am

PSP Headphone Remote

Post by pspwill »

Is there any sample code around for using the headphone remote? I cant find any in the sdk so.

Thanks
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

You don't really need it. The peek commands work like in sceCtrl, and the Is[...]Exist return only true/false when called...
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

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.
RasZilan
Posts: 2
Joined: Wed Sep 27, 2006 8:34 am

Post by RasZilan »

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: Select all

#include <pspkernel.h>
#include <pspdebug.h> 
#include <pspctrl.h>
#include <psphprm.h>

PSP_MODULE_INFO&#40;"Remote Code Display", 0, 1, 1&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;

          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;

          sceKernelSleepThreadCB&#40;&#41;;

          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;

          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;

          return thid;
&#125; 




int main&#40;&#41; &#123;
	  pspDebugScreenInit&#40;&#41;;
	  SetupCallbacks&#40;&#41;; 

	  u32 remoteButtons;

	  printf&#40;"Please Press The Pause Key"&#41;; 

	  while&#40;1&#41; &#123;
	  	
	  	sceHprmPeekCurrentKey&#40;&remoteButtons&#41;;

	  	if&#40;remoteButtons & PSP_HPRM_PLAYPAUSE&#41;&#123;
	  		break; 
	  	&#125;
	  &#125;

	  printf&#40;"Pause Key Pressed"&#41;;


	  sceKernelSleepThread&#40;&#41;; 

	  return 0;
&#125; 
makefile

Code: Select all

TARGET = remote
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Remote Code Display

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/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 :)
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

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.
RasZilan
Posts: 2
Joined: Wed Sep 27, 2006 8:34 am

Post by RasZilan »

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....
Post Reply