summaryrefslogtreecommitdiffstats
path: root/src/skel
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-01-22 21:40:28 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2021-01-22 21:43:49 +0100
commit226e3b83dafbff6e59b8d351441026c5a6a4bf25 (patch)
treeff214ec3d124746ae08fba9ef1128f286c89c772 /src/skel
parentfix (diff)
downloadre3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.tar
re3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.tar.gz
re3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.tar.bz2
re3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.tar.lz
re3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.tar.xz
re3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.tar.zst
re3-226e3b83dafbff6e59b8d351441026c5a6a4bf25.zip
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/glfw/glfw.cpp18
-rw-r--r--src/skel/win/win.cpp14
2 files changed, 29 insertions, 3 deletions
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 786ada5e..332f59f0 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -1602,10 +1602,16 @@ main(int argc, char *argv[])
SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &NewStickyKeys, SPIF_SENDCHANGE);
#endif
- // This part is needed because controller initialisation overwrites loaded settings.
{
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("gta3.set", "r");
if ( gta3set )
@@ -1618,6 +1624,10 @@ main(int argc, char *argv[])
#ifdef LOAD_INI_SETTINGS
LoadINIControllerSettings();
+ if (connectedPadButtons != 0) {
+ ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons);
+ SaveINIControllerSettings();
+ }
#endif
}
@@ -2132,6 +2142,12 @@ void joysChangeCB(int jid, int event)
#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 16c37490..3bda4e9d 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -2150,12 +2150,18 @@ WinMain(HINSTANCE instance,
ShowWindow(PSGLOBAL(window), cmdShow);
UpdateWindow(PSGLOBAL(window));
- // This part is needed because controller initialisation overwrites loaded settings.
{
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("gta3.set", "r");
-
+
if ( gta3set )
{
ControlsManager.LoadSettings(gta3set);
@@ -2166,6 +2172,10 @@ WinMain(HINSTANCE instance,
#ifdef LOAD_INI_SETTINGS
LoadINIControllerSettings();
+ if (connectedPadButtons != 0) {
+ ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons);
+ SaveINIControllerSettings();
+ }
#endif
}