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