protected void Initialize()
        {
            if (m_IsInitialized)
            {
                return;
            }

            if (deviceManager == null)
            {
                deviceManager = new InputDeviceManager();
            }

            if (eventManager == null)
            {
                eventManager = new InputEventManager();
            }

            if (nativeDeviceManager == null)
            {
                nativeDeviceManager = new NativeInputDeviceManager();
            }

            #if UNITY_EDITOR
            // Clean up profiles used by devices. We don't serialize profiles but let InputDeviceManager
            // re-create them after domain reloads.
            profileManager.ConsolidateProfilesWithThoseUsedByDevices(deviceManager.devices);
            #endif

            nativeDeviceManager.Initialize(deviceManager, profileManager);

            nativeEventManager = new NativeInputEventManager();
            nativeEventManager.Initialize(eventManager, nativeDeviceManager);
            nativeEventManager.onReceivedEvents += OnProcessEvents;

            eventManager.rewriters.children.Add(
                new InputHandlerCallback {
                processEvent = deviceManager.RemapEvent
            });
            eventManager.consumers.children.Insert(0, deviceManager);

            NativeInputSystem.onUpdate += OnUpdate;

            currentUpdateType = NativeInputUpdateType.EndBeforeRender;

            m_IsInitialized = true;
        }