00001
00002
00003
00004
00005 #ifndef pads_h
00006 #define pads_h
00007
00008 #include "eetypes.h"
00009 #include "libpad.h"
00010
00011 #include "ps2s/types.h"
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 class Pads
00023 {
00024 public:
00025 static void Init( const char* module_path );
00026 static void Read( void );
00027
00028 static const unsigned int kSelect = 0,
00029 kLeftStickButton = 1,
00030 kRightStickButton = 2,
00031 kStart = 3,
00032 kLeftUp = 4,
00033 kLeftRight = 5,
00034 kLeftDown = 6,
00035 kLeftLeft = 7,
00036 kL2 = 8,
00037 kR2 = 9,
00038 kL1 = 10,
00039 kR1 = 11,
00040 kRightUp = 12,
00041 kRightRight = 13,
00042 kRightDown = 14,
00043 kRightLeft = 15;
00044 };
00045
00046 class CPad
00047 {
00048 public:
00049 CPad( unsigned int port );
00050
00051 bool Open( void );
00052 void Read( void );
00053
00054 bool IsDown( unsigned int button );
00055 bool IsUp( unsigned int button );
00056 bool WasPushed( unsigned int button );
00057 bool WasReleased( unsigned int button );
00058
00059 float RightStickX( void ) { return CurStatus.rightStick.xPos; }
00060 float RightStickY( void ) { return CurStatus.rightStick.yPos; }
00061
00062 float LeftStickX( void ) { return CurStatus.leftStick.xPos; }
00063 float LeftStickY( void ) { return CurStatus.leftStick.yPos; }
00064
00065 private:
00066 typedef struct {
00067 tU16 select : 1;
00068 tU16 i : 1;
00069 tU16 j : 1;
00070 tU16 start : 1;
00071
00072 tU16 leftUp : 1;
00073 tU16 leftRight : 1;
00074 tU16 leftDown : 1;
00075 tU16 leftLeft : 1;
00076
00077 tU16 l2 : 1;
00078 tU16 r2 : 1;
00079 tU16 l1 : 1;
00080 tU16 r1 : 1;
00081
00082 tU16 rightUp : 1;
00083 tU16 rightRight : 1;
00084 tU16 rightDown : 1;
00085 tU16 rightLeft : 1;
00086 } tButtonsPressed;
00087
00088 typedef struct {
00089 tU8 xVal, yVal;
00090 tU8 xCenter, yCenter;
00091 float xPos, yPos;
00092 bool isCentered;
00093 } tStickData;
00094
00095 typedef struct {
00096 tU8 success;
00097 tU8 statLen;
00098 tU16 buttons;
00099 tU8 r3h;
00100 tU8 r3v;
00101 tU8 l3h;
00102 tU8 l3v;
00103 tU8 kanAtsu[12];
00104 tU8 whoKnows[12];
00105 tStickData rightStick, leftStick;
00106 } tPadStatus;
00107
00108 bool UpdateStick( tStickData* stickCur, tStickData* stickLast );
00109
00110 tU128 DmaBuffer[scePadDmaBufferMax] __attribute__ ((aligned(64)));
00111 tPadStatus CurStatus __attribute__ ((aligned(16)));
00112 tPadStatus LastStatus __attribute__ ((aligned(16)));
00113 unsigned int uiPort;
00114 bool bPadModeSet;
00115
00116
00117 };
00118
00119 extern CPad Pad0;
00120 extern CPad Pad1;
00121
00122 #endif // pads_h