annotate controler.c @ 79:376bac6b05f1

*** empty log message ***
author gongo
date Thu, 09 Nov 2006 08:28:48 +0000
parents a1908b83f8fa
children 8edae89a3877
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
1 /*
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
2 * $Id$
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
3 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
4 #include "libps2.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
5 #include "ps2util.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
6 #include "controler.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
7
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
8 SGO_PAD pad;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
9
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
10 #ifdef DEMO_CREATE
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
11 extern void setPadValue(int pad);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
12 #endif
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
13 extern int getPadValue();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
14
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
15 Bool
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16 padCheck()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
17 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
18 int pad1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
19
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20 pad1 = sjoy_get_ps2_button( JOYPAD_1 );
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
21
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
22 if (pad1 & SJOY_PS2_START) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
23 pad.st += (pad.st < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
24 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
25 pad.st = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
26 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
27
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
28 if (pad1 & SJOY_PS2_SELECT) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
29 pad.se += (pad.se < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 pad.se = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
33 if (pad1 & SJOY_PS2_LEFT) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
34 pad.left += (pad.left < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
35 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
36 pad.left = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38 if (pad1 & SJOY_PS2_RIGHT) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
39 pad.right += (pad.right < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
40 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 pad.right = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43 if (pad1 & SJOY_PS2_UP) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
44 pad.up += (pad.up < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
45 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 pad.up = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 if (pad1 & SJOY_PS2_DOWN) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
49 pad.down += (pad.down < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
50 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
51 pad.down = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53 if (pad1 & SJOY_PS2_R1) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
54 pad.r1 += (pad.r1 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
55 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
56 pad.r1 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
57 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
58 if (pad1 & SJOY_PS2_R2) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
59 pad.r2 += (pad.r2 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
60 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
61 pad.r2 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
62 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
63 if (pad1 & SJOY_PS2_L1) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
64 pad.l1 += (pad.l1 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
65 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
66 pad.l1 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
67 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
68 if (pad1 & SJOY_PS2_L2) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
69 pad.l2 += (pad.l2 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
70 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
71 pad.l2 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
72 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
73 if (pad1 & SJOY_PS2_CROSS) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
74 pad.cross += (pad.cross < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
75 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
76 pad.cross = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
77 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
78 if (pad1 & SJOY_PS2_CIRCLE) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
79 pad.circle += (pad.circle < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
80 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
81 pad.circle = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
82 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
83 if (pad1 & SJOY_PS2_TRIANGLE) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
84 pad.triangle += (pad.triangle < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
85 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
86 pad.triangle = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
87 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
88 if (pad1 & SJOY_PS2_SQUARE) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
89 pad.square += (pad.square < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
90 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
91 pad.square = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
92 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
93
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
94 if ( (pad1 & SJOY_PS2_SELECT) && (pad1 & SJOY_PS2_START) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
95 (pad1 & SJOY_PS2_L1) && (pad1 & SJOY_PS2_R1) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
96 (pad1 & SJOY_PS2_L2) && (pad1 & SJOY_PS2_R2)) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
97 return FALSE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
98 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
99
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
100 return TRUE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
101 }