mirror of
https://github.com/GTAmodding/re3.git
synced 2025-08-24 19:10:50 +00:00
Switch PR & remove X11 part from CMakeLists
This commit is contained in:
commit
8641e9d0bb
37 changed files with 470 additions and 22 deletions
|
@ -54,9 +54,13 @@ target_compile_definitions(${EXECUTABLE} PRIVATE USE_OUR_VERSIONING)
|
|||
|
||||
if(${PROJECT}_AUDIO STREQUAL "OAL")
|
||||
find_package(OpenAL REQUIRED)
|
||||
target_include_directories(${EXECUTABLE} PRIVATE ${OPENAL_INCLUDE_DIR})
|
||||
target_link_libraries(${EXECUTABLE} PRIVATE ${OPENAL_LIBRARY})
|
||||
target_compile_definitions(${EXECUTABLE} PRIVATE ${OPENAL_DEFINITIONS})
|
||||
if(TARGET OpenAL::OpenAL)
|
||||
target_link_libraries(${EXECUTABLE} PRIVATE OpenAL::OpenAL)
|
||||
else()
|
||||
target_include_directories(${EXECUTABLE} PRIVATE ${OPENAL_INCLUDE_DIR})
|
||||
target_link_libraries(${EXECUTABLE} PRIVATE ${OPENAL_LIBRARY})
|
||||
target_compile_definitions(${EXECUTABLE} PRIVATE ${OPENAL_DEFINITIONS})
|
||||
endif()
|
||||
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL)
|
||||
elseif(${PROJECT}_AUDIO STREQUAL "MSS")
|
||||
find_package(MilesSDK REQUIRED)
|
||||
|
@ -120,13 +124,19 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|||
)
|
||||
endif()
|
||||
|
||||
if(NINTENDO_SWITCH)
|
||||
set(${PROJECT}_C_CXX_EXTENSIONS ON)
|
||||
else()
|
||||
set(${PROJECT}_C_CXX_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
set_target_properties(${EXECUTABLE}
|
||||
PROPERTIES
|
||||
C_STANDARD 11
|
||||
C_EXTENSIONS OFF
|
||||
C_EXTENSIONS ${${PROJECT}_C_CXX_EXTENSIONS}
|
||||
C_STANDARD_REQUIRED ON
|
||||
CXX_STANDARD 11
|
||||
CXX_EXTENSIONS OFF
|
||||
CXX_EXTENSIONS ${${PROJECT}_C_CXX_EXTENSIONS}
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
|
||||
|
@ -140,3 +150,5 @@ if(${PROJECT}_INSTALL)
|
|||
install(FILES $<TARGET_PDB_FILE:${EXECUTABLE}> DESTINATION "." OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
re3_platform_target(${EXECUTABLE} INSTALL)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -5925,6 +5933,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) {
|
||||
|
|
|
@ -760,6 +760,7 @@ public:
|
|||
CONTROLLER_DUALSHOCK4,
|
||||
CONTROLLER_XBOX360,
|
||||
CONTROLLER_XBOXONE,
|
||||
CONTROLLER_NINTENDO_SWITCH,
|
||||
};
|
||||
|
||||
static int8 m_PrefsControllerType;
|
||||
|
|
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 },
|
||||
|
@ -753,7 +753,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
|
||||
|
@ -887,7 +891,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,
|
||||
|
||||
#ifndef 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 },
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc
|
||||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#include <switch.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
|
|
@ -157,6 +157,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 PS2_MENU
|
||||
#elif defined GTA_PC
|
||||
# define EXTERNAL_3D_SOUND
|
||||
# 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
|
||||
|
@ -322,7 +329,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_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
|
||||
|
@ -348,7 +355,7 @@ enum Config {
|
|||
//# define PS2_MENU_USEALLPAGEICONS
|
||||
#else
|
||||
|
||||
# ifdef XINPUT
|
||||
# if defined(XINPUT) || defined(GTA_HANDHELD)
|
||||
# define GAMEPAD_MENU // Add gamepad menu
|
||||
# endif
|
||||
|
||||
|
@ -467,6 +474,14 @@ enum Config {
|
|||
#undef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#endif // VANILLA_DEFINES
|
||||
|
||||
#if defined(AUDIO_OAL) && !defined(EXTERNAL_3D_SOUND)
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
#include "Population.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#ifdef DETECT_JOYSTICK_MENU
|
||||
#include "crossplatform.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "assert.h"
|
||||
|
|
|
@ -198,6 +198,20 @@ char* casepath(char const* path, bool checkPathFirst)
|
|||
size_t rl = 0;
|
||||
|
||||
DIR* d;
|
||||
char* c;
|
||||
|
||||
#if defined(__SWITCH__) || defined(PSP2)
|
||||
if( (c = strstr(p, ":/")) != NULL) // scheme used by some environments, eg. switch, vita
|
||||
{
|
||||
size_t deviceNameOffset = c - p + 3;
|
||||
char* deviceNamePath = (char*)alloca(deviceNameOffset + 1);
|
||||
strlcpy(deviceNamePath, p, deviceNameOffset);
|
||||
deviceNamePath[deviceNameOffset] = 0;
|
||||
d = opendir(deviceNamePath);
|
||||
p = c + 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (p[0] == '/' || p[0] == '\\')
|
||||
{
|
||||
d = opendir("/");
|
||||
|
@ -212,7 +226,7 @@ char* casepath(char const* path, bool checkPathFirst)
|
|||
|
||||
bool cantProceed = false; // just convert slashes in what's left in string, don't correct case of letters(because we can't)
|
||||
bool mayBeTrailingSlash = false;
|
||||
char* c;
|
||||
|
||||
while (c = strsep(&p, "/\\"))
|
||||
{
|
||||
// May be trailing slash(allow), slash at the start(avoid), or multiple slashes(avoid)
|
||||
|
@ -279,3 +293,133 @@ char* casepath(char const* path, bool checkPathFirst)
|
|||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
/* Taken from glibc */
|
||||
char *realpath(const char *name, char *resolved)
|
||||
{
|
||||
char *rpath, *dest = NULL;
|
||||
const char *start, *end, *rpath_limit;
|
||||
long int path_max;
|
||||
|
||||
/* As per Single Unix Specification V2 we must return an error if
|
||||
either parameter is a null pointer. We extend this to allow
|
||||
the RESOLVED parameter to be NULL in case the we are expected to
|
||||
allocate the room for the return value. */
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
/* As per Single Unix Specification V2 we must return an error if
|
||||
the name argument points to an empty string. */
|
||||
if (name[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
#ifdef PATH_MAX
|
||||
path_max = PATH_MAX;
|
||||
#else
|
||||
path_max = pathconf(name, _PC_PATH_MAX);
|
||||
if (path_max <= 0)
|
||||
path_max = 1024;
|
||||
#endif
|
||||
|
||||
if (!resolved)
|
||||
{
|
||||
rpath = (char*)malloc(path_max);
|
||||
if (!rpath)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
rpath = resolved;
|
||||
rpath_limit = rpath + path_max;
|
||||
|
||||
if (name[0] != '/')
|
||||
{
|
||||
if (!getcwd(rpath, path_max))
|
||||
{
|
||||
rpath[0] = '\0';
|
||||
goto error;
|
||||
}
|
||||
dest = (char*)memchr(rpath, '\0', path_max);
|
||||
}
|
||||
else
|
||||
{
|
||||
rpath[0] = '/';
|
||||
dest = rpath + 1;
|
||||
}
|
||||
|
||||
for (start = end = name; *start; start = end)
|
||||
{
|
||||
/* Skip sequence of multiple path-separators. */
|
||||
while (*start == '/')
|
||||
++start;
|
||||
|
||||
/* Find end of path component. */
|
||||
for (end = start; *end && *end != '/'; ++end)
|
||||
/* Nothing. */;
|
||||
|
||||
if (end - start == 0)
|
||||
break;
|
||||
else if (end - start == 1 && start[0] == '.')
|
||||
/* nothing */;
|
||||
else if (end - start == 2 && start[0] == '.' && start[1] == '.')
|
||||
{
|
||||
/* Back up to previous component, ignore if at root already. */
|
||||
if (dest > rpath + 1)
|
||||
while ((--dest)[-1] != '/')
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t new_size;
|
||||
|
||||
if (dest[-1] != '/')
|
||||
*dest++ = '/';
|
||||
|
||||
if (dest + (end - start) >= rpath_limit)
|
||||
{
|
||||
ptrdiff_t dest_offset = dest - rpath;
|
||||
char *new_rpath;
|
||||
|
||||
if (resolved)
|
||||
{
|
||||
if (dest > rpath + 1)
|
||||
dest--;
|
||||
*dest = '\0';
|
||||
goto error;
|
||||
}
|
||||
new_size = rpath_limit - rpath;
|
||||
if (end - start + 1 > path_max)
|
||||
new_size += end - start + 1;
|
||||
else
|
||||
new_size += path_max;
|
||||
new_rpath = (char *)realloc(rpath, new_size);
|
||||
if (!new_rpath)
|
||||
goto error;
|
||||
rpath = new_rpath;
|
||||
rpath_limit = rpath + new_size;
|
||||
|
||||
dest = rpath + dest_offset;
|
||||
}
|
||||
|
||||
dest = (char*)memcpy(dest, start, end - start);
|
||||
*dest = '\0';
|
||||
}
|
||||
}
|
||||
if (dest > rpath + 1 && dest[-1] == '/')
|
||||
--dest;
|
||||
*dest = '\0';
|
||||
|
||||
return rpath;
|
||||
|
||||
error:
|
||||
if (!resolved)
|
||||
free(rpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ssize_t readlink (const char * __path, char * __buf, size_t __buflen)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -157,3 +157,28 @@ bool FindNextFile(HANDLE, WIN32_FIND_DATA*);
|
|||
void FileTimeToSystemTime(time_t*, SYSTEMTIME*);
|
||||
void GetDateFormat(int, int, SYSTEMTIME*, int, char*, int);
|
||||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
|
||||
// tweak glfw values for switch to match expected pc bindings
|
||||
#ifdef GLFW_GAMEPAD_BUTTON_A
|
||||
#undef GLFW_GAMEPAD_BUTTON_A
|
||||
#endif
|
||||
#define GLFW_GAMEPAD_BUTTON_A 1
|
||||
|
||||
#ifdef GLFW_GAMEPAD_BUTTON_B
|
||||
#undef GLFW_GAMEPAD_BUTTON_B
|
||||
#endif
|
||||
#define GLFW_GAMEPAD_BUTTON_B 0
|
||||
|
||||
#ifdef GLFW_GAMEPAD_BUTTON_X
|
||||
#undef GLFW_GAMEPAD_BUTTON_X
|
||||
#endif
|
||||
#define GLFW_GAMEPAD_BUTTON_X 3
|
||||
|
||||
#ifdef GLFW_GAMEPAD_BUTTON_Y
|
||||
#undef GLFW_GAMEPAD_BUTTON_Y
|
||||
#endif
|
||||
#define GLFW_GAMEPAD_BUTTON_Y 2
|
||||
|
||||
#endif
|
||||
|
|
|
@ -821,7 +821,9 @@ PadHandler(RsEvent event, void *param)
|
|||
RwBool
|
||||
AttachInputDevices(void)
|
||||
{
|
||||
#ifndef IGNORE_MOUSE_KEYBOARD
|
||||
RsInputDeviceAttach(rsKEYBOARD, KeyboardHandler);
|
||||
#endif
|
||||
|
||||
RsInputDeviceAttach(rsPAD, PadHandler);
|
||||
|
||||
|
|
|
@ -12,12 +12,14 @@ DWORD _dwOperatingSystemVersion;
|
|||
#include "resource.h"
|
||||
#else
|
||||
long _dwOperatingSystemVersion;
|
||||
#ifndef __SWITCH__
|
||||
#ifndef __APPLE__
|
||||
#include <sys/sysinfo.h>
|
||||
#else
|
||||
#include <mach/mach_host.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
|
@ -51,7 +53,7 @@ long _dwOperatingSystemVersion;
|
|||
#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.
|
||||
#if !defined _WIN32 && !defined __APPLE__ && !defined __SWITCH__ // && !defined WAYLAND
|
||||
#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_HANDHELD // && !defined WAYLAND
|
||||
#define GET_KEYBOARD_INPUT_FROM_X11
|
||||
#endif
|
||||
|
||||
|
@ -324,6 +326,78 @@ psNativeTextureSupport(void)
|
|||
#define CMDSTR LPSTR
|
||||
#endif
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __SWITCH__
|
||||
|
||||
static HidVibrationValue SwitchVibrationValues[2];
|
||||
static HidVibrationDeviceHandle SwitchVibrationDeviceHandles[2][2];
|
||||
static HidVibrationDeviceHandle SwitchVibrationDeviceGC;
|
||||
|
||||
static PadState SwitchPad;
|
||||
|
||||
static Result HidInitializationResult[2];
|
||||
static Result HidInitializationGCResult;
|
||||
|
||||
static void _psInitializeVibration()
|
||||
{
|
||||
HidInitializationResult[0] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[0], 2, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld);
|
||||
if(R_FAILED(HidInitializationResult[0])) {
|
||||
printf("Failed to initialize VibrationDevice for Handheld Mode\n");
|
||||
}
|
||||
HidInitializationResult[1] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[1], 2, HidNpadIdType_No1, HidNpadStyleSet_NpadFullCtrl);
|
||||
if(R_FAILED(HidInitializationResult[1])) {
|
||||
printf("Failed to initialize VibrationDevice for Detached Mode\n");
|
||||
}
|
||||
HidInitializationGCResult = hidInitializeVibrationDevices(&SwitchVibrationDeviceGC, 1, HidNpadIdType_No1, HidNpadStyleTag_NpadGc);
|
||||
if(R_FAILED(HidInitializationResult[1])) {
|
||||
printf("Failed to initialize VibrationDevice for GC Mode\n");
|
||||
}
|
||||
|
||||
SwitchVibrationValues[0].freq_low = 160.0f;
|
||||
SwitchVibrationValues[0].freq_high = 320.0f;
|
||||
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadFullCtrl);
|
||||
padInitializeDefault(&SwitchPad);
|
||||
}
|
||||
|
||||
static void _psHandleVibration()
|
||||
{
|
||||
padUpdate(&SwitchPad);
|
||||
|
||||
uint8 target_device = padIsHandheld(&SwitchPad) ? 0 : 1;
|
||||
|
||||
if(R_SUCCEEDED(HidInitializationResult[target_device])) {
|
||||
CPad* pad = CPad::GetPad(0);
|
||||
|
||||
// value conversion based on SDL2 switch port
|
||||
SwitchVibrationValues[0].amp_high = SwitchVibrationValues[0].amp_low = pad->ShakeFreq == 0 ? 0.0f : 320.0f;
|
||||
SwitchVibrationValues[0].freq_low = pad->ShakeFreq == 0.0 ? 160.0f : (float)pad->ShakeFreq * 1.26f;
|
||||
SwitchVibrationValues[0].freq_high = pad->ShakeFreq == 0.0 ? 320.0f : (float)pad->ShakeFreq * 1.26f;
|
||||
|
||||
if (pad->ShakeDur < CTimer::GetTimeStepInMilliseconds())
|
||||
pad->ShakeDur = 0;
|
||||
else
|
||||
pad->ShakeDur -= CTimer::GetTimeStepInMilliseconds();
|
||||
if (pad->ShakeDur == 0) pad->ShakeFreq = 0;
|
||||
|
||||
|
||||
if(target_device == 1 && R_SUCCEEDED(HidInitializationGCResult)) {
|
||||
// gamecube rumble
|
||||
hidSendVibrationGcErmCommand(SwitchVibrationDeviceGC, pad->ShakeFreq > 0 ? HidVibrationGcErmCommand_Start : HidVibrationGcErmCommand_Stop);
|
||||
}
|
||||
|
||||
memcpy(&SwitchVibrationValues[1], &SwitchVibrationValues[0], sizeof(HidVibrationValue));
|
||||
hidSendVibrationValues(SwitchVibrationDeviceHandles[target_device], SwitchVibrationValues, 2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void _psInitializeVibration() {}
|
||||
static void _psHandleVibration() {}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
@ -407,6 +481,8 @@ psInitialize(void)
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
_psInitializeVibration();
|
||||
|
||||
gGameState = GS_START_UP;
|
||||
TRACE("gGameState = GS_START_UP");
|
||||
|
@ -484,6 +560,9 @@ psInitialize(void)
|
|||
_dwMemAvailPhys = (uint64_t)(vm_stat.free_count * page_size);
|
||||
debug("Physical memory size %llu\n", _dwMemAvailPhys);
|
||||
debug("Available physical memory %llu\n", size);
|
||||
#elif defined (__SWITCH__)
|
||||
svcGetInfo(&_dwMemAvailPhys, InfoType_UsedMemorySize, CUR_PROCESS_HANDLE, 0);
|
||||
debug("Physical memory size %llu\n", _dwMemAvailPhys);
|
||||
#else
|
||||
struct sysinfo systemInfo;
|
||||
sysinfo(&systemInfo);
|
||||
|
@ -949,13 +1028,15 @@ void psPostRWinit(void)
|
|||
RwVideoMode vm;
|
||||
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
|
||||
|
||||
glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB);
|
||||
#ifndef IGNORE_MOUSE_KEYBOARD
|
||||
#ifndef GET_KEYBOARD_INPUT_FROM_X11
|
||||
glfwSetKeyCallback(PSGLOBAL(window), keypressCB);
|
||||
#endif
|
||||
glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB);
|
||||
glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
|
||||
glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
|
||||
glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
|
||||
#endif
|
||||
glfwSetWindowIconifyCallback(PSGLOBAL(window), windowIconifyCB);
|
||||
glfwSetWindowFocusCallback(PSGLOBAL(window), windowFocusCB);
|
||||
glfwSetJoystickCallback(joysChangeCB);
|
||||
|
@ -1791,7 +1872,7 @@ main(int argc, char *argv[])
|
|||
InitMemoryMgr();
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32) && !defined(__SWITCH__)
|
||||
struct sigaction act;
|
||||
act.sa_sigaction = terminateHandler;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
|
@ -2455,6 +2536,8 @@ void CapturePad(RwInt32 padID)
|
|||
if ( Abs(rightStickPos.y) > 0.3f )
|
||||
pad->PCTempJoyState.RightStickY = (int32)(rightStickPos.y * 128.0f);
|
||||
}
|
||||
|
||||
_psHandleVibration();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue