Example #1
0
        /// <summary>
        /// Get a string from a HID device, based on its string index
        /// </summary>
        /// <param name="index">The index of the string to get</param>
        /// <returns></returns>
        public string DevicesString(int index)
        {
            m_DeviceInfoBuffer.Clear();

            var res = HidApi.hid_get_indexed_string(m_DevicePtr, index, m_DeviceInfoBuffer, MARSHALED_STRING_MAX_LEN);

            return(res == 0 ? m_DeviceInfo.ToString() : null);
        }
Example #2
0
        /// <summary>
        /// Get all available strings of HID device
        /// </summary>
        /// <returns></returns>
        public IEnumerable <string> DeviceStrings()
        {
            const int maxStringNum = 16;
            int       counter      = 0;

            m_DeviceInfoBuffer.Clear();
            while (HidApi.hid_get_indexed_string(m_DevicePtr, counter, m_DeviceInfoBuffer, MARSHALED_STRING_MAX_LEN) == 0 && counter++ < maxStringNum)
            {
                yield return(m_DeviceInfoBuffer.ToString());

                m_DeviceInfoBuffer.Clear();
            }
        }