// Creates new type of (keyboard or gamepad) public InputMapping CreateInputType(InputDevice type, int plyrNum) { switch (type) { case InputDevice.KEYBOARD: KeyboardMapping kybrd = InputMappingAssetCreator.CreateKeyboardMappingAsset(definedPath, "KeyboardMapping " + plyrNum); kybrd.type = InputDevice.KEYBOARD; kybrd.plyrID = (PlayerID)(plyrNum); InitializeKeyboardSetup(ref kybrd); return(kybrd); break; case InputDevice.GAMEPAD: GamepadMapping gmpd = InputMappingAssetCreator.CreateGamepadMappingAsset(definedPath, "GamepadMapping " + plyrNum); gmpd.type = InputDevice.GAMEPAD; gmpd.plyrID = (PlayerID)(plyrNum); InitializeGamepadSetup(ref gmpd); return(gmpd); break; } return(null); }
public InputForm GetInputState(GamepadMapping plyrSetup) { InputForm rtnForm = new InputForm(); GamePadState gmpdState = GamePad.GetState((PlayerIndex)(plyrSetup.gmpdID), GamePadDeadZone.IndependentAxes); UpdateButtonStates(ref rtnForm, gmpdState, plyrSetup.m_buttonCodes); UpdateAxisStates(ref rtnForm, gmpdState, plyrSetup.m_axisCodes); return(rtnForm); }
public InputForm GetInputState(GamepadMapping plyrSetup) { InputForm rtnForm = new InputForm(); GamePadState gmpdState = GamePad.GetState((PlayerIndex)(plyrSetup.gmpdID), GamePadDeadZone.IndependentAxes); UpdateButtonStates(ref rtnForm, gmpdState, plyrSetup.m_buttonCodes); UpdateAxisStates(ref rtnForm, gmpdState, plyrSetup.m_axisCodes); return rtnForm; }
public void DisplayMapping(int plyrNum) { // Depending on input type, method of display is decided switch (cachedInputBuilder.playerInputMappings[plyrNum].type) { case InputDevice.KEYBOARD: KeyboardMapping k = cachedInputBuilder.playerInputMappings[plyrNum] as KeyboardMapping; KeyboardDisplaySetup(ref k, plyrNum, "Keyboard"); break; case InputDevice.GAMEPAD: GamepadMapping p = cachedInputBuilder.playerInputMappings[plyrNum] as GamepadMapping; GamepadDisplaySetup(ref p, plyrNum, "Gamepad"); break; } }
private void GamepadDisplaySetup(ref GamepadMapping gmpdInptSetup, int plyrNum, string name) { nAnim[plyrNum, 1].target = EditorGUILayout.Foldout(nAnim[plyrNum, 1].target, name); if (EditorGUILayout.BeginFadeGroup(nAnim[plyrNum, 1].faded)) { EditorGUI.indentLevel++; // Button nAnim[plyrNum, 2].target = EditorGUILayout.Foldout(nAnim[plyrNum, 2].target, "Buttons"); GamepadButtonList <AbstractButtonInput>(nAnim[plyrNum, 2], ref gmpdInptSetup); // Axis nAnim[plyrNum, 3].target = EditorGUILayout.Foldout(nAnim[plyrNum, 3].target, "Axis"); GamepadAxisList <AbstractAxisInput>(nAnim[plyrNum, 3], ref gmpdInptSetup); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); }
private static void GamepadAxisList <T>(AnimBool anim, ref GamepadMapping gmpdInptSetup) where T : struct, IConvertible { if (EditorGUILayout.BeginFadeGroup(anim.faded)) { int i = 0; foreach (string t in Enum.GetNames(typeof(T))) { if (t == "NONE") { continue; // Doesn't show the NONE enum } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(t + ":", GUILayout.Width(100)); // Axis Label gmpdInptSetup.m_axisCodes[i] = (GmpdAxis)EditorGUILayout.EnumPopup(gmpdInptSetup.m_axisCodes[i]); i += 1; EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndFadeGroup(); }
private void InitializeGamepadSetup(ref GamepadMapping plyrGmpdSetup) { plyrGmpdSetup.m_buttonCodes = new GmpdButton[Enum.GetNames(typeof(AbstractButtonInput)).Length]; plyrGmpdSetup.m_axisCodes = new GmpdAxis[Enum.GetNames(typeof(AbstractButtonInput)).Length]; }