follat!
This commit is contained in:
@@ -128,7 +128,7 @@ void Director::initInput()
|
||||
|
||||
input->bindKey(input_start, SDL_SCANCODE_RETURN);
|
||||
|
||||
// Teclado - Otros
|
||||
// Teclado - Control del programa
|
||||
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||||
input->bindKey(input_pause, SDL_SCANCODE_P);
|
||||
input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
||||
@@ -139,6 +139,7 @@ void Director::initInput()
|
||||
input->bindKey(input_showinfo, SDL_SCANCODE_F6);
|
||||
input->bindKey(input_reset, SDL_SCANCODE_F10);
|
||||
|
||||
// Asigna botones a inputs
|
||||
const int numGamePads = input->getNumControllers();
|
||||
for (int i = 0; i < numGamePads; ++i)
|
||||
{
|
||||
@@ -154,8 +155,16 @@ void Director::initInput()
|
||||
|
||||
input->bindGameControllerButton(i, input_start, SDL_CONTROLLER_BUTTON_START);
|
||||
|
||||
// Mando - Otros
|
||||
// Mando - Control del programa
|
||||
input->bindGameControllerButton(i, input_service, SDL_CONTROLLER_BUTTON_BACK);
|
||||
input->bindGameControllerButton(i, input_exit, input_start);
|
||||
input->bindGameControllerButton(i, input_pause, input_fire_right);
|
||||
input->bindGameControllerButton(i, input_video_shaders, input_fire_left);
|
||||
input->bindGameControllerButton(i, input_mute, input_left);
|
||||
input->bindGameControllerButton(i, input_showinfo, input_right);
|
||||
input->bindGameControllerButton(i, input_reset, input_fire_center);
|
||||
input->bindGameControllerButton(i, input_config, input_down);
|
||||
input->bindGameControllerButton(i, input_swap_controllers, input_up);
|
||||
}
|
||||
|
||||
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
|
||||
@@ -167,13 +176,26 @@ void Director::initInput()
|
||||
input->bindGameControllerButton(i, options->controller[index].inputs[j], options->controller[index].buttons[j]);
|
||||
}
|
||||
|
||||
// Modifica las opciones para colocar los valores asignados
|
||||
for (int index = 0; index < numGamePads; ++index)
|
||||
// Asigna botones a inputs desde otros inputs
|
||||
for (int i = 0; i < numGamePads; ++i)
|
||||
{
|
||||
options->controller[index].name = input->getControllerName(index);
|
||||
for (int j = 0; j < (int)options->controller[index].inputs.size(); ++j)
|
||||
input->bindGameControllerButton(i, input_exit, input_start);
|
||||
input->bindGameControllerButton(i, input_reset, input_fire_center);
|
||||
input->bindGameControllerButton(i, input_pause, input_fire_right);
|
||||
input->bindGameControllerButton(i, input_video_shaders, input_fire_left);
|
||||
input->bindGameControllerButton(i, input_mute, input_left);
|
||||
input->bindGameControllerButton(i, input_showinfo, input_right);
|
||||
input->bindGameControllerButton(i, input_config, input_down);
|
||||
input->bindGameControllerButton(i, input_swap_controllers, input_up);
|
||||
}
|
||||
|
||||
// Guarda las asignaciones de botones en las opciones
|
||||
for (int i = 0; i < numGamePads; ++i)
|
||||
{
|
||||
options->controller[i].name = input->getControllerName(i);
|
||||
for (int j = 0; j < (int)options->controller[i].inputs.size(); ++j)
|
||||
{
|
||||
options->controller[index].buttons[j] = input->getControllerBinding(index, options->controller[index].inputs[j]);
|
||||
options->controller[i].buttons[j] = input->getControllerBinding(i, options->controller[i].inputs[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,6 +528,7 @@ void Director::initOptions()
|
||||
c.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
c.name = "NO NAME";
|
||||
|
||||
// Inputs que se guardan en las opciones y, por tanto, a disco
|
||||
c.inputs.clear();
|
||||
c.inputs.push_back(input_fire_left);
|
||||
c.inputs.push_back(input_fire_center);
|
||||
@@ -513,6 +536,7 @@ void Director::initOptions()
|
||||
c.inputs.push_back(input_start);
|
||||
c.inputs.push_back(input_service);
|
||||
|
||||
// Botones asociados a los inputs anteriores
|
||||
c.buttons.clear();
|
||||
c.buttons.push_back(SDL_CONTROLLER_BUTTON_X);
|
||||
c.buttons.push_back(SDL_CONTROLLER_BUTTON_Y);
|
||||
@@ -777,11 +801,11 @@ bool Director::saveConfigFile()
|
||||
const std::string joyIndex = std::to_string(index + 1);
|
||||
file << "controller" + joyIndex + ".name=" + options->controller[index].name + "\n";
|
||||
file << "controller" + joyIndex + ".player=" + std::to_string(options->controller[index].playerId) + "\n";
|
||||
file << "controller" + joyIndex + ".inputs.fire_left=" + std::to_string((int)options->controller[index].buttons[0]) + "\n";
|
||||
file << "controller" + joyIndex + ".inputs.fire_center=" + std::to_string((int)options->controller[index].buttons[1]) + "\n";
|
||||
file << "controller" + joyIndex + ".inputs.fire_right=" + std::to_string((int)options->controller[index].buttons[2]) + "\n";
|
||||
file << "controller" + joyIndex + ".inputs.start=" + std::to_string((int)options->controller[index].buttons[3]) + "\n";
|
||||
file << "controller" + joyIndex + ".inputs.service=" + std::to_string((int)options->controller[index].buttons[4]) + "\n";
|
||||
file << "controller" + joyIndex + ".button.fire_left=" + std::to_string((int)options->controller[index].buttons[0]) + "\n";
|
||||
file << "controller" + joyIndex + ".button.fire_center=" + std::to_string((int)options->controller[index].buttons[1]) + "\n";
|
||||
file << "controller" + joyIndex + ".button.fire_right=" + std::to_string((int)options->controller[index].buttons[2]) + "\n";
|
||||
file << "controller" + joyIndex + ".button.start=" + std::to_string((int)options->controller[index].buttons[3]) + "\n";
|
||||
file << "controller" + joyIndex + ".button.service=" + std::to_string((int)options->controller[index].buttons[4]) + "\n";
|
||||
|
||||
if (index < numPlayers - 1)
|
||||
{
|
||||
@@ -1073,27 +1097,27 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
options->controller[0].playerId = std::max(1, std::min(2, std::stoi(value)));
|
||||
}
|
||||
|
||||
else if (var == "controller1.inputs.fire_left")
|
||||
else if (var == "controller1.button.fire_left")
|
||||
{
|
||||
options->controller[0].buttons[0] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller1.inputs.fire_center")
|
||||
else if (var == "controller1.button.fire_center")
|
||||
{
|
||||
options->controller[0].buttons[1] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller1.inputs.fire_right")
|
||||
else if (var == "controller1.button.fire_right")
|
||||
{
|
||||
options->controller[0].buttons[2] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller1.inputs.start")
|
||||
else if (var == "controller1.button.start")
|
||||
{
|
||||
options->controller[0].buttons[3] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller1.inputs.service")
|
||||
else if (var == "controller1.button.service")
|
||||
{
|
||||
options->controller[0].buttons[4] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
@@ -1108,27 +1132,27 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
options->controller[1].playerId = std::max(1, std::min(2, std::stoi(value)));
|
||||
}
|
||||
|
||||
else if (var == "controller2.inputs.fire_left")
|
||||
else if (var == "controller2.button.fire_left")
|
||||
{
|
||||
options->controller[1].buttons[0] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller2.inputs.fire_center")
|
||||
else if (var == "controller2.button.fire_center")
|
||||
{
|
||||
options->controller[1].buttons[1] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller2.inputs.fire_right")
|
||||
else if (var == "controller2.button.fire_right")
|
||||
{
|
||||
options->controller[1].buttons[2] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller2.inputs.start")
|
||||
else if (var == "controller2.button.start")
|
||||
{
|
||||
options->controller[1].buttons[3] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "controller2.inputs.service")
|
||||
else if (var == "controller2.button.service")
|
||||
{
|
||||
options->controller[1].buttons[4] = (SDL_GameControllerButton)std::stoi(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user