view controler.c @ 79:376bac6b05f1

*** empty log message ***
author gongo
date Thu, 09 Nov 2006 08:28:48 +0000
parents a1908b83f8fa
children 8edae89a3877
line wrap: on
line source

/*
 * $Id$
 */
#include "libps2.h"
#include "ps2util.h"
#include "controler.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 );

    if (pad1 & SJOY_PS2_START) {
	pad.st += (pad.st < 2) ? 1 : 0;
    } else {
	pad.st = 0;
    }

    if (pad1 & SJOY_PS2_SELECT) {
	pad.se += (pad.se < 2) ? 1 : 0;
    } else {
	pad.se = 0;
    }
    if (pad1 & SJOY_PS2_LEFT) {
	pad.left += (pad.left < 2) ? 1 : 0;
    } else {
	pad.left = 0;
    }
    if (pad1 & SJOY_PS2_RIGHT) {
	pad.right += (pad.right < 2) ? 1 : 0;
    } else {
	pad.right = 0;
    }
    if (pad1 & SJOY_PS2_UP) {
	pad.up += (pad.up < 2) ? 1 : 0;
    } else {
	pad.up = 0;
    }
    if (pad1 & SJOY_PS2_DOWN) {
	pad.down += (pad.down < 2) ? 1 : 0;
    } else {
	pad.down = 0;
    }
    if (pad1 & SJOY_PS2_R1) {
	pad.r1 += (pad.r1 < 2) ? 1 : 0;
    } else {
	pad.r1 = 0;
    }
    if (pad1 & SJOY_PS2_R2) {
	pad.r2 += (pad.r2 < 2) ? 1 : 0;
    } else {
	pad.r2 = 0;
    }
    if (pad1 & SJOY_PS2_L1) {
	pad.l1 += (pad.l1 < 2) ? 1 : 0;
    } else {
	pad.l1 = 0;
    }
    if (pad1 & SJOY_PS2_L2) {
	pad.l2 += (pad.l2 < 2) ? 1 : 0;
    } else {
	pad.l2 = 0;
    }
    if (pad1 & SJOY_PS2_CROSS) {
	pad.cross += (pad.cross < 2) ? 1 : 0;
    } else {
	pad.cross = 0;
    }
    if (pad1 & SJOY_PS2_CIRCLE) {
	pad.circle += (pad.circle < 2) ? 1 : 0;
    } else {
	pad.circle = 0;
    }
    if (pad1 & SJOY_PS2_TRIANGLE) {
	pad.triangle += (pad.triangle < 2) ? 1 : 0;
    } else {
	pad.triangle = 0;
    }
    if (pad1 & SJOY_PS2_SQUARE) {
	pad.square += (pad.square < 2) ? 1 : 0;
    } 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;
}