internal List <byte[]> ConvertToMouseCommand(string txt)
        {
            List <byte[]> list = new List <byte[]>();

            string[] tokens = txt.Split(' ');

            for (int i = 0; i < tokens.Length; i++)
            {
                byte reportId = 0;

                byte[] keyDown = TokenToCommand(tokens, ref i, out reportId);
                if (keyDown == null)
                {
                    continue;
                }

                list.Add(keyDown);

                byte[] keyUp = new byte[ReportDescEnumerator.GetReportSize(_reportDescriptor, reportId)];
                keyUp[0] = reportId;

                list.Add(keyUp);
            }

            return(list);
        }
Пример #2
0
        byte [] GetBuffer(byte reportId)
        {
            int bufferSize = ReportDescEnumerator.GetReportSize(_reportDescriptor, reportId);

            if (bufferSize > 8)
            {
                bufferSize = 8;
            }

            byte[] buffer = new byte[bufferSize];

            buffer[0] = reportId;

            return(buffer);
        }
        public byte[] RelativeBuffer(byte reportId, byte button, byte xPos, byte yPos)
        {
            byte[] buffer = new byte[ReportDescEnumerator.GetReportSize(_reportDescriptor, reportId)];
            int    idx    = 0;

            if (reportId != 0)
            {
                buffer[idx++] = reportId;
            }

            buffer[idx++] = button;
            buffer[idx++] = xPos;
            buffer[idx++] = yPos;

            return(buffer);
        }
        public byte[] AbsoluteBuffer(byte reportId, int xPos, int yPos, byte wheel)
        {
            int x = (int)(xPos * 32767 / _screenSizeX);
            int y = (int)(yPos * 32767 / _screenSizeY);

            byte[] buffer = new byte[ReportDescEnumerator.GetReportSize(_reportDescriptor, reportId)];

            buffer[0] = reportId;
            buffer[1] = (byte)(x & 0xff);
            buffer[2] = (byte)((x & 0xff00) >> 8);
            buffer[3] = (byte)(y & 0xff);
            buffer[4] = (byte)((y & 0xff00) >> 8);

            if (buffer.Length > 5)
            {
                buffer[5] = wheel;
            }

            return(buffer);
        }