snes9x/gtk/src/gtk_config.h

177 lines
4.0 KiB
C
Raw Normal View History

/*****************************************************************************\
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
This file is licensed under the Snes9x License.
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
2010-09-25 15:46:12 +00:00
#ifndef __GTK_CONFIG_H
#define __GTK_CONFIG_H
#include "gtk_control.h"
#include "filter/snes_ntsc.h"
2010-09-25 15:46:12 +00:00
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
2018-11-18 19:08:42 +00:00
#include <string>
#include <array>
2010-09-25 15:46:12 +00:00
enum {
HWA_NONE = 0,
HWA_OPENGL = 1,
HWA_XV = 2
};
enum {
HIRES_MERGE = 0,
HIRES_NORMAL = 1,
HIRES_SCALE = 2
};
2010-09-25 15:46:12 +00:00
enum {
ESC_TOGGLE_MENUBAR = 0,
ESC_EXIT_FULLSCREEN = 1,
ESC_EXIT_SNES9X = 2
};
enum {
THROTTLE_TIMER = 0,
THROTTLE_TIMER_FRAMESKIP = 1,
THROTTLE_SOUND_SYNC = 2,
THROTTLE_NONE = 3
};
2010-09-25 15:46:12 +00:00
enum {
SPLASH_IMAGE_BLACK = 0,
SPLASH_IMAGE_SMTPE = 1,
SPLASH_IMAGE_PATTERN = 2,
2019-03-25 21:16:08 +00:00
SPLASH_IMAGE_BLUE = 3,
SPLASH_IMAGE_COMBO = 4,
SPLASH_IMAGE_STARFIELD = 5,
SPLASH_IMAGE_SNOW = 6
};
2010-09-25 15:46:12 +00:00
class Snes9xConfig
{
2018-11-02 01:44:06 +00:00
public:
Snes9xConfig();
int load_config_file();
int save_config_file();
int load_defaults();
void rebind_keys();
2010-09-25 15:46:12 +00:00
2018-11-02 01:44:06 +00:00
/* Screen options */
bool full_screen_on_open;
bool change_display_resolution;
bool fullscreen;
bool ui_visible;
int default_esc_behavior;
bool prevent_screensaver;
int xrr_index;
bool scale_to_fit;
bool maintain_aspect_ratio;
int aspect_ratio;
int scale_method;
bool overscan;
bool multithreading;
int hires_effect;
bool force_inverted_byte_order;
int splash_image;
2018-11-02 01:44:06 +00:00
snes_ntsc_setup_t ntsc_setup;
int ntsc_format;
float ntsc_hue;
float ntsc_saturation;
float ntsc_contrast;
float ntsc_brightness;
float ntsc_sharpness;
float ntsc_artifacts;
float ntsc_gamma;
float ntsc_resolution;
float ntsc_fringing;
float ntsc_bleed;
float ntsc_merge_fields;
int ntsc_scanline_intensity;
int scanline_filter_intensity;
int hw_accel;
bool allow_opengl;
bool allow_xv;
bool allow_xrandr;
2018-11-02 01:44:06 +00:00
/* Data options */
int save_sram_after_secs;
std::string sram_directory;
std::string savestate_directory;
std::string cheat_directory;
std::string patch_directory;
std::string export_directory;
std::string last_directory;
std::string last_shader_directory;
2018-11-02 01:44:06 +00:00
/* Controls */
std::array<JoypadBinding, NUM_JOYPADS> pad;
std::array<Binding, NUM_EMU_LINKS> shortcut;
2018-11-02 01:44:06 +00:00
/* Netplay */
bool netplay_is_server;
bool netplay_sync_reset;
bool netplay_send_rom;
int netplay_default_port;
int netplay_max_frame_loss;
std::string netplay_last_rom;
std::string netplay_last_host;
int netplay_last_port;
bool netplay_activated;
bool netplay_server_up;
2018-11-02 01:44:06 +00:00
/* Operational */
std::vector<std::string> sound_drivers;
int sound_driver;
bool mute_sound;
bool mute_sound_turbo;
int sound_buffer_size;
int sound_playback_rate;
bool auto_input_rate;
int sound_input_rate;
bool rom_loaded;
int window_width, window_height;
int preferences_width, preferences_height;
int shader_parameters_width, shader_parameters_height;
2019-02-18 02:55:59 +00:00
int current_display_tab;
bool pause_emulation_on_switch;
int num_threads;
bool screensaver_needs_reset;
bool modal_dialogs;
bool enable_icons;
bool pointer_is_visible;
gint64 pointer_timestamp;
unsigned int rewind_granularity;
unsigned int rewind_buffer_size;
int current_save_slot;
2018-11-06 22:30:50 +00:00
2018-11-02 01:44:06 +00:00
XRRScreenResources *xrr_screen_resources;
XRRCrtcInfo *xrr_crtc_info;
2010-09-25 15:46:12 +00:00
#ifdef USE_OPENGL
bool sync_to_vblank;
bool use_pbos;
int pbo_format;
bool npot_textures;
bool use_shaders;
std::string shader_filename;
bool use_glfinish;
bool use_sync_control;
2010-09-25 15:46:12 +00:00
#endif
gtk: Support adding/removing joysticks at runtime Reworked how/where SDL events are polled: - poll_joystick_events is now a static member of JoyDevice so it can be called from outside when needed (preference window for config and caliration). - S9xProcessEvents calls JoyDevice::poll_joystick_events directly so events are polled when no joysticks are attached. - JoyDevice::poll_joystick_events handles SDL_JOYDEVICE{ADDED,REMOVED} events. - Individual JoyDevice no longer call poll_joystick_events from get_events. Reworked how attached joysticks are maintained in Snes9xConfig: - Use a map for joysticks keyed on SDL JoystickID (instance id in sdl parlance), which is stable while a joystick is attached instead of an array keyed on device_index. The instance id is what poll_joystick_events gets with every event (except for SDL_JOYDEVICEADDED which gets a device_index...) Instance id is an incrementing int starting from 0, they are never reused. i.e. each attach/dettach/attach cycle yields a new id. Whereas device index are reused and can "move". - On SDL_JOYDEVICEADDED the joystick is handed a "joynum", that is, an int from 0 to NUM_JOYPADS-1. A new joystick always get the lowest available joynum. (joynum was already a member of JoyDevice but wasn't initialized, this seemed like a proper way to use it.) - On SDL_JOYDEVICEREMOVED, the joystick associated with the instance id is simply removed from the map. All this allows for the following behaviors. It is possible to start without any joystick, add one joystick and it works. (disconnect/reconnect cycles with a single joystick also work) Joystick numbers are "stable" while they remain connected. For example: - Start with joystick0 and joystick1 connected - if joystick0 is disconnected, joystick1 keeps its number and keeps working - if joystick0 (or any new joystick) is connected at this time, it gets to become joystick0 If all joysticks are disconnected while snes9x is running, the order of the "reconnections" will determine the joystick number of each joystick. I think there is room for improvement still, with regards to code organization. For instance, there could be a "JoyDevices" class which would handle all the attached JoyDevice. This would allow moving all the "joystick_*" methods from Snes9xConfig to that new class, and poll_joystick_events could also be moved there. The functionality wouldn't change, but the intent/ownership would probably be clearer.
2022-02-16 04:14:11 +00:00
JoyDevices joysticks;
int joystick_threshold;
2010-09-25 15:46:12 +00:00
};
std::string get_config_dir();
std::string get_config_file_name();
2010-09-25 15:46:12 +00:00
#endif /* __GTK_CONFIG_H */