1 /*---------------------------------------------------------------------------* 2 Project: Cafe 3 File: pad.h 4 5 Copyright (C) Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 *---------------------------------------------------------------------------*/ 14 15 #ifndef __PAD_H__ 16 #define __PAD_H__ 17 18 #include <types.h> 19 #include <cafe/os.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 // Caution: Define PAD_USESPEC as long as breadboards or prototype 26 // controllers (including DS4) are in use. 27 #define PAD_USESPEC 28 29 #ifdef __MWERKS__ 30 #pragma warn_padding off 31 #endif 32 33 typedef struct PADStatus 34 { 35 u16 button; // OR of PAD_BUTTON_* bits 36 s8 stickX; // -128 <= stickX <= 127 37 s8 stickY; // -128 <= stickY <= 127 38 s8 substickX; // -128 <= substickX <= 127 39 s8 substickY; // -128 <= substickY <= 127 40 u8 triggerLeft; // 0 <= triggerLeft <= 255 41 u8 triggerRight; // 0 <= triggerRight <= 255 42 u8 analogA; // 0 <= analogA <= 255 43 u8 analogB; // 0 <= analogB <= 255 44 s8 err; // one of PAD_ERR_* number 45 } PADStatus; 46 47 #ifdef __MWERKS__ 48 #pragma warn_padding reset 49 #endif 50 51 #define PAD_MAX_CONTROLLERS 4 52 53 #define PAD_BUTTON_LEFT 0x0001 54 #define PAD_BUTTON_RIGHT 0x0002 55 #define PAD_BUTTON_DOWN 0x0004 56 #define PAD_BUTTON_UP 0x0008 57 #define PAD_TRIGGER_Z 0x0010 58 #define PAD_BUTTON_Z PAD_TRIGGER_Z 59 #define PAD_TRIGGER_R 0x0020 60 #define PAD_BUTTON_R PAD_TRIGGER_R 61 #define PAD_TRIGGER_L 0x0040 62 #define PAD_BUTTON_L PAD_TRIGGER_L 63 #define PAD_BUTTON_A 0x0100 64 #define PAD_BUTTON_B 0x0200 65 #define PAD_BUTTON_X 0x0400 66 #define PAD_BUTTON_Y 0x0800 67 #define PAD_BUTTON_MENU 0x1000 68 #define PAD_BUTTON_START 0x1000 69 70 #define PAD_CHAN0 0 71 #define PAD_CHAN1 1 72 #define PAD_CHAN2 2 73 #define PAD_CHAN3 3 74 75 #define PAD_CHAN0_BIT 0x80000000 76 #define PAD_CHAN1_BIT 0x40000000 77 #define PAD_CHAN2_BIT 0x20000000 78 #define PAD_CHAN3_BIT 0x10000000 79 80 #define PAD_ERR_NONE 0 81 #define PAD_ERR_NO_CONTROLLER -1 82 #define PAD_ERR_NOT_READY -2 83 #define PAD_ERR_TRANSFER -3 84 85 #define PAD_MOTOR_STOP 0 86 #define PAD_MOTOR_RUMBLE 1 87 #define PAD_MOTOR_STOP_HARD 2 88 89 #ifdef PAD_USESPEC 90 #define PAD_SPEC_0 0 // breadboard (ver 0.x) 91 #define PAD_SPEC_1 1 // 1st prototypes (ver 1.0) 92 #define PAD_SPEC_2 2 // 2nd prototypes (ver 3.0 FPGA) 93 #define PAD_SPEC_3 3 // DS3 94 #define PAD_SPEC_4 4 // DS4 95 #define PAD_SPEC_5 5 // DS5 (production version) 96 #endif // PAD_USESPEC 97 98 // clamp algorithm for stick 99 #define PAD_STICK_CLAMP_OCTA_WITH_MARGIN 0 100 #define PAD_STICK_CLAMP_OCTA_WITHOUT_MARGIN 1 101 #define PAD_STICK_CLAMP_CIRCLE_WITH_MARGIN 2 102 #define PAD_STICK_CLAMP_CIRCLE_WITHOUT_MARGIN 3 103 // clamp algorithm for trigger 104 #define PAD_TRIGGER_FIXED_BASE 0 105 #define PAD_TRIGGER_INDIVIDUAL_BASE 1 106 107 108 void PADInit ( void ); 109 void PADRead ( PADStatus* status ); 110 111 void PADClamp ( PADStatus* status ); 112 void PADClampCircle ( PADStatus* status ); 113 void PADClamp2 ( PADStatus* status, u32 type ); 114 void PADClampCircle2 ( PADStatus* status, u32 type ); 115 116 #ifdef __cplusplus 117 } 118 #endif 119 120 #endif // __PAD_H__ 121