From 28f266302fbeea2d75d5a62de651d464ab380798 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 4 Jul 2021 18:52:48 +0200 Subject: Add Nintendo Switch initial support --- src/core/common.h | 4 ++++ src/core/config.h | 9 +++++++-- src/core/re3.cpp | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/common.h b/src/core/common.h index da162762..99aafc5a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,6 +11,10 @@ #define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc #endif +#ifdef GTA_SWITCH +#include +#endif + #include #include #include diff --git a/src/core/config.h b/src/core/config.h index 885f98b8..edb5fb5a 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -319,7 +319,7 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif -#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined __SWITCH__) +#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined GTA_SWITCH) #define DETECT_JOYSTICK_MENU // Then we'll expect user to enter Controller->Detect joysticks if his joystick isn't detected at the start. #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m @@ -439,7 +439,7 @@ enum Config { #endif // Streaming -#if !defined(_WIN32) && !defined(__SWITCH__) +#if !defined(_WIN32) && !defined(GTA_SWITCH) //#define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash - also not utilized too much right now(see commented LoadAllRequestedModels in Streaming.cpp) #define FLUSHABLE_STREAMING // Make it possible to interrupt reading when processing file isn't needed anymore. #endif @@ -461,4 +461,9 @@ enum Config { #undef PEDS_REPORT_CRIMES_ON_PHONE #endif +#ifdef GTA_SWITCH + #define IGNORE_MOUSE_KEYBOARD // ignore mouse & keyboard input + #define USE_UNNAMED_SEM // named semaphores are unsupported on the switch +#endif + #endif // VANILLA_DEFINES diff --git a/src/core/re3.cpp b/src/core/re3.cpp index b7d89363..40be153a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -45,9 +45,7 @@ #include "Population.h" #include "IniFile.h" -#ifdef DETECT_JOYSTICK_MENU #include "crossplatform.h" -#endif #ifndef _WIN32 #include "assert.h" -- cgit v1.2.3 From 6da20aa7232e92b19af28d1bcd2dacacc3898789 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 4 Jul 2021 19:15:23 +0200 Subject: Enable Gamepad Menu on Switch --- src/core/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index edb5fb5a..462dd713 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -345,7 +345,7 @@ enum Config { //# define PS2_MENU_USEALLPAGEICONS #else -# ifdef XINPUT +# if defined(XINPUT) || defined(GTA_SWITCH) # define GAMEPAD_MENU // Add gamepad menu # endif -- cgit v1.2.3 From ca5d3c881133d1fb3c2d9af16de81b63304bc88f Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Mon, 5 Jul 2021 20:02:44 +0200 Subject: Replace GTA_SWITCH macro and use GAMEPAD_MENU * Replace GTA_SWITCH macro with __SWITCH__ for platform specific stuff and GTA_HANDHELD for the rest (which could be used by other ports) * Use GAMEPAD_MENU on GTA_HANDHELD, which will replace the usual controller setup (which contains some useless features for handhelds) * Fix some identation inconsistencies * Disable PC_PLAYER_CONTROLS on GTA_HANDHELD builds --- src/core/MenuScreensCustom.cpp | 12 +++++++++--- src/core/common.h | 2 +- src/core/config.h | 20 +++++++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 033ed9b9..5b0fd60c 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -36,7 +36,7 @@ #ifdef CUSTOM_FRONTEND_OPTIONS -#ifdef IMPROVED_VIDEOMODE +#if defined(IMPROVED_VIDEOMODE) && !defined(GTA_HANDHELD) #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, "VideoMode", "Windowed", screenModes, 2, true, ScreenModeAfterChange, true) }, #else #define VIDEOMODE_SELECTOR @@ -418,10 +418,10 @@ CMenuScreenCustom aScreens[MENUPAGES] = { }, // MENUPAGE_CONTROLLER_SETTINGS = 4 -#ifdef GAMEPAD_MENU +#if defined(GAMEPAD_MENU) && !defined(GTA_HANDHELD) { "FET_AGS", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, nil, nil, #else - { "FET_CON", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil, + { "FET_AGS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil, #endif MENUACTION_CTRLCONFIG, "FEC_CCF", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, MENUACTION_CTRLDISPLAY, "FEC_CDP", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, @@ -751,7 +751,11 @@ CMenuScreenCustom aScreens[MENUPAGES] = { // MENUPAGE_OPTIONS = 41 { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, nil, nil, +#ifdef GTA_HANDHELD + MENUACTION_CHANGEMENU, "FET_CTL", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, +#else MENUACTION_CHANGEMENU, "FET_CTL", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC }, +#endif MENUACTION_LOADRADIO, "FET_AUD", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, MENUACTION_CHANGEMENU, "FET_DIS", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, #ifdef GRAPHICS_MENU_OPTIONS @@ -885,7 +889,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = { { "FET_GFX", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, new CCustomScreenLayout({MENUSPRITE_MAINMENU, 50, 0, 20, FONT_HEADING, FESCREEN_LEFT_ALIGN, true, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), GraphicsGoBack, +#ifdef GTA_HANDHELD MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, +#endif MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, VIDEOMODE_SELECTOR MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, diff --git a/src/core/common.h b/src/core/common.h index 99aafc5a..31aab2b3 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,7 +11,7 @@ #define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc #endif -#ifdef GTA_SWITCH +#ifdef __SWITCH__ #include #endif diff --git a/src/core/config.h b/src/core/config.h index 462dd713..8171f987 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -158,6 +158,11 @@ enum Config { #define GTA_VERSION GTA3_PC_11 +// Enable configuration for handheld console ports +#if defined(__SWITCH__) || defined(PSP2) + #define GTA_HANDHELD +#endif + #if defined GTA_PS2 # define GTA_PS2_STUFF # define RANDOMSPLASH @@ -166,7 +171,9 @@ enum Config { # define ANIM_COMPRESSION # define PS2_MENU #elif defined GTA_PC -# define PC_PLAYER_CONTROLS // mouse player/cam mode +# ifndef GTA_HANDHELD +# define PC_PLAYER_CONTROLS // mouse player/cam mode +# endif # define GTA_REPLAY # define GTA_SCENE_EDIT # define PC_MENU @@ -319,7 +326,7 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif -#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined GTA_SWITCH) +#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined GTA_HANDHELD) #define DETECT_JOYSTICK_MENU // Then we'll expect user to enter Controller->Detect joysticks if his joystick isn't detected at the start. #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m @@ -345,7 +352,7 @@ enum Config { //# define PS2_MENU_USEALLPAGEICONS #else -# if defined(XINPUT) || defined(GTA_SWITCH) +# if defined(XINPUT) || defined(GTA_HANDHELD) # define GAMEPAD_MENU // Add gamepad menu # endif @@ -439,7 +446,7 @@ enum Config { #endif // Streaming -#if !defined(_WIN32) && !defined(GTA_SWITCH) +#if !defined(_WIN32) && !defined(__SWITCH__) //#define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash - also not utilized too much right now(see commented LoadAllRequestedModels in Streaming.cpp) #define FLUSHABLE_STREAMING // Make it possible to interrupt reading when processing file isn't needed anymore. #endif @@ -461,8 +468,11 @@ enum Config { #undef PEDS_REPORT_CRIMES_ON_PHONE #endif -#ifdef GTA_SWITCH +#ifdef GTA_HANDHELD #define IGNORE_MOUSE_KEYBOARD // ignore mouse & keyboard input +#endif + +#ifdef __SWITCH__ #define USE_UNNAMED_SEM // named semaphores are unsupported on the switch #endif -- cgit v1.2.3 From a99a04ed49fe5cea1eb8292d9ffeefb40d10ac82 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Tue, 6 Jul 2021 18:05:21 +0200 Subject: Add Switch controller asset and configuration * Add GXT string for the Nintendo Switch Controller * Add frontend and button textures for Nintendo Switch controllers * Fix wrong #ifndef when hiding screen resolution option on GTA_HANDHELD --- src/core/ControllerConfig.cpp | 14 ++++++++++++++ src/core/Frontend.cpp | 20 ++++++++++++++++++++ src/core/Frontend.h | 1 + src/core/MenuScreensCustom.cpp | 4 ++-- 4 files changed, 37 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index e72af7e4..8775792f 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2644,6 +2644,14 @@ const char *PlayStationButtons[][MAX_CONTROLLERACTIONS] = #undef PS2_CROSS #undef PS2_SQUARE +const char *NintendoSwitchButtons_noIcons[][MAX_CONTROLLERACTIONS] = + CONTROLLER_BUTTONS("Y", "A", "B", "X", "L", "ZL", "LS", "R", "ZR", "RS", "BACK"); + +#ifdef BUTTON_ICONS +const char *NintendoSwitchButtons[][MAX_CONTROLLERACTIONS] = + CONTROLLER_BUTTONS("~T~", "~O~", "~X~", "~Q~", "~K~", "~M~", "~A~", "~J~", "~V~", "~C~", "BACK"); +#endif + #undef CONTROLLER_BUTTONS #undef VFB @@ -2664,6 +2672,9 @@ void CControllerConfigManager::GetWideStringOfCommandKeys(uint16 action, wchar * case CMenuManager::CONTROLLER_DUALSHOCK4: Buttons = CFont::ButtonsSlot != -1 ? PlayStationButtons : PlayStationButtons_noIcons; break; + case CMenuManager::CONTROLLER_NINTENDO_SWITCH: + Buttons = CFont::ButtonsSlot != -1 ? NintendoSwitchButtons : NintendoSwitchButtons_noIcons; + break; default: #endif Buttons = CFont::ButtonsSlot != -1 ? XboxButtons : XboxButtons_noIcons; @@ -2679,6 +2690,9 @@ void CControllerConfigManager::GetWideStringOfCommandKeys(uint16 action, wchar * case CMenuManager::CONTROLLER_DUALSHOCK4: Buttons = PlayStationButtons_noIcons; break; + case CMenuManager::CONTROLLER_NINTENDO_SWITCH: + Buttons = NintendoSwitchButtons_noIcons; + break; default: Buttons = XboxButtons_noIcons; break; diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index ecb893b4..0f4218a4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -142,8 +142,12 @@ int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW; #endif #ifdef GAMEPAD_MENU +#ifdef __SWITCH__ +int8 CMenuManager::m_PrefsControllerType = CONTROLLER_NINTENDO_SWITCH; +#else int8 CMenuManager::m_PrefsControllerType = CONTROLLER_XBOXONE; #endif +#endif int32 CMenuManager::OS_Language = LANG_ENGLISH; int8 CMenuManager::m_PrefsUseVibration; @@ -3674,6 +3678,7 @@ const char* controllerTypesPaths[] = { "MODELS/FRONTEND_DS4.TXD", "MODELS/FRONTEND_X360.TXD", "MODELS/FRONTEND_XONE.TXD", + "MODELS/FRONTEND_NSW.TXD", }; void @@ -3686,6 +3691,9 @@ CMenuManager::LoadController(int8 type) case CONTROLLER_DUALSHOCK4: CFont::LoadButtons("MODELS/PS3BTNS.TXD"); break; + case CONTROLLER_NINTENDO_SWITCH: + CFont::LoadButtons("MODELS/NSWBTNS.TXD"); + break; default: CFont::LoadButtons("MODELS/X360BTNS.TXD"); break; @@ -5928,6 +5936,18 @@ CMenuManager::PrintController(void) TEXT_L2R2_Y += 5.0f; TEXT_SELECT_X += 3.0f; break; + case CONTROLLER_NINTENDO_SWITCH: + TEXT_L1_Y += 5.0f; + TEXT_L1_Y_VEH = TEXT_L1_Y; + TEXT_R1_Y += 5.0f; + TEXT_TRIANGLE_Y += 3.0f; + TEXT_CIRCLE_Y += 3.0f; + TEXT_CROSS_Y += 3.0f; + TEXT_LSTICK_Y -= 23.0f; + TEXT_DPAD_Y += 25.0; + TEXT_RSTICK_Y += 1.0f; + TEXT_R3_Y += 1.0f; + break; }; if (m_DisplayControllerOnFoot) { diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 32e5ef9d..6e6c40f7 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -760,6 +760,7 @@ public: CONTROLLER_DUALSHOCK4, CONTROLLER_XBOX360, CONTROLLER_XBOXONE, + CONTROLLER_NINTENDO_SWITCH, }; static int8 m_PrefsControllerType; diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 5b0fd60c..586b51fa 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -388,7 +388,7 @@ void DetectJoystickGoBack() { #endif #ifdef GAMEPAD_MENU -const char* controllerTypes[] = { "FEC_DS2", "FEC_DS3", "FEC_DS4", "FEC_360", "FEC_ONE" }; +const char* controllerTypes[] = { "FEC_DS2", "FEC_DS3", "FEC_DS4", "FEC_360", "FEC_ONE", "FEC_NSW" }; void ControllerTypeAfterChange(int8 before, int8 after) { FrontEndMenuManager.LoadController(after); @@ -889,7 +889,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = { { "FET_GFX", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, new CCustomScreenLayout({MENUSPRITE_MAINMENU, 50, 0, 20, FONT_HEADING, FESCREEN_LEFT_ALIGN, true, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), GraphicsGoBack, -#ifdef GTA_HANDHELD +#ifndef GTA_HANDHELD MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, #endif MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, -- cgit v1.2.3