Switch fixes (#4503)
* InputManager: support split joycons, fix mappings * CFileSystem: getAbsoluteFilename() - replace double slashes * CFileSystem: typo in macro * debug: use touch handler for debug (strange behaviour on switch SDL) * InputManager: don't need SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS
This commit is contained in:
parent
cee737e405
commit
cc125c5f68
@ -587,7 +587,9 @@ bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory)
|
||||
|
||||
io::path CFileSystem::getAbsolutePath(const io::path& filename) const
|
||||
{
|
||||
#if defined(_IRR_WINDOWS_CE_PLATFORM_) || defined(__SWITCH__)
|
||||
#ifdef __SWITCH__
|
||||
return core::stringc(filename).replace(core::stringc("//"), core::stringc("/"));
|
||||
#elif defined(_IRR_WINDOWS_CE_PLATFORM_)
|
||||
return filename;
|
||||
#elif defined(_IRR_WINDOWS_API_)
|
||||
wchar_t *p=0;
|
||||
|
@ -142,6 +142,10 @@ void CMountPointReader::buildDirectory()
|
||||
|
||||
if (full == "")
|
||||
continue;
|
||||
#ifdef __SWITCH__
|
||||
if (full.lastChar() == '.')
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if (!list->isDirectory(i))
|
||||
{
|
||||
|
@ -522,13 +522,22 @@ void GamepadConfig::initSDLMapping()
|
||||
if (actions_map.find(SDL_CONTROLLER_BUTTON_LEFTSHOULDER) != actions_map.end() &&
|
||||
actions_map.find(SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) != actions_map.end())
|
||||
{
|
||||
#ifdef __SWITCH__
|
||||
setBindingFromTuple(PA_ACCEL, actions_map.at(SDL_CONTROLLER_BUTTON_A));
|
||||
setBindingFromTuple(PA_BRAKE, actions_map.at(SDL_CONTROLLER_BUTTON_B));
|
||||
setBindingFromTuple(PA_FIRE, actions_map.at(SDL_CONTROLLER_BUTTON_X));
|
||||
setBindingFromTuple(PA_LOOK_BACK, actions_map.at(SDL_CONTROLLER_BUTTON_Y));
|
||||
// Split joycons will only have one minus button (left joycon)
|
||||
setBindingFromTuple(PA_RESCUE, actions_map.at(SDL_CONTROLLER_BUTTON_LEFTSTICK));
|
||||
#else
|
||||
setBindingFromTuple(PA_ACCEL, actions_map.at(SDL_CONTROLLER_BUTTON_Y));
|
||||
setBindingFromTuple(PA_BRAKE, actions_map.at(SDL_CONTROLLER_BUTTON_X));
|
||||
setBindingFromTuple(PA_FIRE, actions_map.at(SDL_CONTROLLER_BUTTON_B));
|
||||
setBindingFromTuple(PA_NITRO, actions_map.at(SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
|
||||
setBindingFromTuple(PA_DRIFT, actions_map.at(SDL_CONTROLLER_BUTTON_RIGHTSHOULDER));
|
||||
setBindingFromTuple(PA_LOOK_BACK, actions_map.at(SDL_CONTROLLER_BUTTON_A));
|
||||
setBindingFromTuple(PA_RESCUE, actions_map.at(SDL_CONTROLLER_BUTTON_BACK));
|
||||
#endif
|
||||
setBindingFromTuple(PA_NITRO, actions_map.at(SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
|
||||
setBindingFromTuple(PA_DRIFT, actions_map.at(SDL_CONTROLLER_BUTTON_RIGHTSHOULDER));
|
||||
setBindingFromTuple(PA_PAUSE_RACE, actions_map.at(SDL_CONTROLLER_BUTTON_START));
|
||||
setBindingFromTuple(PA_MENU_SELECT, actions_map.at(SDL_CONTROLLER_BUTTON_A));
|
||||
setBindingFromTuple(PA_MENU_CANCEL, actions_map.at(SDL_CONTROLLER_BUTTON_B));
|
||||
|
@ -69,6 +69,22 @@
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
extern "C" {
|
||||
#define Event libnx_Event
|
||||
#define u64 libnx_u64
|
||||
#define u32 libnx_u32
|
||||
#define s64 libnx_s64
|
||||
#define s32 libnx_s32
|
||||
#include <switch/runtime/pad.h>
|
||||
#undef u64
|
||||
#undef u32
|
||||
#undef s64
|
||||
#undef s32
|
||||
#undef Event
|
||||
}
|
||||
#endif
|
||||
|
||||
InputManager *input_manager;
|
||||
|
||||
using GUIEngine::EventPropagation;
|
||||
@ -89,16 +105,20 @@ InputManager::InputManager() : m_mode(BOOTSTRAP),
|
||||
|
||||
m_master_player_only = false;
|
||||
#ifndef SERVER_ONLY
|
||||
#ifdef __SWITCH__
|
||||
padConfigureInput(8, HidNpadStyleSet_NpadStandard);
|
||||
// Otherwise we report 'B' as 'A' (like Xbox controller)
|
||||
SDL_SetHint(
|
||||
SDL_HINT_GAMECONTROLLERCONFIG,
|
||||
"53776974636820436F6E74726F6C6C65,Switch Controller,a:b0,b:b1,back:b11,dpdown:b15,dpleft:b12,dpright:b14,dpup:b13,leftshoulder:b6,leftstick:b4,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b5,righttrigger:b9,rightx:a2,righty:a3,start:b10,x:b2,y:b3,\n"
|
||||
);
|
||||
#endif // __SWITCH__
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) != 0)
|
||||
{
|
||||
Log::error("InputManager", "Failed to init SDL game controller: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
#ifdef __SWITCH__
|
||||
// Otherwise we report 'B' as 'A' (like Xbox controller)
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0");
|
||||
#endif
|
||||
#endif
|
||||
#endif // SERVER_ONLY
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -206,6 +226,9 @@ void InputManager::update(float dt)
|
||||
if (wiimote_manager)
|
||||
wiimote_manager->update();
|
||||
#endif
|
||||
#ifdef __SWITCH__
|
||||
hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);
|
||||
#endif
|
||||
|
||||
for (auto it = m_gamepads_timer.begin(); it != m_gamepads_timer.end();)
|
||||
{
|
||||
|
@ -1068,19 +1068,27 @@ bool onEvent(const SEvent &event)
|
||||
if(!UserConfigParams::m_artist_debug_mode)
|
||||
return true; // keep handling the events
|
||||
|
||||
if (event.EventType == EET_MOUSE_INPUT_EVENT)
|
||||
if (event.EventType == EET_MOUSE_INPUT_EVENT || event.EventType == EET_TOUCH_INPUT_EVENT)
|
||||
{
|
||||
if (GUIEngine::ModalDialog::isADialogActive() ||
|
||||
GUIEngine::ScreenKeyboard::isActive())
|
||||
return true;
|
||||
|
||||
// Create the menu (only one menu at a time)
|
||||
#ifdef MOBILE_STK
|
||||
#if defined(MOBILE_STK) || defined(__SWITCH__)
|
||||
#ifdef __SWITCH__
|
||||
int x = 100;
|
||||
int y = 100;
|
||||
#else
|
||||
int x = 10 * irr_driver->getActualScreenSize().Height / 480;
|
||||
int y = 30 * irr_driver->getActualScreenSize().Height / 480;
|
||||
if (event.MouseInput.X < x && event.MouseInput.Y < y &&
|
||||
#else
|
||||
if ((event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN ||
|
||||
#endif // __SWITCH__
|
||||
if ( event.EventType == EET_MOUSE_INPUT_EVENT ?
|
||||
(event.MouseInput.X < x && event.MouseInput.Y < y) :
|
||||
(event.TouchInput.X < x && event.TouchInput.Y < y) &&
|
||||
#else // MOBILE_STK
|
||||
if ( event.EventType == EET_MOUSE_INPUT_EVENT &&
|
||||
(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN ||
|
||||
event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN) &&
|
||||
#endif
|
||||
!g_debug_menu_visible)
|
||||
|
Loading…
Reference in New Issue
Block a user