public static void Process(States value, Controller controller) { var current = value.Current as State; if (controller.SharedState.LeftThrottleEnabled) { int z = current.Zr * 2; // for this curve we want the top and bottom of the throttle to be the full multiplier // The middle is where it will damper the movement // Shift the value down to -16k to +16K int shifted_value = z - (1024 * 16); // .2 makes a good dead zone in the middle of the throttle shifted_value = Curves.Calculate(shifted_value, (16 * 1024), .2); // Move the value back up z = shifted_value + (1024 * 16); controller.SetJoystickAxis(z, vJoy.Wrapper.Axis.HID_USAGE_RZ, vJoyTypes.Throttle); } if (controller.SharedState.RightThrottleEnabled) { int z = current.Z * 2; // Zero is full throttle // 32K is no throttle // When the throttles split and Zr is is around 32K turn on reverse thrusting var difference = current.Zr - current.Z; if (current.Zr > 15500 && difference > 1000) { if (controller.GetJoystickButton(MappedButtons.AlternateReverseToggle, vJoyTypes.Virtual) == false) { controller.Logger.LogDebug("Reverse Throttle On"); controller.SetJoystickButton(true, MappedButtons.AlternateReverseToggle, vJoyTypes.Virtual); } } else { if (controller.GetJoystickButton(MappedButtons.AlternateReverseToggle, vJoyTypes.Virtual)) { controller.Logger.LogDebug("Reverse Throttle Off"); controller.SetJoystickButton(false, MappedButtons.AlternateReverseToggle, vJoyTypes.Virtual); } } // Invert the values. We want the multipler to rise the closer we get to full throttle //int z_inverted = (1024 * 32) - z; //z_inverted = Curves.Calculate(z_inverted, (32 * 1024), .5); // Invert the value again //z = (1024 * 32) - z_inverted; controller.SetJoystickAxis(z, vJoy.Wrapper.Axis.HID_USAGE_Z, vJoyTypes.Throttle); } }
public static void Process(AltStates value, Controller controller) { var current = value.Current as State; // x = -512 to 511 // y = -512 to 511 // z = -512 to 511 // z = 0 to 255 // Z is off by about -13 to -15 var zRaw = current.R; if (zRaw > 108 && zRaw < 128) { zRaw = 128; } int y = current.Y * 128; int x = current.X * 128; int z = zRaw * 128; // Add X an Y together to use the toe brakes to go up and down int combined = ((128 * 255) / 2) + (current.Y * 64 - current.X * 64); combined = Curves.Calculate(combined - (16 * 1024), (16 * 1024), .2) + 16 * 1024; controller.SetJoystickAxis(combined, vJoy.Wrapper.Axis.HID_USAGE_RX, vJoyTypes.StickAndPedals); controller.SetJoystickAxis(z, vJoy.Wrapper.Axis.HID_USAGE_RZ, vJoyTypes.StickAndPedals); }
// twist = -32 to 31 private void Controller_Rotate(object sender, RotateEventArgs e) { int z = ((e.R * -1) + 32) * 16 * 32; this.swff2Controller.VisualState.UpdateAxis3((UInt32)z); z = Curves.Calculate(z - (16 * 1024), (16 * 1024), .4) + 16 * 1024; swff2Controller.SetJoystickAxis(z, HID_USAGES.HID_USAGE_Z, vJoyTypes.StickAndPedals); }
public static void Process(States value, Controller controller) { // twist = -32 to 31 var current = value.Current as State; int z = ((current.R * -1) + 32) * 16 * 32; z = Curves.Calculate(z - (16 * 1024), (16 * 1024), .4) + 16 * 1024; controller.SetJoystickAxis(z, vJoy.Wrapper.Axis.HID_USAGE_Z, vJoyTypes.StickAndPedals); }
public static void Process(States value, Controller controller) { var current = value.Current as State; int y = ((current.Y * -1) + 511) * 32; int x = ((current.X * -1) + 511) * 32; x = Curves.Calculate(x - (16 * 1024), (16 * 1024), .4) + 16 * 1024; y = Curves.Calculate(y - (16 * 1024), (16 * 1024), .4) + 16 * 1024; controller.SetJoystickAxis(x, vJoy.Wrapper.Axis.HID_USAGE_X, vJoyTypes.StickAndPedals); controller.SetJoystickAxis(y, vJoy.Wrapper.Axis.HID_USAGE_Y, vJoyTypes.StickAndPedals); }
// x = -512 to 511 // y = -512 to 511 // z = -512 to 511 private void Controller_Move(object sender, MoveEventArgs e) { int y = ((e.Y * -1) + 511) * 32; int x = ((e.X * -1) + 511) * 32; //this.scController.VisualState.UpdateAxis1((UInt32)x); //this.scController.VisualState.UpdateAxis2((UInt32)y); x = Curves.Calculate(x - (16 * 1024), (16 * 1024), .5) + 16 * 1024; y = Curves.Calculate(y - (16 * 1024), (16 * 1024), .5) + 16 * 1024; scController.SetJoystickAxis(x, HID_USAGES.HID_USAGE_X, vJoyTypes.Commander); scController.SetJoystickAxis(y, HID_USAGES.HID_USAGE_Y, vJoyTypes.Commander); }
public static void Process(States value, Controller controller) { var current = value.Current as State; // x = -512 to 511 // y = -512 to 511 // z = -512 to 511 int y = ((current.Y * -1) + 511) * 32; int x = ((current.X * -1) + 511) * 32; int z = ((current.R * -1) + 511) * 32; x = Curves.Calculate(x - (16 * 1024), (16 * 1024), .5) + 16 * 1024; y = Curves.Calculate(y - (16 * 1024), (16 * 1024), .5) + 16 * 1024; controller.SetJoystickAxis(x, vJoy.Wrapper.Axis.HID_USAGE_X, vJoyTypes.Commander); controller.SetJoystickAxis(y, vJoy.Wrapper.Axis.HID_USAGE_Y, vJoyTypes.Commander); controller.SetJoystickAxis(z, vJoy.Wrapper.Axis.HID_USAGE_Z, vJoyTypes.Commander); }
// x = 0 to 255 // y = 0 to 255 // z = 0 to 255 private void Controller_Move(object sender, MoveEventArgs e) { int y = e.Y * 128; int x = e.X * 128; bool buttonX = e.X > 128; bool buttonY = e.Y > 128; //this.ChPedalsController.VisualState.UpdateAxis1((UInt32)x); //this.ChPedalsController.VisualState.UpdateAxis2((UInt32)y); int combined = ((128 * 255) / 2) + (e.Y * 64 - e.X * 64); combined = Curves.Calculate(combined - (16 * 1024), (16 * 1024), .2) + 16 * 1024; //chPedalsController.SetJoystickAxis(x, HID_USAGES.HID_USAGE_X); //chPedalsController.SetJoystickAxis(y, HID_USAGES.HID_USAGE_Y); chPedalsController.SetJoystickAxis(combined, HID_USAGES.HID_USAGE_RX, vJoyTypes.StickAndPedals); //chPedalsController.SetJoystickButton(buttonX, 21, vJoyTypes.StickAndPedals); //chPedalsController.SetJoystickButton(buttonY, 22, vJoyTypes.StickAndPedals); }
private void Controller_ThrottleLeft(object sender, ThrottleAxisEventArgs e) { if (LeftEnabled) { int z = e.AxisValue * 2; this.tmThrottleController.VisualState.UpdateAxis1((UInt32)z); // for this curve we want the top and bottom of the throttle to be the full multiplier // The middle is where it will damper the movement // Shift the value down to -16k to +16K int shifted_value = z - (1024 * 16); // .2 makes a good dead zone in the middle of the throttle shifted_value = Curves.Calculate(shifted_value, (16 * 1024), .2); // Move the value back up z = shifted_value + (1024 * 16); tmThrottleController.SetJoystickAxis(z, HID_USAGES.HID_USAGE_RZ, vJoyTypes.Throttle); } }