private bool SetCoreOptions(void *data) { if (data == null) { return(false); } try { _wrapper.Core.DeserializeOptions(); retro_core_option_definition *defs = (retro_core_option_definition *)data; for (; defs->key != IntPtr.Zero; ++defs) { string key = Marshal.PtrToStringAnsi(defs->key); string description = defs->desc != IntPtr.Zero ? Marshal.PtrToStringAnsi(defs->desc) : ""; string info = defs->info != IntPtr.Zero ? Marshal.PtrToStringAnsi(defs->info) : ""; string defaultValue = defs->default_value != IntPtr.Zero ? Marshal.PtrToStringAnsi(defs->default_value) : ""; List <string> possibleValues = new(); for (int i = 0; i < defs->values.Length; ++i) { if (defs->values[i].value == IntPtr.Zero) { break; } possibleValues.Add(Marshal.PtrToStringAnsi(defs->values[i].value)); } string value = ""; if (!string.IsNullOrWhiteSpace(defaultValue)) { value = defaultValue; } else if (possibleValues.Count > 0) { value = possibleValues[0]; } if (_wrapper.Core.CoreOptions[key] == null) { _wrapper.Core.CoreOptions[key] = new CoreOption(key, description, info, value, possibleValues.ToArray()); } else { _wrapper.Core.CoreOptions[key].Update(key, description, info, possibleValues.ToArray()); } } _wrapper.Core.SerializeOptions(); return(true); } catch (Exception e) { Logger.Instance.LogError($"Failed to retrieve and write the core options, they must be entered manually in the configuration file for now... (Exception message: {e.Message})"); return(false); } }
/* * FIXME: Figure out why data isn't providing proper addresses... * Trying to read intl->us gives invalid/unreadable memory * Definitions for retro_core_option_definition or retro_core_option_value don't really matter here I think. * Since intl->local and intl->us are of IntPtr type, shouldn't this give a valid memory address either way? */ private bool SetCoreOptionsIntl(void *data) { if (data == null) { return(false); } retro_core_options_intl * intl = (retro_core_options_intl *)data; retro_core_option_definition *us = (retro_core_option_definition *)intl->us; return(ENVIRONMENT_NOT_IMPLEMENTED(retro_environment.RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL)); }