X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=input.h;h=ee7cbee9e5f9d5828e970998878d78c7a20ffa34;hb=3f852e50468d59b8d65abd100bcb29964b9b046a;hp=cd5f826b8d3dfb2016d5805110f87fdff700103c;hpb=bf8478e3656ae729248a594a57d111f08bed41e0;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/input.h b/input.h index cd5f826..ee7cbee 100644 --- a/input.h +++ b/input.h @@ -15,6 +15,7 @@ enum sr_bind{ k_srbind_trick0, k_srbind_trick1, k_srbind_trick2, + k_srbind_sit, k_srbind_use, k_srbind_reset, k_srbind_camera, @@ -28,6 +29,11 @@ enum sr_bind{ k_srbind_replay_play, k_srbind_replay_freecam, k_srbind_replay_resume, + k_srbind_world_left, + k_srbind_world_right, + k_srbind_home, + k_srbind_lobby, + k_srbind_chat, k_srbind_max, }; @@ -43,6 +49,7 @@ enum sr_axis{ k_sraxis_mbrowse_h, k_sraxis_mbrowse_v, k_sraxis_replay_h, + k_sraxis_mworld_h, k_sraxis_max }; @@ -109,14 +116,20 @@ static const char *button_display_string( enum sr_bind button ) [k_srbind_camera] = controller_glyph( SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ), [k_srbind_mleft] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_LEFT ), [k_srbind_mright] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_RIGHT ), + [k_srbind_world_left] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_LEFT ), + [k_srbind_world_right] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_RIGHT ), + [k_srbind_home] = controller_glyph( SDL_CONTROLLER_BUTTON_Y ), [k_srbind_mup] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_UP ), [k_srbind_mdown] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_DOWN ), [k_srbind_mback] = controller_glyph( SDL_CONTROLLER_BUTTON_B ), [k_srbind_maccept]= controller_glyph( SDL_CONTROLLER_BUTTON_A ), [k_srbind_mopen] = controller_glyph( SDL_CONTROLLER_BUTTON_GUIDE ), -[k_srbind_replay_play]= controller_glyph( SDL_CONTROLLER_BUTTON_A ), +[k_srbind_replay_play]= controller_glyph( SDL_CONTROLLER_BUTTON_X ), [k_srbind_replay_freecam]=controller_glyph(SDL_CONTROLLER_BUTTON_Y ), -[k_srbind_replay_resume]=controller_glyph( SDL_CONTROLLER_BUTTON_LEFTSHOULDER ) +[k_srbind_replay_resume]=controller_glyph( SDL_CONTROLLER_BUTTON_A ), + [k_srbind_sit] = controller_glyph( SDL_CONTROLLER_BUTTON_B ), + [k_srbind_lobby] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_LEFT ), + [k_srbind_chat] = "" }; const char *keyboard_table[ k_srbind_max ] = { @@ -130,14 +143,20 @@ static const char *button_display_string( enum sr_bind button ) [k_srbind_camera] = KEYBOARD_GLYPH( "C" ), [k_srbind_mleft] = KEYBOARD_GLYPH( "\x93" ), [k_srbind_mright] = KEYBOARD_GLYPH( "\x95" ), + [k_srbind_world_left] = KEYBOARD_GLYPH( "\x93" ), + [k_srbind_world_right] = KEYBOARD_GLYPH( "\x95" ), + [k_srbind_home] = KEYBOARD_GLYPH( "H" ), [k_srbind_mup] = KEYBOARD_GLYPH( "\x94" ), [k_srbind_mdown] = KEYBOARD_GLYPH( "\x96" ), [k_srbind_mback] = "\xa3", [k_srbind_maccept]= "\xa2", [k_srbind_mopen] = "\xa3" , -[k_srbind_replay_play]= "\xa1", +[k_srbind_replay_play]= KEYBOARD_GLYPH( "G" ), [k_srbind_replay_freecam] = KEYBOARD_GLYPH( "F" ), -[k_srbind_replay_resume]=KEYBOARD_GLYPH( "R" ) +[k_srbind_replay_resume]= "\xa1", + [k_srbind_sit] = KEYBOARD_GLYPH( "Z" ), + [k_srbind_lobby] = KEYBOARD_GLYPH( "" ), // FIXME: what is tab? + [k_srbind_chat] = KEYBOARD_GLYPH( "Y" ) }; if( vg_input.display_input_method == k_input_method_controller ) @@ -152,14 +171,16 @@ static const char *axis_display_string( enum sr_axis axis ) [k_sraxis_grab] = "\x90", [k_sraxis_mbrowse_h] = "\x88", [k_sraxis_mbrowse_v] = "\x89", - [k_sraxis_replay_h] = "\x88" + [k_sraxis_replay_h] = "\x8f\x90", + [k_sraxis_mworld_h] = "\x93\x95" }; const char *keyboard_table[ k_sraxis_max ] = { [k_sraxis_grab] = "\x9e", [k_sraxis_mbrowse_h] = KEYBOARD_GLYPH("\x93")KEYBOARD_GLYPH("\x95"), [k_sraxis_mbrowse_v] = KEYBOARD_GLYPH("\x96")KEYBOARD_GLYPH("\x94"), - [k_sraxis_replay_h] = KEYBOARD_GLYPH("\x93")KEYBOARD_GLYPH("\x95"), + [k_sraxis_replay_h] = KEYBOARD_GLYPH("Q")KEYBOARD_GLYPH("E"), + [k_sraxis_mworld_h] = KEYBOARD_GLYPH("\x93")KEYBOARD_GLYPH("\x95"), }; if( vg_input.display_input_method == k_input_method_controller ) @@ -192,10 +213,16 @@ static const char *joystick_display_string( enum sr_joystick joystick, else return keyboard_table[ joystick ][axis]; } -static int buttons_filter_fixed(void) -{ - if( !srinput.enabled ) return 1; - if( vg_ui.wants_mouse ) return 1; +static int input_filter_generic(void){ + if( !srinput.enabled || vg_ui.wants_mouse || vg_console.enabled ) + return 1; + else + return 0; +} + +static int buttons_filter_fixed(void){ + if( input_filter_generic() ) + return 1; if( vg.engine_stage == k_engine_stage_update_fixed ) if( vg.fixed_iterations > 0 ) @@ -205,8 +232,7 @@ static int buttons_filter_fixed(void) } /* Rising edge of button */ -static int button_down( enum sr_bind button ) -{ +static int button_down( enum sr_bind button ){ if( buttons_filter_fixed() ) return 0; if( srinput.button_states[ button ][0] && @@ -217,8 +243,7 @@ static int button_down( enum sr_bind button ) } /* Falling edge of button */ -static int button_up( enum sr_bind button ) -{ +static int button_up( enum sr_bind button ){ if( buttons_filter_fixed() ) return 0; if( !srinput.button_states[ button ][0] && @@ -229,23 +254,25 @@ static int button_up( enum sr_bind button ) } /* State of button */ -static int button_press( enum sr_bind button ) -{ - if( vg_ui.wants_mouse ) return 0; - return srinput.button_states[ button ][0]; +static int button_press( enum sr_bind button ){ + if( input_filter_generic() ) + return 0; + return + srinput.button_states[ button ][0]; } -static void joystick_state( enum sr_joystick joystick, v2f state ) -{ - if( vg_ui.wants_mouse ) +static void joystick_state( enum sr_joystick joystick, v2f state ){ + if( input_filter_generic() ) v2_zero( state ); else v2_copy( srinput.joystick_states[ joystick ][0], state ); } static float axis_state( enum sr_axis axis ){ - if( vg_ui.wants_mouse ) return 0.0f; - else return srinput.axis_states[axis][0]; + if( input_filter_generic() ) + return 0.0f; + else + return srinput.axis_states[axis][0]; } static void setbtn( enum sr_bind button, u8 value ) @@ -286,6 +313,9 @@ static void skaterift_preupdate_inputs(void) setbtn( k_srbind_camera, vg_getkey(SDLK_c) ); setbtn( k_srbind_mleft, vg_getkey(SDLK_LEFT) ); setbtn( k_srbind_mright, vg_getkey(SDLK_RIGHT) ); + setbtn( k_srbind_world_left, vg_getkey(SDLK_LEFT) ); + setbtn( k_srbind_world_right, vg_getkey(SDLK_RIGHT) ); + setbtn( k_srbind_home, vg_getkey(SDLK_h) ); setbtn( k_srbind_mup, vg_getkey(SDLK_UP) ); setbtn( k_srbind_mdown, vg_getkey(SDLK_DOWN) ); setbtn( k_srbind_mback, vg_getkey(SDLK_ESCAPE) ); @@ -293,17 +323,25 @@ static void skaterift_preupdate_inputs(void) setbtn( k_srbind_maccept, vg_getkey(SDLK_e) ); setbtn( k_srbind_maccept, vg_getkey(SDLK_RETURN)); setbtn( k_srbind_maccept, vg_getkey(SDLK_RETURN2)); - setbtn( k_srbind_replay_play, vg_getkey(SDLK_SPACE) ); + setbtn( k_srbind_replay_play, vg_getkey(SDLK_g) ); setbtn( k_srbind_replay_freecam, vg_getkey(SDLK_f) ); - setbtn( k_srbind_replay_resume, vg_getkey(SDLK_r) ); + setbtn( k_srbind_replay_resume, vg_getkey(SDLK_SPACE) ); + setbtn( k_srbind_sit, vg_getkey(SDLK_z) ); + setbtn( k_srbind_lobby, vg_getkey(SDLK_TAB) ); + setbtn( k_srbind_chat, vg_getkey(SDLK_y) ); /* axis * --------------------------------------------*/ srinput.axis_states[ k_sraxis_grab ][0] = vg_getkey( SDLK_LSHIFT ); - if( vg_getkey( SDLK_d ) ) + if( vg_getkey( SDLK_e ) ) + srinput.axis_states[ k_sraxis_replay_h ][0] += 1.0f; + if( vg_getkey( SDLK_q ) ) + srinput.axis_states[ k_sraxis_replay_h ][0] -= 1.0f; + + if( vg_getkey( SDLK_d ) ) srinput.joystick_states[k_srjoystick_steer][0][0] += 1.0f; - if( vg_getkey( SDLK_a ) ) + if( vg_getkey( SDLK_a ) ) srinput.joystick_states[k_srjoystick_steer][0][0] -= 1.0f; if( vg_getkey( SDLK_w ) ) srinput.joystick_states[k_srjoystick_steer][0][1] -= 1.0f; @@ -317,11 +355,11 @@ static void skaterift_preupdate_inputs(void) if( vg_getkey( SDLK_LEFT ) ){ srinput.axis_states[ k_sraxis_mbrowse_h ][0] -= 1.0f; - srinput.axis_states[ k_sraxis_replay_h ][0] -= 1.0f; + srinput.axis_states[ k_sraxis_mworld_h ][0] -= 1.0f; } if( vg_getkey( SDLK_RIGHT ) ){ srinput.axis_states[ k_sraxis_mbrowse_h ][0] += 1.0f; - srinput.axis_states[ k_sraxis_replay_h ][0] += 1.0f; + srinput.axis_states[ k_sraxis_mworld_h ][0] += 1.0f; } if( vg_input.active_controller_index >= 0 ){ @@ -339,16 +377,21 @@ static void skaterift_preupdate_inputs(void) setbtn( k_srbind_camera, buttons[ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ] ); setbtn( k_srbind_mleft, buttons[ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] ); setbtn( k_srbind_mright, buttons[ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ] ); + setbtn( k_srbind_world_left, buttons[ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] ); + setbtn( k_srbind_world_right,buttons[ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ]); + setbtn( k_srbind_home, buttons[ SDL_CONTROLLER_BUTTON_Y ] ); setbtn( k_srbind_mup, buttons[ SDL_CONTROLLER_BUTTON_DPAD_UP ] ); setbtn( k_srbind_mdown, buttons[ SDL_CONTROLLER_BUTTON_DPAD_DOWN ] ); setbtn( k_srbind_mback, buttons[ SDL_CONTROLLER_BUTTON_B ] ); setbtn( k_srbind_maccept,buttons[ SDL_CONTROLLER_BUTTON_A ] ); setbtn( k_srbind_mopen, buttons[ SDL_CONTROLLER_BUTTON_START ] ); setbtn( k_srbind_mback, buttons[ SDL_CONTROLLER_BUTTON_START ] ); - setbtn( k_srbind_replay_resume, - buttons[ SDL_CONTROLLER_BUTTON_LEFTSHOULDER ] ); - setbtn( k_srbind_replay_play, buttons[ SDL_CONTROLLER_BUTTON_A ] ); + setbtn( k_srbind_replay_resume, buttons[ SDL_CONTROLLER_BUTTON_A ] ); + setbtn( k_srbind_replay_play, buttons[ SDL_CONTROLLER_BUTTON_X ] ); setbtn( k_srbind_replay_freecam, buttons[ SDL_CONTROLLER_BUTTON_Y ] ); + setbtn( k_srbind_sit, buttons[ SDL_CONTROLLER_BUTTON_B ] ); + setbtn( k_srbind_lobby, buttons[ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] ); + // k_srbind_chat float *axis = controller->axises; float *steer = srinput.joystick_states[ k_srjoystick_steer ][0], @@ -368,7 +411,8 @@ static void skaterift_preupdate_inputs(void) axisgrab[0] += vg_maxf( 0.0f, axis[ SDL_CONTROLLER_AXIS_TRIGGERRIGHT ] ); axisbrowseh[0] += axis[ SDL_CONTROLLER_AXIS_LEFTX ]; axisbrowsev[0] += axis[ SDL_CONTROLLER_AXIS_LEFTY ]; - axisreplayh[0] += axis[ SDL_CONTROLLER_AXIS_LEFTX ]; + axisreplayh[0] += vg_maxf(0.0f,axis[SDL_CONTROLLER_AXIS_TRIGGERRIGHT]); + axisreplayh[0] -= vg_maxf(0.0f,axis[SDL_CONTROLLER_AXIS_TRIGGERLEFT]); float lh = axis[ SDL_CONTROLLER_AXIS_LEFTX ], lv = axis[ SDL_CONTROLLER_AXIS_LEFTY ],