gsdx: reduce code duplication for key event

This commit is contained in:
Gregory Hainaut 2016-10-14 19:18:11 +02:00
parent a4658eac24
commit 37a1230c01
1 changed files with 18 additions and 54 deletions

View File

@ -580,11 +580,22 @@ void GSRenderer::EndCapture()
void GSRenderer::KeyEvent(GSKeyEventData* e)
{
#ifdef _WIN32
if(e->type == KEYPRESS)
{
#ifdef _WIN32
int step = (::GetAsyncKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
#elif defined(__unix__)
int step = m_shift_key ? -1 : 1;
#define VK_F5 XK_F5
#define VK_F6 XK_F6
#define VK_F7 XK_F7
#define VK_DELETE XK_Delete
#define VK_INSERT XK_Insert
#define VK_PRIOR XK_Prior
#define VK_HOME XK_Home
#endif
switch(e->key)
{
@ -606,7 +617,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
return;
case VK_INSERT:
m_mipmap = !m_mipmap;
printf("GSdx: (Software) Mipmapping is now %s.\n", m_mipmap ? "enabled" : "disabled");
printf("GSdx: Mipmapping is now %s.\n", m_mipmap ? "enabled" : "disabled");
return;
case VK_PRIOR:
m_fxaa = !m_fxaa;
@ -619,66 +630,19 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
}
}
#elif defined(__unix__)
if(e->type == KEYPRESS)
{
int step = m_shift_key ? -1 : 1;
switch(e->key)
{
case XK_F5:
m_interlace = (m_interlace + s_interlace_nb + step) % s_interlace_nb;
printf("GSdx: Set deinterlace mode to %d (%s).\n", (int)m_interlace, theApp.m_gs_interlace.at(m_interlace).name.c_str());
return;
case XK_F6:
if( m_wnd->IsManaged() )
m_aspectratio = (m_aspectratio + s_aspect_ratio_nb + step) % s_aspect_ratio_nb;
return;
case XK_F7:
m_shader = (m_shader + s_post_shader_nb + step) % s_post_shader_nb;
printf("GSdx: Set shader %d.\n", (int)m_shader);
return;
case XK_Delete:
m_aa1 = !m_aa1;
printf("GSdx: (Software) Edge anti-aliasing is now %s.\n", m_aa1 ? "enabled" : "disabled");
return;
case XK_Insert:
m_mipmap = !m_mipmap;
printf("GSdx: (Software) Mipmapping is now %s.\n", m_mipmap ? "enabled" : "disabled");
return;
case XK_Prior:
m_fxaa = !m_fxaa;
printf("GSdx: FXAA anti-aliasing is now %s.\n", m_fxaa ? "enabled" : "disabled");
return;
case XK_Home:
m_shaderfx = !m_shaderfx;
printf("GSdx: External post-processing is now %s.\n", m_shaderfx ? "enabled" : "disabled");
return;
case XK_Shift_L:
case XK_Shift_R:
m_shift_key = true;
return;
case XK_Control_L:
case XK_Control_R:
m_control_key = true;
return;
}
}
else if(e->type == KEYRELEASE)
{
#if defined(__unix__)
switch(e->key)
{
case XK_Shift_L:
case XK_Shift_R:
m_shift_key = false;
m_shift_key = (e->type == KEYPRESS);
return;
case XK_Control_L:
case XK_Control_R:
m_control_key = false;
m_control_key = (e->type == KEYPRESS);
return;
}
}
#endif
}