Mercurial > hg > old > magoroku_racing
diff controler.c @ 0:0fae5658fb0b
Initial revision
author | gongo |
---|---|
date | Thu, 02 Nov 2006 08:55:19 +0000 |
parents | |
children | b6a1385f19be |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controler.c Thu Nov 02 08:55:19 2006 +0000 @@ -0,0 +1,116 @@ +/* + * $Id$ + */ +#include <stdio.h> +#include <stdlib.h> +#include "libps2.h" +#include "ps2util.h" +#include "col.h" +#include "field.h" +#include "car.h" +#include "controler.h" +#include "game.h" + +SGO_PAD pad; + +#ifdef DEMO_CREATE +extern void setPadValue(int pad); +#endif +extern int getPadValue(); + +Bool +padCheck() +{ + int pad1; + + pad1 = sjoy_get_ps2_button( JOYPAD_1 ); + +#ifdef DEMO_CREATE + if (game.state == GAME_MAIN) + setPadValue(pad1); +#endif + + if (pad1 & SJOY_PS2_START) { + pad.st += (pad.st > 100) ? 0 : 1; + } else { + pad.st = 0; + } + + if (game.demo_flg == 1) { + pad1 = getPadValue(); + } + + if (pad1 & SJOY_PS2_SELECT) { + pad.se += (pad.se > 100) ? 0 : 1; + } else { + pad.se = 0; + } + if (pad1 & SJOY_PS2_LEFT) { + pad.left += (pad.left > 100) ? 0 : 1; + } else { + pad.left = 0; + } + if (pad1 & SJOY_PS2_RIGHT) { + pad.right += (pad.right > 100) ? 0 : 1; + } else { + pad.right = 0; + } + if (pad1 & SJOY_PS2_UP) { + pad.up += (pad.up > 100) ? 0 : 1; + } else { + pad.up = 0; + } + if (pad1 & SJOY_PS2_DOWN) { + pad.down += (pad.down > 100) ? 0 : 1; + } else { + pad.down = 0; + } + if (pad1 & SJOY_PS2_R1) { + pad.r1 += (pad.r1 > 100) ? 0 : 1; + } else { + pad.r1 = 0; + } + if (pad1 & SJOY_PS2_R2) { + pad.r2 += (pad.r2 > 100) ? 0 : 1; + } else { + pad.r2 = 0; + } + if (pad1 & SJOY_PS2_L1) { + pad.l1 += (pad.l1 > 100) ? 0 : 1; + } else { + pad.l1 = 0; + } + if (pad1 & SJOY_PS2_L2) { + pad.l2 += (pad.l2 > 100) ? 0 : 1; + } else { + pad.l2 = 0; + } + if (pad1 & SJOY_PS2_CROSS) { + pad.cross += (pad.cross > 100) ? 0 : 1; + } else { + pad.cross = 0; + } + if (pad1 & SJOY_PS2_CIRCLE) { + pad.circle += (pad.circle > 100) ? 0 : 1; + } else { + pad.circle = 0; + } + if (pad1 & SJOY_PS2_TRIANGLE) { + pad.triangle += (pad.triangle > 100) ? 0 : 1; + } else { + pad.triangle = 0; + } + if (pad1 & SJOY_PS2_SQUARE) { + pad.square += (pad.square > 100) ? 0 : 1; + } else { + pad.square = 0; + } + + if ( (pad1 & SJOY_PS2_SELECT) && (pad1 & SJOY_PS2_START) && + (pad1 & SJOY_PS2_L1) && (pad1 & SJOY_PS2_R1) && + (pad1 & SJOY_PS2_L2) && (pad1 & SJOY_PS2_R2)) { + return FALSE; + } + + return TRUE; +}