public static KeyboardSetting GetKetboard(string keyboard) { KeyboardSetting setting = settings[0]; if (keyboard == "Keyboard1") { setting = settings[1]; setting.A = KeyCode.K; setting.B = KeyCode.L; setting.X = KeyCode.J; setting.Y = KeyCode.I; setting.Start = KeyCode.Return; setting.Back = KeyCode.Escape; setting.Left = KeyCode.A; setting.Right = KeyCode.D; setting.Up = KeyCode.W; setting.Down = KeyCode.S; setting.LeftStick = KeyCode.LeftControl; setting.RightStick = KeyCode.LeftAlt; setting.RightShoulder = KeyCode.O; setting.LeftShoulder = KeyCode.U; setting.LeftTrigger = KeyCode.LeftShift; setting.RightTrigger = KeyCode.F; setting.DpadUp = KeyCode.Alpha1; setting.DpadDown = KeyCode.Alpha2; setting.DpadLeft = KeyCode.Alpha3; setting.DpadRight = KeyCode.Alpha4; } else if (keyboard == "Keyboard2") { setting = settings[2]; setting.A = KeyCode.Keypad5; setting.B = KeyCode.Keypad6; setting.X = KeyCode.Keypad4; setting.Y = KeyCode.Keypad8; setting.Start = KeyCode.KeypadEnter; setting.Back = KeyCode.Keypad0; setting.Left = KeyCode.LeftArrow; setting.Right = KeyCode.RightArrow; setting.Up = KeyCode.UpArrow; setting.Down = KeyCode.DownArrow; setting.LeftStick = KeyCode.LeftControl; setting.RightStick = KeyCode.LeftAlt; setting.RightShoulder = KeyCode.Keypad9; setting.LeftShoulder = KeyCode.Keypad7; setting.LeftTrigger = KeyCode.RightControl; setting.RightTrigger = KeyCode.RightAlt; setting.DpadUp = KeyCode.KeypadDivide; setting.DpadDown = KeyCode.KeypadMultiply; setting.DpadLeft = KeyCode.KeypadMinus; setting.DpadRight = KeyCode.KeypadPlus; } //setting.FillDic(); return(setting); }
public static bool GetButtonUp(Button button, Index controlIndex) { code = GetKeycode(button, controlIndex); if (controlIndex == Index.Keyboard1 || controlIndex == Index.Keyboard2) { KeyboardSetting setting1 = KeyboardSetting.GetKetboard(controlIndex.ToString()); return(Input.GetKeyUp(setting1.GetKey(button.ToString()))); } else if (controlIndex != Index.Any) { return(Input.GetKeyUp(code)); } else { KeyboardSetting setting1 = KeyboardSetting.GetKetboard(Index.Keyboard1.ToString()); KeyboardSetting setting2 = KeyboardSetting.GetKetboard(Index.Keyboard2.ToString()); return(Input.GetKeyUp(code) || Input.GetKeyUp(setting1.GetKey(button.ToString())) || Input.GetKeyUp(setting2.GetKey(button.ToString()))); } }
private static void FillKeyboard(ref GamepadState state, Index controlIndex) { KeyboardSetting setting = KeyboardSetting.GetKetboard(controlIndex.ToString()); state.A = Input.GetKey(setting.A); state.B = Input.GetKey(setting.B); state.Y = Input.GetKey(setting.Y); state.X = Input.GetKey(setting.X); state.AUp = Input.GetKeyUp(setting.A); state.BUp = Input.GetKeyUp(setting.B); state.YUp = Input.GetKeyUp(setting.Y); state.XUp = Input.GetKeyUp(setting.X); state.ADown = Input.GetKeyDown(setting.A); state.BDown = Input.GetKeyDown(setting.B); state.YDown = Input.GetKeyDown(setting.Y); state.XDown = Input.GetKeyDown(setting.X); state.RightShoulder = Input.GetKey(setting.RightShoulder); state.LeftShoulder = Input.GetKey(setting.LeftShoulder); state.RightStick = Input.GetKey(setting.RightStick); state.LeftStick = Input.GetKey(setting.LeftStick); state.RightShoulderUp = Input.GetKeyUp(setting.RightShoulder); state.LeftShoulderUp = Input.GetKeyUp(setting.LeftShoulder); state.RightShoulderDown = Input.GetKeyDown(setting.RightShoulder); state.LeftShoulderDwon = Input.GetKeyDown(setting.LeftShoulder); state.RightShoulder = Input.GetKey(setting.RightShoulder); state.LeftShoulder = Input.GetKey(setting.LeftShoulder); state.Start = Input.GetKey(setting.Start); state.Back = Input.GetKey(setting.Back); state.rightStickAxis = Vector2.zero; state.Left = Input.GetKey(setting.Left); state.Right = Input.GetKey(setting.Right); state.Up = Input.GetKey(setting.Up); state.Down = Input.GetKey(setting.Down); move = Vector2.zero; if (state.Left) { move.x += -1.0f; } if (state.Right) { move.x += 1.0f; } if (state.Down) { move.y += -1.0f; } if (state.Up) { move.y += 1.0f; } state.LeftStickAxis = move; dPad = Vector2.zero; if (Input.GetKey(setting.DpadUp)) { dPad.y += 1.0f; } if (Input.GetKey(setting.DpadDown)) { dPad.y += -1.0f; } if (Input.GetKey(setting.DpadRight)) { dPad.x += 1.0f; } if (Input.GetKey(setting.DpadLeft)) { dPad.x += -1.0f; } state.dPadAxis = dPad; state.LeftTrigger = Input.GetKey(setting.LeftTrigger) ? 1.0f : 0.0f; state.RightTrigger = Input.GetKey(setting.RightTrigger) ? 1.0f : 0.0f; state.AnyKeyPressedDownAXYB = state.XDown || state.ADown || state.YDown || state.BDown; }