private string GetControllerMapXml(Player player, ControllerType controllerType, int categoryId, int layoutId, Controller controller) { string text = this.GetBasePlayerPrefsKey(player); text += "|dataType=ControllerMap"; text = text + "|controllerMapType=" + controller.mapTypeString; string text2 = text; text = string.Concat(new object[] { text2, "|categoryId=", categoryId, "|layoutId=", layoutId }); text = text + "|hardwareIdentifier=" + controller.hardwareIdentifier; if (controllerType == ControllerType.Joystick) { Rewired.Joystick joystick = (Rewired.Joystick)controller; text = text + "|hardwareGuid=" + joystick.hardwareTypeGuid.ToString(); } if (!PlayerPrefs.HasKey(text)) { return(string.Empty); } return(PlayerPrefs.GetString(text)); }
private void LoadJoystickCalibrationData(Rewired.Joystick joystick) { if (joystick == null) { return; } joystick.ImportCalibrationMapFromXmlString(this.GetJoystickCalibrationMapXml(joystick)); }
public void SetJoystick(int playerId, Rewired.Joystick joystick) { if (!base.initialized) { return; } this.playerId = playerId; this.joystick = joystick; if (joystick == null) { Debug.LogError("Rewired Control Mapper: Joystick cannot be null!"); return; } float num = 0f; for (int i = 0; i < joystick.axisCount; i++) { int index = i; GameObject gameObject = UITools.InstantiateGUIObject <UnityEngine.UI.Button>(this.axisButtonPrefab, this.axisScrollAreaContent, "Axis" + i); UnityEngine.UI.Button button = gameObject.GetComponent <UnityEngine.UI.Button>(); button.onClick.AddListener(delegate { this.OnAxisSelected(index, button); }); Text componentInSelfOrChildren = UnityTools.GetComponentInSelfOrChildren <Text>(gameObject); if (componentInSelfOrChildren != null) { componentInSelfOrChildren.text = joystick.AxisElementIdentifiers[i].name; } if (num == 0f) { num = UnityTools.GetComponentInSelfOrChildren <LayoutElement>(gameObject).minHeight; } this.axisButtons.Add(button); } float spacing = this.axisScrollAreaContent.GetComponent <VerticalLayoutGroup>().spacing; this.axisScrollAreaContent.sizeDelta = new Vector2(this.axisScrollAreaContent.sizeDelta.x, Mathf.Max((float)joystick.axisCount * (num + spacing) - spacing, this.axisScrollAreaContent.sizeDelta.y)); this.origCalibrationData = joystick.calibrationMap.ToXmlString(); this.displayAreaWidth = this.rightContentContainer.sizeDelta.x; this.rewiredStandaloneInputModule = base.gameObject.transform.root.GetComponentInChildren <RewiredStandaloneInputModule>(); if (this.rewiredStandaloneInputModule != null) { this.menuHorizActionId = ReInput.mapping.GetActionId(this.rewiredStandaloneInputModule.horizontalAxis); this.menuVertActionId = ReInput.mapping.GetActionId(this.rewiredStandaloneInputModule.verticalAxis); } if (joystick.axisCount > 0) { this.SelectAxis(0); } base.defaultUIElement = this.doneButton.gameObject; this.RefreshControls(); this.Redraw(); }
private void SaveJoystickCalibrationData(Rewired.Joystick joystick) { if (joystick == null) { return; } JoystickCalibrationMapSaveData calibrationMapSaveData = joystick.GetCalibrationMapSaveData(); string joystickCalibrationMapPlayerPrefsKey = this.GetJoystickCalibrationMapPlayerPrefsKey(calibrationMapSaveData); PlayerPrefs.SetString(joystickCalibrationMapPlayerPrefsKey, calibrationMapSaveData.map.ToXmlString()); }
private string GetJoystickCalibrationMapXml(Rewired.Joystick joystick) { string text = this.playerPrefsKeyPrefix; text += "|dataType=CalibrationMap"; text = text + "|controllerType=" + joystick.type.ToString(); text = text + "|hardwareIdentifier=" + joystick.hardwareIdentifier; text = text + "|hardwareGuid=" + joystick.hardwareTypeGuid.ToString(); if (!PlayerPrefs.HasKey(text)) { return(string.Empty); } return(PlayerPrefs.GetString(text)); }
private void DrawDialogWindow(int windowId) { if (!this.identifyRequired) { return; } if (this.style == null) { this.style = new GUIStyle(GUI.skin.label); this.style.wordWrap = true; } GUILayout.Space(15f); GUILayout.Label("A joystick has been attached or removed. You will need to identify each joystick by pressing a button on the controller listed below:", this.style, new GUILayoutOption[0]); Rewired.Joystick joystick = this.joysticksToIdentify.Peek(); GUILayout.Label("Press any button on \"" + joystick.name + "\" now.", this.style, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (GUILayout.Button("Skip", new GUILayoutOption[0])) { this.joysticksToIdentify.Dequeue(); return; } }