BACKEND: Allow SDL2 mapping of L2/R2, fix psp2/switch mapping

This commit is contained in:
rsn8887 2020-02-07 13:38:17 -06:00
parent 31ecbd086d
commit eea70a3c8c
8 changed files with 121 additions and 1 deletions

View file

@ -24,11 +24,34 @@
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/translation.h"
#include "backends/platform/sdl/switch/switch.h"
#include "backends/events/switchsdl/switchsdl-events.h"
#include "backends/saves/posix/posix-saves.h"
#include "backends/fs/posix/posix-fs-factory.h"
#include "backends/fs/posix/posix-fs.h"
#include "backends/keymapper/hardware-input.h"
static const Common::HardwareInputTableEntry switchJoystickButtons[] = {
{ "JOY_A", Common::JOYSTICK_BUTTON_A, _s("B") },
{ "JOY_B", Common::JOYSTICK_BUTTON_B, _s("A") },
{ "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Y") },
{ "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("X") },
{ "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Minus") },
{ "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Plus") },
{ "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("L3") },
{ "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("R3") },
{ "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") },
{ "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") },
{ "JOY_LEFT_TRIGGER", Common::JOYSTICK_BUTTON_LEFT_TRIGGER, _s("ZL") },
{ "JOY_RIGHT_TRIGGER", Common::JOYSTICK_BUTTON_RIGHT_TRIGGER, _s("ZR") },
{ "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") },
{ "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") },
{ "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") },
{ "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") },
{ nullptr, 0, nullptr }
};
void OSystem_Switch::init() {
@ -125,3 +148,16 @@ void OSystem_Switch::logMessage(LogMessageType::Type type, const char *message)
Common::String OSystem_Switch::getDefaultLogFileName() {
return "scummvm.log";
}
Common::HardwareInputSet *OSystem_Switch::getHardwareInputSet() {
using namespace Common;
CompositeHardwareInputSet *inputSet = new CompositeHardwareInputSet();
// Users may use USB / bluetooth mice and keyboards
inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
inputSet->addHardwareInputSet(new JoystickHardwareInputSet(switchJoystickButtons));
return inputSet;
}