PSP Coding


 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 [PSP] Using buttons

Go down 
AuthorMessage
Emu



Posts : 21
Points : 29
Reputation : 0
Join date : 2010-10-04

PostSubject: [PSP] Using buttons   Tue Oct 05, 2010 3:59 pm

------------------
Main.c
------------------
/*

*main.c
*This is a simple Hello world from team Odessa by Emu
*A mod of the hello world with additional things added in
* October 4, 2010

*/

#include <pspkernel.h> //psp kernel
#include <pspdebug.h> //psp printing
#include <pspdisplay.h> // psp displaying
#include <pspctrl.h> // psp buttons

PSP_MODULE_INFO("Hello World", 0, 1, 1);

#define printf pspDebugScreenPrintf // defines pspDebugScreenPrintf as printf

/*
*The info below about callbacks is always need so we can use the home button on our psp
*/

// 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;
}

//Our code's main function
int main(){

pspDebugScreenInit(); //Allows things to be printed to the screen
SetupCallbacks(); //Allows callbacks to be called upon
SceCtrlData pad; //Allows buttons to used to call an operation

printf("Hello World");
printf("press X to return to XMB");
//the below executes if true.. 1 = true 0 = false
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS)
{
pspDebugScreenClear();
printf("RETURNING TO XMB, BYE!");
sceKernelSleepThread(3);
return 0;
}
}

sceKernelSleepThread(); //freezes the screen so you can see what you inputed
return 0;
}

------------------------
Makefile - Replace the ???? with whatever you want
------------------------

TARGET = ?????
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = ???????

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

-------------------------
PSP Buttons list
-------------------------

CROSS = X
SQUARE = [ ]
TRIANGLE = /\
CIRCLE = O
RTRIGGER = R
LTRIGGER = L
UP = Dpad ^
DOWN = Dpad v
LEFT = Dpad <
RIGHT = Dpad >
START = Start button
SELECT = Select button

Using different buttons like this [if (pad.Buttons & PSP_CTRL_?????)]
Replace the ???? with whatever button you want
Back to top Go down
View user profile
-LeetGamer-
Admin


Posts : 247
Points : 397
Reputation : 4
Join date : 2010-09-29
Age : 25

PostSubject: Re: [PSP] Using buttons   Tue Oct 05, 2010 4:49 pm

Nice I will use this Very Happy thanks
Back to top Go down
View user profile
Emu



Posts : 21
Points : 29
Reputation : 0
Join date : 2010-10-04

PostSubject: Re: [PSP] Using buttons   Tue Oct 05, 2010 4:59 pm

No problemo
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: [PSP] Using buttons   

Back to top Go down
 
[PSP] Using buttons
Back to top 
Page 1 of 1
 Similar topics
-
» Siggys / Buttons for the Club!

Permissions in this forum:You cannot reply to topics in this forum
PSP Coding :: PSP Programming :: PSP Programming Tutorials :: Homebrew Programming Tutorials-
Jump to: