/* * Copyright (C) 1996 by Sony Computer Entertainment Inc. * All rights Reserved * * pad.h: PadRead() access macro * * Modified by James Banks - 1/1/98 */ #include /* Definitions for True or False */ #define TRUE 1 #define FALSE 0 /* Definitions for Port One and Two */ #define PORT_ONE 0 #define PORT_TWO 1 /* Definitions for the various controller types */ #define NO_CONTROLLER 0xF #define MOUSE 0x1 #define NEGCON_CONTROLLER 0x2 #define STANDARD_PAD 0x4 #define ANALOGUE_JOYSTICK 0x5 #define ANALOGUE_PAD 0x7 /* Standard Pad input definitions */ #define PAD_Up (1<<12) #define PAD_Down (1<<14) #define PAD_Left (1<<15) #define PAD_Right (1<<13) #define PAD_Triangle (1<< 4) #define PAD_Cross (1<< 6) #define PAD_Square (1<< 7) #define PAD_Circle (1<< 5) #define PADi (1<< 9) #define PADj (1<<10) #define PADk (1<< 8) #define PADl (1<< 3) #define PADm (1<< 1) #define PADn (1<< 2) #define PADo (1<< 0) #define PADh (1<<11) #define PADL1 PADn #define PADL2 PADo #define PADR1 PADl #define PADR2 PADm #define PADStart PADh #define PADSelect PADk /* Analogue Pad input definitions * * The analogue pad uses the standard pad controls plus 2 additional stick controls. * The byte offsets are as follows */ #define ANALOGUE_PAD_LEFT3X 6 #define ANALOGUE_PAD_LEFT3Y 7 #define ANALOGUE_PAD_RIGHT3X 4 #define ANALOGUE_PAD_RIGHT3Y 5 /* Analogue Joystick input definitions * * Again byte offsets for the x & y movements (same as analogue pad) */ #define ANALOGUE_JOYSTICK_LEFTX ANALOGUE_PAD_LEFT3X #define ANALOGUE_JOYSTICK_LEFTY ANALOGUE_PAD_LEFT3Y #define ANALOGUE_JOYSTICK_RIGHTX ANALOGUE_PAD_RIGHT3X #define ANALOGUE_JOYSTICK_RIGHTY ANALOGUE_PAD_RIGHT3Y /* Button definitions for Analogue joystick */ #define ANALOGUE_JOYSTICK_L1 Padm #define ANALOGUE_JOYSTICK_L2 Pado #define ANALOGUE_JOYSTICK_R1 PAD_Triangle #define ANALOGUE_JOYSTICK_R2 PAD_Square #define ANALOGUE_JOYSTICK_Triangle PADl #define ANALOGUE_JOYSTICK_Circle PAD_Circle #define ANALOGUE_JOYSTICK_Cross PAD_Cross #define ANALOGUE_JOYSTICK_Square PADn /* Low level port buffers - DO NOT TOUCH */ volatile u_char* ControllerPadBuffer[2]; /* Controller pad functions */ int SetPadBuffers(void) { GetPadBuf(&ControllerPadBuffer[0], &ControllerPadBuffer[1]); return(1); } /* Checks if a controller is attached to the port * * Returns True if a controller is connected */ u_char CheckControllerConnected(u_char port) { u_char connected_value = *(ControllerPadBuffer[port]); switch(connected_value){ case 0: return TRUE; default: return FALSE; } } /* Identifies which type of controller is attached to the port. * * This should match one of the defined controller types. */ u_char ControllerType(u_char port) { return(*(ControllerPadBuffer[port]+1)>>4); } /* Returns the input from a STANDARD PAD attached */ u_short PadRead(u_char port) { return ~(*(ControllerPadBuffer[port]+2) << 8 | *(ControllerPadBuffer[port]+3)); } /* Returns the input from an ANALOGUE JOYSTICK / PAD */ u_char AnalogueRead(u_char port, u_char byte) { return(*(ControllerPadBuffer[port]+byte)); }