[SPRX] Buttons monitoring for any game!

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Nostafaru

Moderating the Crunch Bunch.
Retired Staff
Community Elite
Community Veteran
Determined Poster
Active Member
Console ID Poster
Apr 6, 2014
2,020
1,783
443
Hey crunchers :)

This will be a method to use buttons monitoring for what ever game you would like.

What is buttons monitoring ?
--------------------------------
Buttons monitoring is something that detects what button you click. And then it can execute a function. Example :

if(Buttons(Buttons.Clicked == Button.X))
{
iPrintln("X button has been pressed"); //Or any other function you would like it to do.
}


This will be the header :
#include<cell/pad.h>
#include <cell/sysmodule.h>
#define MAX_PAD (1)
void PadRead(uint32_t* pbutton1, uint32_t* pbutton2)
{
int i;
int ret;
CellPadInfo2 pad_info;
static uint32_t old_pad_info=0;
CellPadData pad_data;
uint32_t button1 = 0;
uint32_t button2 = 0;

ret = cellPadGetInfo2(&pad_info);
if (ret != CELL_OK){
//printf("cellPadGetInfo2() error (0x%x).\n", ret);
return;
}

/*E Check info field for monitoring the INTERCEPTED state. */
if((pad_info.system_info & CELL_PAD_INFO_INTERCEPTED) &&
(!(old_pad_info & CELL_PAD_INFO_INTERCEPTED)))
{
//printf ("This program lost the ownership of the game pad data\n");
old_pad_info = pad_info.system_info;
}
else if((!(pad_info.system_info & CELL_PAD_INFO_INTERCEPTED)) &&
(old_pad_info & CELL_PAD_INFO_INTERCEPTED))
{
// printf ("This program got the ownership of the game pad data\n");
old_pad_info = pad_info.system_info;
}

for (i = 0; i < MAX_PAD; i ++)
{
if (pad_info.port_status & CELL_PAD_STATUS_CONNECTED == 0)
continue;

ret = cellPadGetData(i, &pad_data);
if (ret != CELL_PAD_OK || pad_data.len == 0)
continue;

button1 = pad_data.button [CELL_PAD_BTN_OFFSET_DIGITAL1];
button2 = pad_data.button [CELL_PAD_BTN_OFFSET_DIGITAL2];
}
*pbutton1 = button1;
*pbutton2 = button2;
return;
}





You can use it like this :

Initializ :
Code:
#inlcude "pad.h"
extern "C" int main(void)//main entry
{
cellPadInit(MAX_PAD);
}

Buttons detection :
Code:
uint32_t button1,button2;
PadRead(&button1, &button2);//use in thread
if(button2 & CELL_PAD_CTRL_TRIANGLE)
{
print("pad detected");
}
 
General chit-chat
Help Users
    Chat Bot: damario has joined the room.