Advertisement
BaSs_HaXoR

Sprx Button Monitoring Header

Aug 15th, 2014
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. //Button Monitoring Header
  2. //(pad.h)
  3. //Milky4444 & Sony
  4.  
  5. // GO TO THIS ONE IF YOU PLAN ON USING BUTTON MONITORING! > http://pastebin.com/NJ1dbYAj
  6.  
  7. #include<cell/pad.h>
  8. #include <cell/sysmodule.h>
  9. #define MAX_PAD                                     (1)
  10. void PadRead(uint32_t* pbutton1, uint32_t* pbutton2)
  11. {
  12.     int         i;
  13.     int         ret;
  14.     CellPadInfo2 pad_info;
  15.     static uint32_t old_pad_info=0;
  16.     CellPadData pad_data;
  17.     uint32_t    button1 = 0;
  18.     uint32_t    button2 = 0;
  19.  
  20.     ret = cellPadGetInfo2(&pad_info);
  21.     if (ret != CELL_OK){
  22.         //printf("cellPadGetInfo2() error (0x%x).\n", ret);
  23.         return;
  24.     }
  25.  
  26.      /*E Check info field for monitoring the INTERCEPTED state. */
  27.     if((pad_info.system_info & CELL_PAD_INFO_INTERCEPTED) &&
  28.        (!(old_pad_info & CELL_PAD_INFO_INTERCEPTED)))
  29.     {
  30.         //printf ("This program lost the ownership of the game pad data\n");
  31.         old_pad_info = pad_info.system_info;
  32.     }
  33.     else if((!(pad_info.system_info & CELL_PAD_INFO_INTERCEPTED)) &&
  34.             (old_pad_info & CELL_PAD_INFO_INTERCEPTED))
  35.     {
  36.        // printf ("This program got the ownership of the game pad data\n");
  37.         old_pad_info = pad_info.system_info;
  38.     }
  39.  
  40.     for (i = 0; i < MAX_PAD; i ++)
  41.     {
  42.         if (pad_info.port_status[i] & CELL_PAD_STATUS_CONNECTED == 0)
  43.             continue;
  44.  
  45.         ret = cellPadGetData(i, &pad_data);
  46.         if (ret != CELL_PAD_OK || pad_data.len == 0)
  47.             continue;
  48.  
  49.         button1 = pad_data.button [CELL_PAD_BTN_OFFSET_DIGITAL1];
  50.         button2 = pad_data.button [CELL_PAD_BTN_OFFSET_DIGITAL2];
  51.     }
  52.     *pbutton1 = button1;
  53.     *pbutton2 = button2;
  54.     return;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement