#pragma once // IO settings of the SDL2 port (BreaknesSDL). // // The format repeats the config of the managed application (Breaknes/IOConfig.json), // but the settings are stored in a separate file (IOConfigSDL.json by default) so // that the two applications never overlap each other's settings (issue #516). #include #include namespace BreaknesSDL { /// /// Default name of the IO settings file of the SDL2 port. /// The managed application uses its own "IOConfig.json", so the settings never overlap. /// const char* const kDefaultIOConfigPath = "IOConfigSDL.json"; /// /// The motherboard of the SDL2 port. The board configuration (name, APU, PPUs, /// p1, TV layout and TV<->PPU binding) is read from BoardDescription.json /// (issue #515). The IO settings reference the board by this name. /// By default a real NES board is used (issue #521); the debug boards /// ("NES Debug: ...") can be selected on the command line with --board. /// const char* const kSDLBoardName = "NES (NES-CPU-07, 1987)"; /// /// Associative binding of a device IOState (actuator) to an input event of the PC. /// The binding string is the name of the SDL input event, e.g. "Up", /// "Controller0_ButtonA", "Controller0_DPadUp", "Controller0_AxisLeftX-". /// struct IOConfigBinding { int actuator_id = 0; std::string binding; }; /// /// Attach of the device to a motherboard port. /// struct IOConfigPort { std::string board; int port = -1; }; /// /// A registered device of the device pool (added/removed by the user, see IO/IO.h /// for the list of DeviceID). /// struct IOConfigDevice { uint32_t device_id = 0; std::string name; std::vector attached; std::vector bindings; }; /// /// The whole IO settings document. /// struct IOConfig { std::string descr; std::vector devices; }; /// /// Load/save of the IO settings and helper methods. /// class IOConfigManager { public: /// /// Load the IO settings from the JSON file. /// /// false if the file is missing or cannot be parsed. static bool Load(const char* path, IOConfig& config); /// /// Save the IO settings to the JSON file. /// static bool Save(const IOConfig& config, const char* path); /// /// Human-readable name of the device type by DeviceID (see IO/IO.h). /// static std::string DeviceIDToString(uint32_t device_id); /// /// Default device name used when a device is added without a user-specified name. /// static std::string GetDefaultDeviceName(uint32_t device_id); }; }