Shipwright/libultraship/libultraship/GameSettings.cpp
KiritoDev 219804cbe4
Controller Configuration UI and JSON Config (#760)
* Initial controller hud ui

* Reverted fbdemo changes

* Moved config to json and implemented controller config

* fix build on linux, gitignore new config file

* fix build

* Fix compilation and file directory paths

* Call save on cvar save

* Fixed cvar loading and added deck slots to the config

* Changed control deck port 0 to use a physical device by default

* Added gyro and rumble & fixed loading errors

* Save config on toggle menubar

* fix linux build

* Fixed drift calculation

* Controller config now saves when pressing F1

* Removed ExitGame hook from ImGuiImpl

* Moved mappings to a map

* Added GetKeyName

* untranslate scancodes

* Fixed hud layout on keyboard device

* Fixed keyboard read on hud

* Fixed crash when reloading controllers

* Removed ConfigFile and changed file extension

* Changed Dummy to Disconnected and fixed filters

* Removed function leftover

* Changed ControllerHud to InputEditor

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: David Chavez <david@dcvz.io>
2022-07-13 23:12:11 -04:00

57 lines
1.6 KiB
C++

#include "GameSettings.h"
// Audio
#include <cstddef>
#include <PR/ultra64/types.h>
#include <PR/ultra64/sptask.h>
#include <PR/ultra64/pi.h>
#include <PR/ultra64/message.h>
#include "Cvar.h"
#include "GlobalCtx2.h"
#include "ImGuiImpl.h"
#include "../../soh/include/z64audio.h"
#include "Hooks.h"
#include "../../soh/soh/Enhancements/debugconsole.h"
#include "Window.h"
#include "Lib/Fast3D/gfx_rendering_api.h"
#define ABS(var) var < 0 ? -(var) : var
using namespace Ship;
namespace Game {
bool DeSyncAudio = false;
void UpdateAudio() {
Audio_SetGameVolume(SEQ_BGM_MAIN, CVar_GetFloat("gMainMusicVolume", 1));
Audio_SetGameVolume(SEQ_BGM_SUB, CVar_GetFloat("gSubMusicVolume", 1));
Audio_SetGameVolume(SEQ_FANFARE, CVar_GetFloat("gSFXMusicVolume", 1));
Audio_SetGameVolume(SEQ_SFX, CVar_GetFloat("gFanfareVolume", 1));
}
void LoadSettings() {
DebugConsole_LoadCVars();
}
void SaveSettings() {
DebugConsole_SaveCVars();
}
void InitSettings() {
ModInternal::RegisterHook<ModInternal::AudioInit>(UpdateAudio);
ModInternal::RegisterHook<ModInternal::GfxInit>([] {
gfx_get_current_rendering_api()->set_texture_filter((FilteringMode) CVar_GetS32("gTextureFilter", FILTER_THREE_POINT));
SohImGui::console->opened = CVar_GetS32("gConsoleEnabled", 0);
SohImGui::controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0);
UpdateAudio();
});
}
void SetSeqPlayerVolume(SeqPlayers playerId, float volume) {
Audio_SetGameVolume(playerId, volume);
}
}