canvi de pc
This commit is contained in:
@@ -149,91 +149,93 @@ void Director::loadScoreFile() {
|
||||
|
||||
// Asigna los botones y teclas al objeto Input
|
||||
void Director::bindInputs() {
|
||||
static auto input = Input::get();
|
||||
|
||||
// Teclado - Movimiento del jugador
|
||||
Input::get()->bindKey(Input::Action::UP, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(Input::Action::DOWN, SDL_SCANCODE_DOWN);
|
||||
Input::get()->bindKey(Input::Action::LEFT, SDL_SCANCODE_LEFT);
|
||||
Input::get()->bindKey(Input::Action::RIGHT, SDL_SCANCODE_RIGHT);
|
||||
input->bindKey(Input::Action::UP, SDL_SCANCODE_UP);
|
||||
input->bindKey(Input::Action::DOWN, SDL_SCANCODE_DOWN);
|
||||
input->bindKey(Input::Action::LEFT, SDL_SCANCODE_LEFT);
|
||||
input->bindKey(Input::Action::RIGHT, SDL_SCANCODE_RIGHT);
|
||||
|
||||
// Teclado - Disparo del jugador
|
||||
Input::get()->bindKey(Input::Action::FIRE_LEFT, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(Input::Action::FIRE_CENTER, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(Input::Action::FIRE_RIGHT, SDL_SCANCODE_E);
|
||||
input->bindKey(Input::Action::FIRE_LEFT, SDL_SCANCODE_Q);
|
||||
input->bindKey(Input::Action::FIRE_CENTER, SDL_SCANCODE_W);
|
||||
input->bindKey(Input::Action::FIRE_RIGHT, SDL_SCANCODE_E);
|
||||
|
||||
// Teclado - Interfaz
|
||||
Input::get()->bindKey(Input::Action::START, SDL_SCANCODE_RETURN);
|
||||
input->bindKey(Input::Action::START, SDL_SCANCODE_RETURN);
|
||||
|
||||
// Teclado - Menu de servicio
|
||||
Input::get()->bindKey(Input::Action::SERVICE, SDL_SCANCODE_0);
|
||||
Input::get()->bindKey(Input::Action::SM_SELECT, SDL_SCANCODE_RETURN);
|
||||
Input::get()->bindKey(Input::Action::SM_BACK, SDL_SCANCODE_BACKSPACE);
|
||||
input->bindKey(Input::Action::SERVICE, SDL_SCANCODE_0);
|
||||
input->bindKey(Input::Action::SM_SELECT, SDL_SCANCODE_RETURN);
|
||||
input->bindKey(Input::Action::SM_BACK, SDL_SCANCODE_BACKSPACE);
|
||||
|
||||
// Teclado - Control del programa
|
||||
Input::get()->bindKey(Input::Action::EXIT, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(Input::Action::PAUSE, SDL_SCANCODE_P);
|
||||
Input::get()->bindKey(Input::Action::BACK, SDL_SCANCODE_BACKSPACE);
|
||||
input->bindKey(Input::Action::EXIT, SDL_SCANCODE_ESCAPE);
|
||||
input->bindKey(Input::Action::PAUSE, SDL_SCANCODE_P);
|
||||
input->bindKey(Input::Action::BACK, SDL_SCANCODE_BACKSPACE);
|
||||
|
||||
Input::get()->bindKey(Input::Action::WINDOW_DEC_SIZE, SDL_SCANCODE_F1);
|
||||
Input::get()->bindKey(Input::Action::WINDOW_INC_SIZE, SDL_SCANCODE_F2);
|
||||
Input::get()->bindKey(Input::Action::WINDOW_FULLSCREEN, SDL_SCANCODE_F3);
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_VIDEO_SHADERS, SDL_SCANCODE_F4);
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5);
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_VIDEO_VSYNC, SDL_SCANCODE_F6);
|
||||
input->bindKey(Input::Action::WINDOW_DEC_SIZE, SDL_SCANCODE_F1);
|
||||
input->bindKey(Input::Action::WINDOW_INC_SIZE, SDL_SCANCODE_F2);
|
||||
input->bindKey(Input::Action::WINDOW_FULLSCREEN, SDL_SCANCODE_F3);
|
||||
input->bindKey(Input::Action::TOGGLE_VIDEO_SHADERS, SDL_SCANCODE_F4);
|
||||
input->bindKey(Input::Action::TOGGLE_VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5);
|
||||
input->bindKey(Input::Action::TOGGLE_VIDEO_VSYNC, SDL_SCANCODE_F6);
|
||||
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_AUDIO, SDL_SCANCODE_F7);
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_AUTO_FIRE, SDL_SCANCODE_F8);
|
||||
Input::get()->bindKey(Input::Action::CHANGE_LANG, SDL_SCANCODE_F9);
|
||||
input->bindKey(Input::Action::TOGGLE_AUDIO, SDL_SCANCODE_F7);
|
||||
input->bindKey(Input::Action::TOGGLE_AUTO_FIRE, SDL_SCANCODE_F8);
|
||||
input->bindKey(Input::Action::CHANGE_LANG, SDL_SCANCODE_F9);
|
||||
|
||||
Input::get()->bindKey(Input::Action::RESET, SDL_SCANCODE_F10);
|
||||
Input::get()->bindKey(Input::Action::SHOW_INFO, SDL_SCANCODE_F12);
|
||||
input->bindKey(Input::Action::RESET, SDL_SCANCODE_F10);
|
||||
input->bindKey(Input::Action::SHOW_INFO, SDL_SCANCODE_F12);
|
||||
|
||||
// Asigna botones a inputs
|
||||
const int NUM_GAMEPADS = Input::get()->getNumControllers();
|
||||
for (int i = 0; i < NUM_GAMEPADS; ++i) {
|
||||
auto gamepads = input->getGamepads();
|
||||
for (auto &gamepad : gamepads) {
|
||||
// Mando - Movimiento del jugador
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::UP, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::UP, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||
|
||||
// Mando - Disparo del jugador
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::FIRE_LEFT, SDL_GAMEPAD_BUTTON_WEST);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::FIRE_CENTER, SDL_GAMEPAD_BUTTON_NORTH);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_EAST);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::FIRE_LEFT, SDL_GAMEPAD_BUTTON_WEST);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::FIRE_CENTER, SDL_GAMEPAD_BUTTON_NORTH);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_EAST);
|
||||
|
||||
// Mando - Interfaz
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::START, SDL_GAMEPAD_BUTTON_START);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::SERVICE, SDL_GAMEPAD_BUTTON_BACK);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::START, SDL_GAMEPAD_BUTTON_START);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::SERVICE, SDL_GAMEPAD_BUTTON_BACK);
|
||||
}
|
||||
|
||||
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
|
||||
const size_t MAX_CONTROLLERS = std::min(2, NUM_GAMEPADS);
|
||||
for (size_t i = 0; i < MAX_CONTROLLERS; ++i) {
|
||||
for (auto &controller : Options::controllers) {
|
||||
if (Input::get()->getControllerName(i) == controller.name) {
|
||||
if (input->getControllerName(i) == controller.name) {
|
||||
for (size_t j = 0; j < controller.inputs.size(); ++j) {
|
||||
Input::get()->bindGameControllerButton(i, controller.inputs.at(j), controller.buttons.at(j));
|
||||
input->bindGameControllerButton(i, controller.inputs.at(j), controller.buttons.at(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Asigna botones a inputs desde otros inputs
|
||||
for (int i = 0; i < NUM_GAMEPADS; ++i) {
|
||||
for (auto &gamepad : gamepads) {
|
||||
// Mando - Menu de servicio
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::SM_SELECT, Input::Action::FIRE_LEFT);
|
||||
Input::get()->bindGameControllerButton(i, Input::Action::SM_BACK, Input::Action::FIRE_CENTER);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::SM_SELECT, Input::Action::FIRE_LEFT);
|
||||
input->bindGameControllerButton(gamepad, Input::Action::SM_BACK, Input::Action::FIRE_CENTER);
|
||||
}
|
||||
|
||||
// Guarda las asignaciones de botones en las opciones de los dos primeros mandos
|
||||
for (size_t i = 0; i < MAX_CONTROLLERS; ++i) {
|
||||
// Variables asociadas al mando
|
||||
Options::controllers.at(i).index = i;
|
||||
Options::controllers.at(i).name = Input::get()->getControllerName(i);
|
||||
Options::controllers.at(i).name = input->getControllerName(i);
|
||||
Options::controllers.at(i).plugged = true;
|
||||
// Asignaciones de botones
|
||||
for (size_t j = 0; j < Options::controllers.at(i).inputs.size(); ++j) {
|
||||
Options::controllers.at(i).buttons.at(j) = Input::get()->getControllerBinding(i, Options::controllers.at(i).inputs.at(j));
|
||||
Options::controllers.at(i).buttons.at(j) = input->getControllerBinding(i, Options::controllers.at(i).inputs.at(j));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user