Advertisement
BaSs_HaXoR

[SPRX] button monitoring for everygame

Aug 11th, 2014
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.24 KB | None | 0 0
  1. /*CREDITS TO MILKY4444 !!! <3
  2. [SPRX] button monitoring for everygame(no addresses)
  3. hi ngu, i was testing a round with the pad library in the ps3sdk... i got it working  but it can mess with your game controls so try to use in game. the header: https://www.mediafire.com/?0wxbbzb5faflygq
  4. how to use:
  5. initialize:
  6. */
  7.  
  8.  
  9. //-----------------------------------------------------------------------------------------------------------------------//
  10.  
  11.  
  12. //PUT THIS IN YOUR HEADER:
  13. #include<cell/pad.h>
  14. #include <cell/sysmodule.h>
  15. #define MAX_PAD                                     (1)
  16. void PadRead(uint32_t* pbutton1, uint32_t* pbutton2)
  17. {
  18.     int         i;
  19.     int         ret;
  20.     CellPadInfo2 pad_info;
  21.     static uint32_t old_pad_info=0;
  22.     CellPadData pad_data;
  23.     uint32_t    button1 = 0;
  24.     uint32_t    button2 = 0;
  25.  
  26.     ret = cellPadGetInfo2(&pad_info);
  27.     if (ret != CELL_OK){
  28.         //printf("cellPadGetInfo2() error (0x%x).\n", ret);
  29.         return;
  30.     }
  31.  
  32.      /*E Check info field for monitoring the INTERCEPTED state. */
  33.     if((pad_info.system_info & CELL_PAD_INFO_INTERCEPTED) &&
  34.        (!(old_pad_info & CELL_PAD_INFO_INTERCEPTED)))
  35.     {
  36.         //printf ("This program lost the ownership of the game pad data\n");
  37.         old_pad_info = pad_info.system_info;
  38.     }
  39.     else if((!(pad_info.system_info & CELL_PAD_INFO_INTERCEPTED)) &&
  40.             (old_pad_info & CELL_PAD_INFO_INTERCEPTED))
  41.     {
  42.        // printf ("This program got the ownership of the game pad data\n");
  43.         old_pad_info = pad_info.system_info;
  44.     }
  45.  
  46.     for (i = 0; i < MAX_PAD; i ++)
  47.     {
  48.         if (pad_info.port_status[i] & CELL_PAD_STATUS_CONNECTED == 0)
  49.             continue;
  50.  
  51.         ret = cellPadGetData(i, &pad_data);
  52.         if (ret != CELL_PAD_OK || pad_data.len == 0)
  53.             continue;
  54.  
  55.         button1 = pad_data.button [CELL_PAD_BTN_OFFSET_DIGITAL1];
  56.         button2 = pad_data.button [CELL_PAD_BTN_OFFSET_DIGITAL2];
  57.     }
  58.     *pbutton1 = button1;
  59.     *pbutton2 = button2;
  60.     return;
  61. }
  62.  
  63. //-----------------------------------------------------------------------------------------------------------------------//
  64.  
  65. #inlcude "pad.h"
  66. extern "C" int main(void)//main entry
  67. {
  68. cellPadInit(MAX_PAD);
  69. }
  70. //detect buttons:
  71.  
  72. uint32_t button1,button2;
  73. PadRead(&button1, &button2);//use in thread
  74.         if(button2 & CELL_PAD_CTRL_TRIANGLE)
  75.         {
  76.             print("pad detected");
  77.         }
  78. enjoy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement