/source/pad.c
C | 78 lines | 46 code | 32 blank | 0 comment | 8 complexity | 558548de2caf95e5f5602221d63e60b3 MD5 | raw file
1#include "pad.h" 2#include <sysutil/events.h> 3 4unsigned temp_pad = 0, new_pad = 0, old_pad = 0; 5 6PadInfo padinfo; 7PadData paddata; 8int pad_alive=0; 9 10 11int rumble1_on = 0; 12int rumble2_on = 0; 13int last_rumble = 0; 14 15 16unsigned ps3pad_read() 17{ 18 int n; 19 20 PadActParam actparam; 21 22 unsigned butt = 0; 23 24 pad_alive = 0; 25 26 sysCheckCallback(); 27 28 ioPadGetInfo(&padinfo); 29 30 for(n = 0; n < MAX_PADS; n++) { 31 32 if(padinfo.status[n]) { 33 34 ioPadGetData(n, &paddata); 35 pad_alive = 1; 36 butt = (paddata.button[2] << 8) | (paddata.button[3] & 0xff); 37 break; 38 39 } 40 } 41 42 43 if(!pad_alive) butt = 0; 44 else { 45 actparam.small_motor = 0; 46 actparam.large_motor = 0; 47 48 if(rumble1_on) { 49 50 actparam.large_motor = 255; 51 52 rumble1_on++; 53 54 if(rumble1_on > 15) rumble1_on = 0; 55 56 } 57 58 if(rumble2_on) { 59 60 actparam.small_motor = 1; 61 62 rumble2_on++; 63 64 if(rumble2_on > 10) rumble2_on = 0; 65 } 66 67 last_rumble = n; 68 69 ioPadSetActDirect(n, &actparam); 70 } 71 72 temp_pad = butt; 73 74 new_pad = temp_pad & (~old_pad); old_pad = temp_pad; 75 76 77return butt; 78}