Exemplo n.º 1
0
        public static ClKeyboard GenerateFelix()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 15;
            kb.Name              = "Felix";
            kb.SaveFileExtension = "arb2f";
            kb.Commands.Add("uniqueksetkey");

            // buttons
            for (var i = 0; i < 4; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    var bi = new ClButtonInfo();
                    bi.X       = i;
                    bi.Y       = j;
                    bi.Command = 0;
                    bi.GW      = 72;
                    bi.GH      = 72;


                    bi.GX = 5 + i * 77;
                    bi.GY = 5 + j * 77;
                    kb.Buttons.Add(bi);
                }
            }
            return(kb);
        }
Exemplo n.º 2
0
        public List <string> GenerateCommand(ClKeyboard board, bool isScancode = true)
        {
            var lt       = new List <string>();
            var layCount = 0;

            if (this.KeyDatas.Count > 0)
            {
                layCount = this.KeyDatas.Max(ele => ele.Z) + 1;
            }
            lt.Add("uniqueksetlay(" + layCount + " ");
            lt.Add("uniqueksetsublay(" + layCount + " ");
            foreach (var kd in this.KeyDatas)
            {
                string keyVal;
                if (isScancode)
                {
                    keyVal = kd.Key.ValScan.ToString();
                }
                else
                {
                    keyVal = kd.Key.ValASCII.ToString();
                }
                lt.Add(board.Commands[kd.Command] + "(" + kd.X + "(" + kd.Y + "(" + kd.Z + "(" + keyVal + "(" + kd.Key.KeyType + " ");
            }

            foreach (var ad in this.AddonDatas)
            {
                lt.AddRange(ad.GetCommands());
            }

            return(lt);
        }
Exemplo n.º 3
0
        public static void CreateDefaultKeyboards()
        {
            if (!Directory.Exists(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD)))
            {
                Directory.CreateDirectory(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD));
            }

            MdCore.Serialize(ClKeyboard.GenerateDiverge2(), Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "diverge-2-3" + MdConstant.E_KEYBOARD));
            var d2r = ClKeyboard.GenerateDiverge2();

            d2r.Commands[0] = "uniqueksetsubkey";
            d2r.Commands[1] = "uniqueksetkey";
            MdCore.Serialize(d2r, Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "diverge-2-3-rightmaster" + MdConstant.E_KEYBOARD));
            MdCore.Serialize(ClKeyboard.GenerateDivergeTM(), Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "diverge-tm-1-2" + MdConstant.E_KEYBOARD));
            var dtmr = ClKeyboard.GenerateDivergeTM();

            dtmr.Commands[0] = "uniqueksetsubkey";
            dtmr.Commands[1] = "uniqueksetkey";
            MdCore.Serialize(dtmr, Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "diverge-tm-1-2-rightmaster" + MdConstant.E_KEYBOARD));
            MdCore.Serialize(ClKeyboard.GenerateTerminusMini(), Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "terminus-mini" + MdConstant.E_KEYBOARD));
            MdCore.Serialize(ClKeyboard.GenerateTerminusMini2(), Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "terminus-mini-2" + MdConstant.E_KEYBOARD));
            MdCore.Serialize(ClKeyboard.GenerateFelix(), Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "felix" + MdConstant.E_KEYBOARD));
            MdCore.Serialize(ClKeyboard.GenerateTerminus2(), Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "terminus-2" + MdConstant.E_KEYBOARD));
            var t2mr = ClKeyboard.GenerateTerminus2();

            t2mr.Commands[0] = "uniqueksetsubkey";
            t2mr.Commands[1] = "uniqueksetkey";
            MdCore.Serialize(t2mr, Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD, "terminus-2-rightmaster" + MdConstant.E_KEYBOARD));
        }
Exemplo n.º 4
0
 public UCLayer(ClKeyboard keyboard, ClLayoutContainer layout, int layer)
 {
     InitializeComponent();
     this.Layer       = layer;
     this.LTitle.Text = "Layer " + layer;
     this.Buttons     = new List <Button>();
     foreach (var bi in keyboard.Buttons)
     {
         var btn = new Button();
         btn.Text = "Null";
         btn.Tag  = bi.X + "_" + bi.Y + "_" + this.Layer + "_" + bi.Command;
         btn.Size = new Size(bi.GW, bi.GH);
         this.Buttons.Add(btn);
         this.PLMain.Add(btn, new Point(bi.GX, bi.GY));
         if (this.PLMain.Size.Width < bi.GX + bi.GW)
         {
             this.PLMain.Size = new Size(bi.GX + bi.GW, this.PLMain.Size.Height);
         }
         if (this.PLMain.Size.Height < bi.GY + bi.GH)
         {
             this.PLMain.Size = new Size(this.PLMain.Size.Width, bi.GY + bi.GH);
         }
         btn.Click   += (sender, e) => PressedKey(sender, e);
         btn.KeyDown += (sender, e) => KeyboardInput(sender, e);
     }
     LoadLayout(layout);
     InitHandle();
 }
Exemplo n.º 5
0
        public static ClKeyboard GenerateDivergeTM()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 13;
            kb.Name              = "Diverge TM 1 and 2";
            kb.SaveFileExtension = "arb2dtm";
            kb.Commands.Add("uniqueksetkey");
            kb.Commands.Add("uniqueksetsubkey");

            // buttons
            for (var i = 0; i < 6; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    for (var s = 0; s < 2; s++)
                    {
                        if ((i == 5) && (j == 3))
                        {
                            //do nothing
                        }
                        else
                        {
                            var bi = new ClButtonInfo();
                            bi.X       = i;
                            bi.Y       = j;
                            bi.Command = s;
                            bi.GW      = 72;
                            bi.GH      = 72;


                            if (s == 0)
                            {
                                bi.GX = 5 + i * 77;
                            }
                            else
                            {
                                bi.GX = s * 935 - (5 + i * 77);
                            }
                            if ((i == 4) && (j == 3))
                            {
                                bi.GW = 149;
                                if (s == 1)
                                {
                                    bi.GX = bi.GX - 77;
                                }
                            }
                            bi.GY = 5 + j * 77;
                            kb.Buttons.Add(bi);
                        }
                    }
                }
            }
            return(kb);
        }
Exemplo n.º 6
0
 public UCKeyboard(ClKeyboard keyboard, ClLayoutContainer layout)
 {
     InitializeComponent();
     this.Keyboard   = keyboard;
     this.Layers     = new List <UCLayer>();
     this.initalized = true;
     LoadLayout(layout);
     this.SavePath         = "<UNSAVED LAYOUT>";
     this.LLayoutName.Text = "<UNSAVED LAYOUT>";
     InitHandle();
 }
Exemplo n.º 7
0
 public ClKeyboard(ClKeyboard input)
 {
     this.Name    = input.Name;
     this.Buttons = new List <ClButtonInfo>();
     foreach (var btn in input.Buttons)
     {
         this.Buttons.Add(new ClButtonInfo(btn));
     }
     this.Commands = new List <string>();
     foreach (var str in input.Commands)
     {
         this.Commands.Add(str);
     }
     this.MaxLayers         = input.MaxLayers;
     this.SaveFileExtension = input.SaveFileExtension;
 }
Exemplo n.º 8
0
        public static void Init()
        {
            MdConfig.Init();
            CurrentKeyboardType = new ClKeyboard();
            CurrentLayout       = new ClLayoutContainer();
            CurrentKeyboardUI   = new UCKeyboard();
            KeyMenuKey          = new ClKey();
            CurrentInputMethod  = new ClDisplayCharacterContainer();
            KeyGroup            = new ClKeyGroup();
            SP = new SerialPort();

            if (File.Exists("favicon.ico"))
            {
                WindowIcon = new Icon(Path.Combine(MdConstant.root, MdConstant.N_ICON));
            }


            CurrentInputMethod = MdConfig.Main.GetCurrentInputMethod();
            KeyGroup           = MdCore.Deserialize <ClKeyGroup>(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYGROUP, "Core" + MdConstant.E_KEYGROUP));
        }
Exemplo n.º 9
0
        public static ClKeyboard GenerateDiverge2()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 8;
            kb.Name              = "Diverge 2 and 3";
            kb.SaveFileExtension = "arb2d2";
            kb.Commands.Add("uniqueksetkey");
            kb.Commands.Add("uniqueksetsubkey");

            // buttons
            for (var i = 0; i < 8; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    for (var s = 0; s < 2; s++)
                    {
                        if ((i != 7) || (j == 4))
                        {
                            var bi = new ClButtonInfo();
                            bi.X       = i;
                            bi.Y       = j;
                            bi.Command = s;
                            bi.GW      = 72;
                            bi.GH      = 72;
                            if (s == 0)
                            {
                                bi.GX = 5 + i * 77;
                            }
                            else
                            {
                                bi.GX = s * 1242 - (5 + i * 77);
                            }
                            bi.GY = 5 + j * 77;
                            kb.Buttons.Add(bi);
                        }
                    }
                }
            }
            return(kb);
        }
Exemplo n.º 10
0
        public static ClKeyboard GenerateTerminusMini()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 6;
            kb.Name              = "Terminus Mini";
            kb.SaveFileExtension = "arb2tm";
            kb.Commands.Add("uniqueksetkey");

            // buttons
            for (var i = 0; i < 12; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    if (((i == 5) && (j == 3)) || ((i == 7) && (j == 3)))
                    {
                        //do nothing
                    }
                    else
                    {
                        var bi = new ClButtonInfo();
                        bi.X       = i;
                        bi.Y       = j;
                        bi.Command = 0;
                        bi.GW      = 72;
                        bi.GH      = 72;


                        bi.GX = 5 + i * 77;
                        if (((i == 4) && (j == 3)) || ((i == 6) && (j == 3)))
                        {
                            bi.GW = 149;
                        }
                        bi.GY = 5 + j * 77;
                        kb.Buttons.Add(bi);
                    }
                }
            }
            return(kb);
        }
Exemplo n.º 11
0
        public static ClKeyboard GenerateTerminusMini2()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 6;
            kb.Name              = "Terminus Mini 2";
            kb.SaveFileExtension = "arb2tm2";
            kb.Commands.Add("uniqueksetkey");

            // buttons
            for (var i = 0; i < 10; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    //if ((i == 5 && j == 3) || (i == 7 && j == 3))
                    {
                        //do nothing
                    }
                    //else
                    {
                        var bi = new ClButtonInfo();
                        bi.X       = i;
                        bi.Y       = j;
                        bi.Command = 0;
                        bi.GW      = 72;
                        bi.GH      = 72;

                        if ((i > 4) && (j < 3))
                        {
                            bi.GX = 5 + (i + 2) * 77;
                        }
                        else
                        {
                            bi.GX = 5 + i * 77;
                        }

                        if ((i > 4) && (j == 3))
                        {
                            bi.GX = 5 + (i + 1) * 77;
                        }


                        if ((i > 5) && (j == 3))
                        {
                            bi.GX = 5 + (i + 2) * 77;
                        }

                        if (((i == 4) && (j == 3)) || ((i == 5) && (j == 3)))
                        {
                            bi.GW = 149;
                        }
                        bi.GY = 5 + j * 77;
                        kb.Buttons.Add(bi);
                    }
                }
            }


            for (var i = 5; i < 7; i++)
            {
                for (var j = 0; j < 3; j++)
                {
                    var bi = new ClButtonInfo();
                    bi.Y = 4;
                    if ((i == 5) && (j == 2))
                    {
                        bi.X = 2;
                    }
                    else if ((i == 5) && (j == 1))
                    {
                        bi.X = 3;
                    }
                    else if ((i == 5) && (j == 0))
                    {
                        bi.X = 4;
                    }
                    else if ((i == 6) && (j == 0))
                    {
                        bi.X = 5;
                    }
                    else if ((i == 6) && (j == 1))
                    {
                        bi.X = 6;
                    }
                    else if ((i == 6) && (j == 2))
                    {
                        bi.X = 7;
                    }
                    bi.Command = 0;
                    bi.GW      = 72;
                    bi.GH      = 72;


                    bi.GX = 5 + i * 77;
                    bi.GY = 5 + j * 77;
                    kb.Buttons.Add(bi);
                }
            }

            return(kb);
        }
Exemplo n.º 12
0
        public static ClKeyboard GenerateTerminus2()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 10;
            kb.Name              = "Terminus 2";
            kb.SaveFileExtension = "arb2t2";
            kb.Commands.Add("uniqueksetkey");
            kb.Commands.Add("uniqueksetsubkey");

            // buttons
            for (var i = 0; i < 7; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    if ((j == 4) && ((i == 2) || (i == 6)))
                    {
                        // do nothing
                    }
                    else
                    {
                        var bi = new ClButtonInfo();
                        bi.X       = i;
                        bi.Y       = j;
                        bi.Command = 0;
                        bi.GW      = 72;
                        bi.GH      = 72;

                        if ((j == 4) && (i < 5))
                        {
                            bi.GW = 91;
                        }


                        if ((j == 4) && (i == 5))
                        {
                            bi.GW = 149;
                        }

                        bi.GX = 5 + i * 77;

                        if ((j == 4) && (i < 2))
                        {
                            bi.GX = 5 + i * 97;
                        }

                        if ((j == 4) && (i > 2) && (i < 5))
                        {
                            bi.GX = 5 + (i - 1) * 96;
                        }
                        bi.GY = 5 + j * 77;
                        kb.Buttons.Add(bi);
                    }
                }
            }


            for (var i = 0; i < 7; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    if ((j == 4) && (i == 1))
                    {
                        // do nothing
                    }
                    else
                    {
                        var bi = new ClButtonInfo();
                        bi.X       = i;
                        bi.Y       = j;
                        bi.Command = 1;
                        bi.GW      = 72;
                        bi.GH      = 72;


                        if ((j == 4) && (i == 0))
                        {
                            bi.GW = 149;
                        }

                        bi.GX = 544 + i * 77;
                        bi.GY = 5 + j * 77;
                        kb.Buttons.Add(bi);
                    }
                }
            }

            return(kb);
        }
Exemplo n.º 13
0
        public static ClKeyboard GenerateDiverge2()
        {
            var kb = new ClKeyboard();

            kb.MaxLayers         = 8;
            kb.Name              = "Diverge 2 and 3";
            kb.SaveFileExtension = "arb2d2";
            kb.Commands.Add("uniqueksetkey");
            kb.Commands.Add("uniqueksetsubkey");

            var basexl = 5;
            var basexr = 1237;
            var basey  = 5;

            // buttons
            for (var i = 0; i < 8; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    for (var s = 0; s < 2; s++)
                    {
                        if ((i != 7) || (j == 4))
                        {
                            var bi = new ClButtonInfo();
                            bi.X       = i;
                            bi.Y       = j;
                            bi.Command = s;
                            bi.GW      = 72;
                            bi.GH      = 72;

                            bi.GX = i * 77;
                            bi.GY = basey + j * 77;

                            if (i == 1)
                            {
                                bi.GY += 55;
                            }
                            else if (i == 2 || i == 5)
                            {
                                bi.GY += 20;
                            }
                            else if (i == 6)
                            {
                                bi.GY += 30;
                            }

                            if (j == 4 && i >= 5)
                            {
                                bi.GX += 20;
                                if (i == 5)
                                {
                                    bi.GY += 20;
                                }
                                else if (i == 6)
                                {
                                    bi.GY += 30;
                                }
                                else if (i == 7)
                                {
                                    bi.GY += 90;
                                }
                            }

                            if (s == 0)
                            {
                                bi.GX = basexl + bi.GX;
                            }
                            else
                            {
                                bi.GX = basexr - bi.GX;
                            }

                            kb.Buttons.Add(bi);
                        }
                    }
                }
            }
            return(kb);
        }