private void OnGUI() { if (!this.identifyRequired) { return; } if (this.joysticksToIdentify == null || this.joysticksToIdentify.Count == 0) { this.Reset(); } else { Rect rect; ((Rect) ref rect).\u002Ector((float)((double)Screen.get_width() * 0.5 - 125.0), (float)((double)Screen.get_height() * 0.5 - 125.0), 250f, 250f); // ISSUE: method pointer GUILayout.Window(0, rect, new GUI.WindowFunction((object)this, __methodptr(DrawDialogWindow)), "Joystick Identification Required", (GUILayoutOption[])Array.Empty <GUILayoutOption>()); GUI.FocusWindow(0); if ((double)Time.get_time() < (double)this.nextInputAllowedTime || !ReInput.get_controllers().SetUnityJoystickIdFromAnyButtonOrAxisPress((int)((Controller)this.joysticksToIdentify.Peek()).id, 0.8f, false)) { return; } this.joysticksToIdentify.Dequeue(); this.SetInputDelay(); if (this.joysticksToIdentify.Count != 0) { return; } this.Reset(); } }
private void OnDisable() { this.inputMapper.Stop(); this.inputMapper.RemoveAllEventListeners(); ReInput.remove_ControllerConnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerChanged)); ReInput.remove_ControllerDisconnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerChanged)); }
private void OnEnable() { this.updateMode = Remapping.UpdateMode.ButtonSelectMode; this.selectedControllerType = (ControllerType)2; this.selectedControllerId = 0; this.settingOrDeleteWindow.SetActive(false); if (!ReInput.get_isReady()) { return; } ReInput.add_ControllerConnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerChanged)); ReInput.add_ControllerDisconnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerChanged)); ((UnityEventBase)this.settingButton.get_onClick()).RemoveAllListeners(); ((UnityEventBase)this.deleteButton.get_onClick()).RemoveAllListeners(); ((UnityEventBase)this.returnButton.get_onClick()).RemoveAllListeners(); // ISSUE: method pointer ((UnityEvent)this.settingButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(\u003COnEnable\u003Em__0))); // ISSUE: method pointer ((UnityEvent)this.deleteButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(\u003COnEnable\u003Em__1))); // ISSUE: method pointer ((UnityEvent)this.returnButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(\u003COnEnable\u003Em__2))); this.SetJoystickActiv(); this.SetControllerToDropdown(); this.LoadControllerSetting(); this.InitializeUI(); }
private void Initialize() { ReInput.add_InputSourceUpdateEvent(new Action(this.OnInputSourceUpdate)); this.joysticks = (TouchJoystickExample[])((Component)this).GetComponentsInChildren <TouchJoystickExample>(); this.buttons = (TouchButtonExample[])((Component)this).GetComponentsInChildren <TouchButtonExample>(); this.axisCount = this.joysticks.Length * 2; this.buttonCount = this.buttons.Length; this.axisValues = new float[this.axisCount]; this.buttonValues = new bool[this.buttonCount]; this.controller = (CustomController)((Player.ControllerHelper)ReInput.get_players().GetPlayer(this.playerId).controllers).GetControllerWithTag <CustomController>(this.controllerTag); if (this.controller == null) { Debug.LogError((object)("A matching controller was not found for tag \"" + this.controllerTag + "\"")); } if (((Controller)this.controller).get_buttonCount() != this.buttonValues.Length || ((ControllerWithAxes)this.controller).get_axisCount() != this.axisValues.Length) { Debug.LogError((object)"Controller has wrong number of elements!"); } if (this.useUpdateCallbacks && this.controller != null) { this.controller.SetAxisUpdateCallback(new Func <int, float>(this.GetAxisValueCallback)); this.controller.SetButtonUpdateCallback(new Func <int, bool>(this.GetButtonValueCallback)); } this.initialized = true; }
private bool IsMenuAxis(int actionId, int axisIndex) { if (Object.op_Equality((Object)this.rewiredStandaloneInputModule, (Object)null)) { return(false); } IList <Player> allPlayers = ReInput.get_players().get_AllPlayers(); int count1 = ((ICollection <Player>)allPlayers).Count; for (int index1 = 0; index1 < count1; ++index1) { IList <JoystickMap> maps = (IList <JoystickMap>)((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)allPlayers[index1].controllers).maps).GetMaps <JoystickMap>((int)((Controller)this.joystick).id); if (maps != null) { int count2 = ((ICollection <JoystickMap>)maps).Count; for (int index2 = 0; index2 < count2; ++index2) { IList <ActionElementMap> axisMaps = ((ControllerMapWithAxes)maps[index2]).get_AxisMaps(); if (axisMaps != null) { int count3 = ((ICollection <ActionElementMap>)axisMaps).Count; for (int index3 = 0; index3 < count3; ++index3) { ActionElementMap actionElementMap = axisMaps[index3]; if (actionElementMap.get_actionId() == actionId && actionElementMap.get_elementIndex() == axisIndex) { return(true); } } } } } } return(false); }
private void Awake() { Screen.set_orientation((ScreenOrientation)3); this.player = ReInput.get_players().GetPlayer(0); ReInput.add_InputSourceUpdateEvent(new Action(this.OnInputUpdate)); this.controller = (CustomController)((Player.ControllerHelper) this.player.controllers).GetControllerWithTag((ControllerType)20, "TiltController"); }
private void Update() { if (!ReInput.get_isReady()) { return; } this.DrawActiveElements(); }
private void Start() { if (!ReInput.get_isReady()) { return; } this.DrawLabels(); }
private void Update() { if (!ReInput.get_isReady()) { return; } this.AssignJoysticksToPlayers(); }
private void Update() { if (!ReInput.get_isReady() || this.initialized) { return; } this.Initialize(); }
public void ResetRewired() { ReInput.Reset(); #if (UNITY_IOS || UNITY_TVOS || UNITY_STANDALONE_OSX) appleVirtualController = null; #endif }
private void Update() { if (!ReInput.get_isReady() || this.player == null) { return; } this.GetInput(); this.ProcessInput(); }
private void InitializeUI() { IEnumerator enumerator1 = ((Transform)this.actionNameSortArea).GetEnumerator(); try { while (enumerator1.MoveNext()) { Object.Destroy((Object)((Component)enumerator1.Current).get_gameObject()); } } finally { if (enumerator1 is IDisposable disposable) { disposable.Dispose(); } } IEnumerator enumerator2 = ((Transform)this.keyInputButtonSortArea).GetEnumerator(); try { while (enumerator2.MoveNext()) { Object.Destroy((Object)((Component)enumerator2.Current).get_gameObject()); } } finally { if (enumerator2 is IDisposable disposable) { disposable.Dispose(); } } this.rows.Clear(); using (IEnumerator <InputAction> enumerator3 = ReInput.get_mapping().ActionsInCategory("Default").GetEnumerator()) { while (((IEnumerator)enumerator3).MoveNext()) { InputAction current = enumerator3.Current; if (current.get_userAssignable()) { if (current.get_type() == 1) { this.CreateUIRow(current, (AxisRange)1, current.get_descriptiveName()); } else if (current.get_type() == null) { this.CreateUIRow(current, (AxisRange)0, current.get_descriptiveName()); this.CreateUIRow(current, (AxisRange)1, string.IsNullOrEmpty(current.get_positiveDescriptiveName()) ? current.get_descriptiveName() + " +" : current.get_positiveDescriptiveName()); this.CreateUIRow(current, (AxisRange)2, string.IsNullOrEmpty(current.get_negativeDescriptiveName()) ? current.get_descriptiveName() + " -" : current.get_negativeDescriptiveName()); } } } } this.RedrawUI(); }
private void Awake() { if (!ReInput.get_unityJoystickIdentificationRequired()) { return; } ReInput.add_ControllerConnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.JoystickConnected)); ReInput.add_ControllerDisconnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.JoystickDisconnected)); this.IdentifyAllJoysticks(); }
private void Update() { for (int rewiredPlayerId = 0; rewiredPlayerId < ReInput.get_players().get_playerCount(); ++rewiredPlayerId) { if (ReInput.get_players().GetPlayer(rewiredPlayerId).GetButtonDown("JoinGame")) { this.AssignNextPlayer(rewiredPlayerId); } } }
void DrawInputFoldout(ReInput input) { if (!input.Validate()) { foldoutStyle.normal.textColor = Color.red; } else { foldoutStyle.normal.textColor = Color.blue; } using (new GUILayout.HorizontalScope()) { string foldoutName = $"{input.Name} {(settings.FoldoutToggles[input] ? " ↓" : " →")}"; if (GUILayout.Button(foldoutName)) { settings.FoldoutToggles[input] = !settings.FoldoutToggles[input]; } if (GUILayout.Button(ContentHelpers.RemoveButtonLabel, EditorStyles.miniButtonLeft)) { inputToRemove = input; } if (GUILayout.Button(ContentHelpers.CopyButtonLabel, EditorStyles.miniButtonMid)) { var copy = input.DeepCopy(); ((ReInputMap)target).InputMap.Add(copy); wasAdded = true; } if (GUILayout.Button(ContentHelpers.MoveDownButtonLabel, EditorStyles.miniButtonMid)) { int indexOf = targetAs.InputMap.IndexOf(input); if (indexOf == -1 || indexOf == targetAs.InputMap.Count - 1) { return; } targetAs.InputMap[indexOf] = targetAs.InputMap[indexOf + 1]; targetAs.InputMap[indexOf + 1] = input; wasAdded = true; } if (GUILayout.Button(ContentHelpers.MoveUpButtonLabel, EditorStyles.miniButtonRight)) { int indexOf = targetAs.InputMap.IndexOf(input); if (indexOf == -1 || indexOf == 0 || targetAs.InputMap.Count == 0) { return; } targetAs.InputMap[indexOf] = targetAs.InputMap[indexOf - 1]; targetAs.InputMap[indexOf - 1] = input; wasAdded = true; } } }
private Player FindPlayerWithoutJoystick() { IList <Player> players = ReInput.get_players().get_Players(); for (int index = 0; index < ((ICollection <Player>)players).Count; ++index) { if (((Player.ControllerHelper)players[index].controllers).get_joystickCount() <= 0) { return(players[index]); } } return((Player)null); }
private void Update() { if (!ReInput.get_isReady()) { return; } if (!this.initialized) { this.Initialize(); } this.GetInput(); this.ProcessInput(); }
private void OnEnable() { if (!ReInput.get_isReady()) { return; } this.inputMapper.get_options().set_timeout(5f); this.inputMapper.get_options().set_ignoreMouseXAxis(true); this.inputMapper.get_options().set_ignoreMouseYAxis(true); ReInput.add_ControllerConnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerChanged)); ReInput.add_ControllerDisconnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerChanged)); this.inputMapper.add_InputMappedEvent(new Action <InputMapper.InputMappedEventData>(this.OnInputMapped)); this.inputMapper.add_StoppedEvent(new Action <InputMapper.StoppedEventData>(this.OnStopped)); this.InitializeUI(); }
public void IdentifyAllJoysticks() { this.Reset(); if (ReInput.get_controllers().get_joystickCount() == 0) { return; } Joystick[] joysticks = ReInput.get_controllers().GetJoysticks(); if (joysticks == null) { return; } this.identifyRequired = true; this.joysticksToIdentify = new Queue <Joystick>((IEnumerable <Joystick>)joysticks); this.SetInputDelay(); }
private void AssignNextPlayer(int rewiredPlayerId) { if (this.playerMap.Count >= this.maxPlayers) { Debug.LogError((object)"Max player limit already reached!"); } else { int nextGamePlayerId = this.GetNextGamePlayerId(); this.playerMap.Add(new PressStartToJoinExample_Assigner.PlayerMap(rewiredPlayerId, nextGamePlayerId)); Player player = ReInput.get_players().GetPlayer(rewiredPlayerId); ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)player.controllers).maps).SetMapsEnabled(false, "Assignment"); ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)player.controllers).maps).SetMapsEnabled(true, "Default"); Debug.Log((object)("Added Rewired Player id " + (object)rewiredPlayerId + " to game player " + (object)nextGamePlayerId)); } }
private void DrawActiveElements() { for (int index = 0; index < this._uiElementsArray.Length; ++index) { this._uiElementsArray[index].element.Deactivate(); } for (int index = 0; index < this._sticks.Length; ++index) { this._sticks[index].Reset(); } IList <InputAction> actions = ReInput.get_mapping().get_Actions(); for (int index = 0; index < ((ICollection <InputAction>)actions).Count; ++index) { this.ActivateElements(this.player, actions[index].get_id()); } }
private void GetAxisButtonDeadZone(int playerId, int actionId, ref float value) { InputAction action = ReInput.get_mapping().GetAction(actionId); if (action == null) { return; } int behaviorId = action.get_behaviorId(); InputBehavior inputBehavior = ReInput.get_mapping().GetInputBehavior(playerId, behaviorId); if (inputBehavior == null) { return; } value = inputBehavior.get_buttonDeadZone() + 0.1f; }
private void Update() { if (!ReInput.get_isReady()) { return; } IDualShock4Extension firstDs4 = this.GetFirstDS4(this.player); if (firstDs4 != null) { ((Component)this).get_transform().set_rotation(firstDs4.GetOrientation()); this.HandleTouchpad(firstDs4); this.accelerometerTransform.LookAt(Vector3.op_Addition(this.accelerometerTransform.get_position(), firstDs4.GetAccelerometerValue())); } if (this.player.GetButtonDown("CycleLight")) { this.SetRandomLightColor(); } if (this.player.GetButtonDown("ResetOrientation")) { this.ResetOrientation(); } if (this.player.GetButtonDown("ToggleLightFlash")) { if (this.isFlashing) { this.StopLightFlash(); } else { this.StartLightFlash(); } this.isFlashing = !this.isFlashing; } if (this.player.GetButtonDown("VibrateLeft")) { ((IControllerVibrator)firstDs4).SetVibration(0, 1f, 1f); } if (!this.player.GetButtonDown("VibrateRight")) { return; } ((IControllerVibrator)firstDs4).SetVibration(1, 1f, 1f); }
private void OnDisable() { if (!ReInput.get_isReady()) { return; } Player player = ReInput.get_players().GetPlayer(0); if (player == null) { return; } player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedX)); player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedY)); player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnCycleColor)); player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnCycleColorReverse)); player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedX)); player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedY)); }
private void AssignJoysticksToPlayers() { IList <Joystick> joysticks = ReInput.get_controllers().get_Joysticks(); for (int index = 0; index < ((ICollection <Joystick>)joysticks).Count; ++index) { Joystick joystick = joysticks[index]; if (!ReInput.get_controllers().IsControllerAssigned(((Controller)joystick).get_type(), (int)((Controller)joystick).id) && ((Controller)joystick).GetAnyButtonDown()) { ((Player.ControllerHelper) this.FindPlayerWithoutJoystick()?.controllers).AddController((Controller)joystick, false); } } if (!this.DoAllPlayersHaveJoysticks()) { return; } ReInput.get_configuration().set_autoAssignJoysticks(true); ((Behaviour)this).set_enabled(false); }
public static Player GetRewiredPlayer(int gamePlayerId) { if (!ReInput.get_isReady()) { return((Player)null); } if (Object.op_Equality((Object)PressStartToJoinExample_Assigner.instance, (Object)null)) { Debug.LogError((object)"Not initialized. Do you have a PressStartToJoinPlayerSelector in your scehe?"); return((Player)null); } for (int index = 0; index < PressStartToJoinExample_Assigner.instance.playerMap.Count; ++index) { if (PressStartToJoinExample_Assigner.instance.playerMap[index].gamePlayerId == gamePlayerId) { return(ReInput.get_players().GetPlayer(PressStartToJoinExample_Assigner.instance.playerMap[index].rewiredPlayerId)); } } return((Player)null); }
private void LogActionMap() { using (IEnumerator <InputAction> enumerator = ((IEnumerable <InputAction>)ReInput.get_mapping().get_Actions()).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { InputAction current = enumerator.Current; Debug.Log((object)"↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"); Debug.Log((object)("ID → " + (object)current.get_id())); Debug.Log((object)("Name → " + current.get_name())); Debug.Log((object)("Type → " + (object)current.get_type())); Debug.Log((object)("DescriptiveName → " + current.get_descriptiveName())); Debug.Log((object)("PositiveDescriptiveName → " + current.get_positiveDescriptiveName())); Debug.Log((object)("NegativeDescriptiveName → " + current.get_negativeDescriptiveName())); Debug.Log((object)("BehaviorID → " + (object)current.get_behaviorId())); Debug.Log((object)("CategoryID → " + (object)current.get_categoryId())); Debug.Log((object)("UserAssignble → " + (object)current.get_userAssignable())); Debug.Log((object)"↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"); } } }
private void Update() { if (!ReInput.get_isReady()) { return; } this.pointer.get_transform().Rotate(Vector3.get_forward(), ((PlayerController.Axis) this.mouse.get_wheel().get_yAxis()).get_value() * 20f); if (this.mouse.get_leftButton().get_justPressed()) { this.CreateClickEffect(new Color(0.0f, 1f, 0.0f, 1f)); } if (this.mouse.get_rightButton().get_justPressed()) { this.CreateClickEffect(new Color(1f, 0.0f, 0.0f, 1f)); } if (!this.mouse.get_middleButton().get_justPressed()) { return; } this.CreateClickEffect(new Color(1f, 1f, 0.0f, 1f)); }
private void Awake() { this._uiElementsArray = new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement[23] { new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(0, this.leftStickX), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(1, this.leftStickY), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(17, this.leftStickButton), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(2, this.rightStickX), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(3, this.rightStickY), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(18, this.rightStickButton), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(4, this.actionBottomRow1), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(5, this.actionBottomRow2), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(6, this.actionBottomRow3), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(7, this.actionTopRow1), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(8, this.actionTopRow2), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(9, this.actionTopRow3), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(14, this.center1), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(15, this.center2), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(16, this.center3), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(19, this.dPadUp), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(20, this.dPadRight), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(21, this.dPadDown), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(22, this.dPadLeft), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(10, this.leftShoulder), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(11, this.leftTrigger), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(12, this.rightShoulder), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.UIElement(13, this.rightTrigger) }; for (int index = 0; index < this._uiElementsArray.Length; ++index) { this._uiElements.Add(this._uiElementsArray[index].id, this._uiElementsArray[index].element); } this._sticks = new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.Stick[2] { new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.Stick(this.leftStick, 0, 1), new Rewired.Demos.GamepadTemplateUI.GamepadTemplateUI.Stick(this.rightStick, 2, 3) }; ReInput.add_ControllerConnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerConnected)); ReInput.add_ControllerDisconnectedEvent(new Action <ControllerStatusChangedEventArgs>(this.OnControllerDisconnected)); }