Ejemplo n.º 1
0
        public static HidpValueCaps FromBytes(byte[] bytes, int offset, out int nextByteOffset)
        {
            int nextOffset;

            var hbc = new HidpValueCaps()
            {
                UsagePage         = (ushort)(((ushort)bytes[offset + 1] << 8) | (ushort)(bytes[offset + 0])),
                ReportID          = bytes[offset + 2],
                IsAlias           = bytes[offset + 3] > 0 ? true : false,
                BitField          = (ushort)(((ushort)bytes[offset + 5] << 8) | (ushort)(bytes[offset + 4])),
                LinkCollection    = (ushort)(((ushort)bytes[offset + 7] << 8) | (ushort)(bytes[offset + 6])),
                LinkUsage         = (ushort)(((ushort)bytes[offset + 9] << 8) | (ushort)(bytes[offset + 8])),
                LinkUsagePage     = (ushort)(((ushort)bytes[offset + 11] << 8) | (ushort)(bytes[offset + 10])),
                IsRange           = bytes[offset + 12] > 0 ? true : false,
                IsStringRange     = bytes[offset + 13] > 0 ? true : false,
                IsDesignatorRange = bytes[offset + 14] > 0 ? true : false,
                IsAbsolute        = bytes[offset + 15] > 0 ? true : false,
                HasNull           = bytes[offset + 16] > 0 ? true : false,
                BitSize           = (ushort)(((ushort)bytes[offset + 19] << 8) | (ushort)(bytes[offset + 18])),
                ReportCount       = (ushort)(((ushort)bytes[offset + 21] << 8) | (ushort)(bytes[offset + 20])),
                ////// skip reserved
                UnitsExp    = (uint)(((uint)bytes[offset + 35] << 24) | ((uint)bytes[offset + 34] << 16) | ((uint)bytes[offset + 33] << 8) | (uint)(bytes[offset + 32])),
                Units       = (uint)(((uint)bytes[offset + 39] << 24) | ((uint)bytes[offset + 38] << 16) | ((uint)bytes[offset + 37] << 8) | (uint)(bytes[offset + 36])),
                LogicalMin  = (int)(((int)bytes[offset + 43] << 24) | ((int)bytes[offset + 42] << 16) | ((int)bytes[offset + 41] << 8) | (int)(bytes[offset + 40])),
                LogicalMax  = (int)(((int)bytes[offset + 47] << 24) | ((int)bytes[offset + 46] << 16) | ((int)bytes[offset + 45] << 8) | (int)(bytes[offset + 44])),
                PhysicalMin = (int)(((int)bytes[offset + 51] << 24) | ((int)bytes[offset + 50] << 16) | ((int)bytes[offset + 49] << 8) | (int)(bytes[offset + 48])),
                PhysicalMax = (int)(((int)bytes[offset + 55] << 24) | ((int)bytes[offset + 54] << 16) | ((int)bytes[offset + 53] << 8) | (int)(bytes[offset + 52])),

                Range = HidpValueValueCapsRange.FromBytes(bytes, offset + 56, out nextOffset),
            };

            nextByteOffset = nextOffset;

            return(hbc);
        }
Ejemplo n.º 2
0
        public static HidpValueValueCapsRange FromBytes(byte[] bytes, int offset, out int nextByteOffset)
        {
            var hvvcp = new HidpValueValueCapsRange()
            {
                UsageMin      = (ushort)(((ushort)bytes[offset + 1] << 8) | (ushort)(bytes[offset + 0])),
                UsageMax      = (ushort)(((ushort)bytes[offset + 3] << 8) | (ushort)(bytes[offset + 2])),
                StringMin     = (ushort)(((ushort)bytes[offset + 5] << 8) | (ushort)(bytes[offset + 4])),
                StringMax     = (ushort)(((ushort)bytes[offset + 7] << 8) | (ushort)(bytes[offset + 6])),
                DesignatorMin = (ushort)(((ushort)bytes[offset + 9] << 8) | (ushort)(bytes[offset + 8])),
                DesignatorMax = (ushort)(((ushort)bytes[offset + 11] << 8) | (ushort)(bytes[offset + 10])),
                DataIndexMin  = (ushort)(((ushort)bytes[offset + 13] << 8) | (ushort)(bytes[offset + 12])),
                DataIndexMax  = (ushort)(((ushort)bytes[offset + 15] << 8) | (ushort)(bytes[offset + 14])),
            };

            nextByteOffset = offset + 15 + 1;

            return(hvvcp);
        }