Exemple #1
0
        static void InitializeDeviceControlInfoOfType(Type deviceType, TypePair key)
        {
            List <DomainEntry> entries = new List <DomainEntry>();

            // This will get all the supported controls for a device type,
            // including non-standard ones that are only supplied by certain device profiles.
            var dict = InputSystem.GetSupportedControlsForDeviceType(deviceType);

            // This will give us a dummy instance of the device.
            // We want to look up the names here, so that if it renames any controls,
            // we get the renamed name rather than the standardized name.
            InputDevice device = GetReferenceDevice(deviceType);

            foreach (var kvp in dict)
            {
                if (key.controlType.IsAssignableFrom(kvp.Key.controlType.value))
                {
                    string       usedName = kvp.Key.standardName;
                    InputControl control  = device.GetControlFromHash(kvp.Key.hash);
                    if (control != null)
                    {
                        usedName = control.name;
                    }

                    entries.Add(new DomainEntry()
                    {
                        name         = usedName,
                        hash         = kvp.Key.hash,
                        standardized = kvp.Value
                    });
                }
            }

            s_DeviceControlEntriesOfType[key] = entries;
        }