Lines Matching refs:kp
148 KPADInsideStatus *kp = &inside_kpads[ chan ] ;
176 idx1 = kp->bufIdx - 1 ;
186 switch( kp->uniRingBuf[idx1].u.core.dev ) {
210 kp->uniRingBuf[idx1].u.core.err = WPAD_ERR_INVALID ;
213 &kp->uniRingBuf[ idx1 ].u,
240 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADSetBtnRepeat() local
245 kp->btn_repeat_delay = (u16)(s32)( delay_sec * 200.0f + 0.5f ) ; in KPADSetBtnRepeat()
246 kp->btn_repeat_pulse = (u16)(s32)( pulse_sec * 200.0f + 0.5f ) ; in KPADSetBtnRepeat()
249 kp->btn_repeat_delay = KPAD_BTN_NO_RPT_DELAY ; in KPADSetBtnRepeat()
250 kp->btn_repeat_pulse = 0 ; in KPADSetBtnRepeat()
254 kp->btn_repeat_time = 0 ; in KPADSetBtnRepeat()
255 kp->btn_repeat_next = kp->btn_repeat_delay ; in KPADSetBtnRepeat()
256 kp->btn_cl_repeat_time = 0 ; in KPADSetBtnRepeat()
257 kp->btn_cl_repeat_next = kp->btn_repeat_delay ; in KPADSetBtnRepeat()
354 static void calc_dpd2pos_scale( KPADInsideStatus *kp ) in calc_dpd2pos_scale() argument
367 if ( kp->center_org.x < 0.0f ) { in calc_dpd2pos_scale()
368 sx += kp->center_org.x ; in calc_dpd2pos_scale()
370 sx -= kp->center_org.x ; in calc_dpd2pos_scale()
374 if ( kp->center_org.y < 0.0f ) { in calc_dpd2pos_scale()
375 sy += kp->center_org.y ; in calc_dpd2pos_scale()
377 sy -= kp->center_org.y ; in calc_dpd2pos_scale()
381 kp->dpd2pos_scale = scale / ( ( sx < sy ) ? sx : sy ) ; in calc_dpd2pos_scale()
388 static void reset_kpad( KPADInsideStatus *kp ) in reset_kpad() argument
391 KPADStatus *sp = &kp->status ; in reset_kpad()
392 KPADEXStatus *ep = &kp->status.ex_status ; in reset_kpad()
394 kp->resetReq = FALSE ; in reset_kpad()
397 kp->kobj_frame_min.x = -1.0f + kp_err_outside_frame ; in reset_kpad()
398 kp->kobj_frame_max.x = 1.0f - kp_err_outside_frame ; in reset_kpad()
399 kp->kobj_frame_min.y = -((f32)KPAD_DPD_RESO_WY / KPAD_DPD_RESO_WX) + kp_err_outside_frame ; in reset_kpad()
400 kp->kobj_frame_max.y = ((f32)KPAD_DPD_RESO_WY / KPAD_DPD_RESO_WX) - kp_err_outside_frame ; in reset_kpad()
402 kp->err_dist_speed_1 = 1.0f / kp_err_dist_speed ; in reset_kpad()
403 kp->err_dist_speedM_1 = -1.0f / kp_err_dist_speed ; in reset_kpad()
404 kp->ah_circle_radius2 = kp_ah_circle_radius * kp_ah_circle_radius ; in reset_kpad()
406 kp->err_dist_min = kp_err_dist_min ; in reset_kpad()
407 kp->dist_vv1 = kp_dist_vv1 ; in reset_kpad()
411 kp->btn_repeat_time = 0 ; in reset_kpad()
412 kp->btn_repeat_next = kp->btn_repeat_delay ; in reset_kpad()
416 kp->dpd_valid2_ct = 0 ; in reset_kpad()
421 sp->horizon.x = kp->acc_horizon.x = kp->obj_horizon.x = 1.0f ; in reset_kpad()
422 sp->horizon.y = kp->acc_horizon.y = kp->obj_horizon.y = 0.0f ; in reset_kpad()
429 sp->dist = kp->dist_org ; in reset_kpad()
432 kp->sec_dist = sp->dist ; in reset_kpad()
433 kp->sec_length = kp->trust_sec_length = kp->dist_vv1 / kp->sec_dist ; in reset_kpad()
434 kp->sec_nrm = kp->sec_nrm_hori ; in reset_kpad()
441 kp->hard_acc = sp->acc ; in reset_kpad()
443 kp->ah_circle_pos = kp->acc_horizon ; in reset_kpad()
444 kp->ah_circle_ct = kp_ah_circle_ct ; in reset_kpad()
447 kp->valid_objs = 0 ; in reset_kpad()
449 op = &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ; in reset_kpad()
452 } while ( --op >= kp->kobj_sample ) ; in reset_kpad()
454 op = &kp->kobj_regular[ KPAD_USE_OBJECTS - 1 ] ; in reset_kpad()
457 } while ( --op >= kp->kobj_regular ) ; in reset_kpad()
460 kp->bufCount = 0 ; // Ring buffer unprocessed in reset_kpad()
463 kp->exResetReq = TRUE ; in reset_kpad()
487 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADCalibrateDPD() local
488 KPADStatus *sp = &kp->status ; in KPADCalibrateDPD()
494 if ( kp->valid_objs != KPAD_USE_OBJECTS ) return ( kp->valid_objs ) ; in KPADCalibrateDPD()
499 vx = kp->hard_acc.x ; in KPADCalibrateDPD()
500 vy = kp->hard_acc.y ; in KPADCalibrateDPD()
503 kp->accXY_nrm_hori.x = vx / f1 ; in KPADCalibrateDPD()
504 kp->accXY_nrm_hori.y = vy / f1 ; in KPADCalibrateDPD()
510 op1 = kp->kobj_sample ; in KPADCalibrateDPD()
520 kp->kobj_regular[ 0 ] = *op1 ; in KPADCalibrateDPD()
521 kp->kobj_regular[ 1 ] = *op2 ; in KPADCalibrateDPD()
525 kp->kobj_regular[ 0 ] = *op2 ; in KPADCalibrateDPD()
526 kp->kobj_regular[ 1 ] = *op1 ; in KPADCalibrateDPD()
533 calc_dpd2pos_scale( kp ) ; in KPADCalibrateDPD()
536 vx = kp->kobj_regular[ KPAD_USE_OBJECTS - 1 ].center.x - kp->kobj_regular[ 0 ].center.x ; in KPADCalibrateDPD()
537 vy = kp->kobj_regular[ KPAD_USE_OBJECTS - 1 ].center.y - kp->kobj_regular[ 0 ].center.y ; in KPADCalibrateDPD()
539 kp->sec_nrm_hori.x = vx * f1 ; in KPADCalibrateDPD()
540 kp->sec_nrm_hori.y = vy * f1 ; in KPADCalibrateDPD()
545 kp->dist_org = kp->dist_vv1 * f1 ; in KPADCalibrateDPD()
552 return ( kp->valid_objs ) ; in KPADCalibrateDPD()
583 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADSetSensorHeight() local
585 kp->center_org.x = 0.0f ; in KPADSetSensorHeight()
586 kp->center_org.y = -level ; in KPADSetSensorHeight()
587 calc_dpd2pos_scale( kp ) ; in KPADSetSensorHeight()
594 static void calc_button_repeat( KPADInsideStatus *kp, u32 dev_type, u32 count ) in calc_button_repeat() argument
596 KPADStatus *sp = &kp->status ; in calc_button_repeat()
597 KPADEXStatus *ep = &kp->status.ex_status ; in calc_button_repeat()
601 kp->btn_repeat_time = 0 ; in calc_button_repeat()
602 kp->btn_repeat_next = kp->btn_repeat_delay ; in calc_button_repeat()
605 if ( sp->trig && kp->btn_repeat_pulse ) { in calc_button_repeat()
610 kp->btn_repeat_time += count ; in calc_button_repeat()
611 if ( kp->btn_repeat_time >= KPAD_BTN_NO_RPT_DELAY ) { in calc_button_repeat()
612 kp->btn_repeat_time -= KPAD_BTN_NO_RPT_DELAY ; in calc_button_repeat()
616 if ( kp->btn_repeat_time >= kp->btn_repeat_next ) { in calc_button_repeat()
620 kp->btn_repeat_next += kp->btn_repeat_pulse ; in calc_button_repeat()
623 if ( kp->btn_repeat_time >= KPAD_BTN_RPT_TIME_MAX ) { in calc_button_repeat()
624 kp->btn_repeat_time -= KPAD_BTN_RPT_TIME_MAX ; in calc_button_repeat()
625 kp->btn_repeat_next -= KPAD_BTN_RPT_TIME_MAX ; in calc_button_repeat()
635 kp->btn_cl_repeat_time = 0 ; in calc_button_repeat()
636 kp->btn_cl_repeat_next = kp->btn_repeat_delay ; in calc_button_repeat()
639 if ( ep->cl.trig && kp->btn_repeat_pulse ) { in calc_button_repeat()
644 kp->btn_cl_repeat_time += count ; in calc_button_repeat()
645 if ( kp->btn_cl_repeat_time >= KPAD_BTN_NO_RPT_DELAY ) { in calc_button_repeat()
646 kp->btn_cl_repeat_time -= KPAD_BTN_NO_RPT_DELAY ; in calc_button_repeat()
650 if ( kp->btn_cl_repeat_time >= kp->btn_cl_repeat_next ) { in calc_button_repeat()
654 kp->btn_cl_repeat_next += kp->btn_repeat_pulse ; in calc_button_repeat()
657 if ( kp->btn_cl_repeat_time >= KPAD_BTN_RPT_TIME_MAX ) { in calc_button_repeat()
658 kp->btn_cl_repeat_time -= KPAD_BTN_RPT_TIME_MAX ; in calc_button_repeat()
659 kp->btn_cl_repeat_next -= KPAD_BTN_RPT_TIME_MAX ; in calc_button_repeat()
670 static void read_kpad_button( KPADInsideStatus *kp, u32 dev_type, u32 count, u32 core, u32 fs, u32 … in read_kpad_button() argument
672 KPADStatus *sp = &kp->status ; in read_kpad_button()
673 KPADEXStatus *ep = &kp->status.ex_status ; in read_kpad_button()
686 if ( kp->exResetReq ) { in read_kpad_button()
703 if ( kp->exResetReq ) { in read_kpad_button()
722 calc_button_repeat( kp, dev_type, count ) ; in read_kpad_button()
729 static void calc_acc( KPADInsideStatus *kp, f32 *acc, f32 acc2 ) in calc_acc() argument
737 if ( kp->acc_play_mode == KPAD_PLAY_MODE_LOOSE ) { in calc_acc()
745 if ( f1 >= kp->acc_play_radius ) { in calc_acc()
750 f1 /= kp->acc_play_radius ; in calc_acc()
754 f1 *= kp->acc_sensitivity ; in calc_acc()
759 if ( f2 < -kp->acc_play_radius ) { in calc_acc()
760 *acc += ( f2 + kp->acc_play_radius ) * kp->acc_sensitivity ; in calc_acc()
761 } else if ( f2 > kp->acc_play_radius ) { in calc_acc()
762 *acc += ( f2 - kp->acc_play_radius ) * kp->acc_sensitivity ; in calc_acc()
771 static void calc_acc_horizon( KPADInsideStatus *kp ) in calc_acc_horizon() argument
777 f1 = sqrtf( kp->hard_acc.x * kp->hard_acc.x + kp->hard_acc.y * kp->hard_acc.y ) ; in calc_acc_horizon()
779 ax = kp->hard_acc.x / f1 ; in calc_acc_horizon()
780 ay = kp->hard_acc.y / f1 ; in calc_acc_horizon()
789 vx = kp->accXY_nrm_hori.x * ax + kp->accXY_nrm_hori.y * ay ; in calc_acc_horizon()
790 vy = kp->accXY_nrm_hori.y * ax - kp->accXY_nrm_hori.x * ay ; in calc_acc_horizon()
793 ax = ( vx - kp->acc_horizon.x ) * f1 + kp->acc_horizon.x ; in calc_acc_horizon()
794 ay = ( vy - kp->acc_horizon.y ) * f1 + kp->acc_horizon.y ; in calc_acc_horizon()
799 kp->acc_horizon.x = ax / f1 ; in calc_acc_horizon()
800 kp->acc_horizon.y = ay / f1 ; in calc_acc_horizon()
804 kp->ah_circle_pos.x += ( kp->acc_horizon.x - kp->ah_circle_pos.x ) * kp_ah_circle_pw ; in calc_acc_horizon()
805 kp->ah_circle_pos.y += ( kp->acc_horizon.y - kp->ah_circle_pos.y ) * kp_ah_circle_pw ; in calc_acc_horizon()
807 vx = kp->acc_horizon.x - kp->ah_circle_pos.x ; in calc_acc_horizon()
808 vy = kp->acc_horizon.y - kp->ah_circle_pos.y ; in calc_acc_horizon()
809 if ( vx*vx + vy*vy <= kp->ah_circle_radius2 ) { in calc_acc_horizon()
810 if ( kp->ah_circle_ct ) -- kp->ah_circle_ct ; in calc_acc_horizon()
812 kp->ah_circle_ct = kp_ah_circle_ct ; in calc_acc_horizon()
816 static void calc_acc_vertical( KPADInsideStatus *kp ) in calc_acc_vertical() argument
818 KPADStatus *sp = &kp->status ; in calc_acc_vertical()
823 ax = sqrtf( f2 = kp->hard_acc.x * kp->hard_acc.x + kp->hard_acc.y * kp->hard_acc.y ) ; in calc_acc_vertical()
824 ay = - kp->hard_acc.z ; in calc_acc_vertical()
861 static void read_kpad_acc( KPADInsideStatus *kp, KPADUnifiedWpadStatus *uwp ) in read_kpad_acc() argument
863 KPADStatus *sp = &kp->status ; in read_kpad_acc()
883 kp->hard_acc.x = clamp_acc( (f32)(s32)-uwp->u.core.accX * kp->acc_scale_x, kp_rm_acc_max ) ; in read_kpad_acc()
884 kp->hard_acc.y = clamp_acc( (f32)(s32)-uwp->u.core.accZ * kp->acc_scale_z, kp_rm_acc_max ) ; in read_kpad_acc()
885 kp->hard_acc.z = clamp_acc( (f32)(s32) uwp->u.core.accY * kp->acc_scale_y, kp_rm_acc_max ) ; in read_kpad_acc()
891 calc_acc( kp, &sp->acc.x, kp->hard_acc.x ) ; in read_kpad_acc()
892 calc_acc( kp, &sp->acc.y, kp->hard_acc.y ) ; in read_kpad_acc()
893 calc_acc( kp, &sp->acc.z, kp->hard_acc.z ) ; in read_kpad_acc()
903 calc_acc_horizon( kp ) ; in read_kpad_acc()
904 calc_acc_vertical( kp ) ; in read_kpad_acc()
917 fsrc.x = clamp_acc( (f32)(s32)-uwp->u.fs.fsAccX * kp->fs_acc_scale_x, kp_fs_acc_max ) ; in read_kpad_acc()
918 fsrc.y = clamp_acc( (f32)(s32)-uwp->u.fs.fsAccZ * kp->fs_acc_scale_z, kp_fs_acc_max ) ; in read_kpad_acc()
919 fsrc.z = clamp_acc( (f32)(s32) uwp->u.fs.fsAccY * kp->fs_acc_scale_y, kp_fs_acc_max ) ; in read_kpad_acc()
921 if ( kp->fsAccRevise ) { in read_kpad_acc()
929 calc_acc( kp, &sp->ex_status.fs.acc.x, fsrc.x ) ; in read_kpad_acc()
930 calc_acc( kp, &sp->ex_status.fs.acc.y, fsrc.y ) ; in read_kpad_acc()
931 calc_acc( kp, &sp->ex_status.fs.acc.z, fsrc.z ) ; in read_kpad_acc()
945 static void get_kobj( KPADInsideStatus *kp, DPDObject *wobj_p ) in get_kobj() argument
954 kobj_p = &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ; in get_kobj()
969 } while ( --kobj_p >= kp->kobj_sample ) ; in get_kobj()
976 static void check_kobj_outside_frame( KPADInsideStatus *kp, KPADObject *kobj_t ) in check_kobj_outside_frame() argument
983 if ( kobj_p->center.x <= kp->kobj_frame_min.x || kobj_p->center.x >= kp->kobj_frame_max.x || in check_kobj_outside_frame()
984 … kobj_p->center.y <= kp->kobj_frame_min.y || kobj_p->center.y >= kp->kobj_frame_max.y ) { in check_kobj_outside_frame()
1018 static f32 calc_horizon( KPADInsideStatus *kp, Vec2 *p1, Vec2 *p2, Vec2 *hori ) in calc_horizon() argument
1029 hori->x = kp->sec_nrm_hori.x * vx + kp->sec_nrm_hori.y * vy ; in calc_horizon()
1030 hori->y = kp->sec_nrm_hori.y * vx - kp->sec_nrm_hori.x * vy ; in calc_horizon()
1032 return ( kp->dist_vv1 * f1 ) ; in calc_horizon()
1039 static s8 select_2obj_first( KPADInsideStatus *kp ) in select_2obj_first() argument
1045 op1 = kp->kobj_sample ; in select_2obj_first()
1053 f1 = calc_horizon( kp, &op1->center, &op2->center, &hori ) ; in select_2obj_first()
1056 if ( f1 <= kp->err_dist_min || f1 >= kp_err_dist_max ) continue ; in select_2obj_first()
1058 f1 = kp->acc_horizon.x * hori.x + kp->acc_horizon.y * hori.y ; in select_2obj_first()
1073 } while ( ++op2 <= &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ) ; in select_2obj_first()
1074 } while ( ++op1 < &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ) ; in select_2obj_first()
1079 kp->kobj_regular[ 0 ] = *rp1 ; in select_2obj_first()
1080 kp->kobj_regular[ 1 ] = *rp2 ; in select_2obj_first()
1089 static s8 select_2obj_continue( KPADInsideStatus *kp ) in select_2obj_continue() argument
1098 op1 = kp->kobj_sample ; in select_2obj_continue()
1114 f1 *= kp->dist_vv1 ; // Distance in select_2obj_continue()
1115 if ( f1 <= kp->err_dist_min || f1 >= kp_err_dist_max ) continue ; in select_2obj_continue()
1118 f1 -= kp->sec_dist ; in select_2obj_continue()
1120 f1 *= kp->err_dist_speedM_1 ; in select_2obj_continue()
1122 f1 *= kp->err_dist_speed_1 ; in select_2obj_continue()
1127 f2 = kp->sec_nrm.x * nrm.x + kp->sec_nrm.y * nrm.y ; in select_2obj_continue()
1150 } while ( ++op2 <= &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ) ; in select_2obj_continue()
1151 } while ( ++op1 < &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ) ; in select_2obj_continue()
1156 kp->kobj_regular[ 0 ] = *rp1 ; in select_2obj_continue()
1157 kp->kobj_regular[ 1 ] = *rp2 ; in select_2obj_continue()
1166 static s8 select_1obj_first( KPADInsideStatus *kp ) in select_1obj_first() argument
1174 vx = kp->sec_nrm_hori.x * kp->acc_horizon.x + kp->sec_nrm_hori.y * kp->acc_horizon.y ; in select_1obj_first()
1175 vy = kp->sec_nrm_hori.y * kp->acc_horizon.x - kp->sec_nrm_hori.x * kp->acc_horizon.y ; in select_1obj_first()
1178 vx *= kp->trust_sec_length ; in select_1obj_first()
1179 vy *= kp->trust_sec_length ; in select_1obj_first()
1182 op1 = kp->kobj_sample ; in select_1obj_first()
1191 if ( p1.x <= kp->kobj_frame_min.x || p1.x >= kp->kobj_frame_max.x || in select_1obj_first()
1192 p1.y <= kp->kobj_frame_min.y || p1.y >= kp->kobj_frame_max.y ) { in select_1obj_first()
1194 if ( p2.x > kp->kobj_frame_min.x && p2.x < kp->kobj_frame_max.x && in select_1obj_first()
1195 p2.y > kp->kobj_frame_min.y && p2.y < kp->kobj_frame_max.y ) { in select_1obj_first()
1197 kp->kobj_regular[ 1 ] = *op1 ; in select_1obj_first()
1199 kp->kobj_regular[ 0 ].center = p1 ; in select_1obj_first()
1200 kp->kobj_regular[ 0 ].error_fg = 0 ; in select_1obj_first()
1201 kp->kobj_regular[ 0 ].state_fg = -1 ; in select_1obj_first()
1207 if ( p2.x <= kp->kobj_frame_min.x || p2.x >= kp->kobj_frame_max.x || in select_1obj_first()
1208 p2.y <= kp->kobj_frame_min.y || p2.y >= kp->kobj_frame_max.y ) { in select_1obj_first()
1210 kp->kobj_regular[ 0 ] = *op1 ; in select_1obj_first()
1212 kp->kobj_regular[ 1 ].center = p2 ; in select_1obj_first()
1213 kp->kobj_regular[ 1 ].error_fg = 0 ; in select_1obj_first()
1214 kp->kobj_regular[ 1 ].state_fg = -1 ; in select_1obj_first()
1220 } while ( ++op1 < &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS ] ) ; in select_1obj_first()
1229 static s8 select_1obj_continue( KPADInsideStatus *kp ) in select_1obj_continue() argument
1237 op1 = kp->kobj_regular ; in select_1obj_continue()
1242 op2 = kp->kobj_sample ; in select_1obj_continue()
1254 } while ( ++op2 < &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS ] ) ; in select_1obj_continue()
1255 } while ( ++op1 < &kp->kobj_regular[ KPAD_USE_OBJECTS ] ) ; in select_1obj_continue()
1263 … kp->sec_nrm.x = kp->sec_nrm_hori.x * kp->acc_horizon.x + kp->sec_nrm_hori.y * kp->acc_horizon.y ; in select_1obj_continue()
1264 … kp->sec_nrm.y = kp->sec_nrm_hori.y * kp->acc_horizon.x - kp->sec_nrm_hori.x * kp->acc_horizon.y ; in select_1obj_continue()
1267 vx = kp->sec_length * kp->sec_nrm.x ; in select_1obj_continue()
1268 vy = kp->sec_length * kp->sec_nrm.y ; in select_1obj_continue()
1269 if ( rp1 == &kp->kobj_regular[ 0 ] ) { in select_1obj_continue()
1270 kp->kobj_regular[ 1 ].center.x = rp1->center.x + vx ; in select_1obj_continue()
1271 kp->kobj_regular[ 1 ].center.y = rp1->center.y + vy ; in select_1obj_continue()
1272 kp->kobj_regular[ 1 ].error_fg = 0 ; in select_1obj_continue()
1273 kp->kobj_regular[ 1 ].state_fg = -1 ; in select_1obj_continue()
1275 kp->kobj_regular[ 0 ].center.x = rp1->center.x - vx ; in select_1obj_continue()
1276 kp->kobj_regular[ 0 ].center.y = rp1->center.y - vy ; in select_1obj_continue()
1277 kp->kobj_regular[ 0 ].error_fg = 0 ; in select_1obj_continue()
1278 kp->kobj_regular[ 0 ].state_fg = -1 ; in select_1obj_continue()
1281 if ( kp->status.dpd_valid_fg < 0 ) { in select_1obj_continue()
1292 static void calc_obj_horizon( KPADInsideStatus *kp ) in calc_obj_horizon() argument
1297 vx = kp->kobj_regular[ 1 ].center.x - kp->kobj_regular[ 0 ].center.x ; in calc_obj_horizon()
1298 vy = kp->kobj_regular[ 1 ].center.y - kp->kobj_regular[ 0 ].center.y ; in calc_obj_horizon()
1299 kp->sec_length = sqrtf( vx * vx + vy * vy ) ; // Should not be zero in calc_obj_horizon()
1301 f1 = 1.0f / kp->sec_length ; in calc_obj_horizon()
1302 kp->sec_dist = kp->dist_vv1 * f1 ; in calc_obj_horizon()
1304 kp->sec_nrm.x = ( vx *= f1 ) ; in calc_obj_horizon()
1305 kp->sec_nrm.y = ( vy *= f1 ) ; in calc_obj_horizon()
1307 kp->obj_horizon.x = kp->sec_nrm_hori.x * vx + kp->sec_nrm_hori.y * vy ; in calc_obj_horizon()
1308 kp->obj_horizon.y = kp->sec_nrm_hori.y * vx - kp->sec_nrm_hori.x * vy ; in calc_obj_horizon()
1315 static void calc_dpd_variable( KPADInsideStatus *kp, s8 valid_fg_next ) in calc_dpd_variable() argument
1317 KPADStatus *sp = &kp->status ; in calc_dpd_variable()
1331 pos.x = kp->sec_nrm_hori.x * kp->sec_nrm.x + kp->sec_nrm_hori.y * kp->sec_nrm.y ; in calc_dpd_variable()
1332 pos.y = kp->sec_nrm_hori.y * kp->sec_nrm.x - kp->sec_nrm_hori.x * kp->sec_nrm.y ; in calc_dpd_variable()
1346 if ( kp->hori_play_mode == KPAD_PLAY_MODE_LOOSE ) { in calc_dpd_variable()
1348 if ( f1 >= kp->hori_play_radius ) { in calc_dpd_variable()
1353 f1 /= kp->hori_play_radius ; in calc_dpd_variable()
1357 f1 *= kp->hori_sensitivity ; in calc_dpd_variable()
1372 if ( f1 > kp->hori_play_radius ) { in calc_dpd_variable()
1374 f1 = ( f1 - kp->hori_play_radius ) / f1 * kp->hori_sensitivity ; in calc_dpd_variable()
1398 dist = kp->dist_vv1 / kp->sec_length ; in calc_dpd_variable()
1415 if ( kp->dist_play_mode == KPAD_PLAY_MODE_LOOSE ) { in calc_dpd_variable()
1417 if ( f1 >= kp->dist_play_radius ) { in calc_dpd_variable()
1422 f1 /= kp->dist_play_radius ; in calc_dpd_variable()
1426 f1 *= kp->dist_sensitivity ; in calc_dpd_variable()
1438 if ( f1 > kp->dist_play_radius ) { in calc_dpd_variable()
1440 f1 = ( f1 - kp->dist_play_radius ) / f1 * kp->dist_sensitivity ; in calc_dpd_variable()
1461 pos.x = ( kp->kobj_regular[ 0 ].center.x + kp->kobj_regular[ 1 ].center.x ) * 0.5f ; in calc_dpd_variable()
1462 pos.y = ( kp->kobj_regular[ 0 ].center.y + kp->kobj_regular[ 1 ].center.y ) * 0.5f ; in calc_dpd_variable()
1465 f1 = kp->sec_nrm.x * kp->sec_nrm_hori.x + kp->sec_nrm.y * kp->sec_nrm_hori.y ; in calc_dpd_variable()
1466 f2 = -kp->sec_nrm.y * kp->sec_nrm_hori.x + kp->sec_nrm.x * kp->sec_nrm_hori.y ; in calc_dpd_variable()
1471 vec.x = ( kp->center_org.x - vec.x ) * kp->dpd2pos_scale ; in calc_dpd_variable()
1472 vec.y = ( kp->center_org.y - vec.y ) * kp->dpd2pos_scale ; in calc_dpd_variable()
1475 pos.x = -kp->accXY_nrm_hori.y * vec.x + kp->accXY_nrm_hori.x * vec.y ; in calc_dpd_variable()
1476 pos.y = -kp->accXY_nrm_hori.x * vec.x - kp->accXY_nrm_hori.y * vec.y ; in calc_dpd_variable()
1490 if ( kp->pos_play_mode == KPAD_PLAY_MODE_LOOSE ) { in calc_dpd_variable()
1492 if ( f1 >= kp->pos_play_radius ) { in calc_dpd_variable()
1497 f1 /= kp->pos_play_radius ; in calc_dpd_variable()
1501 f1 *= kp->pos_sensitivity ; in calc_dpd_variable()
1511 if ( f1 > kp->pos_play_radius ) { in calc_dpd_variable()
1513 f1 = ( f1 - kp->pos_play_radius ) / f1 * kp->pos_sensitivity ; in calc_dpd_variable()
1538 static void read_kpad_dpd( KPADInsideStatus *kp, KPADUnifiedWpadStatus *uwp ) in read_kpad_dpd() argument
1540 KPADStatus *sp = &kp->status ; in read_kpad_dpd()
1550 || ( uwp->fmt == WPAD_FMT_GUITAR && kp->dpdCurrState ) ) { in read_kpad_dpd()
1552 get_kobj( kp, &uwp->u.core.obj[ WPAD_DPD_MAX_OBJECTS - 1 ] ) ; in read_kpad_dpd()
1555 op1 = &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ; in read_kpad_dpd()
1558 } while ( --op1 >= kp->kobj_sample ) ; in read_kpad_dpd()
1565 check_kobj_outside_frame( kp, kp->kobj_sample ) ; // Set the surrounding objects to invalid in read_kpad_dpd()
1566 …check_kobj_same_position( kp->kobj_sample ) ; // Set the objects at the same coordinates to inva… in read_kpad_dpd()
1569 kp->valid_objs = 0 ; in read_kpad_dpd()
1570 op1 = &kp->kobj_sample[ WPAD_DPD_MAX_OBJECTS - 1 ] ; in read_kpad_dpd()
1572 if ( op1->error_fg == 0 ) ++ kp->valid_objs ; in read_kpad_dpd()
1573 } while ( --op1 >= kp->kobj_sample ) ; in read_kpad_dpd()
1580 if ( kp->valid_objs >= 2 ) in read_kpad_dpd()
1582 valid_fg_next = select_2obj_continue( kp ) ; in read_kpad_dpd()
1585 if ( kp->valid_objs >= 1 ) in read_kpad_dpd()
1587 valid_fg_next = select_1obj_continue( kp ) ; in read_kpad_dpd()
1592 if ( kp->valid_objs >= 2 ) in read_kpad_dpd()
1594 valid_fg_next = select_2obj_first( kp ) ; in read_kpad_dpd()
1597 if ( kp->valid_objs >= 1 ) in read_kpad_dpd()
1599 valid_fg_next = select_1obj_continue( kp ) ; in read_kpad_dpd()
1604 if ( kp->valid_objs >= 2 ) in read_kpad_dpd()
1606 valid_fg_next = select_2obj_first( kp ) ; in read_kpad_dpd()
1610 if ( kp->valid_objs == 1 ) in read_kpad_dpd()
1612 valid_fg_next = select_1obj_first( kp ) ; in read_kpad_dpd()
1626 calc_obj_horizon( kp ) ; in read_kpad_dpd()
1629 if ( kp->ah_circle_ct == 0 ) { in read_kpad_dpd()
1630 …if ( kp->obj_horizon.x * kp->acc_horizon.x + kp->obj_horizon.y * kp->acc_horizon.y <= kp_err_acc_i… in read_kpad_dpd()
1633 kp->kobj_regular[ 0 ].error_fg = in read_kpad_dpd()
1634 kp->kobj_regular[ 1 ].error_fg = 1 ; in read_kpad_dpd()
1640 if ( kp->dpd_valid2_ct == 200 ) { in read_kpad_dpd()
1641 kp->trust_sec_length = kp->sec_length ; in read_kpad_dpd()
1643 ++ kp->dpd_valid2_ct ; in read_kpad_dpd()
1646 kp->dpd_valid2_ct = 0 ; in read_kpad_dpd()
1649 kp->dpd_valid2_ct = 0 ; in read_kpad_dpd()
1653 calc_dpd_variable( kp, valid_fg_next ) ; in read_kpad_dpd()
1731 static void read_kpad_ext( KPADInsideStatus *kp, KPADUnifiedWpadStatus *uwp ) in read_kpad_ext() argument
1733 KPADEXStatus *ep = &kp->status.ex_status ; in read_kpad_ext()
1746 if ( kp->exResetReq ) { in read_kpad_ext()
1747 kp->exResetReq = FALSE ; in read_kpad_ext()
1764 if ( kp->exResetReq ) { in read_kpad_ext()
1765 kp->exResetReq = FALSE ; in read_kpad_ext()
1772 kp->btn_cl_repeat_time = 0 ; in read_kpad_ext()
1773 kp->btn_cl_repeat_next = kp->btn_repeat_delay ; in read_kpad_ext()
1783 if ( kp->exResetReq ) { in read_kpad_ext()
1784 kp->exResetReq = FALSE ; in read_kpad_ext()
1791 kp->btn_cl_repeat_time = 0 ; in read_kpad_ext()
1792 kp->btn_cl_repeat_next = kp->btn_repeat_delay ; in read_kpad_ext()
1802 if ( kp->exResetReq ) { in read_kpad_ext()
1803 kp->exResetReq = FALSE ; in read_kpad_ext()
1810 kp->btn_cl_repeat_time = 0 ; in read_kpad_ext()
1811 kp->btn_cl_repeat_next = kp->btn_repeat_delay ; in read_kpad_ext()
1820 if ( kp->exResetReq ) { in read_kpad_ext()
1821 kp->exResetReq = FALSE ; in read_kpad_ext()
1830 } else if ( !kp->wbcGetWeightAveDone ) { in read_kpad_ext()
1840 …kp->wbcWeightAve [ idx ] = ( kp->wbcWeightAve[ idx ] * kp_wbc_ave_sample + ep->bl.weight[ idx ] ) … in read_kpad_ext()
1841 ep->bl.weight_ave[ idx ] = kp->wbcWeightAve[ idx ] ; in read_kpad_ext()
1882 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADiRead() local
1913 if ( kp->readLocked ) { in KPADiRead()
1918 kp->readLocked = TRUE ; in KPADiRead()
1923 reset_kpad( kp ) ; in KPADiRead()
1925 if ( kp->dpd_ctrl_callback && in KPADiRead()
1926 kp->dpdPreCallbackDone && in KPADiRead()
1927 !kp->dpdPostCallbackDone ) { in KPADiRead()
1931 kp->readLocked = FALSE ; in KPADiRead()
1939 if ( kp->resetReq ) { in KPADiRead()
1941 kp->status.wpad_err = (s8)WPAD_ERR_INVALID ; in KPADiRead()
1942 reset_kpad( kp ) ; in KPADiRead()
1948 if ( kp->bufCount > 1 && in KPADiRead()
1954 bufCount = kp->bufCount ; in KPADiRead()
1964 idx = (s32) kp->bufIdx ; in KPADiRead()
1967 idx += kp->uniRingBufExLen + KPAD_RING_BUFS ; in KPADiRead()
1971 uwp = &kp->uniRingBufEx[ idx - KPAD_RING_BUFS ] ; in KPADiRead()
1973 uwp = &kp->uniRingBuf[ idx ] ; in KPADiRead()
1990 if ( kp->status.dev_type != uwp->u.core.dev ) { in KPADiRead()
1999 idx += kp->uniRingBufExLen + KPAD_RING_BUFS ; in KPADiRead()
2002 uwp = &kp->uniRingBufEx[ idx - KPAD_RING_BUFS ] ; in KPADiRead()
2004 uwp = &kp->uniRingBuf[ idx ] ; in KPADiRead()
2009 kp->bufCount = 1 ; in KPADiRead()
2021 idx = (s32)( kp->bufIdx - copy_ct - 1 ) ; in KPADiRead()
2023 idx += kp->uniRingBufExLen + KPAD_RING_BUFS ; in KPADiRead()
2028 uwp = &kp->uniRingBufEx[ idx - KPAD_RING_BUFS ] ; in KPADiRead()
2030 uwp = &kp->uniRingBuf[ idx ] ; in KPADiRead()
2036 if ( idx >= kp->uniRingBufExLen + KPAD_RING_BUFS ) { in KPADiRead()
2053 kp->acc_scale_x = 1.0f / core1G.x ; in KPADiRead()
2054 kp->acc_scale_y = 1.0f / core1G.y ; in KPADiRead()
2055 kp->acc_scale_z = 1.0f / core1G.z ; in KPADiRead()
2059 kp->acc_scale_x = 1.0f / 100 ; in KPADiRead()
2060 kp->acc_scale_y = 1.0f / 100 ; in KPADiRead()
2061 kp->acc_scale_z = 1.0f / 100 ; in KPADiRead()
2066 kp->fs_acc_scale_x = 1.0f / fs1G.x ; in KPADiRead()
2067 kp->fs_acc_scale_y = 1.0f / fs1G.y ; in KPADiRead()
2068 kp->fs_acc_scale_z = 1.0f / fs1G.z ; in KPADiRead()
2072 kp->fs_acc_scale_x = 1.0f / 200 ; in KPADiRead()
2073 kp->fs_acc_scale_y = 1.0f / 200 ; in KPADiRead()
2074 kp->fs_acc_scale_z = 1.0f / 200 ; in KPADiRead()
2083 if ( kp->btnProcMode == KPAD_BUTTON_PROC_MODE_TIGHT ) in KPADiRead()
2090 if ( kp->status.dev_type != uwp->u.core.dev ) { in KPADiRead()
2091 kp->status.dev_type = uwp->u.core.dev ; // Update the device type in KPADiRead()
2092 … kp->exResetReq = TRUE ; // Reset the extension controller information in KPADiRead()
2096 kp->status.wpad_err = uwp->u.core.err ; in KPADiRead()
2098 kp->status.data_format = uwp->fmt ; in KPADiRead()
2100 lastDev = kp->status.dev_type ; in KPADiRead()
2132 lastCoreButton = (u32)( kp->status.hold & 0x00009F1F ) ; in KPADiRead()
2135 lastFsButton = kp->status.hold ; in KPADiRead()
2138 lastClButton = kp->status.ex_status.cl.hold ; in KPADiRead()
2141 read_kpad_button( kp, lastDev, 1, lastCoreButton, lastFsButton, lastClButton ) ; in KPADiRead()
2145 read_kpad_ext( kp, uwp ) ; in KPADiRead()
2148 read_kpad_acc( kp, uwp ) ; in KPADiRead()
2149 read_kpad_dpd( kp, uwp ) ; in KPADiRead()
2154 kp->status.dpd_valid_fg = 0 ; in KPADiRead()
2158 tp[ 0 ].k = kp->status ; in KPADiRead()
2171 if ( kp->status.dev_type != uwp->u.core.dev ) { in KPADiRead()
2172 kp->status.dev_type = uwp->u.core.dev ; in KPADiRead()
2173 kp->exResetReq = TRUE ; in KPADiRead()
2204 lastCoreButton = (u32)( kp->status.hold & 0x00009F1F ) ; in KPADiRead()
2207 lastFsButton = kp->status.hold ; in KPADiRead()
2210 lastClButton = kp->status.ex_status.cl.hold ; in KPADiRead()
2213 … read_kpad_button( kp, lastDev, (u32)return_ct, lastCoreButton, lastFsButton, lastClButton ) ; in KPADiRead()
2221 kp->status.wpad_err = uwp->u.core.err ; in KPADiRead()
2223 kp->status.data_format = uwp->fmt ; in KPADiRead()
2227 read_kpad_ext( kp, uwp ) ; in KPADiRead()
2230 read_kpad_acc( kp, uwp ) ; in KPADiRead()
2231 read_kpad_dpd( kp, uwp ) ; in KPADiRead()
2236 kp->status.dpd_valid_fg = 0 ; in KPADiRead()
2240 tp[ 0 ].k = kp->status ; in KPADiRead()
2245 kp->readLocked = FALSE ; in KPADiRead()
2284 KPADInsideStatus *kp ; in KPADInitEx() local
2313 kp = &inside_kpads[ i ] ; in KPADInitEx()
2316 kp->appConnectCallback = WPADSetConnectCallback( i, KPADiConnectCallback ) ; in KPADInitEx()
2318 kp->appSamplingCallback = WPADSetSamplingCallback( i, KPADiSamplingCallback ) ; in KPADInitEx()
2321 kp->wbcIssued = FALSE ; in KPADInitEx()
2322 kp->wbcEnabled = FALSE ; in KPADInitEx()
2323 kp->wbcSetup = FALSE ; in KPADInitEx()
2327 kp->dpdCurrState = FALSE ; in KPADInitEx()
2328 kp->dpdNextState = TRUE ; in KPADInitEx()
2329 kp->dpdCmd = WPADGetDpdFormat( i ) ; in KPADInitEx()
2332 kp->status.dev_type = WPAD_DEV_NOT_FOUND ; in KPADInitEx()
2333 kp->status.data_format = WPAD_FMT_CORE ; in KPADInitEx()
2335 kp->dist_org = idist_org ; in KPADInitEx()
2336 kp->accXY_nrm_hori = iaccXY_nrm_hori ; in KPADInitEx()
2337 kp->sec_nrm_hori = isec_nrm_hori ; in KPADInitEx()
2338 kp->center_org = icenter_org ; in KPADInitEx()
2339 calc_dpd2pos_scale( kp ) ; in KPADInitEx()
2342 kp->pos_play_radius = in KPADInitEx()
2343 kp->hori_play_radius = in KPADInitEx()
2344 kp->dist_play_radius = in KPADInitEx()
2345 kp->acc_play_radius = 0.0f ; in KPADInitEx()
2347 kp->pos_sensitivity = in KPADInitEx()
2348 kp->hori_sensitivity = in KPADInitEx()
2349 kp->dist_sensitivity = in KPADInitEx()
2350 kp->acc_sensitivity = 1.0f ; in KPADInitEx()
2352 kp->pos_play_mode = in KPADInitEx()
2353 kp->hori_play_mode = in KPADInitEx()
2354 kp->dist_play_mode = in KPADInitEx()
2355 kp->acc_play_mode = KPAD_PLAY_MODE_LOOSE ; in KPADInitEx()
2360 kp->btnProcMode = KPAD_BUTTON_PROC_MODE_LOOSE ; in KPADInitEx()
2366 kp->fsAccRevise = 0 ; in KPADInitEx()
2370 kp->uniRingBufExLen = length / 4 ; in KPADInitEx()
2371 kp->uniRingBufEx = &uniRingBufs[ i * kp->uniRingBufExLen ] ; in KPADInitEx()
2373 kp->uniRingBufExLen = 0 ; in KPADInitEx()
2374 kp->uniRingBufEx = NULL ; in KPADInitEx()
2378 kp->uniRingBuf[idx].u.core.err = WPAD_ERR_NO_CONTROLLER ; in KPADInitEx()
2380 for ( idx = 0 ; idx < kp->uniRingBufExLen ; idx++ ) { in KPADInitEx()
2381 kp->uniRingBufEx[idx].u.core.err = WPAD_ERR_NO_CONTROLLER ; in KPADInitEx()
2416 KPADInsideStatus *kp ; in KPADShutdown() local
2423 kp = &inside_kpads[ chan ] ; in KPADShutdown()
2425 if ( kp->appSamplingCallback ) { in KPADShutdown()
2426 WPADSetSamplingCallback( chan, kp->appSamplingCallback ) ; in KPADShutdown()
2430 if ( kp->appConnectCallback ) { in KPADShutdown()
2431 WPADSetConnectCallback( chan, kp->appConnectCallback ) ; in KPADShutdown()
2466 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADiConnectCallback() local
2477 kp->dpdCurrState = FALSE ; in KPADiConnectCallback()
2478 kp->dpdCmd = WPAD_DPD_OFF ; in KPADiConnectCallback()
2480 kp->wbcIssued = FALSE ; in KPADiConnectCallback()
2481 kp->wbcEnabled = FALSE ; in KPADiConnectCallback()
2482 kp->wbcSetup = FALSE ; in KPADiConnectCallback()
2487 kp->uniRingBuf[idx].u.core.err = WPAD_ERR_NO_CONTROLLER ; in KPADiConnectCallback()
2489 for ( idx = 0 ; idx < kp->uniRingBufExLen ; idx++ ) { in KPADiConnectCallback()
2490 kp->uniRingBufEx[idx].u.core.err = WPAD_ERR_NO_CONTROLLER ; in KPADiConnectCallback()
2494 if ( kp->appConnectCallback ) { in KPADiConnectCallback()
2495 kp->appConnectCallback( chan, reason ) ; in KPADiConnectCallback()
2509 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADiControlWbcCallback() local
2511 kp->wbcEnabled = (u8)( ( result == WPAD_ERR_NONE ) ? TRUE : FALSE ) ; in KPADiControlWbcCallback()
2512 kp->wbcIssued = FALSE ; in KPADiControlWbcCallback()
2517 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADiUpdateTempWbcCallback() local
2519 kp->wbcSetZeroPoint1Done = (u8)( ( result == WPAD_ERR_NONE ) ? TRUE : FALSE ) ; in KPADiUpdateTempWbcCallback()
2520 kp->wbcIssued = FALSE ; in KPADiUpdateTempWbcCallback()
2525 KPADInsideStatus *kp = &inside_kpads[ WPAD_CHAN3 ] ; in KPADResetWbcZeroPoint() local
2528 kp->wbcSetZeroPoint1Done = FALSE ; in KPADResetWbcZeroPoint()
2529 kp->wbcSetZeroPoint2Done = FALSE ; in KPADResetWbcZeroPoint()
2530 kp->wbcSetZeroPoint3Done = FALSE ; in KPADResetWbcZeroPoint()
2531 kp->wbcZeroPointWaitCount = 0 ; in KPADResetWbcZeroPoint()
2532 kp->wbcZeroPointSampleCount = 0 ; in KPADResetWbcZeroPoint()
2534 kp->wbcGetWeightAveDone = FALSE ; in KPADResetWbcZeroPoint()
2535 kp->wbcWeightAveSampleCount = 0 ; in KPADResetWbcZeroPoint()
2538 kp->wbcZeroPoint[ i ] = 0 ; in KPADResetWbcZeroPoint()
2539 kp->wbcWeightAve[ i ] = 0 ; in KPADResetWbcZeroPoint()
2558 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADSetControlDpdCallback() local
2562 kp->dpd_ctrl_callback = callback ; in KPADSetControlDpdCallback()
2568 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADiControlDpdCallback() local
2571 if ( kp->dpd_ctrl_callback && in KPADiControlDpdCallback()
2572 !kp->dpdPostCallbackDone ) { in KPADiControlDpdCallback()
2573 kp->dpdPostCallbackDone = TRUE ; in KPADiControlDpdCallback()
2574 kp->dpd_ctrl_callback( chan, KPAD_STATE_CTRL_DPD_FINISHED ) ; in KPADiControlDpdCallback()
2575 kp->dpdPreCallbackDone = FALSE ; in KPADiControlDpdCallback()
2578 kp->dpdCurrState = (u8)WPADIsDpdEnabled( chan ) ; in KPADiControlDpdCallback()
2579 kp->dpdIssued = FALSE ; in KPADiControlDpdCallback()
2587 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADiSamplingCallback() local
2617 idx = kp->bufIdx ; in KPADiSamplingCallback()
2618 if ( idx >= KPAD_RING_BUFS + kp->uniRingBufExLen ) { in KPADiSamplingCallback()
2623 uwp = &kp->uniRingBufEx[ idx - KPAD_RING_BUFS ] ; in KPADiSamplingCallback()
2625 uwp = &kp->uniRingBuf[ idx ] ; in KPADiSamplingCallback()
2630 kp->bufIdx = (u8)( idx + 1 ) ; in KPADiSamplingCallback()
2631 if ( kp->bufCount < kp->uniRingBufExLen + KPAD_RING_BUFS ) { in KPADiSamplingCallback()
2632 kp->bufCount++ ; in KPADiSamplingCallback()
2635 if ( kp->aimReq ) { in KPADiSamplingCallback()
2636 if ( kp->aimEnabled ) { in KPADiSamplingCallback()
2647 kp->aimReq = FALSE ; in KPADiSamplingCallback()
2664 if ( kp->dpdNextState ) { in KPADiSamplingCallback()
2668 curDpd = (u32)( WPADIsDpdEnabled( chan ) ? kp->dpdCmd : WPAD_DPD_OFF ); in KPADiSamplingCallback()
2671 if ( kp->dpd_ctrl_callback && in KPADiSamplingCallback()
2672 !kp->dpdPreCallbackDone ) { in KPADiSamplingCallback()
2673 kp->dpdPreCallbackDone = TRUE ; in KPADiSamplingCallback()
2674 kp->dpd_ctrl_callback( chan, KPAD_STATE_CTRL_DPD_START ) ; in KPADiSamplingCallback()
2675 kp->dpdPostCallbackDone = FALSE ; in KPADiSamplingCallback()
2677 if ( !kp->dpdIssued ) { in KPADiSamplingCallback()
2678 kp->dpdIssued = TRUE ; in KPADiSamplingCallback()
2681 kp->dpdCmd = table[ idx ].dpd ; in KPADiSamplingCallback()
2692 if ( !kp->wbcIssued && !kp->wbcEnabled ) { in KPADiSamplingCallback()
2695 kp->wbcIssued = TRUE ; in KPADiSamplingCallback()
2697 } else if ( kp->wbcEnabled && !kp->wbcSetup ) { in KPADiSamplingCallback()
2699 if ( !kp->wbcIssued ) { in KPADiSamplingCallback()
2701 kp->wbcIssued = TRUE ; in KPADiSamplingCallback()
2704 kp->wbcSetup = (u8)( WBCGetCalibrationStatus() ) ; in KPADiSamplingCallback()
2705 kp->wbcIssued = (u8)( ( kp->wbcSetup ) ? FALSE : TRUE ) ; in KPADiSamplingCallback()
2707 } else if ( !kp->wbcIssued && kp->wbcSetup && !kp->wbcSetZeroPoint1Done ) { in KPADiSamplingCallback()
2710 kp->wbcIssued = TRUE ; in KPADiSamplingCallback()
2712 } else if ( kp->wbcSetZeroPoint1Done && !kp->wbcSetZeroPoint2Done ) { in KPADiSamplingCallback()
2716 } else if ( ++kp->wbcZeroPointWaitCount > kp_wbc_wait_count ) { in KPADiSamplingCallback()
2717 kp->wbcSetZeroPoint2Done = TRUE ; in KPADiSamplingCallback()
2719 } else if ( kp->wbcSetZeroPoint2Done && !kp->wbcSetZeroPoint3Done ) { in KPADiSamplingCallback()
2722 kp->wbcZeroPointSampleCount++ ; in KPADiSamplingCallback()
2723 …kp->wbcZeroPoint[ 0 ] = ( kp->wbcZeroPoint[ 0 ] * ( kp->wbcZeroPointSampleCount - 1 ) + uwp->u.bl.… in KPADiSamplingCallback()
2724 …kp->wbcZeroPoint[ 1 ] = ( kp->wbcZeroPoint[ 1 ] * ( kp->wbcZeroPointSampleCount - 1 ) + uwp->u.bl.… in KPADiSamplingCallback()
2725 …kp->wbcZeroPoint[ 2 ] = ( kp->wbcZeroPoint[ 2 ] * ( kp->wbcZeroPointSampleCount - 1 ) + uwp->u.bl.… in KPADiSamplingCallback()
2726 …kp->wbcZeroPoint[ 3 ] = ( kp->wbcZeroPoint[ 3 ] * ( kp->wbcZeroPointSampleCount - 1 ) + uwp->u.bl.… in KPADiSamplingCallback()
2728 if ( kp->wbcZeroPointSampleCount > kp_wbc_ave_sample ) { in KPADiSamplingCallback()
2729 kp->wbcSetZeroPoint3Done = TRUE ; in KPADiSamplingCallback()
2730 WBCSetZEROPoint( kp->wbcZeroPoint, WPAD_PRESS_UNITS ) ; in KPADiSamplingCallback()
2733 } else if ( kp->wbcSetZeroPoint3Done && !kp->wbcGetWeightAveDone ) { in KPADiSamplingCallback()
2738 kp->wbcWeightAveSampleCount++ ; in KPADiSamplingCallback()
2739 …kp->wbcWeightAve[ 0 ] = ( kp->wbcWeightAve[ 0 ] * ( kp->wbcWeightAveSampleCount - 1 ) + weight[ 0 … in KPADiSamplingCallback()
2740 …kp->wbcWeightAve[ 1 ] = ( kp->wbcWeightAve[ 1 ] * ( kp->wbcWeightAveSampleCount - 1 ) + weight[ 1 … in KPADiSamplingCallback()
2741 …kp->wbcWeightAve[ 2 ] = ( kp->wbcWeightAve[ 2 ] * ( kp->wbcWeightAveSampleCount - 1 ) + weight[ 2 … in KPADiSamplingCallback()
2742 …kp->wbcWeightAve[ 3 ] = ( kp->wbcWeightAve[ 3 ] * ( kp->wbcWeightAveSampleCount - 1 ) + weight[ 3 … in KPADiSamplingCallback()
2744 if ( kp->wbcWeightAveSampleCount > kp_wbc_ave_sample ) { in KPADiSamplingCallback()
2745 kp->wbcGetWeightAveDone = TRUE ; in KPADiSamplingCallback()
2753 if ( kp->appSamplingCallback ) { in KPADiSamplingCallback()
2754 kp->appSamplingCallback( chan ) ; in KPADiSamplingCallback()
2768 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADGetUnifiedWpadStatus() local
2775 if ( count > kp->uniRingBufExLen + KPAD_RING_BUFS ) { in KPADGetUnifiedWpadStatus()
2776 count = kp->uniRingBufExLen + KPAD_RING_BUFS ; in KPADGetUnifiedWpadStatus()
2781 idx = kp->bufIdx ; in KPADGetUnifiedWpadStatus()
2784 idx = kp->uniRingBufExLen + KPAD_RING_BUFS - 1 ; in KPADGetUnifiedWpadStatus()
2791 uwp = &kp->uniRingBufEx[ idx - KPAD_RING_BUFS ] ; in KPADGetUnifiedWpadStatus()
2793 uwp = &kp->uniRingBuf[ idx ] ; in KPADGetUnifiedWpadStatus()
2823 KPADInsideStatus *kp = &inside_kpads[ chan ] ; in KPADSetReviseMode() local
2825 kp->fsAccRevise = (u8)sw ; in KPADSetReviseMode()