From ee89c485fcce7f3b9a189f7a80b3a1b2933f79bd Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 24 Jan 2021 13:42:45 +0300 Subject: sync --- src/skel/glfw/glfw.cpp | 66 +++++++++++++++++++++++++++++--------------------- src/skel/win/win.cpp | 36 ++++++++++++++++++--------- 2 files changed, 63 insertions(+), 39 deletions(-) (limited to 'src/skel') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index d0818d6d..3e7ba0ab 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1,22 +1,30 @@ #if defined RW_GL3 && !defined LIBRW_SDL2 #ifdef _WIN32 -#include +#include +#include #include +#include #include #include -#include -#include -#include + +DWORD _dwOperatingSystemVersion; +#include "resource.h" +#else +long _dwOperatingSystemVersion; +#ifndef __APPLE__ +#include +#else +#include +#include +#endif +#include +#include +#include +#include #endif -#define WITHWINDOWS #include "common.h" - -#pragma warning( push ) -#pragma warning( disable : 4005) -#pragma warning( pop ) - #if (defined(_MSC_VER)) #include #endif /* (defined(_MSC_VER)) */ @@ -72,23 +80,6 @@ static psGlobalType PsGlobal; size_t _dwMemAvailPhys; RwUInt32 gGameState; -#ifdef _WIN32 -DWORD _dwOperatingSystemVersion; -#include "resource.h" -#else -long _dwOperatingSystemVersion; -#ifndef __APPLE__ -#include -#else -#include -#include -#endif -#include -#include -#include -#include -#endif - #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS char gSelectedJoystickName[128] = ""; #endif @@ -1646,6 +1637,13 @@ main(int argc, char *argv[]) { CFileMgr::SetDirMyDocuments(); +#ifdef LOAD_INI_SETTINGS + // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons. + // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it, + // so we can add new joy bindings **on top of** stored bindings. + int connectedPadButtons = ControlsManager.ms_padButtonsInited; +#endif + int32 gta3set = CFileMgr::OpenFile("gta_vc.set", "r"); if ( gta3set ) @@ -1655,6 +1653,14 @@ main(int argc, char *argv[]) } CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } +#endif } #ifdef _WIN32 @@ -2167,6 +2173,12 @@ void joysChangeCB(int jid, int event) PSGLOBAL(joy1id) = jid; #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS strcpy(gSelectedJoystickName, glfwGetJoystickName(jid)); +#endif + // This is behind LOAD_INI_SETTINGS, because otherwise the Init call below will destroy/overwrite your bindings. +#ifdef LOAD_INI_SETTINGS + int count; + glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); + ControlsManager.InitDefaultControlConfigJoyPad(count); #endif } else if (PSGLOBAL(joy2id) == -1) PSGLOBAL(joy2id) = jid; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index db6215f0..87c3846a 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2,7 +2,6 @@ #define _WIN32_WINDOWS 0x0500 #define WINVER 0x0500 -#define DIRECTINPUT_VERSION 0x0800 #include #include @@ -20,13 +19,7 @@ #pragma warning( push ) #pragma warning( disable : 4005) -#ifdef USE_D3D9 -#include -#else -#include -#endif #include -#include #include #pragma warning( pop ) @@ -41,6 +34,9 @@ #pragma comment( lib, "strmiids.lib" ) #pragma comment( lib, "dinput8.lib" ) +#define WITHD3D +#define WITHDINPUT +#include "common.h" #if (defined(_MSC_VER)) #include #endif /* (defined(_MSC_VER)) */ @@ -81,7 +77,6 @@ static psGlobalType PsGlobal; #define JIF(x) if (FAILED(hr=(x))) \ {debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;} -#include "common.h" #include "main.h" #include "FileMgr.h" #include "Text.h" @@ -92,12 +87,14 @@ static psGlobalType PsGlobal; #include "Frontend.h" #include "Game.h" #include "PCSave.h" -#include "MemoryCard.h" -#include "Sprite2d.h" #include "AnimViewer.h" -#include "Font.h" #include "MemoryMgr.h" +#ifdef PS2_MENU +#include "MemoryCard.h" +#include "Font.h" +#endif + VALIDATE_SIZE(psGlobalType, 0x28); // DirectShow interfaces @@ -2148,8 +2145,15 @@ WinMain(HINSTANCE instance, { CFileMgr::SetDirMyDocuments(); +#ifdef LOAD_INI_SETTINGS + // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons. + // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it, + // so we can add new joy bindings **on top of** stored bindings. + int connectedPadButtons = ControlsManager.ms_padButtonsInited; +#endif + int32 gta3set = CFileMgr::OpenFile("gta_vc.set", "r"); - + if ( gta3set ) { ControlsManager.LoadSettings(gta3set); @@ -2157,6 +2161,14 @@ WinMain(HINSTANCE instance, } CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } +#endif } SetErrorMode(SEM_FAILCRITICALERRORS); -- cgit v1.2.3