//Gear Lever controlled RightPedal Z. int gearValue = controller.GearLever; if (gearValue == -2) { joystick.setAxis(1, controller.Scaled.RightPedal / 5, HID_USAGES.HID_USAGE_Z); } else if (gearValue == -1) { joystick.setAxis(1, controller.Scaled.RightPedal / 4, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 1) { joystick.setAxis(1, controller.Scaled.RightPedal / 3, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 2) { joystick.setAxis(1, controller.Scaled.RightPedal / 2, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 3) { joystick.setAxis(1, controller.Scaled.RightPedal / 2 + controller.Scaled.RightPedal / 5, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear3, 10); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 4) { joystick.setAxis(1, controller.Scaled.RightPedal / 2 + controller.Scaled.RightPedal / 4, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear4, 12); controller.SetLEDState(ControllerLEDEnum.Gear3, 10); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 5) { joystick.setAxis(1, controller.Scaled.RightPedal, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear5, 15); controller.SetLEDState(ControllerLEDEnum.Gear4, 12); controller.SetLEDState(ControllerLEDEnum.Gear3, 10); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); }
The set led parts are optional but they are nice. Evochron Legacy also has a button that reverses throttle so I just us that instead of having R be a dedicated reverse. Combining this with what was previously mentioned would probably be the best. You'll also have to put the first two gear changes in an if statement so that you don't just get repeated key presses and you'll have to define a variable for the current gear value after the public int getRefreshRate() part. Something like gearValueSaved. You'll use this in your encapsulating if statement. If gearValueSaved != gearValue then send key down else send key up. I'm sure there are more elegant ways to do it using link statements and what not.
//Gear Lever controlled RightPedal Z. int gearValue = controller.GearLever; if (gearValue == -2) { controller.sendKeyPress(SBC.Key.NumPad1); //this will send a constant press if -2 } else if (gearValue == -1 && gearValueSaved != gearValue) //this will only send key press if -1 & false { controller.sendKeyPress(SBC.Key.X); } else if (gearValue == 1) { joystick.setAxis(1, controller.Scaled.RightPedal / 3, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 2) { joystick.setAxis(1, controller.Scaled.RightPedal / 2, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 3) { joystick.setAxis(1, controller.Scaled.RightPedal / 2 + controller.Scaled.RightPedal / 5, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear3, 10); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 4) { joystick.setAxis(1, controller.Scaled.RightPedal / 2 + controller.Scaled.RightPedal / 4, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear4, 12); controller.SetLEDState(ControllerLEDEnum.Gear3, 10); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); } else if (gearValue == 5) { joystick.setAxis(1, controller.Scaled.RightPedal, HID_USAGES.HID_USAGE_Z); controller.SetLEDState(ControllerLEDEnum.Gear5, 15); controller.SetLEDState(ControllerLEDEnum.Gear4, 12); controller.SetLEDState(ControllerLEDEnum.Gear3, 10); controller.SetLEDState(ControllerLEDEnum.Gear2, 8); controller.SetLEDState(ControllerLEDEnum.Gear1, 6); controller.SetLEDState(ControllerLEDEnum.GearN, 4); }
You could then if you wanted "cruise control" wrap all of that in an if statement that's bound to a toggle switch and you'd have to come up with a way to save the axis position to a var outside of the gear if statements. You could also code something up so that a key press is sent only if an axis is greater than a specific number. This would be a sort of hybrid set up where once you release said pedal it would stop sending key presses and the game would stop increasing throttle. If you wanted to get real fance you could probably combine all of these things. Since the gear lever can set it so your pedal can only travel up to a certain point defined as a number on your axis you could try to code it so that once it reaches a point near the top of that specific gear setting it sends a keypress for set throttle to x percentage if you where to tie that to a gear state change then you would probably not need to code a cruise control toggle.
Edited by Buttsechuani, 08 August 2016 - 10:57 PM.