Esempio n. 1
0
 /// <summary>
 /// Kalkylerar status värde, beroende på hur inställningarna är satta.
 /// </summary>
 /// <param name="localAxis"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 private int calculateStateValue(axis localAxis, int value)
 {
     if (localAxis.reverse)
     {
         return((localAxis.max - value) + localAxis.min);
     }
     else
     {
         return(value);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Set min,max,saturation and deadzone to axis
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="propertieAxis"></param>
 private void setAxiskValue(ObjectProperties axis, axis propertieAxis)
 {
     try
     {
         /* Loopa igenom alla axlar */
         axis.SetRange(propertieAxis.min, propertieAxis.max);
         axis.DeadZone   = propertieAxis.deadZone;
         axis.Saturation = propertieAxis.saturation;
     }
     catch
     {
         log("setAxiskValue", "Axis " + axis.ToString() + " does not exist");
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Constructor, do the following to loop through and select your joystick
        /// SlimDX.DirectInput.DirectInput dinput = new SlimDX.DirectInput.DirectInput();
        /// foreach (SlimDX.DirectInput.DeviceInstance device in dinput.GetDevices(SlimDX.DirectInput.DeviceClass.GameController, SlimDX.DirectInput.DeviceEnumerationFlags.AttachedOnly))
        /// {
        ///     Console.WriteLine("Controller:" + device.InstanceName);
        ///
        ///     DirectX.Joystick.onLog = logMessages;
        ///     DirectX.Joystick.debug = false;
        ///     joystick = new DirectX.Joystick(dinput, device);
        ///
        ///     joystick.axisX.min = 1;
        ///     joystick.axisX.max = 99;
        ///     joystick.axisX.deadZone = 0;
        ///     joystick.axisX.saturation = 10000;
        ///
        ///     joystick.setJoystickValues();
        ///
        ///     controlHelper = new controllHelper(joystick);
        ///     joystick.start();
        ///
        ///     break;
        /// }
        /// </summary>
        /// <param name="dInput"></param>
        /// <param name="joystickInstance"></param>
        public Joystick(DirectInput dInput, DeviceInstance joystickInstance)
        {
            this.joystickInstance = joystickInstance;
            JoystickName          = joystickInstance.ProductName;

            joystickDevice = new SlimDX.DirectInput.Joystick(dInput, joystickInstance.InstanceGuid);  // slimDX replacement
            joystickDevice.SetNotification(onJoystickEvent);
            joystickDevice.Acquire();

            axisY     = new axis();
            axisX     = new axis();
            axisZ     = new axis();
            axisRy    = new axis();
            axisRx    = new axis();
            axisRz    = new axis();
            axisExtra = new axis();

            /* initiate default joystick values.*/
            setJoystickValues();
        }