forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSP Headphone Remote

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pspwill



Joined: 17 Nov 2005
Posts: 51

PostPosted: Mon Sep 18, 2006 7:26 am    Post subject: PSP Headphone Remote Reply with quote

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

Thanks
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Mon Sep 18, 2006 7:56 am    Post subject: Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Tue Sep 19, 2006 4:07 am    Post subject: Reply with quote

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
View user's profile Send private message
RasZilan



Joined: 27 Sep 2006
Posts: 2

PostPosted: Wed Sep 27, 2006 8:59 am    Post subject: Reply with quote

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
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Wed Sep 27, 2006 4:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
RasZilan



Joined: 27 Sep 2006
Posts: 2

PostPosted: Thu Sep 28, 2006 3:47 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group