private void DeleteInterface() { if (this.listViewInterface.SelectedItems.Count < 1) { return; } MInterface mi = this.listViewInterface.SelectedItems[0].Tag as MInterface; Program.ConfigMgt.Config.Interfaces.Remove(mi); RefreshInterfaceList(); }
/// <summary> /// Sets the state name used by the LoadState and SaveState functions. /// The extension (.sav) does not need to be included in the argument. /// </summary> /// <param name="t_name">The state name as a string.</param> public void SetStateName(string t_name) { // TODO: Although this method works, it would be preferrable to use the WriteArray function to write the StateName // alone for performance improvement. But when I tried to implement this, only the first character of the // string was being written, thus the function did not work at all. MInterface mi = ReadStructFromMemory(); mi.StateName = t_name; WriteStructToMemory(mi); }
/// <summary> /// Writes the whole struct to Dolphin's Shared Memory. /// </summary> /// <param name="t_mInterface">The MInterface object to be written.</param> private void WriteStructToMemory(MInterface t_mInterface) { int size = Marshal.SizeOf(typeof(MInterface)); byte[] data = new byte[size]; // Using an IntPtr to convert the MInterface to a byte array IntPtr p = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(t_mInterface, p, false); Marshal.Copy(p, data, 0, data.Length); m_accessor.WriteArray <byte>(0, data, 0, data.Length); }
public FormMInterface(MInterface mi) { InitializeComponent(); _mInterface = mi; if (_mInterface == null) { _mInterface = new MInterface(); this.Text = "Add Interface"; } else { this.Text = "Edit Interface"; } LoadSetting(); }
private void EditInterface() { if (this.listViewInterface.SelectedItems.Count < 1) { return; } MInterface mi = this.listViewInterface.SelectedItems[0].Tag as MInterface; FormMInterface frm = new FormMInterface(mi); if (frm.ShowDialog(this) != DialogResult.OK) { return; } RefreshInterfaceList(); }
private void AddInterface() { FormMInterface frm = new FormMInterface(null); if (frm.ShowDialog(this) != DialogResult.OK) { return; } MInterface mi = frm.MInterface; if (mi == null) { return; } Program.ConfigMgt.Config.Interfaces.Add(mi); RefreshInterfaceList(); }
/// <summary> /// Updates the MInterface object with Dolphin's Shared Memory and activates the events caused by Dolphin. /// </summary> private void Update(object sender, EventArgs myEventArgs) { m_mInterface = ReadStructFromMemory(); if (m_mInterface.FrameCount != _frameCount && FrameCountChanged != null) { FrameCountChanged(this, EventArgs.Empty); } _frameCount = m_mInterface.FrameCount; if (m_mInterface.InputFrameCount != _inputFrameCount && InputFrameCountChanged != null) { InputFrameCountChanged(this, EventArgs.Empty); } _inputFrameCount = m_mInterface.InputFrameCount; if (m_mInterface.IsMoviePlayingBack != _moviePlayingBack && MoviePlaybackStateChanged != null) { MoviePlaybackStateChanged(this, EventArgs.Empty); } _moviePlayingBack = m_mInterface.IsMoviePlayingBack; SendInputsToDolphin(); }
public DolphinMemoryInterface() { // Initializing Shared Memory Communication m_file = MemoryMappedFile.OpenExisting(MEMORY_MAP_OBJECT); m_accessor = m_file.CreateViewAccessor(0, MEMORY_MAP_SIZE, MemoryMappedFileAccess.ReadWrite); // Initializing internal variables that handle event activation m_mInterface = ReadStructFromMemory(); _frameCount = m_mInterface.FrameCount; _inputFrameCount = m_mInterface.InputFrameCount; _moviePlayingBack = m_mInterface.IsMoviePlayingBack; // Initializing queue of inputs m_inputsToSend = new Queue <GCController>(); // Initializing timer that calls Update in every inverval of TIMER_INTERVAL_MS Timer m_timer = new Timer(); m_timer.Tick += new EventHandler(Update); m_timer.Interval = TIMER_INTERVAL_MS; m_timer.Start(); }
public FormMInterfaceHost(MInterface mi) { InitializeComponent(); _mInterface = mi; LoadSetting(); }