public static AttachDevice ( |
||
inputDevice | ||
return | void |
void UpdateInternal(ulong updateTick, float deltaTime) { var deviceCount = devices.Count; for (var i = 0; i < deviceCount; i++) { var device = devices[i]; var nintendoDevice = device as INintendoSwitchInputDevice; if (nintendoDevice != null) { nintendoDevice.UpdateInternalState(); if (nintendoDevice.IsPresent != device.IsAttached) { if (nintendoDevice.IsPresent) { InputManager.AttachDevice(device); } else { InputManager.DetachDevice(device); } } } } }
public override void Update(ulong updateTick, float deltaTime) { lock (devicesLock) { var attachedGamepadsCount = attachedGamepads.Count; for (var i = 0; i < attachedGamepadsCount; i++) { var gamepad = attachedGamepads[i]; var device = new UWPDevice(gamepad, ++deviceId); InputManager.AttachDevice(device); devices.Add(device); } attachedGamepads.Clear(); var detachedGamepadsCount = detachedGamepads.Count; for (var i = 0; i < detachedGamepadsCount; i++) { var gamepad = detachedGamepads[i]; var device = FindDeviceWithGamepad(gamepad); InputManager.DetachDevice(device); devices.Remove(device); } detachedGamepads.Clear(); } }
void CreateDevice() { device = new InputDevice("TouchDevice"); device.AddControl(InputControlType.LeftStickX, "LeftStickX"); device.AddControl(InputControlType.LeftStickY, "LeftStickY"); device.AddControl(InputControlType.RightStickX, "RightStickX"); device.AddControl(InputControlType.RightStickY, "RightStickY"); device.AddControl(InputControlType.LeftTrigger, "LeftTrigger"); device.AddControl(InputControlType.RightTrigger, "RightTrigger"); device.AddControl(InputControlType.DPadUp, "DPadUp"); device.AddControl(InputControlType.DPadDown, "DPadDown"); device.AddControl(InputControlType.DPadLeft, "DPadLeft"); device.AddControl(InputControlType.DPadRight, "DPadRight"); device.AddControl(InputControlType.Action1, "Action1"); device.AddControl(InputControlType.Action2, "Action2"); device.AddControl(InputControlType.Action3, "Action3"); device.AddControl(InputControlType.Action4, "Action4"); device.AddControl(InputControlType.LeftBumper, "LeftBumper"); device.AddControl(InputControlType.RightBumper, "RightBumper"); device.AddControl(InputControlType.Menu, "Menu"); for (var control = InputControlType.Button0; control <= InputControlType.Button19; control++) { device.AddControl(control, control.ToString()); } InputManager.AttachDevice(device); }
public override void Update(float updateTime, float deltaTime) { for (int deviceIndex = 0; deviceIndex < 4; deviceIndex++) { var device = devices[deviceIndex] as XInputDevice; // Unconnected devices won't be updated otherwise, so poll here. if (!device.IsConnected) { device.Update(updateTime, deltaTime); } if (device.IsConnected != deviceConnected[deviceIndex]) { if (device.IsConnected) { InputManager.AttachDevice(device); } else { InputManager.DetachDevice(device); } deviceConnected[deviceIndex] = device.IsConnected; } } }
private void CreateDevice() { device = new TouchInputDevice(); device.AddControl(InputControlType.LeftStickLeft, "LeftStickLeft"); device.AddControl(InputControlType.LeftStickRight, "LeftStickRight"); device.AddControl(InputControlType.LeftStickUp, "LeftStickUp"); device.AddControl(InputControlType.LeftStickDown, "LeftStickDown"); device.AddControl(InputControlType.RightStickLeft, "RightStickLeft"); device.AddControl(InputControlType.RightStickRight, "RightStickRight"); device.AddControl(InputControlType.RightStickUp, "RightStickUp"); device.AddControl(InputControlType.RightStickDown, "RightStickDown"); device.AddControl(InputControlType.DPadUp, "DPadUp"); device.AddControl(InputControlType.DPadDown, "DPadDown"); device.AddControl(InputControlType.DPadLeft, "DPadLeft"); device.AddControl(InputControlType.DPadRight, "DPadRight"); device.AddControl(InputControlType.LeftTrigger, "LeftTrigger"); device.AddControl(InputControlType.RightTrigger, "RightTrigger"); device.AddControl(InputControlType.LeftBumper, "LeftBumper"); device.AddControl(InputControlType.RightBumper, "RightBumper"); for (InputControlType inputControlType = InputControlType.Action1; inputControlType <= InputControlType.Action4; inputControlType++) { device.AddControl(inputControlType, inputControlType.ToString()); } device.AddControl(InputControlType.Menu, "Menu"); for (InputControlType inputControlType2 = InputControlType.Button0; inputControlType2 <= InputControlType.Button19; inputControlType2++) { device.AddControl(inputControlType2, inputControlType2.ToString()); } InputManager.AttachDevice(device); }
void OnEnable() { if (logDebugInfo) { Debug.Log("InControl (version " + InputManager.Version + ")"); Logger.OnLogMessage += LogMessage; } InputManager.InvertYAxis = invertYAxis; InputManager.EnableXInput = enableXInput; InputManager.Setup(); foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile; InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
public VirtualControlInputDeviceManager() { device = new InputDevice("VirtualControlInputDevice", 2, 2); device.AddAnalogControl(InputControlType.LeftStickX, "Virtual Stick"); device.AddAnalogControl(InputControlType.LeftStickY, "Virtual Stick"); device.AddButtonControl(InputControlType.Action1, "Virtual Button 1"); device.AddButtonControl(InputControlType.Action2, "Virtual Button 2"); InputManager.AttachDevice(device); var virtualStick = new VirtualControlStick(InputControlType.LeftStickX, InputControlType.LeftStickY); Node.AddChild(virtualStick); virtualControls.Add(virtualStick); var buttonPosition1 = new Vector2(Futile.screen.halfWidth - 128, -Futile.screen.halfHeight + 64); var virtualButton1 = new VirtualControlButton(InputControlType.Action1, "VirtualInput/ButtonA", buttonPosition1); Node.AddChild(virtualButton1); virtualControls.Add(virtualButton1); var buttonPosition2 = new Vector2(Futile.screen.halfWidth - 64, -Futile.screen.halfHeight + 128); var virtualButton2 = new VirtualControlButton(InputControlType.Action2, "VirtualInput/ButtonB", buttonPosition2); Node.AddChild(virtualButton2); virtualControls.Add(virtualButton2); Futile.touchManager.AddMultiTouchTarget(this); }
void OnEnable() { if (EnforceSingleton() == false) { return; } InputManager.InvertYAxis = invertYAxis; InputManager.SuspendInBackground = suspendInBackground; InputManager.EnableICade = enableICade; InputManager.EnableXInput = enableXInput; InputManager.XInputUpdateRate = (uint)Mathf.Max(xInputUpdateRate, 0); InputManager.XInputBufferSize = (uint)Mathf.Max(xInputBufferSize, 0); InputManager.EnableNativeInput = enableNativeInput; InputManager.NativeInputEnableXInput = nativeInputEnableXInput; InputManager.NativeInputUpdateRate = (uint)Mathf.Max(nativeInputUpdateRate, 0); InputManager.NativeInputPreventSleep = nativeInputPreventSleep; if (InputManager.SetupInternal()) { if (logDebugInfo) { Debug.Log("InControl (version " + InputManager.Version + ")"); Logger.OnLogMessage -= LogMessage; Logger.OnLogMessage += LogMessage; } foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfileBase; if (customProfileInstance != null) { InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } } } #if UNITY_5_4_OR_NEWER SceneManager.sceneLoaded -= OnSceneWasLoaded; SceneManager.sceneLoaded += OnSceneWasLoaded; #endif if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
void AttachKeyboardDeviceWithConfig(UnityInputDeviceProfile config) { if (keyboardDevicesAttached) { return; } var keyboardDevice = new UnityInputDevice(config); devices.Add(keyboardDevice); InputManager.AttachDevice(keyboardDevice); keyboardDevicesAttached = true; }
void OnEnable() { if (instance == null) { instance = this; if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } } else if (this != instance) { isBeingDestroyed = true; //If destroying, we don't want to reset the InputManager Destroy(gameObject); } if (logDebugInfo) { Debug.Log("InControl (version " + InputManager.Version + ")"); Logger.OnLogMessage += HandleOnLogMessage; } InputManager.InvertYAxis = invertYAxis; InputManager.EnableXInput = enableXInput; InputManager.SetupInternal(); foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile; InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
void OnEnable() { if (!SetupSingleton()) { return; } InputManager.InvertYAxis = invertYAxis; InputManager.EnableXInput = enableXInput; InputManager.XInputUpdateRate = (uint)Mathf.Max(xInputUpdateRate, 0); InputManager.XInputBufferSize = (uint)Mathf.Max(xInputBufferSize, 0); InputManager.EnableICade = enableICade; if (InputManager.SetupInternal()) { if (logDebugInfo) { Debug.Log("InControl (version " + InputManager.Version + ")"); Logger.OnLogMessage += LogMessage; } foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as InputDeviceProfile; if (customProfileInstance != null) { InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } } } if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
private void UpdateInternal(ulong updateTick, float deltaTime) { for (int i = 0; i < 8; i++) { XboxOneInputDevice xboxOneInputDevice = devices[i] as XboxOneInputDevice; if (xboxOneInputDevice.IsConnected != deviceConnected[i]) { if (xboxOneInputDevice.IsConnected) { InputManager.AttachDevice(xboxOneInputDevice); } else { InputManager.DetachDevice(xboxOneInputDevice); } deviceConnected[i] = xboxOneInputDevice.IsConnected; } } }
void OnEnable() { InputManager.Setup(); foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile; InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } Debug.Log("InControl (version " + InputManager.Version + ")"); }
void SetActive(bool value) { if (active != value) { active = value; ICadeNative.SetActive(active); if (active) { StartWorker(); InputManager.AttachDevice(device); } else { StopWorker(); InputManager.DetachDevice(device); } } }
void DetectAttachedJoystickDevice(int unityJoystickId, string unityJoystickName) { var matchedDeviceProfile = deviceProfiles.Find(config => config.HasJoystickName(unityJoystickName)); UnityInputDeviceProfile deviceProfile = null; if (matchedDeviceProfile == null) { deviceProfile = new UnknownDeviceProfile(unityJoystickName); deviceProfiles.Add(deviceProfile); } else { deviceProfile = matchedDeviceProfile; } foreach (var device in devices) { var unityDevice = device as UnityInputDevice; if (unityDevice != null && unityDevice.IsConfiguredWith(deviceProfile, unityJoystickId)) { Logger.LogInfo("Device \"" + unityJoystickName + "\" is already configured with " + deviceProfile.Name); return; } } var inputDevice = new UnityInputDevice(deviceProfile, unityJoystickId); devices.Add(inputDevice); InputManager.AttachDevice(inputDevice); if (matchedDeviceProfile == null) { Logger.LogWarning("Attached device has no matching profile: \"" + unityJoystickName + "\""); } else { Logger.LogInfo("Attached device \"" + unityJoystickName + "\" matched profile: " + deviceProfile.Name); } }
void UpdateInternal(ulong updateTick, float deltaTime) { for (var deviceIndex = 0; deviceIndex < maxDevices; deviceIndex++) { var device = devices[deviceIndex] as XboxOneInputDevice; if (device.IsConnected != deviceConnected[deviceIndex]) { if (device.IsConnected) { InputManager.AttachDevice(device); } else { InputManager.DetachDevice(device); } deviceConnected[deviceIndex] = device.IsConnected; } } }
void AttachDevice(UnityInput.InputDevice unityDevice) { var unityGamepad = unityDevice as UnityInput.Gamepad; if (unityGamepad != null) { if (internalDevices.ContainsKey(unityDevice.deviceId)) { return; } var inputDevice = new NewUnityInputDevice(unityGamepad); internalDevices.Add(unityDevice.deviceId, inputDevice); InputManager.AttachDevice(inputDevice); } // else // { // Debug.Log( $"Discarding device: {unityDevice.displayName}" ); // } }
void CreateDevice() { device = new TouchInputDevice(); device.AddControl(InputControlType.LeftStickLeft, "LeftStickLeft"); device.AddControl(InputControlType.LeftStickRight, "LeftStickRight"); device.AddControl(InputControlType.LeftStickUp, "LeftStickUp"); device.AddControl(InputControlType.LeftStickDown, "LeftStickDown"); device.AddControl(InputControlType.RightStickLeft, "RightStickLeft"); device.AddControl(InputControlType.RightStickRight, "RightStickRight"); device.AddControl(InputControlType.RightStickUp, "RightStickUp"); device.AddControl(InputControlType.RightStickDown, "RightStickDown"); device.AddControl(InputControlType.DPadUp, "DPadUp"); device.AddControl(InputControlType.DPadDown, "DPadDown"); device.AddControl(InputControlType.DPadLeft, "DPadLeft"); device.AddControl(InputControlType.DPadRight, "DPadRight"); device.AddControl(InputControlType.LeftTrigger, "LeftTrigger"); device.AddControl(InputControlType.RightTrigger, "RightTrigger"); device.AddControl(InputControlType.LeftBumper, "LeftBumper"); device.AddControl(InputControlType.RightBumper, "RightBumper"); for (var control = InputControlType.Action1; control <= InputControlType.Action12; control++) { device.AddControl(control, control.ToString()); } device.AddControl(InputControlType.Menu, "Menu"); for (var control = InputControlType.Button0; control <= InputControlType.Button19; control++) { device.AddControl(control, control.ToString()); } InputManager.AttachDevice(device); }
public override void Update(ulong updateTick, float deltaTime) { for (var deviceIndex = 0; deviceIndex < 4; deviceIndex++) { var device = devices[deviceIndex] as OuyaEverywhereDevice; if (device.IsConnected != deviceConnected[deviceIndex]) { if (device.IsConnected) { device.BeforeAttach(); InputManager.AttachDevice(device); } else { InputManager.DetachDevice(device); } deviceConnected[deviceIndex] = device.IsConnected; } } }
void OnEnable() { SetupSingleton(); if (logDebugInfo) { Debug.Log("InControl (version " + InputManager.Version + ")"); Logger.OnLogMessage += LogMessage; } InputManager.InvertYAxis = invertYAxis; InputManager.EnableXInput = enableXInput; InputManager.XInputUpdateRate = (uint)Mathf.Max(xInputUpdateRate, 0); InputManager.XInputBufferSize = (uint)Mathf.Max(xInputBufferSize, 0); InputManager.SetupInternal(); foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as InputDeviceProfile; InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } //var lastDevice = (string)SaveManager.Instance.GetValue(SaveManager.LastInputDevice, "Keyboard/Mouse"); //InputManager.ActiveDevice.Name = lastDevice; }
void OnEnable() { if (originalInstance != null && originalInstance != this) { //Remove the duplicate Destroy(this.gameObject); return; } originalInstance = this; if (logDebugInfo) { Debug.Log("InControl (version " + InputManager.Version + ")"); Logger.OnLogMessage += HandleOnLogMessage; } InputManager.InvertYAxis = invertYAxis; InputManager.EnableXInput = enableXInput; InputManager.SetupInternal(); foreach (var className in customProfiles) { var classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile; InputManager.AttachDevice(new UnityInputDevice(customProfileInstance)); } } if (dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
public override void Update(ulong updateTick, float deltaTime) { for (int i = 0; i < 4; i++) { XInputDevice xInputDevice = devices[i] as XInputDevice; if (!xInputDevice.IsConnected) { xInputDevice.GetState(); } if (xInputDevice.IsConnected != deviceConnected[i]) { if (xInputDevice.IsConnected) { InputManager.AttachDevice(xInputDevice); } else { InputManager.DetachDevice(xInputDevice); } deviceConnected[i] = xInputDevice.IsConnected; } } }
static void CreateDevice() { Device = new InputDevice("TouchDevice"); Device.AddControl(InputControlType.LeftStickX, "LeftStickX"); Device.AddControl(InputControlType.LeftStickY, "LeftStickY"); Device.AddControl(InputControlType.RightStickX, "RightStickX"); Device.AddControl(InputControlType.RightStickY, "RightStickY"); Device.AddControl(InputControlType.LeftTrigger, "LeftTrigger"); Device.AddControl(InputControlType.RightTrigger, "RightTrigger"); Device.AddControl(InputControlType.DPadUp, "DPadUp"); Device.AddControl(InputControlType.DPadDown, "DPadDown"); Device.AddControl(InputControlType.DPadLeft, "DPadLeft"); Device.AddControl(InputControlType.DPadRight, "DPadRight"); Device.AddControl(InputControlType.Action1, "Action1"); Device.AddControl(InputControlType.Action2, "Action2"); Device.AddControl(InputControlType.Action3, "Action3"); Device.AddControl(InputControlType.Action4, "Action4"); Device.AddControl(InputControlType.LeftBumper, "LeftBumper"); Device.AddControl(InputControlType.RightBumper, "RightBumper"); Device.AddControl(InputControlType.Menu, "Menu"); InputManager.AttachDevice(Device); }
void AttachDevice(UnityInputDevice device) { devices.Add(device); InputManager.AttachDevice(device); }
private void AttachDevice(UnityInputDevice device) { device.Passive = (((int)controllerEnableMask & (1 << device.JoystickId - 1)) == 0); devices.Add(device); InputManager.AttachDevice(device); }
void AttachDevice(NativeInputDevice device) { detachedDevices.Remove(device); attachedDevices.Add(device); InputManager.AttachDevice(device); }