PS2GL
OpenGL*-like API for the PS2
Loading...
Searching...
No Matches
pads.h
1/* Copyright (C) 2000,2001,2002 Sony Computer Entertainment America
2
3 This file is subject to the terms and conditions of the GNU Lesser
4 General Public License Version 2.1. See the file "COPYING" in the
5 main directory of this archive for more details. */
6
7#ifndef pads_h
8#define pads_h
9
10#include "libpad.h"
11
12#include "ps2s/types.h"
13
14#define scePadDmaBufferMax (256 / 16)
15
16/********************************************
17 * types
18 */
19
20/********************************************
21 * class def
22 */
23
24namespace Pads {
25void Init(void);
26void Read(void);
27
28static const unsigned int kSelect = 0,
29 kLeftStickButton = 1,
30 kRightStickButton = 2,
31 kStart = 3,
32 kLeftUp = 4,
33 kLeftRight = 5,
34 kLeftDown = 6,
35 kLeftLeft = 7,
36 kL2 = 8,
37 kR2 = 9,
38 kL1 = 10,
39 kR1 = 11,
40 kRightUp = 12,
41 kRightRight = 13,
42 kRightDown = 14,
43 kRightLeft = 15;
44}
45
46class CPad {
47public:
48 CPad(unsigned int port);
49
50 bool Open(void);
51 void Read(void);
52
53 bool IsDown(unsigned int button);
54 bool IsUp(unsigned int button);
55 bool WasPushed(unsigned int button);
56 bool WasReleased(unsigned int button);
57
58 float RightStickX(void) { return CurStatus.rightStick.xPos; }
59 float RightStickY(void) { return CurStatus.rightStick.yPos; }
60
61 float LeftStickX(void) { return CurStatus.leftStick.xPos; }
62 float LeftStickY(void) { return CurStatus.leftStick.yPos; }
63
64private:
65 typedef struct {
66 tU16 select : 1;
67 tU16 i : 1;
68 tU16 j : 1;
69 tU16 start : 1;
70
71 tU16 leftUp : 1;
72 tU16 leftRight : 1;
73 tU16 leftDown : 1;
74 tU16 leftLeft : 1;
75
76 tU16 l2 : 1;
77 tU16 r2 : 1;
78 tU16 l1 : 1;
79 tU16 r1 : 1;
80
81 tU16 rightUp : 1;
82 tU16 rightRight : 1;
83 tU16 rightDown : 1;
84 tU16 rightLeft : 1;
86
87 typedef struct {
88 tU8 xVal, yVal;
89 tU8 xCenter, yCenter;
90 float xPos, yPos;
91 bool isCentered;
92 } tStickData;
93
94 typedef struct {
95 tU8 success;
96 tU8 statLen;
97 tU16 buttons; /* 16 buttons */
98 tU8 r3h;
99 tU8 r3v;
100 tU8 l3h;
101 tU8 l3v;
102 tU8 kanAtsu[12]; // deal with this crap later
103 tU8 whoKnows[12]; // make the structure 32 bytes long
104 tStickData rightStick, leftStick;
105 } tPadStatus;
106
107 bool IsDown(tPadStatus status, unsigned int button);
108 bool IsUp(tPadStatus status, unsigned int button);
109 bool UpdateStick(tStickData* stickCur, tStickData* stickLast);
110
111 tU128 DmaBuffer[scePadDmaBufferMax] __attribute__((aligned(64)));
112 tPadStatus CurStatus __attribute__((aligned(16)));
113 tPadStatus LastStatus __attribute__((aligned(16)));
114 unsigned int uiPort;
115 bool bPadModeSet;
116};
117
118extern CPad Pad0;
119extern CPad Pad1;
120
121#endif // pads_h
Definition pads.h:46