Move set_keybinds autoconfiguration (that is done on every console

port) to driver.c - reducing lots of duplicate code
This commit is contained in:
twinaphex 2013-03-16 17:24:24 +01:00
parent fb1355b975
commit c26653fca8
5 changed files with 32 additions and 121 deletions

View File

@ -895,12 +895,44 @@ void init_video_input(void)
RARCH_ERR("Cannot init input driver. Exiting ...\n");
rarch_fail(1, "init_video_input()");
}
}
else
{
RARCH_ERR("Cannot find input driver. Exiting ...\n");
rarch_fail(1, "init_video_input()");
}
if (driver.input != NULL)
{
for(unsigned i = 0; i < MAX_PLAYERS; i++)
{
unsigned action = 0;
if (driver.input->set_keybinds)
action |= (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS);
switch (g_settings.input.dpad_emulation[i])
{
case ANALOG_DPAD_LSTICK:
action |= (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
break;
case ANALOG_DPAD_RSTICK:
action |= (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
break;
case ANALOG_DPAD_NONE:
action |= (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
break;
default:
break;
}
if (action)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
action);
}
}
}
#ifdef HAVE_OVERLAY

View File

@ -446,37 +446,6 @@ static void *gx_input_init(void)
SYS_SetPowerCallback(power_callback);
#endif
for(unsigned i = 0; i < MAX_PLAYERS; i++)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
for(unsigned i = 0; i < MAX_PLAYERS; i++)
{
unsigned keybind_action = 0;
switch (g_settings.input.dpad_emulation[i])
{
case ANALOG_DPAD_LSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
break;
case ANALOG_DPAD_RSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
break;
case ANALOG_DPAD_NONE:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
break;
default:
break;
}
if (keybind_action)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
keybind_action);
}
return (void*)-1;
}

View File

@ -513,36 +513,6 @@ static void* ps3_input_init(void)
cellMouseInit(MAX_MICE);
#endif
for(unsigned i = 0; i < MAX_PLAYERS; i++)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
for(unsigned i = 0; i < MAX_PLAYERS; i++)
{
unsigned keybind_action = 0;
switch (g_settings.input.dpad_emulation[i])
{
case ANALOG_DPAD_LSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
break;
case ANALOG_DPAD_RSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
break;
case ANALOG_DPAD_NONE:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
break;
default:
break;
}
if (keybind_action)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
keybind_action);
}
return (void*)-1;
}

View File

@ -167,36 +167,6 @@ static void* psp_input_initialize(void)
#endif
sceCtrlSetSamplingMode(DEFAULT_SAMPLING_MODE);
for(unsigned i = 0; i < MAX_PLAYERS; i++)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
for(unsigned i = 0; i < MAX_PLAYERS; i++)
{
unsigned keybind_action = 0;
switch (g_settings.input.dpad_emulation[i])
{
case ANALOG_DPAD_LSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
break;
case ANALOG_DPAD_RSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
break;
case ANALOG_DPAD_NONE:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
break;
default:
break;
}
if (keybind_action)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
action);
}
return (void*)-1;
}

View File

@ -399,36 +399,6 @@ static void *xdk_input_init(void)
while(XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY) {}
#endif
for(unsigned i = 0; i < MAX_PLAYERS; i++)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
for(unsigned i = 0; i < MAX_PLAYERS; i++)
{
unsigned keybind_action = 0;
switch (g_settings.input.dpad_emulation[i])
{
case ANALOG_DPAD_LSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
break;
case ANALOG_DPAD_RSTICK:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
break;
case ANALOG_DPAD_NONE:
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
break;
default:
break;
}
if (keybind_action)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
keybind_action);
}
return (void*)-1;
}