void CreateKeyMap(XR_Enum.InputType inputType, int totalInput) { int[] enumValues = XR_Utilities.GetDeviceControllerKeysValues((XR_Enum.DefaultController)deviceType, inputType); for (int i = 0; i < totalInput; i++) { KeyMap keyMap = GetKeyMap(enumValues[i], inputType); } }
public void UpdateKeyMap(KeyMap keyMap) { for (int i = 0; i < keyMappingList.Count; i++) { if (keyMappingList[i].Equals(keyMap)) { keyMappingList[i] = keyMap; } } }
public KeyMap GetKeyMap(int buttonID, XR_Enum.InputType inputType) { if (keyMappingList == null) { keyMappingList = new List <KeyMap>(); } KeyMap keyMap = keyMappingList.Find((obj) => (obj.inputType == inputType && obj.mainInput == buttonID)); if (keyMap == null || keyMap.KeyID == null) { keyMap = new KeyMap(buttonID, inputType); keyMappingList.Add(keyMap); } return(keyMap); }
void KeyBinding() { EditorGUILayout.Space(); if (m_keyBindingData.controllerList.Count > 0) { if (m_keyBindingData.controllerList.Count > 0) { EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); if (GUILayout.Button("<==", GUILayout.Width(50))) { if (m_keyBindingData.currentControllerIndex > 0) { m_keyBindingData.currentControllerIndex--; } else { m_keyBindingData.currentControllerIndex = m_keyBindingData.controllerList.Count - 1; } } GUILayout.FlexibleSpace(); List <string> deviceName = new List <string>(); List <int> deviceIndex = new List <int>(); for (int i = 0; i < m_keyBindingData.controllerList.Count; i++) { deviceName.Add(m_keyBindingData.controllerList[i].Name + " " + m_keyBindingData.controllerList[i].hand); deviceIndex.Add(i); } if (deviceName.Count > 0) { m_keyBindingData.currentControllerIndex = EditorGUILayout.IntPopup(m_keyBindingData.currentControllerIndex, deviceName.ToArray(), deviceIndex.ToArray(), GUILayout.MinWidth(10)); } GUILayout.FlexibleSpace(); if (GUILayout.Button("==>", GUILayout.Width(50))) { if (m_keyBindingData.currentControllerIndex < m_keyBindingData.controllerList.Count - 1) { m_keyBindingData.currentControllerIndex++; } else { m_keyBindingData.currentControllerIndex = 0; } } EditorGUILayout.EndHorizontal(); ControllerStruct controller = m_keyBindingData.GetControllerByIndex(m_keyBindingData.currentControllerIndex); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); EditorGUILayout.LabelField("Name: " + controller.Name.ToString(), EditorStyles.boldLabel, GUILayout.Width(200)); EditorGUILayout.LabelField("Hand: " + controller.hand.ToString(), EditorStyles.boldLabel, GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); if (controller.TotalButton > 0) { //EditorGUILayout.LabelField("Button Press/Touch", EditorStyles.boldLabel, GUILayout.Width(250)); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); EditorGUILayout.LabelField("Button Name", EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.LabelField("Key Mapping", EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.EndHorizontal(); XR_Enum.InputType inputType = XR_Enum.InputType.Bool; string[] enumNames = XR_Utilities.GetDeviceControllerKeysName((XR_Enum.DefaultController)controller.deviceType, inputType); int[] enumValues = XR_Utilities.GetDeviceControllerKeysValues((XR_Enum.DefaultController)controller.deviceType, inputType); if (enumValues != null) { for (int i = 1; i <= controller.TotalButton; i++) { KeyMap keyMap = controller.GetKeyMap(enumValues[i], inputType); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); string featureUsageName = ((XR_Enum.FeatureUsageButton)enumValues[i]).ToString(); EditorGUILayout.LabelField(featureUsageName, GUILayout.Width(150)); //keyMap.enumType = EditorGUILayout.Popup(keyMap.enumType, GetButtonsEnum, GUILayout.Width(100)); keyMap.mapedInput = EditorGUILayout.IntPopup(keyMap.mapedInput, enumNames, enumValues, GUILayout.Width(100)); controller.UpdateKeyMap(keyMap); EditorGUILayout.EndHorizontal(); } } } if (controller.TotalAxis1DButton > 0) { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); EditorGUILayout.LabelField("Axis1D Name", EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.LabelField("Key Mapping", EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.EndHorizontal(); XR_Enum.InputType inputType = XR_Enum.InputType.Axis1D; string[] enumNames = XR_Utilities.GetDeviceControllerKeysName((XR_Enum.DefaultController)controller.deviceType, inputType); int[] enumValues = XR_Utilities.GetDeviceControllerKeysValues((XR_Enum.DefaultController)controller.deviceType, inputType); if (enumValues != null) { for (int i = 1; i <= controller.TotalAxis1DButton; i++) { KeyMap keyMap = controller.GetKeyMap(enumValues[i], inputType); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); string featureUsageName = ((XR_Enum.FeatureUsageAxis)enumValues[i]).ToString(); EditorGUILayout.LabelField(featureUsageName, GUILayout.Width(150)); keyMap.mapedInput = EditorGUILayout.IntPopup(keyMap.mapedInput, enumNames, enumValues, GUILayout.Width(100)); controller.UpdateKeyMap(keyMap); EditorGUILayout.EndHorizontal(); } } } if (controller.TotalAxis2DButton > 0) { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); EditorGUILayout.LabelField("Axis2D Name", EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.LabelField("Key Mapping", EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.EndHorizontal(); XR_Enum.InputType inputType = XR_Enum.InputType.Axis2D; string[] enumNames = XR_Utilities.GetDeviceControllerKeysName((XR_Enum.DefaultController)controller.deviceType, inputType); int[] enumValues = XR_Utilities.GetDeviceControllerKeysValues((XR_Enum.DefaultController)controller.deviceType, inputType); if (enumValues != null) { for (int i = 1; i <= controller.TotalAxis2DButton; i++) { KeyMap keyMap = controller.GetKeyMap(enumValues[i], inputType); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); string featureUsageName = ((XR_Enum.FeatureUsage2DAxis)enumValues[i]).ToString(); EditorGUILayout.LabelField(featureUsageName, GUILayout.Width(150)); keyMap.mapedInput = EditorGUILayout.IntPopup(keyMap.mapedInput, enumNames, enumValues, GUILayout.Width(100)); controller.UpdateKeyMap(keyMap); EditorGUILayout.EndHorizontal(); } } } } } EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(350)); EditorGUILayout.EndHorizontal(); }