From c5713adb0a57d4476c9c0ecf2bd4ebe274d5f925 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 10 Feb 2016 16:30:50 +0200 Subject: [PATCH] default_prefs reset check. --- cfgfile.cpp | 12 +++++++----- consolehook.cpp | 2 +- include/inputdevice.h | 3 ++- include/options.h | 2 +- inputdevice.cpp | 30 ++++++++++++++++++++---------- main.cpp | 2 +- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 87ac95f9..678dafc3 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -1585,7 +1585,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_str (f, _T("gfx_colour_mode"), colormode1[p->color_mode]); cfgfile_write_bool(f, _T("gfx_blacker_than_black"), p->gfx_blackerthanblack); cfgfile_dwrite_bool(f, _T("gfx_monochrome"), p->gfx_grayscale); - cfgfile_write_str(f, _T("gfx_atari_palette_fix"), threebitcolors[p->gfx_threebitcolors]); + cfgfile_dwrite_str(f, _T("gfx_atari_palette_fix"), threebitcolors[p->gfx_threebitcolors]); cfgfile_dwrite_bool (f, _T("gfx_black_frame_insertion"), p->lightboost_strobo); cfgfile_write_str (f, _T("gfx_api"), filterapi[p->gfx_api]); cfgfile_dwrite (f, _T("gfx_horizontal_tweak"), _T("%d"), p->gfx_extrawidth); @@ -6036,14 +6036,14 @@ static void default_prefs_mini (struct uae_prefs *p, int type) #include "sounddep/sound.h" -void default_prefs (struct uae_prefs *p, int type) +void default_prefs (struct uae_prefs *p, bool reset, int type) { int i; int roms[] = { 6, 7, 8, 9, 10, 14, 5, 4, 3, 2, 1, -1 }; TCHAR zero = 0; struct zfile *f; - reset_inputdevice_config (p); + reset_inputdevice_config (p, reset); memset (p, 0, sizeof (*p)); _tcscpy (p->description, _T("UAE default configuration")); p->config_hardware_path[0] = 0; @@ -6082,8 +6082,10 @@ void default_prefs (struct uae_prefs *p, int type) p->jports[1].id = -1; p->jports[2].id = -1; p->jports[3].id = -1; - inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, 0); - inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, 0); + if (reset) { + inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, 0); + inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, 0); + } p->keyboard_lang = KBD_LANG_US; p->produce_sound = 3; diff --git a/consolehook.cpp b/consolehook.cpp index c427b578..25a05597 100644 --- a/consolehook.cpp +++ b/consolehook.cpp @@ -21,7 +21,7 @@ void consolehook_config (struct uae_prefs *p) struct uaedev_config_info ci = { 0 }; int roms[] = { 15, 31, 16, 46, -1 }; - default_prefs (p, 0); + default_prefs (p, true, 0); //p->headless = 1; p->produce_sound = 0; p->gfx_resolution = 0; diff --git a/include/inputdevice.h b/include/inputdevice.h index 20d270a2..38ba7c57 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -179,6 +179,7 @@ extern int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHA extern int inputdevice_get_mapping (int devnum, int num, uae_u64 *pflags, int *port, TCHAR *name, TCHAR *custom, int sub); extern void inputdevice_copyconfig (struct uae_prefs *src, struct uae_prefs *dst); extern void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum, int selectedwidget); +extern void inputdevice_copyjports(struct uae_prefs *srcprefs, struct uae_prefs *dstprefs); extern void inputdevice_swap_ports (struct uae_prefs *p, int devnum); extern void inputdevice_swap_compa_ports (struct uae_prefs *p, int portswap); extern void inputdevice_config_change (void); @@ -280,7 +281,7 @@ extern void inputdevice_reset (void); extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f); extern void read_inputdevice_config (struct uae_prefs *p, const TCHAR *option, TCHAR *value); -extern void reset_inputdevice_config (struct uae_prefs *pr); +extern void reset_inputdevice_config (struct uae_prefs *pr, bool reset); extern int inputdevice_joyport_config(struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int type, bool candefault); extern void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type); extern int inputdevice_getjoyportdevice (int port, int val); diff --git a/include/options.h b/include/options.h index 36a3c30b..2da006aa 100644 --- a/include/options.h +++ b/include/options.h @@ -755,7 +755,7 @@ extern void error_log (const TCHAR*, ...); extern TCHAR *get_error_log (void); extern bool is_error_log (void); -extern void default_prefs (struct uae_prefs *, int); +extern void default_prefs (struct uae_prefs *, bool, int); extern void discard_prefs (struct uae_prefs *, int); int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR*); diff --git a/inputdevice.cpp b/inputdevice.cpp index 2284ac43..0f5a69ea 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -1016,17 +1016,19 @@ static void reset_inputdevice_config_temp(void) temp_uid.lastdevtype = -1; } -void reset_inputdevice_config (struct uae_prefs *prefs) +void reset_inputdevice_config (struct uae_prefs *prefs, bool reset) { for (int i = 0; i < MAX_INPUT_SETTINGS; i++) reset_inputdevice_slot (prefs, i); reset_inputdevice_config_temp(); - for (int i = 0; i < MAX_JPORTS; i++) { - struct jport_config *jp = &jport_config_store[i]; - memset(jp, 0, sizeof(struct jport_config)); + if (reset) { + for (int i = 0; i < MAX_JPORTS; i++) { + struct jport_config *jp = &jport_config_store[i]; + memset(jp, 0, sizeof(struct jport_config)); + } + inputdevice_store_clear(); } - inputdevice_store_clear(); } static void set_kbr_default_event (struct uae_input_device *kbr, struct uae_input_device_kbr_default *trans, int num) @@ -2315,6 +2317,7 @@ static void inputdevice_mh_abs (int x, int y, uae_u32 buttonbits) } #endif } +#if 0 if (uaeboard_bank.baseaddr) { uae_u8 tmp[16]; @@ -2403,8 +2406,10 @@ static void inputdevice_mh_abs (int x, int y, uae_u32 buttonbits) p[1] |= 4; } } +#endif } +#if 0 void mousehack_write(int reg, uae_u16 val) { switch (reg) @@ -2417,7 +2422,7 @@ void mousehack_write(int reg, uae_u16 val) break; } } - +#endif #if 0 static void inputdevice_mh_abs_v36 (int x, int y) @@ -6552,12 +6557,10 @@ static void resetinput (void) } } -void inputdevice_updateconfig_internal (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs) +void inputdevice_copyjports(struct uae_prefs *srcprefs, struct uae_prefs *dstprefs) { - keyboard_default = keyboard_default_table[currprefs.input_keyboard_type]; - for (int i = 0; i < MAX_JPORTS; i++) { - copyjport (srcprefs, dstprefs, i); + copyjport(srcprefs, dstprefs, i); } if (srcprefs) { for (int i = 0; i < MAX_JPORTS_CUSTOM; i++) { @@ -6565,6 +6568,13 @@ void inputdevice_updateconfig_internal (struct uae_prefs *srcprefs, struct uae_p } } +} + +void inputdevice_updateconfig_internal (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs) +{ + keyboard_default = keyboard_default_table[currprefs.input_keyboard_type]; + + inputdevice_copyjports(srcprefs, dstprefs); resetinput (); joysticks = dstprefs->joystick_settings[dstprefs->input_selected_setting]; diff --git a/main.cpp b/main.cpp index 4b2630b6..723b71f5 100644 --- a/main.cpp +++ b/main.cpp @@ -1041,7 +1041,7 @@ static int real_main2 (int argc, TCHAR **argv) #endif set_config_changed (); if (restart_config[0]) { - default_prefs (&currprefs, 0); + default_prefs (&currprefs, true, 0); fixup_prefs (&currprefs, true); } -- 2.47.3