/*---------------------------------------------------------------------------* 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. *---------------------------------------------------------------------------*/ #ifdef KPAD_INSIDE_H__ #error KPADinside.h of KPADOld cannot be used with that of KPAD version 2 #endif #ifndef KPADOLD_INSIDE_H__ #define KPADOLD_INSIDE_H__ #ifdef __cplusplus extern "C" { #endif #include /******************************************************************************* DEFINE *******************************************************************************/ //----- Various calculation constants #define KPAD_CMOS_FOV WPAD_DPD_ANGLE // CMOS lens angle of view (in degrees) (Field Of View) #define KPAD_CMOS_HFOV_TAN 0.383864f // Tangent of half angle (Half) 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 used for determining position #define KPAD_BTN_RPT_TIME_MAX 20000 // btn_repeat_time range (will not be this value) #define KPAD_BTN_NO_RPT_DELAY 40000 // Delay setting when not repeating /******************************************************************************* TYPEDEF *******************************************************************************/ typedef struct { Vec2 center ; // Center of mass coordinate (coordinate system where the horizontal range of CMOS will be + or - 1) s8 error_fg ; // -1: not displayed, 0: OK, 1: too far out, 2: same coordinate s8 state_fg ; // -1: expected value, 0: normal s8 _fg_1 ; // Extra s8 _fg_2 ; // Extra } KPADObject ; typedef struct { KPADStatus status ; //----- Variables adjusting the controller response f32 pos_play_radius ; // Tolerance radius (size at pos coordinate system) f32 pos_sensitivity ; // Tracking sensitivity (0: slow -> 1: sensitive) f32 hori_play_radius ; // Adjust response of 'horizon' f32 hori_sensitivity ; // f32 dist_play_radius ; // Adjust response of 'dist' f32 dist_sensitivity ; // f32 acc_play_radius ; // Adjust the response of 'acc' f32 acc_sensitivity ; // //----- DPD calibration values f32 dist_org ; // Distance at calibration Vec2 accXY_nrm_hori ; // XY acceleration direction when the controller is placed horizontally Vec2 sec_nrm_hori ; // Direction from left mark to right mark when the controller is placed horizontally Vec2 center_org ; // Coordinate during calibration f32 dpd2pos_scale ; // Scale value where the left and right pointing edge in the shooting range will be + or - 1 //----- Variables used for internal control KPADObject kobj_sample[ WPAD_DPD_MAX_OBJECTS ] ; // All captured marks will be placed KPADObject kobj_regular[ KPAD_USE_OBJECTS ] ; // Left to right order (top to bottom order for straight vertical) s16 valid_objs ; // Valid object count u16 work_ct ; // Number of DPD processes in a single game frame s16 wpad_chan_no ; // IO channel number s16 wpad_ring_idx ; // Processed ring buffer WPADCLStatus wpad_ring_bf[ KPAD_RING_BUFS ] ;// Buffer storing the SDK variable f32 sec_length ; // Distance between left and right mark Vec2 sec_nrm ; // Direction from the left to right mark f32 sec_dist ; // Raw distance from the TV (meter) f32 trust_sec_length ; // Trusted interval distance stored here Vec hard_acc ; // Raw acceleration Vec2 obj_horizon ; // Tilt calculated by the object Vec2 acc_horizon ; // Tilt calculated by the acceleration (either side) Vec2 ah_circle_pos ; // Point chasing the acc_horizon u16 ah_circle_ct ; // Countdown if in a certain range (stopped if zero) u8 dpd_valid2_ct ; // Number of successful consecutive two point recognitions s8 _fg_4 ; // Extra //----- Button controls u16 btn_repeat_time ; // Time for counting u16 btn_repeat_next ; // Time of setting next flag u16 btn_repeat_delay ; // Repeat start time u16 btn_repeat_pulse ; // Repeat interval time //----- For Classic Controller unit u16 btn_cl_repeat_time ; // Time for counting u16 btn_cl_repeat_next ; // Time of setting next flag u16 btn_cl_repeat_delay ; // Repeat start time u16 btn_cl_repeat_pulse ; // Repeat interval time BOOL dpd_set_enabled; // Whether DPD module should be turned on or off (TRUE indicates ON) BOOL dpd_request_flag ; // Flag indicating whether the DPD module settings change has been issued BOOL dpd_ctrl_busy; // Flag indicating whether DPD module is busy KPADControlDpdCallback dpd_ctrl_callback; // User callback when DPD setting change becomes necessary BOOL dpd_ctrl_retry_flag; // DPD type and data format configuration retry request flag } KPADInsideStatus ; /******************************************************************************* EXTERNAL WORK *******************************************************************************/ //----- Various adjustments extern f32 kp_obj_interval ; // Separation between marks at each extremes (in meters) extern f32 kp_acc_horizon_pw ; // Calculating twist from acceleration extern f32 kp_ah_circle_radius ; // Stationary state determination radius extern f32 kp_ah_circle_pw ; // Stationary state determination tracking level extern u16 kp_ah_circle_ct ; // Stationary state determination count //----- Values determined to be an error. extern f32 kp_err_outside_frame ; // Surrounding area width where center of mass coordinate will be invalid (not all surrounding lights are necessarily shown) extern f32 kp_err_dist_min ; // Minimum operational distance (in meters) extern f32 kp_err_dist_max ; // Maximum operational distance (in meters) extern f32 kp_err_dist_speed ; // Accepted range of distance change (in meters) extern f32 kp_err_first_inpr ; // Internal product of acceleration tilt and object tilt when selecting two points for the first time extern f32 kp_err_next_inpr ; // Accepted range of tilt change (internal product value) extern f32 kp_err_acc_inpr ; // Accepted range of acceleration tilt and internal product value at stationary state extern f32 kp_err_up_inpr ; // Accepted internal product range with controller pointed upwards extern f32 kp_err_near_pos ; // Distance from the previous point when selecting one point as a continuation //----- KPAD extern KPADInsideStatus inside_kpads[] ; /******************************************************************************* EXTERNAL FUNCTION *******************************************************************************/ #ifdef __cplusplus } #endif #endif // KPADOLD_INSIDE_H__