/*---------------------------------------------------------------------------* Project: KPAD library File: KPADinside.h Programmers: Keizo Ohta HIRATSU Daisuke Copyright 2005 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef KPAD_INSIDE_H__ #define KPAD_INSIDE_H__ #ifdef __cplusplus extern "C" { #endif #include /******************************************************************************* DEFINE *******************************************************************************/ //----- Constant used to calculate various things #define KPAD_CMOS_FOV WPAD_DPD_ANGLE // Field of view of CMOS lens #define KPAD_CMOS_HFOV_TAN 0.383864f // Tangent to half of angle of CMOS_FOV #define KPAD_CMOS_RESO_WX 128 // CMOS resolution #define KPAD_CMOS_RESO_WY 96 #define KPAD_CMOS_RESO_CX (KPAD_CMOS_RESO_WX / 2) #define KPAD_CMOS_RESO_CY (KPAD_CMOS_RESO_WY / 2) #define KPAD_DPD_RESO_WX WPAD_DPD_IMG_RESO_WX // DPD resolution #define KPAD_DPD_RESO_WY WPAD_DPD_IMG_RESO_WY #define KPAD_DPD_RESO_CX (KPAD_DPD_RESO_WX / 2) #define KPAD_DPD_RESO_CY (KPAD_DPD_RESO_WY / 2) #define KPAD_USE_OBJECTS 2 // Number of marks to be used for grasping the position #define KPAD_BTN_RPT_TIME_MAX 20000 // btn_repeat_time range (cannot assume this value) #define KPAD_BTN_NO_RPT_DELAY 40000 // Delay setting when repeat not set /******************************************************************************* TYPEDEF *******************************************************************************/ typedef struct { Vec2 center ; // Center of gravity coordinates (coordinate system where the horizontal range of CMOS is +/-1 s8 error_fg ; // -1: Not displayed, 0: OK, 1: Too far outside, 2: Same coordinates s8 state_fg ; // -1: Predicted value, 0: Normal s8 _fg_1 ; // Preparations s8 _fg_2 ; // Preparations } KPADObject ; typedef struct { KPADStatus status ; //----- Variable for adjusting controller response f32 pos_play_radius ; // Play radius (size in the pos coordinate system) f32 pos_sensitivity ; // Sensitivity (0: Insensitive -> 1: Sensitive) f32 hori_play_radius ; // Adjust horizon sensitivity f32 hori_sensitivity ; // f32 dist_play_radius ; // Adjust dist sensitivity f32 dist_sensitivity ; // f32 acc_play_radius ; // Adjust acc sensitivity f32 acc_sensitivity ; // //----- DPD calibration values f32 dist_org ; // Distance after calibration Vec2 accXY_nrm_hori ; // XY acceleration direction when the controller is in the horizontal plane Vec2 sec_nrm_hori ; // Direction from left mark to right mark when the controller is in the horizontal plane Vec2 center_org ; // Coordinates during calibration f32 dpd2pos_scale ; // Scale value where the left/right end of pointing is within +/- of the ??sassho?? //----- Variables used for internal control KPADObject kobj_sample[ WPAD_DPD_MAX_OBJECTS ] ; // All retrieved marks are included KPADObject kobj_regular[ KPAD_USE_OBJECTS ] ; // Left-to-right order (bottom-to-top order when oriented vertically) s16 valid_objs ; // Number of valid objects u16 work_ct ; // Number of times DPD processing is performed per game frame s16 wpad_chan_no ; // IO channel number s16 wpad_ring_idx ; // Processed ring buffer WPADCLStatus wpad_ring_bf[ KPAD_RING_BUFS ] ;// Buffer used to store SDK variable f32 sec_length ; // Distance from left mark to right mark Vec2 sec_nrm ; // Direction from left mark to right mark f32 sec_dist ; // Raw distance from TV (in meters) f32 trust_sec_length ; // Reliable distance between sections is saved here Vec hard_acc ; // Raw acceleration Vec2 obj_horizon ; // Orientation calculated based on the object Vec2 acc_horizon ; // Orientation calculated based on the acceleration (left-right) Vec2 ah_circle_pos ; // Point following the acc_horizon u16 ah_circle_ct ; // Countdown if within a certain range (stop at zero) u8 dpd_valid2_ct ; // Number of consecutive successful recognitions of two points s8 _fg_4 ; // Preparations //----- Control button u16 btn_repeat_time ; // Ongoing time count u16 btn_repeat_next ; // Next time to set flag u16 btn_repeat_delay ; // Time to start repeat u16 btn_repeat_pulse ; // Time between repeats //----- for a Classic Controller unit u16 btn_cl_repeat_time ; // Ongoing time count u16 btn_cl_repeat_next ; // Next time to set flag u16 btn_cl_repeat_delay ; // Time to start repeat u16 btn_cl_repeat_pulse ; // Time between repeats } KPADInsideStatus ; /******************************************************************************* EXTERNAL WORK *******************************************************************************/ //----- Various adjustments extern f32 kp_obj_interval ; // Distance between both marks (in meters) extern f32 kp_acc_horizon_pw ; // Conditions when calculating the rotation from the acceleration extern f32 kp_ah_circle_radius ; // Radius used to determine if the controller is at rest extern f32 kp_ah_circle_pw ; // Sensitivity conditions used to determine if the controller is at rest extern u16 kp_ah_circle_ct ; // Count for determining if the controller is at rest //----- Numeric values viewed as errors extern f32 kp_err_outside_frame ; // Peripheral width where center of gravity coordinates are disabled (peripheral light may not be entirely displayed) extern f32 kp_err_dist_min ; // Maximum operation distance (in meters) extern f32 kp_err_dist_max ; // Maximum operation distance (in meters) extern f32 kp_err_dist_speed ; // Allowable range of variation in distance (in meters) extern f32 kp_err_first_inpr ; // Inner product of acceleration slope and object inclination when selecting first two points extern f32 kp_err_next_inpr ; // Allowable range in variation of inclination (inner product) extern f32 kp_err_acc_inpr ; // Allowable range of inner product with acceleration slope when controller has been brought to rest extern f32 kp_err_up_inpr ; // Allowable range of inner product when controller is facing up extern f32 kp_err_near_pos ; // Distance from last point when selecting the next point //----- ‚j‚o‚`‚c unit extern KPADInsideStatus inside_kpads[] ; /******************************************************************************* EXTERNAL FUNCTION *******************************************************************************/ #ifdef __cplusplus } #endif #endif // KPAD_INSIDE_H__