/// <summary> /// Returns true there are analog/digital mismatches /// </summary> /// <returns></returns> public bool TestForAnalogDigitalConflicts() { KeyboardMouseControlMap[] maps = new KeyboardMouseControlMap[] { ls_f, rs_f, ls_b, rs_b, ls_l, rs_l, ls_r, rs_r, leftTrigger, rightTrigger, shoulderL, shoulderR, a, b, x, y, back, start, DpadF, DpadB, DpadL, DpadR, leftClick, rightClick }; for (int i = 1; i < maps.Length; i++) { if (maps[i].IsAnalog) { continue; } } //make sure buttons are digital maps = new KeyboardMouseControlMap[] { shoulderL, shoulderR, a, b, x, y, back, start, DpadF, DpadB, DpadL, DpadR, leftClick, rightClick }; foreach (KeyboardMouseControlMap map in maps) { if (map.IsAnalog) { return(true); } } //directions must be analog or digital, not both if (ls_f.IsAnalog != ls_b.IsAnalog || ls_l.IsAnalog != ls_r.IsAnalog || rs_f.IsAnalog != rs_b.IsAnalog || rs_l.IsAnalog != rs_r.IsAnalog) { return(true); } return(false); }
/// <summary> /// Returns true if two or more mappings share the same value /// </summary> /// <returns></returns> public bool TestForConflicts() { KeyboardMouseControlMap[] maps = new KeyboardMouseControlMap[] { ls_f, rs_f, ls_b, rs_b, ls_l, rs_l, ls_r, rs_r, leftTrigger, rightTrigger, shoulderL, shoulderR, a, b, x, y, back, start, DpadF, DpadB, DpadL, DpadR, leftClick, rightClick }; Array.Sort <KeyboardMouseControlMap>(maps); for (int i = 1; i < maps.Length; i++) { if (maps[i - 1].CompareTo(maps[i]) == 0) { return(true); } } return(false); }
/// <summary></summary> public KeyboardMouseControlMapping() { #if !XBOX360 ls_f = Keys.W; rs_f = MouseInput.YAxis; ls_b = Keys.S; rs_b = MouseInput.YAxis; ls_l = Keys.A; rs_l = MouseInput.XAxis; ls_r = Keys.D; rs_r = MouseInput.XAxis; leftTrigger = MouseInput.LeftButton; rightTrigger = MouseInput.RightButton; #else //why someone would want to use the keyboard for control on the 360 is beyond me.. ls_f = Keys.W; rs_f = Keys.I; ls_b = Keys.S; rs_b = Keys.K; ls_l = Keys.A; rs_l = Keys.J; ls_r = Keys.D; rs_r = Keys.L; leftTrigger = Keys.LeftShift; rightTrigger = Keys.LeftControl; #endif a = Keys.Space; b = Keys.E; x = Keys.Z; y = Keys.C; #if XNA_3_0 || XNA_3_1 back = Keys.Escape; #else back = Keys.Back; //The escape key doesn't work in XNA 2! #endif start = Keys.Enter; DpadF = Keys.Up; DpadB = Keys.Down; DpadL = Keys.Left; DpadR = Keys.Right; leftClick = Keys.Q; rightClick = Keys.R; shoulderL = Keys.F; shoulderR = Keys.V; }