Godzil b2b066ba22 Change button name to proper name and add missing (Seriously why it was missing?) support for the Y buttons.
Removed the "flipped" flag as it should not be part of the IO logic.
2019-09-10 16:00:55 +01:00

203 lines
2.5 KiB
C

static int testJoystick=1;
if (testJoystick==1)
{
testJoystick=0;
fprintf(log_get(),"%i joysticks were found.\n\n", SDL_NumJoysticks() );
fprintf(log_get(),"The names of the joysticks are:\n");
for(int tti=0; tti < SDL_NumJoysticks(); tti++ )
{
fprintf(log_get()," %s\n", SDL_JoystickName(tti));
}
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
}
else
{
if (joystick!=NULL)
{
SDL_JoystickClose(0);
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
}
}
while ( SDL_PollEvent(&app_input_event) )
{
if ( app_input_event.type == SDL_QUIT )
{
ws_key_esc = 1;
}
}
if (joystick)
{
if (SDL_JoystickGetButton(joystick,0))
{
ws_key_start=1;
}
else
{
ws_key_start=0;
}
if (SDL_JoystickGetButton(joystick,1))
{
ws_key_button_a=1;
}
else
{
ws_key_button_a=0;
}
if (SDL_JoystickGetButton(joystick,2))
{
ws_key_button_b=1;
}
else
{
ws_key_button_b=0;
}
if (SDL_JoystickGetAxis(joystick,0)<-7000)
{
ws_key_x4=1;
}
else
{
ws_key_x4=0;
}
if (SDL_JoystickGetAxis(joystick,0)>7000)
{
ws_key_x2=1;
}
else
{
ws_key_x2=0;
}
if (SDL_JoystickGetAxis(joystick,1)<-7000)
{
ws_key_x1=1;
}
else
{
ws_key_x1=0;
}
if (SDL_JoystickGetAxis(joystick,1)>7000)
{
ws_key_x3=1;
}
else
{
ws_key_x3=0;
}
ws_key_y4=0;
ws_key_y2=0;
ws_key_y1=0;
ws_key_y3=0;
}
else
{
ws_key_start=0;
ws_key_x4=0;
ws_key_x2=0;
ws_key_x1=0;
ws_key_x3=0;
ws_key_y4=0;
ws_key_y2=0;
ws_key_y1=0;
ws_key_y3=0;
ws_key_button_a=0;
ws_key_button_b=0;
}
uint8 *keystate = SDL_GetKeyState(NULL);
if ( keystate[SDLK_e])
{
dump_memory();
}
if ( keystate[SDLK_r])
{
printf("Boop\n");
ws_reset();
}
if ( keystate[SDLK_ESCAPE] )
{
ws_key_esc = 1;
}
if ( keystate[SDLK_UP] )
{
ws_key_x1=1;
}
if ( keystate[SDLK_DOWN] )
{
ws_key_x3=1;
}
if ( keystate[SDLK_RIGHT] )
{
ws_key_x2=1;
}
if ( keystate[SDLK_LEFT] )
{
ws_key_x4=1;
}
if (keystate[SDLK_RETURN])
{
ws_key_start=1;
}
if (keystate[SDLK_c])
{
ws_key_button_a=1;
}
if (keystate[SDLK_x])
{
ws_key_button_b=1;
}
if (keystate[SDLK_w])
{
ws_key_y1=1;
}
if (keystate[SDLK_a])
{
ws_key_y4=1;
}
if (keystate[SDLK_s])
{
ws_key_y3=1;
}
if (keystate[SDLK_d])
{
ws_key_y2=1;
}
if (keystate[SDLK_o])
{
ws_cyclesByLine+=10;
}
if (keystate[SDLK_l])
{
ws_cyclesByLine-=10;
}