Exemplo n.º 1
0
        //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);
        }
Exemplo n.º 2
0
        //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);
        }
Exemplo n.º 3
0
      //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);
      }
Exemplo n.º 6
0
        //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);
        }
Exemplo n.º 8
0
//	private int scaledValue(int min, int middle, int max, int deadZone)



        //this gets called once every refreshRate milliseconds by main program
        public void mainLoop()
        {
            float lowValue  = 124;
            float highValue = 255;
            int   gearValue;

            int numPixels = 600;

            desiredX = (int)((controller.AimingX / 1024.0) * numPixels);
            desiredY = (int)((controller.AimingY / 1024.0) * numPixels);


            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));
            }

            debugString = "not in";
            if ((bool)controller.GetButtonState(ButtonEnum.RightJoyMainWeapon))
            {
                debugString = "RightJoyMainWeapon";
                desiredX    = currentX;
                desiredY    = currentY;
            }
            if ((bool)controller.GetButtonState(ButtonEnum.RightJoyLockOn))
            {
                int deltaX = desiredX - currentX;
                int deltaY = desiredY - currentY;
                currentX = desiredX;
                currentY = desiredY;

                //debugString = "in";
                InputSimulator.MoveMouseBy(deltaX, deltaY);
            }

            /*
             * 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,32768/2,HID_USAGES.HID_USAGE_X);
             * joystick.setAxis(1,32768/2,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);
        }