mirror of
https://github.com/halpz/re3.git
synced 2025-07-02 15:40:50 +00:00
No more resetting bindings for joypad, create .ini at the first start, joystick hotplug for Linux
This commit is contained in:
@ -1634,10 +1634,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("gta_vc.set", "r");
|
||||
|
||||
if ( gta3set )
|
||||
@ -1650,6 +1656,10 @@ main(int argc, char *argv[])
|
||||
|
||||
#ifdef LOAD_INI_SETTINGS
|
||||
LoadINIControllerSettings();
|
||||
if (connectedPadButtons != 0) {
|
||||
ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons);
|
||||
SaveINIControllerSettings();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2163,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;
|
||||
|
@ -2142,12 +2142,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("gta_vc.set", "r");
|
||||
|
||||
|
||||
if ( gta3set )
|
||||
{
|
||||
ControlsManager.LoadSettings(gta3set);
|
||||
@ -2158,6 +2164,10 @@ WinMain(HINSTANCE instance,
|
||||
|
||||
#ifdef LOAD_INI_SETTINGS
|
||||
LoadINIControllerSettings();
|
||||
if (connectedPadButtons != 0) {
|
||||
ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons);
|
||||
SaveINIControllerSettings();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user