public GenericHID(HIDDescriptor deviceDescriptor)
        {
            m_DeviceDescriptor = deviceDescriptor;
            ControlSetup defaultSetup = new ControlSetup(this);

            m_Mappings = defaultSetup.mappings;
        }
        public override InputDevice TryCreateDevice(string deviceDescriptor)
        {
            HIDDescriptor hidDescriptor = JsonUtility.FromJson <HIDDescriptor>(deviceDescriptor);

            if (IsDeviceValidAsGenericHID(hidDescriptor))
            {
                return(AddGenericHID(hidDescriptor));
            }

            return(null);
        }
        bool IsDeviceValidAsGenericHID(HIDDescriptor descriptor)
        {
            bool isValid = false;

            // The Descriptor needs at least one known element
            if (descriptor.elements != null && descriptor.elements.Length != 0)
            {
                for (int i = 0; i < descriptor.elements.Length; i++)
                {
                    if (HIDHelpers.IsDefinedHIDUsage(descriptor.elements[i]))
                    {
                        isValid = true;
                        break;
                    }
                }
            }
            return(isValid);
        }
 InputDevice AddGenericHID(HIDDescriptor hidDescriptor)
 {
     return(new GenericHID(hidDescriptor));
 }