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
This commit is contained in:
Adrian Graber 2021-07-05 20:02:44 +02:00
parent 02ec56e8f7
commit ca5d3c8811
7 changed files with 39 additions and 28 deletions

View File

@ -40,7 +40,6 @@
"cppStandard": "gnu++11", "cppStandard": "gnu++11",
"defines": [ "defines": [
"__SWITCH__", "__SWITCH__",
"GTA_SWITCH",
"LIBRW", "LIBRW",
"RW_GL3", "RW_GL3",
"AUDIO_OAL" "AUDIO_OAL"

View File

@ -149,10 +149,6 @@ endif()
# Build Nintendo Switch binaries # Build Nintendo Switch binaries
if(NINTENDO_SWITCH) if(NINTENDO_SWITCH)
target_compile_definitions(${EXECUTABLE} PRIVATE
GTA_SWITCH
)
# Needed for OpenAL-Soft # Needed for OpenAL-Soft
target_link_libraries(${EXECUTABLE} PRIVATE target_link_libraries(${EXECUTABLE} PRIVATE
openal # HACK - something broke with latest cmake openal # HACK - something broke with latest cmake

View File

@ -36,7 +36,7 @@
#ifdef CUSTOM_FRONTEND_OPTIONS #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) }, #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, "VideoMode", "Windowed", screenModes, 2, true, ScreenModeAfterChange, true) },
#else #else
#define VIDEOMODE_SELECTOR #define VIDEOMODE_SELECTOR
@ -418,10 +418,10 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
}, },
// MENUPAGE_CONTROLLER_SETTINGS = 4 // MENUPAGE_CONTROLLER_SETTINGS = 4
#ifdef GAMEPAD_MENU #if defined(GAMEPAD_MENU) && !defined(GTA_HANDHELD)
{ "FET_AGS", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, nil, nil, { "FET_AGS", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, nil, nil,
#else #else
{ "FET_CON", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil, { "FET_AGS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil,
#endif #endif
MENUACTION_CTRLCONFIG, "FEC_CCF", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, MENUACTION_CTRLCONFIG, "FEC_CCF", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS },
MENUACTION_CTRLDISPLAY, "FEC_CDP", { 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 // MENUPAGE_OPTIONS = 41
{ "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, nil, nil, { "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 }, MENUACTION_CHANGEMENU, "FET_CTL", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC },
#endif
MENUACTION_LOADRADIO, "FET_AUD", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, MENUACTION_LOADRADIO, "FET_AUD", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS },
MENUACTION_CHANGEMENU, "FET_DIS", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, MENUACTION_CHANGEMENU, "FET_DIS", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
#ifdef GRAPHICS_MENU_OPTIONS #ifdef GRAPHICS_MENU_OPTIONS
@ -885,7 +889,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
{ "FET_GFX", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, { "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, 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 }, MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS },
#endif
MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS },
VIDEOMODE_SELECTOR VIDEOMODE_SELECTOR
MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },

View File

@ -11,7 +11,7 @@
#define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc #define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc
#endif #endif
#ifdef GTA_SWITCH #ifdef __SWITCH__
#include <switch.h> #include <switch.h>
#endif #endif

View File

@ -158,6 +158,11 @@ enum Config {
#define GTA_VERSION GTA3_PC_11 #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 #if defined GTA_PS2
# define GTA_PS2_STUFF # define GTA_PS2_STUFF
# define RANDOMSPLASH # define RANDOMSPLASH
@ -166,7 +171,9 @@ enum Config {
# define ANIM_COMPRESSION # define ANIM_COMPRESSION
# define PS2_MENU # define PS2_MENU
#elif defined GTA_PC #elif defined GTA_PC
# ifndef GTA_HANDHELD
# define PC_PLAYER_CONTROLS // mouse player/cam mode # define PC_PLAYER_CONTROLS // mouse player/cam mode
# endif
# define GTA_REPLAY # define GTA_REPLAY
# define GTA_SCENE_EDIT # define GTA_SCENE_EDIT
# define PC_MENU # define PC_MENU
@ -319,7 +326,7 @@ enum Config {
#if !defined(RW_GL3) && defined(_WIN32) #if !defined(RW_GL3) && defined(_WIN32)
#define XINPUT #define XINPUT
#endif #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. #define DETECT_JOYSTICK_MENU // Then we'll expect user to enter Controller->Detect joysticks if his joystick isn't detected at the start.
#endif #endif
#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m #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 //# define PS2_MENU_USEALLPAGEICONS
#else #else
# if defined(XINPUT) || defined(GTA_SWITCH) # if defined(XINPUT) || defined(GTA_HANDHELD)
# define GAMEPAD_MENU // Add gamepad menu # define GAMEPAD_MENU // Add gamepad menu
# endif # endif
@ -439,7 +446,7 @@ enum Config {
#endif #endif
// Streaming // 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 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. #define FLUSHABLE_STREAMING // Make it possible to interrupt reading when processing file isn't needed anymore.
#endif #endif
@ -461,8 +468,11 @@ enum Config {
#undef PEDS_REPORT_CRIMES_ON_PHONE #undef PEDS_REPORT_CRIMES_ON_PHONE
#endif #endif
#ifdef GTA_SWITCH #ifdef GTA_HANDHELD
#define IGNORE_MOUSE_KEYBOARD // ignore mouse & keyboard input #define IGNORE_MOUSE_KEYBOARD // ignore mouse & keyboard input
#endif
#ifdef __SWITCH__
#define USE_UNNAMED_SEM // named semaphores are unsupported on the switch #define USE_UNNAMED_SEM // named semaphores are unsupported on the switch
#endif #endif

View File

@ -200,7 +200,7 @@ char* casepath(char const* path, bool checkPathFirst)
DIR* d; DIR* d;
char* c; char* c;
#if defined(GTA_SWITCH) || defined(GTA_VITA) #if defined(__SWITCH__) || defined(PSP2)
if( (c = strstr(p, ":/")) != NULL) // scheme used by some environments, eg. switch, vita if( (c = strstr(p, ":/")) != NULL) // scheme used by some environments, eg. switch, vita
{ {
size_t deviceNameOffset = c - p + 3; size_t deviceNameOffset = c - p + 3;
@ -294,7 +294,7 @@ char* casepath(char const* path, bool checkPathFirst)
} }
#endif #endif
#ifdef GTA_SWITCH #ifdef __SWITCH__
/* Taken from glibc */ /* Taken from glibc */
char *realpath(const char *name, char *resolved) char *realpath(const char *name, char *resolved)
{ {

View File

@ -12,7 +12,7 @@ DWORD _dwOperatingSystemVersion;
#include "resource.h" #include "resource.h"
#else #else
long _dwOperatingSystemVersion; long _dwOperatingSystemVersion;
#ifndef GTA_SWITCH #ifndef __SWITCH__
#ifndef __APPLE__ #ifndef __APPLE__
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#else #else
@ -53,7 +53,7 @@ long _dwOperatingSystemVersion;
#include "MemoryMgr.h" #include "MemoryMgr.h"
// We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux. // We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux.
#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_SWITCH // && !defined WAYLAND #if !defined _WIN32 && !defined __APPLE__ && !defined GTA_HANDHELD // && !defined WAYLAND
#define GET_KEYBOARD_INPUT_FROM_X11 #define GET_KEYBOARD_INPUT_FROM_X11
#endif #endif
@ -330,7 +330,7 @@ psNativeTextureSupport(void)
***************************************************************************** *****************************************************************************
*/ */
#ifdef GTA_SWITCH #ifdef __SWITCH__
static HidVibrationValue SwitchVibrationValues[2]; static HidVibrationValue SwitchVibrationValues[2];
static HidVibrationDeviceHandle SwitchVibrationDeviceHandles[2][2]; static HidVibrationDeviceHandle SwitchVibrationDeviceHandles[2][2];
@ -338,10 +338,10 @@ static HidVibrationDeviceHandle SwitchVibrationDeviceGC;
static PadState SwitchPad; static PadState SwitchPad;
Result HidInitializationResult[2]; static Result HidInitializationResult[2];
Result HidInitializationGCResult; static Result HidInitializationGCResult;
void _psInitializeVibration() static void _psInitializeVibration()
{ {
HidInitializationResult[0] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[0], 2, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld); HidInitializationResult[0] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[0], 2, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld);
if(R_FAILED(HidInitializationResult[0])) { if(R_FAILED(HidInitializationResult[0])) {
@ -363,7 +363,7 @@ void _psInitializeVibration()
padInitializeDefault(&SwitchPad); padInitializeDefault(&SwitchPad);
} }
void _psHandleVibration() static void _psHandleVibration()
{ {
padUpdate(&SwitchPad); padUpdate(&SwitchPad);
@ -394,8 +394,8 @@ void _psHandleVibration()
} }
} }
#else #else
void _psInitializeVibration() {} static void _psInitializeVibration() {}
void _psHandleVibration() {} static void _psHandleVibration() {}
#endif #endif
/* /*
@ -561,7 +561,7 @@ psInitialize(void)
debug("Physical memory size %llu\n", _dwMemAvailPhys); debug("Physical memory size %llu\n", _dwMemAvailPhys);
debug("Available physical memory %llu\n", size); debug("Available physical memory %llu\n", size);
#else #else
#ifndef GTA_SWITCH #ifndef __SWITCH__
struct sysinfo systemInfo; struct sysinfo systemInfo;
sysinfo(&systemInfo); sysinfo(&systemInfo);
_dwMemAvailPhys = systemInfo.freeram; _dwMemAvailPhys = systemInfo.freeram;
@ -1871,7 +1871,7 @@ main(int argc, char *argv[])
InitMemoryMgr(); InitMemoryMgr();
#endif #endif
#if !defined(_WIN32) && !defined(GTA_SWITCH) #if !defined(_WIN32) && !defined(__SWITCH__)
struct sigaction act; struct sigaction act;
act.sa_sigaction = terminateHandler; act.sa_sigaction = terminateHandler;
act.sa_flags = SA_SIGINFO; act.sa_flags = SA_SIGINFO;