Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        public FormMInterface(MInterface mi)
        {
            InitializeComponent();

            _mInterface = mi;
            if (_mInterface == null)
            {
                _mInterface = new MInterface();
                this.Text   = "Add Interface";
            }
            else
            {
                this.Text = "Edit Interface";
            }
            LoadSetting();
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        /// <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();
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
 public FormMInterfaceHost(MInterface mi)
 {
     InitializeComponent();
     _mInterface = mi;
     LoadSetting();
 }