diff --git a/pfba/deps/libcross2d/src/3ds/ctr_input.cpp b/pfba/deps/libcross2d/src/3ds/ctr_input.cpp index e05a9c4..1328528 100644 --- a/pfba/deps/libcross2d/src/3ds/ctr_input.cpp +++ b/pfba/deps/libcross2d/src/3ds/ctr_input.cpp @@ -56,7 +56,7 @@ int CTRInput::GetButton(int player) { return -1; } -Input::Player *CTRInput::Update(bool rotate) { +Input::Player *CTRInput::Update(int rotate) { for (int i = 0; i < PLAYER_COUNT; i++) { players[i].state = 0; @@ -82,7 +82,7 @@ Input::Player *CTRInput::Update(bool rotate) { return players; } -void CTRInput::process_buttons(Input::Player &player, bool rotate) { +void CTRInput::process_buttons(Input::Player &player, int rotate) { if (!player.enabled) { return; @@ -98,13 +98,29 @@ void CTRInput::process_buttons(Input::Player &player, bool rotate) { if (held & BIT(mapping)) { if (rotate && key_id[i] == Input::Key::KEY_UP) { - player.state |= Input::Key::KEY_RIGHT; + if (rotate == 1) { + player.state |= Input::Key::KEY_RIGHT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_LEFT; + } } else if (rotate && key_id[i] == Input::Key::KEY_DOWN) { - player.state |= Input::Key::KEY_LEFT; + if (rotate == 1) { + player.state |= Input::Key::KEY_LEFT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_RIGHT; + } } else if (rotate && key_id[i] == Input::Key::KEY_LEFT) { - player.state |= Input::Key::KEY_UP; + if (rotate == 1) { + player.state |= Input::Key::KEY_UP; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_DOWN; + } } else if (rotate && key_id[i] == Input::Key::KEY_RIGHT) { - player.state |= Input::Key::KEY_DOWN; + if (rotate == 1) { + player.state |= Input::Key::KEY_DOWN; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_UP; + } } else { player.state |= key_id[i]; } diff --git a/pfba/deps/libcross2d/src/3ds/ctr_input.h b/pfba/deps/libcross2d/src/3ds/ctr_input.h index 1caad1f..8104410 100644 --- a/pfba/deps/libcross2d/src/3ds/ctr_input.h +++ b/pfba/deps/libcross2d/src/3ds/ctr_input.h @@ -13,11 +13,11 @@ class CTRInput : Input { CTRInput(); virtual ~CTRInput(); - virtual Player *Update(bool rotate = false); + virtual Player *Update(int rotate = 0); virtual int GetButton(int player); private: - virtual void process_buttons(Input::Player &player, bool rotate = false); + virtual void process_buttons(Input::Player &player, int rotate = 0); }; diff --git a/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp b/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp index c67ff80..ea732a4 100644 --- a/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp +++ b/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp @@ -80,7 +80,7 @@ int SDL2Input::GetButton(int player) { return -1; } -Input::Player *SDL2Input::Update(bool rotate) { +Input::Player *SDL2Input::Update(int rotate) { for (int i = 0; i < PLAYER_COUNT; i++) { players[i].state = 0; @@ -116,7 +116,7 @@ Input::Player *SDL2Input::Update(bool rotate) { return players; } -void SDL2Input::process_axis(Input::Player &player, bool rotate) { +void SDL2Input::process_axis(Input::Player &player, int rotate) { if (!player.enabled || !player.data) { return; @@ -126,22 +126,22 @@ void SDL2Input::process_axis(Input::Player &player, bool rotate) { SDL_JoystickGetAxis((SDL_Joystick *) player.data, player.axis_rx)}; if (x[0] > player.dead_zone || x[1] > player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_DOWN : Input::Key::KEY_RIGHT; + player.state |= (rotate == 1) ? Input::Key::KEY_DOWN : (rotate == 3) ? Input::Key::KEY_UP : Input::Key::KEY_RIGHT; } else if (x[0] < -player.dead_zone || x[1] < -player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_UP : Input::Key::KEY_LEFT; + player.state |= (rotate == 1) ? Input::Key::KEY_UP : (rotate == 3) ? Input::Key::KEY_DOWN : Input::Key::KEY_LEFT; } int y[2] = {SDL_JoystickGetAxis((SDL_Joystick *) player.data, player.axis_ly), SDL_JoystickGetAxis((SDL_Joystick *) player.data, player.axis_ry)}; if (y[0] > player.dead_zone || y[1] > player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_LEFT : Input::Key::KEY_DOWN; + player.state |= (rotate == 1) ? Input::Key::KEY_LEFT : (rotate == 3) ? Input::Key::KEY_RIGHT : Input::Key::KEY_DOWN; } else if (y[0] < -player.dead_zone || y[1] < -player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_RIGHT : Input::Key::KEY_UP; + player.state |= (rotate == 1) ? Input::Key::KEY_RIGHT : (rotate == 3) ? Input::Key::KEY_LEFT : Input::Key::KEY_UP; } } -void SDL2Input::process_hat(Input::Player &player, bool rotate) { +void SDL2Input::process_hat(Input::Player &player, int rotate) { if (!player.enabled || !player.data) { return; @@ -152,26 +152,26 @@ void SDL2Input::process_hat(Input::Player &player, bool rotate) { if (value == SDL_HAT_UP || value == SDL_HAT_LEFTUP || value == SDL_HAT_RIGHTUP) { - player.state |= rotate ? Input::Key::KEY_RIGHT : Input::Key::KEY_UP; + player.state |= (rotate == 1) ? Input::Key::KEY_RIGHT : (rotate == 3) ? Input::Key::KEY_LEFT : Input::Key::KEY_UP; } if (value == SDL_HAT_DOWN || value == SDL_HAT_LEFTDOWN || value == SDL_HAT_RIGHTDOWN) { - player.state |= rotate ? Input::Key::KEY_LEFT : Input::Key::KEY_DOWN; + player.state |= (rotate == 1) ? Input::Key::KEY_LEFT : (rotate == 3) ? Input::Key::KEY_RIGHT : Input::Key::KEY_DOWN; } if (value == SDL_HAT_LEFT || value == SDL_HAT_LEFTDOWN || value == SDL_HAT_LEFTUP) { - player.state |= rotate ? Input::Key::KEY_UP : Input::Key::KEY_LEFT; + player.state |= (rotate == 1) ? Input::Key::KEY_UP : (rotate == 3) ? Input::Key::KEY_DOWN : Input::Key::KEY_LEFT; } if (value == SDL_HAT_RIGHT || value == SDL_HAT_RIGHTDOWN || value == SDL_HAT_RIGHTUP) { - player.state |= rotate ? Input::Key::KEY_DOWN : Input::Key::KEY_RIGHT; + player.state |= (rotate == 1) ? Input::Key::KEY_DOWN : (rotate == 3) ? Input::Key::KEY_UP : Input::Key::KEY_RIGHT; } } -void SDL2Input::process_buttons(Input::Player &player, bool rotate) { +void SDL2Input::process_buttons(Input::Player &player, int rotate) { if (!player.enabled || !player.data) { return; @@ -183,7 +183,7 @@ void SDL2Input::process_buttons(Input::Player &player, bool rotate) { #ifdef __PSP2__ // rotate buttons on ps vita to play in portrait mode - if (rotate) { + if (rotate == 1) { switch (mapping) { case 2: // PSP2_CROSS (SDL-Vita) mapping = 1; // PSP2_CIRCLE (SDL-Vita) @@ -200,18 +200,52 @@ void SDL2Input::process_buttons(Input::Player &player, bool rotate) { default: break; } + } else if (rotate == 3) { + switch (mapping) { + case 2: // PSP2_CROSS (SDL-Vita) + mapping = 3; // PSP2_SQUARE (SDL-Vita) + break; + case 3: // PSP2_SQUARE (SDL-Vita) + mapping = 0; // PSP2_TRIANGLE (SDL-Vita) + break; + case 0: // PSP2_TRIANGLE (SDL-Vita) + mapping = 1; // PSP2_CIRCLE (SDL-Vita) + break; + case 1: // PSP2_CIRCLE (SDL-Vita) + mapping = 2; // PSP2_CROSS (SDL-Vita) + break; + default: + break; + } } + #endif if (SDL_JoystickGetButton((SDL_Joystick *) player.data, mapping)) { if (rotate && key_id[i] == Input::Key::KEY_UP) { - player.state |= Input::Key::KEY_RIGHT; + if (rotate == 1) { + player.state |= Input::Key::KEY_RIGHT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_LEFT; + } } else if (rotate && key_id[i] == Input::Key::KEY_DOWN) { - player.state |= Input::Key::KEY_LEFT; + if (rotate == 1) { + player.state |= Input::Key::KEY_LEFT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_RIGHT; + } } else if (rotate && key_id[i] == Input::Key::KEY_LEFT) { - player.state |= Input::Key::KEY_UP; + if (rotate == 1) { + player.state |= Input::Key::KEY_UP; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_DOWN; + } } else if (rotate && key_id[i] == Input::Key::KEY_RIGHT) { - player.state |= Input::Key::KEY_DOWN; + if (rotate == 1) { + player.state |= Input::Key::KEY_DOWN; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_UP; + } } else { player.state |= key_id[i]; } @@ -219,20 +253,36 @@ void SDL2Input::process_buttons(Input::Player &player, bool rotate) { } } -void SDL2Input::process_keyboard(Input::Player &player, bool rotate) { +void SDL2Input::process_keyboard(Input::Player &player, int rotate) { const Uint8 *keys = SDL_GetKeyboardState(NULL); for (int i = 0; i < KEY_COUNT; i++) { if (keys[keyboard.mapping[i]]) { if (rotate && key_id[i] == Input::Key::KEY_UP) { - player.state |= Input::Key::KEY_RIGHT; + if (rotate == 1) { + player.state |= Input::Key::KEY_RIGHT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_LEFT; + } } else if (rotate && key_id[i] == Input::Key::KEY_DOWN) { - player.state |= Input::Key::KEY_LEFT; + if (rotate == 1) { + player.state |= Input::Key::KEY_LEFT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_RIGHT; + } } else if (rotate && key_id[i] == Input::Key::KEY_LEFT) { - player.state |= Input::Key::KEY_UP; + if (rotate == 1) { + player.state |= Input::Key::KEY_UP; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_DOWN; + } } else if (rotate && key_id[i] == Input::Key::KEY_RIGHT) { - player.state |= Input::Key::KEY_DOWN; + if (rotate == 1) { + player.state |= Input::Key::KEY_DOWN; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_UP; + } } else { player.state |= key_id[i]; } diff --git a/pfba/deps/libcross2d/src/sdl2/sdl2_input.h b/pfba/deps/libcross2d/src/sdl2/sdl2_input.h index af36bad..f7ee6fa 100644 --- a/pfba/deps/libcross2d/src/sdl2/sdl2_input.h +++ b/pfba/deps/libcross2d/src/sdl2/sdl2_input.h @@ -14,14 +14,14 @@ class SDL2Input : Input { SDL2Input(); virtual ~SDL2Input(); - virtual Player *Update(bool rotate = false); + virtual Player *Update(int rotate = 0); virtual int GetButton(int player); private: - virtual void process_axis(Input::Player& player, bool rotate = false); - virtual void process_hat(Input::Player& player, bool rotate = false); - virtual void process_buttons(Input::Player &player, bool rotate = false); - virtual void process_keyboard(Input::Player& player, bool rotate = false); + virtual void process_axis(Input::Player& player, int rotate = 0); + virtual void process_hat(Input::Player& player, int rotate = 0); + virtual void process_buttons(Input::Player &player, int rotate = 0); + virtual void process_keyboard(Input::Player& player, int rotate = 0); }; diff --git a/pfba/deps/libcross2d/src/sfml/sfml_input.cpp b/pfba/deps/libcross2d/src/sfml/sfml_input.cpp index 02f3602..9ee72f9 100644 --- a/pfba/deps/libcross2d/src/sfml/sfml_input.cpp +++ b/pfba/deps/libcross2d/src/sfml/sfml_input.cpp @@ -74,7 +74,7 @@ int SFMLInput::GetButton(int player) { return -1; } -Input::Player *SFMLInput::Update(bool rotate) { +Input::Player *SFMLInput::Update(int rotate) { for (int i = 0; i < PLAYER_COUNT; i++) { players[i].state = 0; @@ -125,7 +125,7 @@ Input::Player *SFMLInput::Update(bool rotate) { return players; } -void SFMLInput::process_axis(Input::Player &player, bool rotate) { +void SFMLInput::process_axis(Input::Player &player, int rotate) { if (!player.enabled) { return; @@ -135,9 +135,9 @@ void SFMLInput::process_axis(Input::Player &player, bool rotate) { if (sf::Joystick::hasAxis(player.id, sf::Joystick::X)) { int x = (int) sf::Joystick::getAxisPosition(player.id, sf::Joystick::X) * 320; if (x > player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_DOWN : Input::Key::KEY_RIGHT; + player.state |= (rotate == 1) ? Input::Key::KEY_DOWN : (rotate == 3) ? Input::Key::KEY_UP : Input::Key::KEY_RIGHT; } else if (x < -player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_UP : Input::Key::KEY_LEFT; + player.state |= (rotate == 1) ? Input::Key::KEY_UP : (rotate == 3) ? Input::Key::KEY_DOWN : Input::Key::KEY_LEFT; } } @@ -145,14 +145,14 @@ void SFMLInput::process_axis(Input::Player &player, bool rotate) { if (sf::Joystick::hasAxis(player.id, sf::Joystick::Y)) { int y = (int) sf::Joystick::getAxisPosition(player.id, sf::Joystick::Y) * 320; if (y > player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_LEFT : Input::Key::KEY_DOWN; + player.state |= (rotate == 1) ? Input::Key::KEY_LEFT : (rotate == 3) ? Input::Key::KEY_RIGHT : Input::Key::KEY_DOWN; } else if (y < -player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_RIGHT : Input::Key::KEY_UP; + player.state |= (rotate == 1) ? Input::Key::KEY_RIGHT : (rotate == 3) ? Input::Key::KEY_LEFT : Input::Key::KEY_UP; } } } -void SFMLInput::process_hat(Input::Player &player, bool rotate) { +void SFMLInput::process_hat(Input::Player &player, int rotate) { if (!player.enabled) { return; @@ -162,9 +162,9 @@ void SFMLInput::process_hat(Input::Player &player, bool rotate) { if (sf::Joystick::hasAxis(player.id, sf::Joystick::PovX)) { int x = (int) sf::Joystick::getAxisPosition(player.id, sf::Joystick::PovX) * 320; if (x > player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_DOWN : Input::Key::KEY_RIGHT; + player.state |= (rotate == 1) ? Input::Key::KEY_DOWN : (rotate == 3) ? Input::Key::KEY_UP : Input::Key::KEY_RIGHT; } else if (x < -player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_UP : Input::Key::KEY_LEFT; + player.state |= (rotate == 1) ? Input::Key::KEY_UP : (rotate == 3) ? Input::Key::KEY_DOWN : Input::Key::KEY_LEFT; } } @@ -172,15 +172,15 @@ void SFMLInput::process_hat(Input::Player &player, bool rotate) { if (sf::Joystick::hasAxis(player.id, sf::Joystick::PovY)) { int y = (int) sf::Joystick::getAxisPosition(player.id, sf::Joystick::PovY) * 320; if (y > player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_LEFT : Input::Key::KEY_DOWN; + player.state |= (rotate == 1) ? Input::Key::KEY_LEFT : (rotate == 3) ? Input::Key::KEY_RIGHT : Input::Key::KEY_DOWN; } else if (y < -player.dead_zone) { - player.state |= rotate ? Input::Key::KEY_RIGHT : Input::Key::KEY_UP; + player.state |= (rotate == 1) ? Input::Key::KEY_RIGHT : (rotate == 3) ? Input::Key::KEY_LEFT : Input::Key::KEY_UP; } } } -void SFMLInput::process_buttons(Input::Player &player, bool rotate) { +void SFMLInput::process_buttons(Input::Player &player, int rotate) { if (!player.enabled) { return; @@ -194,13 +194,29 @@ void SFMLInput::process_buttons(Input::Player &player, bool rotate) { if (sf::Joystick::isButtonPressed(player.id, mapping)) { if (rotate && key_id[i] == Input::Key::KEY_UP) { - player.state |= Input::Key::KEY_RIGHT; + if (rotate == 1) { + player.state |= Input::Key::KEY_RIGHT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_LEFT; + } } else if (rotate && key_id[i] == Input::Key::KEY_DOWN) { - player.state |= Input::Key::KEY_LEFT; + if (rotate == 1) { + player.state |= Input::Key::KEY_LEFT; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_RIGHT; + } } else if (rotate && key_id[i] == Input::Key::KEY_LEFT) { - player.state |= Input::Key::KEY_UP; + if (rotate == 1) { + player.state |= Input::Key::KEY_UP; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_DOWN; + } } else if (rotate && key_id[i] == Input::Key::KEY_RIGHT) { - player.state |= Input::Key::KEY_DOWN; + if (rotate == 1) { + player.state |= Input::Key::KEY_DOWN; + } else if (rotate == 3) { + player.state |= Input::Key::KEY_UP; + } } else { player.state |= key_id[i]; } @@ -208,7 +224,7 @@ void SFMLInput::process_buttons(Input::Player &player, bool rotate) { } } -void SFMLInput::process_keyboard(Input::Player &player, bool rotate) { +void SFMLInput::process_keyboard(Input::Player &player, int rotate) { for (int i = 0; i < KEY_COUNT; i++) { sf::Keyboard::Key key((sf::Keyboard::Key) keyboard.mapping[i]); diff --git a/pfba/deps/libcross2d/src/sfml/sfml_input.h b/pfba/deps/libcross2d/src/sfml/sfml_input.h index 13800a6..7174cb0 100644 --- a/pfba/deps/libcross2d/src/sfml/sfml_input.h +++ b/pfba/deps/libcross2d/src/sfml/sfml_input.h @@ -14,14 +14,14 @@ class SFMLInput : Input { SFMLInput(SFMLRenderer *rdr); virtual ~SFMLInput(); - virtual Player *Update(bool rotate = false); + virtual Player *Update(int rotate = 0); virtual int GetButton(int player); private: - virtual void process_axis(Player& player, bool rotate = false); - virtual void process_hat(Player& player, bool rotate = false); - virtual void process_buttons(Player &player, bool rotate = false); - virtual void process_keyboard(Player& player, bool rotate = false); + virtual void process_axis(Player& player, int rotate = 0); + virtual void process_hat(Player& player, int rotate = 0); + virtual void process_buttons(Player &player, int rotate = 0); + virtual void process_keyboard(Player& player, int rotate = 0); SFMLRenderer *renderer; }; diff --git a/pfba/deps/libcross2d/src/skeleton/input.h b/pfba/deps/libcross2d/src/skeleton/input.h index 2f06cb9..7a45c81 100644 --- a/pfba/deps/libcross2d/src/skeleton/input.h +++ b/pfba/deps/libcross2d/src/skeleton/input.h @@ -56,7 +56,7 @@ class Input { virtual ~Input() {}; - virtual Player *Update(bool rotate = false) { return players; }; // to implement + virtual Player *Update(int rotate = 0) { return players; }; // to implement virtual int GetButton(int player) { return -1; }; // to implement virtual int Clear(int player); diff --git a/pfba/gui/config.cpp b/pfba/gui/config.cpp index df2d5a0..e2f8f2d 100644 --- a/pfba/gui/config.cpp +++ b/pfba/gui/config.cpp @@ -76,12 +76,12 @@ Config::Config(const std::string &cfgPath, Renderer *renderer) { // default rom config options_gui.push_back(Option("ROM", {"ROM"}, 0, Option::Index::MENU_ROM_OPTIONS, Option::Type::MENU)); - options_gui.push_back(Option("SCALING", {"NONE", "2X", "FIT", "FIT 4:3", "FIT 3:4", "FULL"}, 1, Option::Index::ROM_SCALING)); + options_gui.push_back(Option("SCALING", {"NONE", "2X", "FIT", "FIT 4:3", "FULL"}, 3, Option::Index::ROM_SCALING)); options_gui.push_back( - Option("FILTER", {"POINT", "LINEAR"}, 0, Option::Index::ROM_FILTER)); + Option("FILTER", {"POINT", "LINEAR"}, 1, Option::Index::ROM_FILTER)); options_gui.push_back( - Option("SHADER", renderer->shaders->GetNames(), 0, Option::Index::ROM_SHADER)); - options_gui.push_back(Option("ROTATION", {"OFF", "ON"}, 0, Option::Index::ROM_ROTATION)); + Option("SHADER", renderer->shaders->GetNames(), 2, Option::Index::ROM_SHADER)); + options_gui.push_back(Option("ROTATION", {"OFF", "ON", "OFF+FLIP", "OFF+CAB MODE"}, 0, Option::Index::ROM_ROTATION)); options_gui.push_back(Option("SHOW_FPS", {"NO", "YES"}, 0, Option::Index::ROM_SHOW_FPS)); options_gui.push_back(Option("FRAMESKIP", {"OFF", "ON"}, 0, Option::Index::ROM_FRAMESKIP)); //options_gui.push_back(Option("M68K", {"ASM", "C"}, 0, Option::Index::ROM_M68K)); diff --git a/pfba/gui/gui.cpp b/pfba/gui/gui.cpp index ff37460..f8cfa34 100644 --- a/pfba/gui/gui.cpp +++ b/pfba/gui/gui.cpp @@ -173,7 +173,6 @@ bool Gui::IsOptionHidden(Option *option) { return option->index == Option::Index::ROM_ROTATION && romSelected != NULL && !(romSelected->flags & BDF_ORIENTATION_VERTICAL); - } void Gui::DrawOptions(bool isRomCfg, std::vector