// For now, initialize prototype stuff here. // This should not be included here in final code. static InputSystem() { s_Devices = new InputDeviceManager(); GameObject go = new GameObject("Input Prototype Controller"); go.hideFlags = HideFlags.DontSaveInEditor; //HideFlags.HideAndDontSave; go.AddComponent <InputManager>(); go.AddComponent <InputManagerEndFrame>(); go.AddComponent <JoystickInputToEvents>(); go.AddComponent <MouseInputToEvents>(); go.AddComponent <KeyboardInputToEvents>(); go.AddComponent <TouchInputToEvents>(); go.AddComponent <VRInputToEvents>(); go.AddComponent <ExecuteAllEvents>(); InputDeviceProfile[] profiles = new InputDeviceProfile[] { new Xbox360MacProfile(), new Xbox360WinProfile(), new OpenVRProfile(), }; s_EventQueue = new InputEventQueue(); s_EventPool = new InputEventPool(); foreach (var profile in profiles) { RegisterProfile(profile); } s_Devices.InitAfterProfiles(); // Set up event tree. s_EventTree = new InputConsumerNode(); s_EventTree.children.Add(new InputConsumerCallback { processEvent = s_Devices.RemapEvent }); rewriters = new InputConsumerNode(); s_EventTree.children.Add(rewriters); s_EventTree.children.Add(s_Devices); consumers = new InputConsumerNode(); s_EventTree.children.Add(consumers); assignedPlayers = new InputConsumerNode(); consumers.children.Add(assignedPlayers); // Global consumers should be processed last. globalPlayers = new InputConsumerNode(); consumers.children.Add(globalPlayers); simulateMouseWithTouches = true; }
public bool IsProfileSupportedOnThisPlatform(InputDeviceProfile profile) { if (profile.supportedPlatforms == null || profile.supportedPlatforms.Length == 0) { return(true); } foreach (var platform in profile.supportedPlatforms) { if (m_Platform.Contains(platform.ToUpper())) { return(true); } } return(false); }
public bool IsProfileSupportedOnThisPlatform(InputDeviceProfile profile) { if (profile.supportedPlatforms == null || profile.supportedPlatforms.Length == 0) { return(true); } #if UNITY_2017_2_OR_NEWER foreach (var platform in profile.supportedPlatforms) { // VR devices can be hot-swapped -- this can change at any point so we should check it every frame (or provide an event). var vrPlatform = (XRSettings.loadedDeviceName + " " + XRDevice.model).ToUpper(); if (m_Platform.Contains(platform.ToUpper()) || vrPlatform.Contains(platform.ToUpper())) { return(true); } } #endif return(false); }
public static void RegisterProfile(InputDeviceProfile profile) { s_Devices.RegisterProfile(profile); }
// For now, initialize prototype stuff here. // This should not be included here in final code. static InputSystem() { s_Devices = new InputDeviceManager(); GameObject go = new GameObject("Input Prototype Controller"); go.hideFlags = HideFlags.HideAndDontSave; go.AddComponent <InputManager>(); go.AddComponent <InputManagerEndFrame>(); go.AddComponent <JoystickInputToEvents>(); go.AddComponent <MouseInputToEvents>(); go.AddComponent <KeyboardInputToEvents>(); go.AddComponent <TouchInputToEvents>(); go.AddComponent <ExecuteAllEvents>(); InputDeviceProfile[] profiles = new InputDeviceProfile[] { new Xbox360MacProfile(), new Xbox360WinProfile() }; s_EventQueue = new InputEventQueue(); s_EventPool = new InputEventPool(); foreach (var profile in profiles) { RegisterProfile(profile); } s_Devices.InitAfterProfiles(); // Set up event tree. s_EventTree = new InputEventTree { name = "Root" }; var remap = new InputEventTree { name = "Remap", processInput = s_Devices.RemapEvent }; s_EventTree.children.Add(remap); rewriterStack = new InputEventTree { name = "Rewriters", isStack = true }; s_EventTree.children.Add(rewriterStack); var state = new InputEventTree { name = "State", processInput = s_Devices.ProcessEvent, beginFrame = s_Devices.BeginFrameEvent }; s_EventTree.children.Add(state); consumerStack = new InputEventTree { name = "Consumers", isStack = true }; s_EventTree.children.Add(consumerStack); // Global consumer stack should come first in stack so it's processed last. globalPlayers = new InputEventTree { name = "Global Players", isStack = true }; consumerStack.children.Add(globalPlayers); assignedPlayers = new InputEventTree { name = "Assigned Players", isStack = true }; consumerStack.children.Add(assignedPlayers); simulateMouseWithTouches = true; }
public void RegisterProfile(InputDeviceProfile profile) { m_Profiles.Add(profile); }