//this gets called once every refreshRate milliseconds by main program public void mainLoop() { joystick.setAxis(1,controller.Scaled.GearLever,HID_USAGES.HID_USAGE_SL1); joystick.setAxis(1,controller.Scaled.AimingX,HID_USAGES.HID_USAGE_X); joystick.setAxis(1,controller.TunerDial,HID_USAGES.HID_USAGE_X); joystick.setAxis(1,controller.Scaled.AimingY,HID_USAGES.HID_USAGE_Y); joystick.setAxis(1,controller.Scaled.RightMiddlePedal,HID_USAGES.HID_USAGE_Z);//throttle joystick.setAxis(1,controller.Scaled.RotationLever,HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1,controller.Scaled.SightChangeX,HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1,controller.Scaled.SightChangeY,HID_USAGES.HID_USAGE_RX); joystick.setAxis(1,controller.Scaled.LeftPedal,HID_USAGES.HID_USAGE_RY); for (int i = 1; i <= vJoyButtons; i++) { joystick.setButton((bool)controller.GetButtonState(i - 1), (uint)1, (char)(i - 1)); } if(lastControllerDial != controller.TunerDial) { controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF2, true, 3, SBC.Key.A + controller.TunerDial, true);//last true means if you hold down the button, lastControllerDial = controller.TunerDial; } joystick.sendUpdate(1); }
const int refreshRate = 50;//number of milliseconds between call to mainLoop //this gets called once by main program public void Initialize() { int baseLineIntensity = 1; //just an average value for LED intensity int emergencyLightIntensity = 15; //for stuff like eject,cockpit Hatch,Ignition, and Start controller = new SteelBattalionController(); controller.Init(50);//50 is refresh rate in milliseconds //set all buttons by default to light up only when you press them down for (int i = 4; i < 4 + 30; i++) { if (i != (int)ButtonEnum.Eject)//excluding eject since we are going to flash that one { controller.AddButtonLightMapping((ButtonEnum)(i - 1), (ControllerLEDEnum)(i), true, baseLineIntensity); } } /* * controller.AddButtonKeyLightMapping(ButtonEnum.CockpitHatch, true, 3, SBC.Key.A, true);//last true means if you hold down the button, * controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF1, true, 3, SBC.Key.B, true); * controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, SBC.Key.C, true);*/ joystick = new vJoy(); acquired = joystick.acquireVJD(1); joystick.resetAll();//have to reset before we use it joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_SL1); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_Z);//throttle joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_RY); }
//this gets called once every refreshRate milliseconds by main program public void mainLoop() { updatePOVhat(); joystick.setAxis(1, controller.AimingX, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, controller.AimingY, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, (controller.RightPedal - controller.MiddlePedal), HID_USAGES.HID_USAGE_Z); //throttle joystick.setAxis(1, controller.RotationLever, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, controller.SightChangeX, HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1, controller.SightChangeY, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, controller.LeftPedal, HID_USAGES.HID_USAGE_RY); joystick.setAxis(1, controller.GearLever, HID_USAGES.HID_USAGE_SL1); joystick.setContPov(1, getDegrees(controller.SightChangeX, controller.SightChangeY), 1); // toggle tricks!!! if (controller.GetButtonState(ButtonEnum.ToggleFilterControl)) //FILT Toggle { controller.AddButtonKeyMapping(ButtonEnum.RightJoyFire, Microsoft.DirectX.DirectInput.Key.BackSlash, true); joystick.setButton(controller.GetButtonState(ButtonEnum.RightJoyFire), 1, 15); } else { controller.AddButtonKeyMapping(ButtonEnum.RightJoyFire, Microsoft.DirectX.DirectInput.Key.NoConvert, true); joystick.setButton(controller.GetButtonState(ButtonEnum.RightJoyFire), 1, 0); } if (controller.GetButtonState(ButtonEnum.ToggleOxygenSupply)) // O2 Supply Toggle { controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, Microsoft.DirectX.DirectInput.Key.D6, true); } else { controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, Microsoft.DirectX.DirectInput.Key.D5, true); } currentResetValue = controller.GetButtonState((int)ButtonEnum.ToggleFuelFlowRate); if (currentResetValue != lastResetValue && currentResetValue) { controller.TestLEDs(1); //reset lights } lastResetValue = currentResetValue; evaluateLeftPedal(); joystick.sendUpdate(1); }
//this gets called once every refreshRate milliseconds by main program public void mainLoop() { joystick.setAxis(1, controller.Scaled.GearLever, HID_USAGES.HID_USAGE_SL1); joystick.setAxis(1, controller.Scaled.AimingX, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, controller.Scaled.AimingY, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, controller.Scaled.RightMiddlePedal, HID_USAGES.HID_USAGE_Z);//throttle joystick.setAxis(1, controller.Scaled.RotationLever, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, controller.Scaled.SightChangeX, HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1, controller.Scaled.SightChangeY, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, controller.Scaled.LeftPedal, HID_USAGES.HID_USAGE_RY); for (int i = 1; i <= vJoyButtons; i++) { joystick.setButton((bool)controller.GetButtonState(i - 1), (uint)1, (char)(i - 1)); } joystick.sendUpdate(1); }
//this gets called once every refreshRate milliseconds by main program public void mainLoop() { joystick.setAxis(1, controller.AimingX, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, controller.AimingY, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, (controller.RightPedal - controller.MiddlePedal), HID_USAGES.HID_USAGE_Z); //throttle joystick.setAxis(1, controller.RotationLever, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, controller.SightChangeX, HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1, controller.SightChangeY, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, controller.LeftPedal, HID_USAGES.HID_USAGE_RY); joystick.setAxis(1, controller.GearLever, HID_USAGES.HID_USAGE_SL1); joystick.setContPov(1, getDegrees(controller.SightChangeX, controller.SightChangeY), 1); for (int i = 1; i <= 32; i++) { joystick.setButton((bool)controller.GetButtonState(i - 1), (uint)1, (char)(i - 1)); } joystick.sendUpdate(1); }
// private uint getDegrees(double x,double y) // { // uint temp = (uint)(System.Math.Atan(y/x)* (180/Math.PI)); // if(x < 0) // temp +=180; // if(x > 0 && y < 0) // temp += 360; // // temp += 90;//origin is vertical on POV not horizontal // // if(temp > 360)//by adding 90 we may have gone over 360 // temp -=360; // // temp*=100; // // if (temp > 35999) // temp = 35999; // if (temp < 0) // temp = 0; // return temp; // } //this gets called once every refreshRate milliseconds by main program public void mainLoop() { joystick.setAxis(1, controller.Scaled.GearLever, HID_USAGES.HID_USAGE_SL1); // Schakelbak joystick.setAxis(1, controller.Scaled.AimingX, HID_USAGES.HID_USAGE_X); // Rechter pook X as joystick.setAxis(1, controller.Scaled.AimingY, HID_USAGES.HID_USAGE_Y); // REchter pook Y as joystick.setAxis(1, controller.Scaled.RightMiddlePedal, HID_USAGES.HID_USAGE_Z); // throttle, rechter en middel pedaal joystick.setAxis(1, controller.Scaled.RotationLever + 4000, HID_USAGES.HID_USAGE_RZ); // Linker pook //joystick.setAxis(1,(controller.Scaled.RotationLever+7920),HID_USAGES.HID_USAGE_RZ); // Linker pook joystick.setAxis(1, controller.Scaled.SightChangeX, HID_USAGES.HID_USAGE_SL0); // Duimpookje X as joystick.setAxis(1, controller.Scaled.SightChangeY, HID_USAGES.HID_USAGE_RX); // Duimpookje Y as joystick.setAxis(1, controller.Scaled.LeftPedal, HID_USAGES.HID_USAGE_RY); // Linker pedaal for (int i = 1; i <= vJoyButtons; i++) { joystick.setButton((bool)controller.GetButtonState(i - 1), (uint)1, (char)(i - 1)); } joystick.sendUpdate(1); }
//this gets called once every refreshRate milliseconds by main program public void mainLoop() { float lowValue = 124; float highValue = 255; int gearValue; if (controller.GearLever == -2)//R { gearValue = -255; } else if (controller.GearLever == -1)//N { gearValue = 124; } else { gearValue = (int)(lowValue + (highValue - lowValue) * ((controller.GearLever - 1.0) / 4.0)); } joystick.setAxis(1, controller.GearLever, HID_USAGES.HID_USAGE_SL1); joystick.setAxis(1, controller.AimingX, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, controller.AimingY, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, -1 * (controller.RightPedal - controller.MiddlePedal), HID_USAGES.HID_USAGE_Z);//throttle joystick.setAxis(1, controller.RotationLever, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, controller.SightChangeX, HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1, controller.SightChangeY, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, controller.LeftPedal, HID_USAGES.HID_USAGE_RY); joystick.setContPov(1, getDegrees(controller.SightChangeX, controller.SightChangeY), 1); for (int i = 1; i <= 32; i++) { joystick.setButton((bool)controller.GetButtonState(i - 1), (uint)1, (char)(i - 1)); } joystick.sendUpdate(1); }
//this gets called once every refreshRate milliseconds by main program public void mainLoop() { updatePOVhat(); int loopdelay = 2; // My pedal timer... this allows slow pedal updating with fast controller polling if (ticka > 0) { loopa++; if (loopa > loopdelay) { ticka = 0; loopa = 0; } } if (tickb > 0) { loopb++; if (loopb > loopdelay) { tickb = 0; loopb = 0; } } if (tickc > 0) { loopc++; if (loopc > loopdelay) { tickc = 0; loopc = 0; } } // Joystick Axes joystick.setAxis(1, controller.AimingX, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, controller.AimingY, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, (controller.RightPedal - controller.MiddlePedal), HID_USAGES.HID_USAGE_Z); //throttle joystick.setAxis(1, controller.RotationLever, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, controller.SightChangeX, HID_USAGES.HID_USAGE_SL1); joystick.setAxis(1, controller.SightChangeY, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, controller.LeftPedal, HID_USAGES.HID_USAGE_RY); joystick.setAxis(1, controller.GearLever, HID_USAGES.HID_USAGE_SL0); joystick.setContPov(1, getDegrees(controller.SightChangeX, controller.SightChangeY), 1); // toggle tricks!!! if (controller.GetButtonState(ButtonEnum.ToggleFilterControl)) //FILT Toggle { controller.AddButtonKeyMapping(ButtonEnum.RightJoyFire, Microsoft.DirectX.DirectInput.Key.BackSlash, true); // Alpha Strike joystick.setButton((bool)controller.GetButtonState(ButtonEnum.RightJoyFire), (uint)1, (char)(15)); // unused button (placeholder) } else { controller.AddButtonKeyMapping(ButtonEnum.RightJoyFire, Microsoft.DirectX.DirectInput.Key.NoConvert, true); // unused button (placeholder) joystick.setButton((bool)controller.GetButtonState(ButtonEnum.RightJoyFire), (uint)1, (char)(0)); // Fire Selected Weapon (joystick button 0) } if (controller.GetButtonState(ButtonEnum.ToggleOxygenSupply)) // O2 Supply Toggle { controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, Microsoft.DirectX.DirectInput.Key.D6, true); } else { controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, Microsoft.DirectX.DirectInput.Key.D5, true); } // Pedals Section if ((jj == 1) && ((controller.LeftPedal) < 50)) // Left pedal released { controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.Space); jj = 0; } if (((controller.LeftPedal) > 50) && (ticka == 0)) // Left pedal pressed { if (controller.GetButtonState(ButtonEnum.ToggleFuelFlowRate)) // Is the FUEL Flow toggle UP? { controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.Space); ticka = 0; // bypass timer so we can jump! loopa = 0; jj = 1; // Jets are on... } else // FUEL Flow toggle must be down... { controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.X); ticka = 1; loopa = 0; controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.X); } } if (((controller.MiddlePedal) > 50) && (tickb == 0)) // Middle pedal pressed { controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.S); tickb = 1; loopb = 0; controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.S); } if (((controller.RightPedal) > 50) && (tickc == 0)) // Right pedal pressed { controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.W); tickc = 1; loopc = 0; controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.W); } joystick.sendUpdate(1); }
bool startedTracking = false; //used to make switching mouse on and off not jumpy // This gets called once by main program public void Initialize() { int baseLineIntensity = 3; // Just an average value for LED intensity int emergencyLightIntensity = 15; // For stuff like eject,cockpit Hatch,Ignition, and Start controller = new SteelBattalionController(); controller.Init(30); // 50 is refresh rate in milliseconds //set all buttons by default to light up only when you press them down for (int i = 4; i < 4 + 30; i++) { if (i != (int)ButtonEnum.Eject) // Excluding eject since we are going to flash that one { controller.AddButtonLightMapping((ButtonEnum)(i - 1), (ControllerLEDEnum)(i), true, baseLineIntensity); } } // Button Bindings controller.AddButtonKeyMapping(ButtonEnum.RightJoyFire, Microsoft.DirectX.DirectInput.Key.D1, true); controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, Microsoft.DirectX.DirectInput.Key.D2, true); controller.AddButtonKeyMapping(ButtonEnum.RightJoyLockOn, Microsoft.DirectX.DirectInput.Key.R, true); controller.AddButtonKeyLightMapping(ButtonEnum.Eject, true, 3, Microsoft.DirectX.DirectInput.Key.O, true); controller.AddButtonKeyLightMapping(ButtonEnum.Ignition, true, 3, Microsoft.DirectX.DirectInput.Key.P, true); //controller.AddButtonKeyLightMapping(ButtonEnum.CockpitHatch, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); //controller.AddButtonKeyLightMapping(ButtonEnum.Start, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); controller.AddButtonKeyLightMapping(ButtonEnum.MultiMonOpenClose, true, 3, Microsoft.DirectX.DirectInput.Key.B, true); controller.AddButtonKeyLightMapping(ButtonEnum.MultiMonMapZoomInOut, true, 3, Microsoft.DirectX.DirectInput.Key.I, true); controller.AddButtonKeyLightMapping(ButtonEnum.MultiMonModeSelect, true, 3, Microsoft.DirectX.DirectInput.Key.Q, true); //controller.AddButtonKeyLightMapping(ButtonEnum.MultiMonSubMonitor, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); controller.AddButtonKeyLightMapping(ButtonEnum.MainMonZoomIn, true, 3, Microsoft.DirectX.DirectInput.Key.Z, true); controller.AddButtonKeyLightMapping(ButtonEnum.MainMonZoomOut, true, 3, Microsoft.DirectX.DirectInput.Key.V, true); //controller.AddButtonKeyLightMapping(ButtonEnum.FunctionFSS, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); controller.AddButtonKeyLightMapping(ButtonEnum.FunctionManipulator, true, 3, Microsoft.DirectX.DirectInput.Key.J, true); controller.AddButtonKeyLightMapping(ButtonEnum.FunctionLineColorChange, true, 3, Microsoft.DirectX.DirectInput.Key.H, true); controller.AddButtonKeyLightMapping(ButtonEnum.Washing, true, 3, Microsoft.DirectX.DirectInput.Key.C, true); controller.AddButtonKeyLightMapping(ButtonEnum.Extinguisher, true, 3, Microsoft.DirectX.DirectInput.Key.Delete, true); //controller.AddButtonKeyLightMapping(ButtonEnum.Chaff, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); controller.AddButtonKeyLightMapping(ButtonEnum.FunctionTankDetach, true, 3, Microsoft.DirectX.DirectInput.Key.Slash, true); controller.AddButtonKeyLightMapping(ButtonEnum.FunctionOverride, true, 3, Microsoft.DirectX.DirectInput.Key.O, true); controller.AddButtonKeyLightMapping(ButtonEnum.FunctionNightScope, true, 3, Microsoft.DirectX.DirectInput.Key.N, true); controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF1, true, 3, Microsoft.DirectX.DirectInput.Key.Tab, true); //controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF2, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); //controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF3, true, 4, Microsoft.DirectX.DirectInput.Key.LeftControl, true); controller.AddButtonKeyLightMapping(ButtonEnum.WeaponConMain, true, 3, Microsoft.DirectX.DirectInput.Key.RightControl, true); controller.AddButtonKeyLightMapping(ButtonEnum.WeaponConSub, true, 3, Microsoft.DirectX.DirectInput.Key.BackSpace, true); //controller.AddButtonKeyLightMapping(ButtonEnum.WeaponConMagazine, true, 3, Microsoft.DirectX.DirectInput.Key.X, true); //controller.AddButtonKeyLightMapping(ButtonEnum.ToggleBufferMaterial, true, 3, Microsoft.DirectX.DirectInput.Key.LeftShift, true); // controller.AddButtonKeyMapping(ButtonEnum.LeftJoySightChange, Microsoft.DirectX.DirectInput.Key.V, true); controller.AddButtonKeyMapping(ButtonEnum.LeftJoySightChange, Microsoft.DirectX.DirectInput.Key.Z, true); joystick = new vJoy(); acquired = joystick.acquireVJD(1); joystick.resetAll(); //have to reset before we use it joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_SL1); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_X); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_Z); //throttle joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_RZ); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_SL0); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, 32768 / 2, HID_USAGES.HID_USAGE_RY); }
/* * //new optional function used for debugging purposes, comment out when running in game as it causes issues * public String getDebugString() * { * return debugString; * } */ //this gets called once every refreshRate milliseconds by main program public void mainLoop() { debugString = ""; //updatePOVhat(); int aimingX = scaleValue(controller.AimingX, 1, 512, 1023, 5); int aimingY = reverse(scaleValue(controller.AimingY, 1, 512, 1021, 5)); //calibration values int rAxis = scaleValue(controller.RotationLever, -421, 1, 510, 5); //calibration values int sCX = scaleValue(controller.SightChangeX, -461, 0, 470, 5); int sCY = scaleValue(controller.SightChangeX, -480, -5, 463, 5); int lPedal = scaleValue(controller.LeftPedal, 30, 1022); int mPedal = scaleValue(controller.MiddlePedal, 128, 1021); int rPedal = scaleValue(controller.RightPedal, 0, 1020); desiredX = (int)(expo(aimingX) * numPixelX); //numPixels stores resolution, i.e. how much we move mouse desiredY = (int)(expo(aimingY) * numPixelY); rAxis = (int)(expo(rAxis) * maxAxisValue); debugString += "expoX " + expo(aimingX) + "\n"; debugString += "expoY " + expo(aimingY) + "\n"; debugString += "expoR " + expo(rAxis) + "\n"; if ((bool)controller.GetButtonState(ButtonEnum.ToggleBufferMaterial)) { //debugString += "aimingX:" + aimingX.ToString() + " desiredX : " + desiredX.ToString() + "currentX " + currentX.ToString() + "\n"; //debugString += "aimingY:" + aimingY.ToString() + " desiredY : " + desiredY.ToString() + "currentY " + currentY.ToString() + "\n"; int deltaX = getDeltaS(aimingX, desiredX, currentX, numPixelExtraX); int deltaY = getDeltaS(aimingY, desiredY, currentY, numPixelExtraY); currentX = desiredX; currentY = desiredY; if (startedTracking) //makes it so you can flip the switch and recenter the joystick { InputSimulator.MoveMouseBy(deltaX, deltaY); } else { startedTracking = true; } } else { startedTracking = false; } // Joystick Axes debugString += "rAxis = " + rAxis + "\n"; //joystick.setAxis(1, xaxis, HID_USAGES.HID_USAGE_X); //joystick.setAxis(1, yaxis, HID_USAGES.HID_USAGE_Y); joystick.setAxis(1, rAxis, HID_USAGES.HID_USAGE_RZ); //joystick.setAxis(1, sCX, HID_USAGES.HID_USAGE_SL1); //joystick.setAxis(1, sCY, HID_USAGES.HID_USAGE_RX); joystick.setAxis(1, (rPedal - mPedal) + maxAxisValue / 2, HID_USAGES.HID_USAGE_SL0); //throttle //joystick.setAxis(1, controller.GearLever, HID_USAGES.HID_USAGE_SL0); joystick.setContPov(1, getDegrees(controller.SightChangeX, controller.SightChangeY), 1); // Pedals Section if ((jj == 0) && (lPedal > (maxAxisValue * 0.10))) // Left pedal pressed { controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.Space); jj = 1; } else if ((jj == 1) && (lPedal < (maxAxisValue * 0.10))) // Left pedal released { controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.Space); jj = 0; } joystick.sendUpdate(1); }
public void setThrottlePeddle() { if ((speed > 0) && (Math.Abs(controller.RightPedal) > peddleDeadZone) && (tickb == 0)) { joystick.setAxis(1, -1 * (controller.RightPedal), HID_USAGES.HID_USAGE_Z);//forward throttle peddleLoop = 1; } else if ((speed == -2) && (Math.Abs(controller.RightPedal) > peddleDeadZone) && (tickb == 0)) { joystick.setAxis(1, ((controller.RightPedal) + 120), HID_USAGES.HID_USAGE_Z);//reverse throttle peddleLoop = 1; } if ((speed > 0) && (Math.Abs(controller.RightPedal) < peddleDeadZone) && (peddleLoop == 1) && (tickb == 0)) { switch (speed) { case -2: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D1); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D1); speedPrevious = -2; break; case -1: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D1); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D1); speedPrevious = -1; break; case 1: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D2); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D2); speedPrevious = 1; break; case 2: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D4); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D4); speedPrevious = 2; break; case 3: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D6); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D6); speedPrevious = 3; break; case 4: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D8); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D8); speedPrevious = 4; break; case 5: controller.sendKeyDown(Microsoft.DirectX.DirectInput.Key.D0); controller.sendKeyUp(Microsoft.DirectX.DirectInput.Key.D0); speedPrevious = 5; break; } peddleLoop = 0; } }