X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=player_common.c;h=110ee1640e33d0fd85816c44ee6d05a67a5b629d;hb=223e75026f958029f9664380ed20a5daa3ee2ae7;hp=4991d231a31f00671635c154c246f9d0b1643e87;hpb=5f34184cad016aa2f8ea530b3be009703459e981;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_common.c b/player_common.c index 4991d23..110ee16 100644 --- a/player_common.c +++ b/player_common.c @@ -3,6 +3,7 @@ #include "player.h" #include "conf.h" +#include "input.h" VG_STATIC float k_cam_spring = 20.0f, @@ -243,39 +244,15 @@ VG_STATIC void player_look( player_instance *player, v3f angles ) mouse_input[1] *= -1.0f; v2_muladds( angles, mouse_input, 0.0025f, angles ); - if( vg_input.controller_should_use_trackpad_look ){ - static v2f last_input; - static v2f vel; - static v2f vel_smooth; + v2f jlook; + joystick_state( k_srjoystick_look, jlook ); - v2f input = { player->input_js2h->axis.value, - player->input_js2v->axis.value }; - - if( cl_invert_y ) - input[1] *= -1.0f; - - if( (v2_length2(last_input) > 0.001f) && (v2_length2(input) > 0.001f) ){ - v2_sub( input, last_input, vel ); - v2_muls( vel, 1.0f/vg.time_delta, vel ); - } - else{ - v2_zero( vel ); - } - - v2_lerp( vel_smooth, vel, vg.time_delta*8.0f, vel_smooth ); - - v2_muladds( angles, vel_smooth, vg.time_delta, angles ); - v2_copy( input, last_input ); - } - else{ - angles[0] += player->input_js2h->axis.value * vg.time_delta * 4.0f; - - float input_y = player->input_js2v->axis.value * vg.time_delta * 4.0f; - if( cl_invert_y ) - input_y *= -1.0f; + angles[0] += jlook[0] * vg.time_delta * 4.0f; + float input_y = jlook[1] * vg.time_delta * 4.0f; + if( cl_invert_y ) + input_y *= -1.0f; - angles[1] += input_y; - } + angles[1] += input_y; angles[1] = vg_clampf( angles[1], -VG_PIf*0.5f, VG_PIf*0.5f ); }