Example #1
0
        public virtual void SendDirectColorCanvas(Color[,] colorDataArg)
        {
            //NOTE: the number of rows and columns for all keyboards are as follows
            //Claymore 23,8
            //TUF K5 5,1
            //Charm(Flare Normal) 24,6
            //Flare COD 24,6
            //Rog CTRL(Rog Scope Normal) 24,6
            //Flare PNK 24,6
            //TUF K7 23,6
            //Scope TKL 26,7
            //This function doesn't work with TUFKB(K5) and Claymore(any model including the core)
            var colorData = colorDataArg.FlattenMatrix();

            byte[] buffer = new byte[64];
            int    XMax   = DirectColorCanvasLength.Item1;
            int    YMax   = DirectColorCanvasLength.Item2;

            int uVar4 = XMax * YMax;

            byte[] generated0x54field = new byte[uVar4];
            for (int y = 0; y < YMax; y++)
            {
                for (int x = 0; x < XMax; x++)
                {
                    generated0x54field[(y * XMax) + x] = (byte)(x * 8 + y);
                }
            }

            buffer[0] = 0xc0;
            buffer[1] = 0x81;

            long lVar10 = 0;

            do
            {
                buffer[2] = (byte)uVar4;
                buffer[3] = (byte)(uVar4 >> 8);

                long uVar7 = 15;

                if (uVar4 != 0)
                {
                    if (uVar4 < 16)
                    {
                        uVar7 = uVar4;
                    }

                    int lVar9 = 0;
                    do
                    {
                        int currentIndexInBuffer = lVar9 * 4 + 4;

                        buffer[currentIndexInBuffer] = generated0x54field[lVar10];

                        buffer[++currentIndexInBuffer] = colorData[lVar10].R;
                        buffer[++currentIndexInBuffer] = colorData[lVar10].G;
                        buffer[++currentIndexInBuffer] = colorData[lVar10].B;

                        lVar9++;
                        lVar10++;
                    } while (lVar9 < uVar7);
                }
                SendIface0ByteArray(buffer);
                if (uVar4 < 16)
                {
                    break;
                }
                uVar4 -= 15;
            } while (uVar4 != 0);
        }