openMSX
GlobalSettings.cc
Go to the documentation of this file.
1 #include "GlobalSettings.hh"
2 #include "SettingsConfig.hh"
4 #include "strCat.hh"
5 #include "view.hh"
6 #include "xrange.hh"
7 #include "build-info.hh"
8 #include <memory>
9 #include <SDL.h>
10 
11 namespace openmsx {
12 
14  : commandController(commandController_)
15  , pauseSetting(commandController, "pause",
16  "pauses the emulation", false, Setting::DONT_SAVE)
17  , powerSetting(commandController, "power",
18  "turn power on/off", false, Setting::DONT_SAVE)
19  , autoSaveSetting(commandController, "save_settings_on_exit",
20  "automatically save settings when openMSX exits", true)
21  , umrCallBackSetting(commandController, "umr_callback",
22  "Tcl proc to call when an UMR is detected", {})
23  , invalidPsgDirectionsSetting(commandController,
24  "invalid_psg_directions_callback",
25  "Tcl proc called when the MSX program has set invalid PSG port directions",
26  {})
27  , invalidPpiModeSetting(commandController,
28  "invalid_ppi_mode_callback",
29  "Tcl proc called when the MSX program has set an invalid PPI mode",
30  {})
31  , resampleSetting(commandController, "resampler", "Resample algorithm",
33  // For Dingux, LQ is good compromise between quality and performance
35 #elif PLATFORM_ANDROID
36  // For Android, BLIP is good compromise between quality and performance
38 #else
39  // For other platforms, default setting may be changed in future
41 #endif
46  , speedManager(commandController)
47  , throttleManager(commandController)
48 {
49  deadzoneSettings = to_vector(
50  view::transform(xrange(SDL_NumJoysticks()), [&](auto i) {
51  return std::make_unique<IntegerSetting>(
52  commandController,
53  strCat("joystick", i + 1, "_deadzone"),
54  "size (as a percentage) of the dead center zone",
55  25, 0, 100);
56  }));
57  getPowerSetting().attach(*this);
58 }
59 
61 {
62  getPowerSetting().detach(*this);
63  commandController.getSettingsConfig().setSaveSettings(
64  autoSaveSetting.getBoolean());
65 }
66 
67 // Observer<Setting>
68 void GlobalSettings::update(const Setting& setting)
69 {
70  if (&setting == &getPowerSetting()) { // either on or off
71  // automatically unpause after a power off/on cycle
72  // this solved a bug, but apart from that this behaviour also
73  // makes more sense
74  getPauseSetting().setBoolean(false);
75  }
76 }
77 
78 } // namespace openmsx
PLATFORM_DINGUX
#define PLATFORM_DINGUX
Definition: build-info.hh:16
openmsx::ResampledSoundDevice::RESAMPLE_HQ
@ RESAMPLE_HQ
Definition: ResampledSoundDevice.hh:19
xrange
auto xrange(T e)
Definition: xrange.hh:170
openmsx::Subject::detach
void detach(Observer< T > &observer)
Definition: Subject.hh:56
openmsx::ResampledSoundDevice::RESAMPLE_LQ
@ RESAMPLE_LQ
Definition: ResampledSoundDevice.hh:19
openmsx::SettingsConfig::setSaveSettings
void setSaveSettings(bool save)
Definition: SettingsConfig.hh:26
openmsx::Setting
Definition: Setting.hh:119
PLATFORM_ANDROID
#define PLATFORM_ANDROID
Definition: build-info.hh:17
view::transform
auto transform(Range &&range, UnaryOp op)
Definition: view.hh:306
SettingsConfig.hh
build-info.hh
view.hh
GlobalSettings.hh
openmsx::ResampledSoundDevice::RESAMPLE_BLIP
@ RESAMPLE_BLIP
Definition: ResampledSoundDevice.hh:19
openmsx::EnumSetting< ResampledSoundDevice::ResampleType >::Map
std::vector< std::pair< std::string, ResampledSoundDevice::ResampleType > > Map
Definition: EnumSetting.hh:35
strCat.hh
openmsx::GlobalSettings::GlobalSettings
GlobalSettings(GlobalCommandController &commandController)
Definition: GlobalSettings.cc:13
GlobalCommandController.hh
openmsx::GlobalSettings::getPauseSetting
BooleanSetting & getPauseSetting()
Definition: GlobalSettings.hh:30
openmsx::BooleanSetting::setBoolean
void setBoolean(bool b)
Definition: BooleanSetting.hh:18
openmsx::GlobalSettings::~GlobalSettings
~GlobalSettings()
Definition: GlobalSettings.cc:60
strCat
std::string strCat(Ts &&...ts)
Definition: strCat.hh:573
openmsx::GlobalCommandController
Definition: GlobalCommandController.hh:35
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
to_vector
auto to_vector(Range &&range) -> std::vector< detail::ToVectorType< T, decltype(std::begin(range))>>
Definition: stl.hh:311
openmsx::BooleanSetting::getBoolean
bool getBoolean() const noexcept
Definition: BooleanSetting.hh:17
xrange.hh
openmsx::GlobalCommandController::getSettingsConfig
SettingsConfig & getSettingsConfig()
Definition: GlobalCommandController.hh:88
openmsx::GlobalSettings::getPowerSetting
BooleanSetting & getPowerSetting()
Definition: GlobalSettings.hh:33