PSP Pro GamerZ

For all your PSP Needs
AKA Team Unknown Forum
 
HomeFAQRegisterLog in
---- Welcome to Team Unknown's official Forum, Don't forget to Register on the forum. Be sure to check out all of our projects such as uo DSONPSP and DigiPSP Also Check out our PSP Programming Tutorials Very Happy ----

Share | 
 

 [Tutorial] C/C++ Tutorials Part 3 - CTRL Pad by KaZ[Tutorial]

Go down 
AuthorMessage
KaZ
Admin
avatar

Posts : 131
Points : 204
Join date : 2010-09-20
Location : In The Sky

PostSubject: [Tutorial] C/C++ Tutorials Part 3 - CTRL Pad by KaZ[Tutorial]   Sat Sep 25, 2010 3:52 pm

ok so in this tutorial i will be showing some basics of the CTRL Pad its basicly like if u press x you can make it do/show/exit or any other buttons like o /\ L R yeh so you should get it.

here is a complete main.c with ctrl pad buttons take alook at it and fiddle with it.
please if you edit it and publish write thanks to the person for such a wonderfull tutorial btw im the person xD

if you want to change the button command goto the lin where it says if(pad.Buttons & PSP_CTRL_CROSS)
edit the word Cross to something of your choice. E.G Circle=O Triangle=/\ Square=Square

CTRL PAD Data:
Code:

while (1)
        {
              SceCtrlData pad;
              sceCtrlReadBufferPositive(&pad, 1);
              if(pad.Buttons & PSP_CTRL_CROSS) {
 // Made with KaZ's Tutorial -Do your stuff below this line
}
}

Here is and example of ctrl pad data on an eboot.pbp
currently if you press CROSS , SQUARE , CIRCLE , TRIANGLE it will recognise wich one you press.

heres a example of an main.c with control pad function [X]:
Code:

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


PSP_MODULE_INFO("example", 0, 1, 2);

#define printf pspDebugScreenPrintf
#define Wait sceKernelDelayThread(3000000);

/* 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 -  pspprogamerz.forummotion.com */
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(int argc, char *argv[])
{
   pspDebugScreenInit();
   SetupCallbacks();
   printf("Example of CTRL Pad on psp\n");
   printf("by KaZ [You must be registered and logged in to see this link.]
while (1)
        {
              SceCtrlData pad;
              sceCtrlReadBufferPositive(&pad, 1);
              if(pad.Buttons & PSP_CTRL_CROSS) {
              printf("You Pressed X");
}
}
   sceKernelSleepThread();
   return 0;
}

so u can see ive added the data if(pad.buttons & PSP_CTRL_CROSS) then i've put a printf to display the text with the button u pressed Smile

[You must be registered and logged in to see this link.]
Back to top Go down
 
[Tutorial] C/C++ Tutorials Part 3 - CTRL Pad by KaZ[Tutorial]
Back to top 
Page 1 of 1
 Similar topics
-
» Curl Tutorial!
» Tutorials - How to add multiple ranks Forumotion
» MOTU Classics: The Thread - Part 2
» Tutorials - Notice using css and table Forumotion
» AOE_Fan's RMS Command Tutorial

Permissions in this forum:You cannot reply to topics in this forum
PSP Pro GamerZ :: PSP :: C++ Tutorials/OSLIB/MIPS/Programming-
Jump to: