@@ -273,6 +273,23 @@ int console_cmd_god(game_state *gs, int argc, char **argv) {
273273 return 0 ;
274274}
275275
276+ int console_keypress (game_state * gs , int argc , char * * argv ) {
277+ SDL_Event sdlevent ;
278+ memset (& sdlevent , 0 , sizeof (sdlevent ));
279+ sdlevent .type = SDL_KEYDOWN ;
280+ sdlevent .key .keysym .sym = SDLK_DOWN ;
281+ sdlevent .key .keysym .scancode = SDL_SCANCODE_DOWN ;
282+ SDL_PushEvent (& sdlevent );
283+
284+ Uint8 * state = (Uint8 * )SDL_GetKeyboardState (NULL );
285+ state [SDL_SCANCODE_DOWN ] = 1 ;
286+
287+ con -> keypress_time = 20 ;
288+ con -> keypress_scancode = SDL_SCANCODE_DOWN ;
289+
290+ return 0 ;
291+ }
292+
276293int console_kreissack (game_state * gs , int argc , char * * argv ) {
277294 game_player * p1 = game_state_get_player (gs , 0 );
278295 p1 -> sp_wins = (2046 ^ (2 << p1 -> pilot -> pilot_id ));
@@ -472,6 +489,7 @@ void console_init_cmd(void) {
472489 console_add_cmd ("stun" , & console_cmd_stun , "Stun the other player" );
473490 console_add_cmd ("rein" , & console_cmd_rein , "R-E-I-N!" );
474491 console_add_cmd ("god" , & console_cmd_god , "Enable god mode" );
492+ console_add_cmd ("keypress" , & console_keypress , "Push a keypress into the input queue" );
475493 console_add_cmd ("kreissack" , & console_kreissack , "Fight Kreissack" );
476494 console_add_cmd ("ez-destruct" , & console_cmd_ez_destruct , "Punch = destruction, kick = scrap" );
477495 console_add_cmd ("warp" , & console_toggle_warp , "Toggle warp speed" );
0 commit comments