Пример #1
0
        void KeybindToIni(Ini.IniSection sect, Dummy.Keybinding kb)
        {
            if (kb == null)
            {
                return;
            }

            sect["edc"] = kb.edown.Count.ToString();
            for (int i = 0; i != kb.edown.Count; i++)
            {
                sect.WriteStruct <Dummy.Keybinding.Event>("edc" + i, kb.edown[i]);
            }

            sect["ehc"] = kb.eheld.Count.ToString();
            for (int i = 0; i != kb.eheld.Count; i++)
            {
                sect.WriteStruct <Dummy.Keybinding.Event>("ehc" + i, kb.eheld[i]);
            }

            sect["euc"] = kb.eup.Count.ToString();
            for (int i = 0; i != kb.eup.Count; i++)
            {
                sect.WriteStruct <Dummy.Keybinding.Event>("euc" + i, kb.eup[i]);
            }
        }
Пример #2
0
        private void btnCfgLoad_Click(object sender, EventArgs e)
        {
            dmy.rekts.Clear();

            if (File.Exists("3dsp.bin"))
            {
                using (FileStream fs = File.OpenRead("3dsp.bin"))
                {
                    while (true)
                    {
                        byte nth = (byte)fs.ReadByte();
                        if (nth == 0xFF)
                        {
                            break;
                        }

                        Dummy.Keybinding kb = dmy.bindings[nth];
                        kb.Import(fs);
                    }

                    int i = fs.ReadByte();

                    while (i > 0)
                    {
                        Dummy.RektButton rb = new Dummy.RektButton();
                        rb.Import(fs);
                        dmy.rekts.Add(rb);
                        i--;
                    }
                }

                btnCfgSave.PerformClick();
                Application.DoEvents();

                KeyconfigExport(new Ini(path));

                File.Delete("3dsp.bin");

                btnCfgLoad.PerformClick();

                return;
            }

            Ini ini = new Ini("3dsp.ini");

            Ini.IniSection sect = null;

            sect          = ini.GetSection("general");
            textIP.Text   = sect.Read("IP", dmy.ipaddr);
            numPort.Value = (UInt16)sect.ReadInt("port", dmy.port);
            path          = sect.Read("kconf", path);

            KeyconfigImport(ini);

            if (File.Exists(path))
            {
                KeyconfigImport(new Ini(path));
            }
        }
Пример #3
0
 public void Import(FileStream fs)
 {
     byte[] buf = new byte[System.Runtime.InteropServices.Marshal.SizeOf(typeof(Rectangle))];
     fs.Read(buf, 0, buf.Length);
     rekt = NativeInput.byte2struct <Rectangle>(buf);
     kb   = new Keybinding();
     kb.Import(fs);
 }
Пример #4
0
        void ProcessKHeld(Dummy.Keybinding key)
        {
            if (key == null)
            {
                return;
            }

            foreach (Dummy.Keybinding.Event evt in key.eheld)
            {
                ProcessEvent(evt);
            }
        }
Пример #5
0
        void ProcessKDown(Dummy.Keybinding key)
        {
            if (key == null)
            {
                return;
            }

            foreach (Dummy.Keybinding.Event evt in key.edown)
            {
                ProcessEvent(evt);
            }
        }
Пример #6
0
        void IniToKeybind(Ini.IniSection sect, Dummy.Keybinding kb)
        {
            if (kb == null)
            {
                return;
            }

            int cnt = 0;

            cnt = sect.ReadInt("edc");
            if (cnt > 0)
            {
                kb.edown.Clear();
                for (int i = 0; i != cnt; i++)
                {
                    kb.edown.Add(sect.ReadStruct <Dummy.Keybinding.Event>("edc" + i).Value);
                }
            }

            cnt = sect.ReadInt("ehc");
            if (cnt > 0)
            {
                kb.eheld.Clear();
                for (int i = 0; i != cnt; i++)
                {
                    kb.eheld.Add(sect.ReadStruct <Dummy.Keybinding.Event>("ehc" + i).Value);
                }
            }

            cnt = sect.ReadInt("euc");
            if (cnt > 0)
            {
                kb.eup.Clear();
                for (int i = 0; i != cnt; i++)
                {
                    kb.eup.Add(sect.ReadStruct <Dummy.Keybinding.Event>("euc" + i).Value);
                }
            }
        }