private void OnActionChange(object obj, InputActionChange inputActionChange) { if (!(obj is InputAction inputAction)) { return; } if (!Enum.TryParse(inputAction.name, out InputActionType coreInputAction)) { return; } // Debug.Log($"{inputAction.name} {inputActionChange} {inputAction.activeControl.device}"); switch (inputActionChange) { case InputActionChange.ActionStarted: ActionEvent(inputAction, coreInputAction, CoreActionEventType.Started); break; case InputActionChange.ActionPerformed: ActionEvent(inputAction, coreInputAction, CoreActionEventType.Performed); break; case InputActionChange.ActionCanceled: ActionEvent(inputAction, coreInputAction, CoreActionEventType.Canceled); break; } }
private void HandleKeyInput(object obj, InputActionChange change) { switch (change) { case InputActionChange.ActionStarted: case InputActionChange.ActionCanceled: var action = (InputAction)obj; if (_keySwitchAssignments.ContainsKey(action.name)) { if (_gamelogicEngine != null) { foreach (var sw in _keySwitchAssignments[action.name]) { sw.IsSwitchEnabled = change == InputActionChange.ActionStarted; _gamelogicEngine.Switch(sw.SwitchId, sw.IsSwitchClosed); } } } else { Logger.Info($"Unmapped input command \"{action.name}\"."); } break; } }
/// <summary> /// Checks to see if the control input has changed (mostly for plugging in a controller etc). /// </summary> /// <param name="obj"></param> /// <param name="change"></param> private void ControllerChanged(object obj, InputActionChange change) { if (change == InputActionChange.ActionPerformed) { var inputAction = (InputAction)obj; var lastControl = inputAction.activeControl; device = lastControl.device; } }
private static void OnActionChange(object mapOrAction, InputActionChange change) { // We only care about action map activations. Steam has no support for enabling or disabling // individual actions and also has no support disabling sets once enabled (can only switch // to different set). if (change != InputActionChange.ActionMapEnabled) { return; } // See if the map has any bindings to SteamControllers. // NOTE: We only support a single SteamController on any action map here. The first SteamController // we find is the one we're doing all the work on. var actionMap = (InputActionMap)mapOrAction; foreach (var action in actionMap.actions) { foreach (var control in action.controls) { var steamController = control.device as SteamController; if (steamController == null) { continue; } // Yes, there's active bindings to a SteamController on the map. Look through the Steam action // sets on the controller for a name match on the action map. If we have one, sync the enable/ // disable status of the set. var actionMapName = actionMap.name; foreach (var set in steamController.steamActionSets) { if (string.Compare(set.name, actionMapName, StringComparison.InvariantCultureIgnoreCase) != 0) { continue; } // Nothing to do if the Steam controller has auto-syncing disabled. if (!steamController.autoActivateSets) { return; } // Sync status. steamController.ActivateSteamActionSet(set.handle); // Done. return; } } } }
private static void OnActionTriggered(object obj, InputActionChange change) { if (change != InputActionChange.ActionTriggered) { return; } ////REVIEW: filter for noise here? // Grab control that triggered the action. var action = (InputAction)obj; var control = action.lastTriggerControl; if (control == null) { return; } // See if it's coming from a device not belonging to any user. var device = control.device; if (ArrayHelpers.ContainsReferenceTo(s_AllDevices, s_AllDeviceCount, device)) { // No, it's a device already assigned to a player so do nothing. return; } // Ok, we know it's a device not assigned to a user and it triggered action. The only // thing that remains is to determine whether it was from an action assigned to a user. var userIndex = -1; for (var i = 0; i < s_AllUserCount; ++i) { var actions = s_AllUserData[i].actions; if (actions != null && actions.Contains(action)) { userIndex = i; break; } } if (userIndex != -1) { var user = s_AllUsers[userIndex]; for (var i = 0; i < s_OnUnassignedDeviceUsed.length; ++i) { s_OnUnassignedDeviceUsed[i](user, action, control); } } }
private void InputSystem_onActionChange(object obj, InputActionChange change) { if (change == InputActionChange.ActionStarted) { var action = (InputAction)obj; var deviceName = action.activeControl.device.displayName; switch (deviceName) { case "Mouse": CurrentControlMode = CONTROL_MODE.KEYBOARDMOUSE; break; case "Keyboard": CurrentControlMode = CONTROL_MODE.KEYBOARDMOUSE; break; } } }
private void OnActionChange(object actionOrMap, InputActionChange change) { switch (change) { // When an action is triggered, we only need a repaint. case InputActionChange.ActionStarted: case InputActionChange.ActionPerformed: case InputActionChange.ActionCanceled: Repaint(); break; case InputActionChange.ActionEnabled: case InputActionChange.ActionDisabled: case InputActionChange.ActionMapDisabled: case InputActionChange.ActionMapEnabled: case InputActionChange.BoundControlsChanged: Refresh(); break; } }
private void HandleKeyInput(object obj, InputActionChange change) { switch (change) { case InputActionChange.ActionStarted: case InputActionChange.ActionCanceled: var action = (InputAction)obj; if (_keySwitchAssignments.ContainsKey(action.name)) { if (GameEngine is IGamelogicEngineWithSwitches engineWithSwitches) { foreach (var switchId in _keySwitchAssignments[action.name]) { engineWithSwitches.Switch(switchId, change == InputActionChange.ActionStarted); } } } else { Logger.Info($"Unmapped input command \"{action.name}\"."); } if (_keyWireAssignments != null && _keyWireAssignments.ContainsKey(action.name)) { foreach (var wireConfig in _keyWireAssignments[action.name]) { switch (wireConfig.Destination) { case WireDestination.Playfield: Wire(wireConfig.PlayfieldItem)?.OnChange(change == InputActionChange.ActionStarted); break; case WireDestination.Device: break; } } } break; } }
private static void OnActionChange(object actionOrMap, InputActionChange change) { switch (change) { case InputActionChange.ActionEnabled: case InputActionChange.ActionMapEnabled: for (var i = 0; i < s_EnabledInstances.Count; ++i) { if (s_EnabledInstances[i].m_Action == null) { s_EnabledInstances[i].ResolveAction(); if (s_EnabledInstances[i].m_Action != null) { s_EnabledInstances[i].SetupVisualizer(); } } } break; case InputActionChange.ActionDisabled: for (var i = 0; i < s_EnabledInstances.Count; ++i) { if (actionOrMap == s_EnabledInstances[i].m_Action) { s_EnabledInstances[i].OnActionDisabled(); } } break; case InputActionChange.ActionMapDisabled: for (var i = 0; i < s_EnabledInstances.Count; ++i) { if (s_EnabledInstances[i].m_Action?.actionMap == actionOrMap) { s_EnabledInstances[i].OnActionDisabled(); } } break; } }
private void HandleKeyInput(object obj, InputActionChange change) { var engineWithSwitches = GameEngine as IGamelogicEngineWithSwitches; switch (change) { case InputActionChange.ActionStarted: case InputActionChange.ActionCanceled: var action = (InputAction)obj; if (_keyBindings.ContainsKey(action.name)) { foreach (var switchId in _keyBindings[action.name]) { engineWithSwitches.Switch(switchId, change == InputActionChange.ActionStarted); } } else { Logger.Info($"Unmapped input command \"{action.name}\"."); } break; } }
private void OnActionChange(object actionOrMap, InputActionChange change) { Refresh(); }