public IInputMap Clone() { JoystickMap clone = new JoystickMap(deviceId); clone.buttons.AddRange(buttons); clone.axes.AddRange(axes); clone.balls.AddRange(balls); clone.hats.AddRange(hats); return(clone); }
public bool SetFrom(IInputMap that) { JoystickMap jsCast = that as JoystickMap; if (jsCast == null) { Debug.LogError("Type incompatibility when trying to call SetFrom on a joystick input map"); return(false); } SetEmpty(); buttons.AddRange(jsCast.buttons); axes.AddRange(jsCast.axes); balls.AddRange(jsCast.balls); hats.AddRange(jsCast.hats); return(true); }
/// <summary> /// Update the joystick info. /// </summary> private void GetJoystickInfo() { // check if any joystick connected. if (!JCS_Input.IsJoystickConnected()) { return; } for (int index = 0; index < mTotalGamePadInGame; ++index) { JoystickMap joystickMap = GetJoysitckMapByIndex(index); // get stick value. joystickMap.stickLeftXVal = JCS_Input.GetAxis(index, JCS_JoystickButton.STICK_LEFT_X); joystickMap.stickLeftYVal = JCS_Input.GetAxis(index, JCS_JoystickButton.STICK_LEFT_Y); joystickMap.stickRightXVal = JCS_Input.GetAxis(index, JCS_JoystickButton.STICK_RIGHT_X); joystickMap.stickRightYVal = JCS_Input.GetAxis(index, JCS_JoystickButton.STICK_RIGHT_Y); } }
// Token: 0x0600421C RID: 16924 RVA: 0x001661C4 File Offset: 0x001643C4 private void InitMappings() { if (this.m_sectionTemplate) { this.m_sectionTemplate.gameObject.SetActive(true); foreach (InputMapCategory inputMapCategory in ReInput.mapping.UserAssignableMapCategories) { if (this.ControllerType == ControlMappingPanel.ControlType.Keyboard) { KeyboardMap keyboardMapInstance = ReInput.mapping.GetKeyboardMapInstance(inputMapCategory.id, 0); MouseMap mouseMapInstance = ReInput.mapping.GetMouseMapInstance(inputMapCategory.id, 0); // We know this name from debugging, or we can dump it. if (inputMapCategory.name == "QuickSlot") { // Loop through our 8 actions we added via ReWired and create the mapping objects for them. for (int i = 0; i < 8; i++) { var aid = ReInput.mapping.GetActionId(string.Format("QS_Instant{0}", i + 12)); ElementAssignment elementAssignment = new ElementAssignment(KeyCode.None, ModifierKeyFlags.None, aid, Pole.Positive); ActionElementMap actionElementMap; keyboardMapInstance.CreateElementMap(elementAssignment, out actionElementMap); mouseMapInstance.CreateElementMap(elementAssignment, out actionElementMap); } } this.InitSections(keyboardMapInstance); this.InitSections(mouseMapInstance); } else if (this.m_lastJoystickController != null) { JoystickMap joystickMapInstance = ReInput.mapping.GetJoystickMapInstance((Joystick)this.m_lastJoystickController, inputMapCategory.id, 0); this.InitSections(joystickMapInstance); } else { this.m_mappingInitialized = false; } } this.m_sectionTemplate.gameObject.SetActive(false); } }
public void Add(IInputMap map) { KeyboardMap kbMap = map as KeyboardMap; if (kbMap != null) { kbMaps.Add(kbMap); } GamepadMap gpButtonMap = map as GamepadMap; if (gpButtonMap != null) { gpButtonMaps.Add(gpButtonMap); } JoystickMap jsButtonMap = map as JoystickMap; if (jsButtonMap != null) { jsMaps.Add(jsButtonMap); } }
public bool HasConflict(IInputMap other, InputAction.Properties properties) { JoystickMap otherMap = other as JoystickMap; if (otherMap == null || otherMap.IsEmpty) { return(false); } bool allowSameFrameMultiInput = properties.allowSameFrameMultiInput; if (allowSameFrameMultiInput) { if (buttons.Count > 0 && otherMap.buttons.Count > 0) { // Check if they match exactly, or if one map is a sub-set of the other var smallerButtonMap = buttons.Count < otherMap.buttons.Count ? buttons : otherMap.buttons; var largerButtonMap = buttons.Count < otherMap.buttons.Count ? otherMap.buttons : buttons; int sameInputCount = 0; foreach (var button in smallerButtonMap) { bool contains = false; foreach (var otherButton in largerButtonMap) { if (button.buttonIndex == otherButton.buttonIndex) { contains = true; break; } } if (contains) { ++sameInputCount; } } if (sameInputCount == smallerButtonMap.Count) { return(true); } } } else { foreach (var button in buttons) { foreach (var otherButton in otherMap.buttons) { if (button.buttonIndex == otherButton.buttonIndex) { return(true); } } } } foreach (var axis in axes) { foreach (var otherAxis in otherMap.axes) { if (axis.axisIndex == otherAxis.axisIndex && (axis.dir == otherAxis.dir || axis.dir == JoystickDevice.AxisDir.Any || otherAxis.dir == JoystickDevice.AxisDir.Any)) { return(true); } } } foreach (var ballIndex in balls) { foreach (var otherBallIndex in otherMap.balls) { if (ballIndex.ballIndex == otherBallIndex.ballIndex) { return(true); } } } foreach (var hat in hats) { foreach (var otherHat in otherMap.hats) { if (hat.hatIndex == otherHat.hatIndex && hat.position == otherHat.position) { return(true); } } } return(false); }
public static bool InitMappingsPrefix(ControlMappingPanel __instance, ref ControlMappingSection ___m_sectionTemplate, ref bool ___m_mappingInitialized, ref Controller ___m_lastJoystickController) { if (___m_sectionTemplate) { ___m_sectionTemplate.gameObject.SetActive(true); foreach (InputMapCategory inputMapCategory in ReInput.mapping.UserAssignableMapCategories) { if (__instance.ControllerType == ControlMappingPanel.ControlType.Keyboard) { KeyboardMap keyboardMapInstance = ReInput.mapping.GetKeyboardMapInstance(inputMapCategory.id, 0); MouseMap mouseMapInstance = ReInput.mapping.GetMouseMapInstance(inputMapCategory.id, 0); // We know this name from debugging, or we can dump it. Debug.Log("Extended Quickslots - InitMappingsPrefix() inputMapCategory = " + inputMapCategory.name); if (inputMapCategory.name == "QuickSlot") { Debug.Log("ExtendedQuickslots - Mapping Quickslots ..."); // Loop through our 8 actions we added via ReWired and create the mapping objects for them. for (int i = 0; i < ExtendedQuickslots.numSlots; i++) { Debug.Log("\tMapping " + string.Format("QS_Instant{0}", i + 12)); var aid = ReInput.mapping.GetActionId(string.Format("QS_Instant{0}", i + 12)); ElementAssignment elementAssignment = new ElementAssignment(KeyCode.None, ModifierKeyFlags.None, aid, Pole.Positive); keyboardMapInstance.CreateElementMap(elementAssignment, out ActionElementMap actionElementMap); mouseMapInstance.CreateElementMap(elementAssignment, out actionElementMap); } } if (inputMapCategory.name == "Actions") { ElementAssignment elementAssignment; int aid; Debug.Log("\tMapping Sit emote"); aid = ReInput.mapping.GetActionId("Sit_Emote"); elementAssignment = new ElementAssignment(KeyCode.None, ModifierKeyFlags.None, aid, Pole.Positive); keyboardMapInstance.CreateElementMap(elementAssignment, out ActionElementMap actionElementMap); mouseMapInstance.CreateElementMap(elementAssignment, out actionElementMap); Debug.Log("\tMapping Alternate Idle Emote"); aid = ReInput.mapping.GetActionId("Alternate_Idle_Emote"); elementAssignment = new ElementAssignment(KeyCode.None, ModifierKeyFlags.None, aid, Pole.Positive); keyboardMapInstance.CreateElementMap(elementAssignment, out actionElementMap); mouseMapInstance.CreateElementMap(elementAssignment, out actionElementMap); } ControlMappingPanel_InitSections(__instance, new object[] { keyboardMapInstance }); ControlMappingPanel_InitSections(__instance, new object[] { mouseMapInstance }); } else if (___m_lastJoystickController != null) { JoystickMap joystickMapInstance = ReInput.mapping.GetJoystickMapInstance((Joystick)___m_lastJoystickController, inputMapCategory.id, 0); ControlMappingPanel_InitSections(__instance, new object[] { joystickMapInstance }); } else { ___m_mappingInitialized = false; } } ___m_sectionTemplate.gameObject.SetActive(false); } return(false); }