// Map the Xbox Controller to a specific set of FreeSpace 2 Keyboard and Mouse controls // Map the Right Analogue Stick (XInput1.Joy2X/Y) to the Mouse // Note that the numeric value affects the speed of the turning, and we use a deadzone of 0.2 to prevent 'twitching'. mouse.DirectInputX = mouse.DirectInputX + 25 * deadzone(XInput1.Joy2X, 0.2) mouse.DirectInputY = mouse.DirectInputY - 25 * deadzone(XInput1.Joy2Y, 0.2) // Map the Right trigger to the left mouse button (Fire Primary) and the Left Trigger to the right mouse button (Fire secondary). // Use a threshold of 0.5 as this is an analogue input but we are converting it to a digital input mouse.Button1 = XInput1.RightTrigger > 0.5 mouse.Button2 = XInput1.LeftTrigger > 0.5 // Map the two shoulder buttons (LB/RB) to advancing the appropriate weapon types. keyboard.Dot = XInput1.RightShoulder keyboard.Slash = XInput1.LeftShoulder // Map the X axis of the left stick to bank left/right controls keyboard.NUMPAD7 = XInput1.Joy1X < -0.5 keyboard.NUMPAD9 = XInput1.Joy1X > 0.5 // Map the Y axis of the left stick to increase / decrease throttle keyboard.Equals = XInput1.Joy1Y > 0.5 keyboard.Minus = XInput1.Joy1Y < -0.5 // Map the left thumb stick button to after-burner and the right thumbstick button to chaff / counter measure keyboard.Tab = XInput1.LeftThumb keyboard.X = XInput1.RightThumb // Map the back button to 'match speed' and the start button to 'Equalize charge on shield' keyboard.M = XInput1.Back keyboard.Q = XInput1.Start // Map A to 'target ship in reticule', X to 'Next Ship', Y to 'Closest Hostile' and B to 'Next Sub-System' keyboard.Y = XInput1.A keyboard.T = XInput1.X keyboard.H = XInput1.Y keyboard.S = XInput1.B // Map the DPad up to Max Throttle and DPad down to Zero throttle keyboard.BackSpace = XInput1.Down keyboard.Backslash = XInput1.Up // Map the DPad left to 'target escort ship' and DPad right to 'target next bomb'. keyboard.E = XInput1.Left keyboard.B = XInput1.Right