private static JoystickAxisDetector AddNewJoystickAxisDetector(string name) { int kIndex = name.IndexOf("k"); int AIndex = name.IndexOf("A"); int joystickIndex = Int32.Parse(name.Substring(kIndex + 1, AIndex - kIndex - 1)); name = name.Substring(kIndex + 1, name.Length - kIndex - 1); int sIndex = name.IndexOf("s"); int inputIndex; JoystickAxisDirection direction; if (name.EndsWith("Negative")) { int NIndex = name.IndexOf("N"); inputIndex = Int32.Parse(name.Substring(sIndex + 1, NIndex - sIndex - 1)); direction = JoystickAxisDirection.Negative; } else { int PIndex = name.IndexOf("P"); inputIndex = Int32.Parse(name.Substring(sIndex + 1, PIndex - sIndex - 1)); direction = JoystickAxisDirection.Positive; } JoystickAxisDetector detector = new JoystickAxisDetector(joystickIndex, inputIndex, direction); joystickAxisDetectors.Add(name, detector); return(detector); }
static InputMapper() { defaultSwitchProControllerMap = new Dictionary <string, InputDetector>(11) { [MOVE_LEFT] = JoystickAxisDetector.ToJoystickAxisDetector("Joystick0Axis0Negative"), [MOVE_RIGHT] = JoystickAxisDetector.ToJoystickAxisDetector("Joystick0Axis0Positive"), [ACCELERATE] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button10"), [JUMP] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button0"), [ATTACK] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button2"), [DODGE] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button1"), [INTERACT] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button3"), [RECOVER] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button7"), [SWITCH_PREV] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button13"), [SWITCH_NEXT] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button14"), [SWITCH_UP] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button11"), [SWITCH_DOWN] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button12"), [SWITCH_CAMERA] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button9"), [PAUSE] = JoystickButtonDetector.ToJoystickButtonDetector("Joystick0Button8") }; defaultKeyboardMap = new Dictionary <string, InputDetector>(11) { [MOVE_LEFT] = KeyDetector.ToKeyDetector("A"), [MOVE_RIGHT] = KeyDetector.ToKeyDetector("D"), [ACCELERATE] = KeyDetector.ToKeyDetector("N"), [JUMP] = KeyDetector.ToKeyDetector("W"), [ATTACK] = KeyDetector.ToKeyDetector("J"), [DODGE] = KeyDetector.ToKeyDetector("K"), [INTERACT] = KeyDetector.ToKeyDetector("U"), [RECOVER] = KeyDetector.ToKeyDetector("F"), [SWITCH_PREV] = KeyDetector.ToKeyDetector("Q"), [SWITCH_NEXT] = KeyDetector.ToKeyDetector("E"), [SWITCH_UP] = KeyDetector.ToKeyDetector("Y"), [SWITCH_DOWN] = KeyDetector.ToKeyDetector("H"), [SWITCH_CAMERA] = KeyDetector.ToKeyDetector("Tab"), [PAUSE] = KeyDetector.ToKeyDetector("Escape") }; }