private string GetAxisName(JoyAxis axis)
        {
            if (axis == JoyAxis.xAxis)
            {
                return(Resource.JoyXAxis);
            }
            else if (axis == JoyAxis.yAxis)
            {
                return(Resource.JoyYAxis);
            }
            else if (axis == JoyAxis.zAxis)
            {
                return(Resource.JoyZAxis);
            }
            else if (axis == JoyAxis.xRot)
            {
                return(Resource.JoyXRot);
            }
            else if (axis == JoyAxis.yRot)
            {
                return(Resource.JoyYRot);
            }
            else if (axis == JoyAxis.zRot)
            {
                return(Resource.JoyZRot);
            }

            return("");
        }
        private void OnButtonChange(GameButton gameBtn, JoyAxis axis)
        {
            //change the option.
            if (gameBtn == GameButton.moveforward)
            {
                FrameworkCore.options.joyMoveForwardAxis = (int)axis;
            }
            else if (gameBtn == GameButton.movestrafe)
            {
                FrameworkCore.options.joyMoveStrafeAxis = (int)axis;
            }
            else if (gameBtn == GameButton.lookhoriz)
            {
                FrameworkCore.options.joyLookStrafeAxis = (int)axis;
            }
            else if (gameBtn == GameButton.lookvert)
            {
                FrameworkCore.options.joyLookForwardAxis = (int)axis;
            }

            //change the menu item's text.
            if (selectedItem != null)
            {
                selectedItem.optionText = GetAxisName(axis);
            }

            //close the popup.
            waitingForInput = false;

            FrameworkCore.PlayCue(sounds.click.activate);
        }
Esempio n. 3
0
 /// <summary>
 /// Create a new Axis using a joystick axis.
 /// </summary>
 /// <param name="x">The JoyAxis to use for X.</param>
 /// <param name="y">The JoyAxis to use for Y.</param>
 /// <param name="joystick">The joystick id to use.</param>
 public Axis(JoyAxis x, JoyAxis y, params int[] joystick)
     : this()
 {
     foreach (var j in joystick)
     {
         AddAxis(x, y, j);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Add a joystick axis.
 /// </summary>
 /// <param name="x">The x axis of the joystick.</param>
 /// <param name="y">The y axis of the joystick.</param>
 /// <param name="joystick">The joystick id.</param>
 /// <returns>The Axis.</returns>
 public Axis AddAxis(JoyAxis x, JoyAxis y, params int[] joystick)
 {
     foreach (var j in joystick)
     {
         xAxes[j].Add(x);
         yAxes[j].Add(y);
     }
     return(this);
 }
Esempio n. 5
0
 /// <summary>
 /// Get the value of a joystick axis from -100 to 100.
 /// </summary>
 /// <param name="axis">The axis to check.</param>
 /// <param name="joystick">The joystick to check.</param>
 /// <returns>The axis value from -100 to 100.</returns>
 public float GetAxis(JoyAxis axis, int joystick = 0)
 {
     if (Joystick.HasAxis((uint)joystick, (Joystick.Axis)axis))
     {
         if (axis == JoyAxis.PovY)
         { //special case for dpad y
             return(Joystick.GetAxisPosition((uint)joystick, (Joystick.Axis)axis) * -1);
         }
         return(Joystick.GetAxisPosition((uint)joystick, (Joystick.Axis)axis));
     }
     return(0);
 }
Esempio n. 6
0
        public AudioSpectrumDevice(BASS_WASAPI_DEVICEINFO device, int devindex, int channels)
        {
            _lines = channels;
            for (int i = 0; i < channels; i++)
            {
                JoyAxis channel = new JoyAxis("Channel " + (i + 1).ToString(), DataFlowDirection.Input, "")
                {
                    min_Value = 0, max_Value = 1
                };
                Channels.Add(channel);
            }

            this.devindex   = devindex;
            this.device     = device;
            this.DeviceName = device.name;
            this.StatusIcon = Properties.Resources.audio.ToImageSource();
            _fft            = new float[1024];
            _lastlevel      = 0;
            _hanctr         = 0;
            _t          = new DispatcherTimer();
            _t.Tick    += _t_Tick;
            _t.Interval = TimeSpan.FromMilliseconds(25); //40hz refresh rate
            //_t.IsEnabled = true;
            _process      = new WASAPIPROC(Process);
            _spectrumdata = new List <double>();
            _initialized  = false;


            //var str = (_devicelist.Items[_devicelist.SelectedIndex] as string)
            //            var array = str.Split(' ');
            //devindex = Convert.ToInt32(array[0]);
            bool result = BassWasapi.BASS_WASAPI_Init(devindex, 0, 0,
                                                      BASSWASAPIInit.BASS_WASAPI_BUFFER,
                                                      1f, 0.05f,
                                                      _process, IntPtr.Zero);

            if (!result)
            {
                var error = Bass.BASS_ErrorGetCode();
                MessageBox.Show(error.ToString());
            }
            else
            {
                _initialized = true;
            }
            BassWasapi.BASS_WASAPI_Start();
            _t.IsEnabled = true;
            _t.Start();
        }
    public JoystickButtonMenu(int numOfButtons,Rect[] rectangles,string[] labels, string inputActionButton,JoyAxis axis)
    {
        if(axis == JoyAxis.Horizontal){
            joystickInputName = "Horizontal";
        }else if(axis == JoyAxis.Vertical){
            joystickInputName = "Vertical";
        }

        numberOfButtons = numOfButtons;
        actionButton = inputActionButton;

        buttons = new JoystickButton[numOfButtons];
        for (int i = 0; i<numOfButtons; i++){
            buttons[i] = new JoystickButton(rectangles[i],labels[i]);
        }

        buttons[0].Focus();
        currentFocus = 0;
    }
        public Midevice()
        {
            LSx = new JoyAxis("Left Stick X", DataFlowDirection.Input);      //, Properties.Resources._360_Left_Stick.ToImageSource());
            LSy = new JoyAxis("Left Stick Y", DataFlowDirection.Input);      //, Properties.Resources._360_Left_Stick.ToImageSource());
            RSx = new JoyAxis("Right Stick X", DataFlowDirection.Input);     //, Properties.Resources._360_Right_Stick.ToImageSource());
            RSy = new JoyAxis("Right Stick Y", DataFlowDirection.Input);     //, Properties.Resources._360_Right_Stick.ToImageSource());

            LS = new Button("Left Stick", DataFlowDirection.Input);          //, Properties.Resources._360_Left_Stick.ToImageSource());
            RS = new Button("Right Stick", DataFlowDirection.Input);         //, Properties.Resources._360_Right_Stick.ToImageSource());

            L2        = new JoyAxis("L2 (Analog)", DataFlowDirection.Input); //, Properties.Resources._360_LT.ToImageSource()) { min_Value = 0 };
            R2        = new JoyAxis("R2 (Analog)", DataFlowDirection.Input); //, Properties.Resources._360_RT.ToImageSource()) { min_Value = 0 };
            L1        = new Button("L1", DataFlowDirection.Input);           //, Properties.Resources._360_LB.ToImageSource());
            R1        = new Button("R1", DataFlowDirection.Input);           //, Properties.Resources._360_RB.ToImageSource());
            L2Digital = new Button("L2 (Digital)", DataFlowDirection.Input); //, Properties.Resources._360_LB.ToImageSource());
            R2Digital = new Button("R2 (Digital)", DataFlowDirection.Input); //, Properties.Resources._360_RB.ToImageSource());

            DUp    = new Button("DPad Up", DataFlowDirection.Input);         //, Properties.Resources._360_Dpad_Up.ToImageSource());
            DDown  = new Button("DPad Down", DataFlowDirection.Input);       //, Properties.Resources._360_Dpad_Down.ToImageSource());
            DLeft  = new Button("DPad Left", DataFlowDirection.Input);       //, Properties.Resources._360_Dpad_Left.ToImageSource());
            DRight = new Button("DPad Right", DataFlowDirection.Input);      //, Properties.Resources._360_Dpad_Right.ToImageSource());

            A = new Button("A", DataFlowDirection.Input);                    //, Properties.Resources._360_A.ToImageSource());
            B = new Button("B", DataFlowDirection.Input);                    //, Properties.Resources._360_B.ToImageSource());
            X = new Button("X", DataFlowDirection.Input);                    //, Properties.Resources._360_X.ToImageSource());
            Y = new Button("Y", DataFlowDirection.Input);                    //, Properties.Resources._360_Y.ToImageSource());

            Start = new Button("Menu", DataFlowDirection.Input);             //, Properties.Resources._360_Start.ToImageSource());
            Back  = new Button("Back", DataFlowDirection.Input);             //, Properties.Resources._360_Back.ToImageSource());
            Mi    = new Button("MI", DataFlowDirection.Input);               //, Properties.Resources._360_Guide.ToImageSource());

            BatteryLevel = new JoyAxis("Battery level", DataFlowDirection.Input);
            GX           = new JoyAxis("Gravity X", DataFlowDirection.Input);
            GY           = new JoyAxis("Gravity Y", DataFlowDirection.Input);
            GZ           = new JoyAxis("Gravity Z", DataFlowDirection.Input);

            BigRumble            = new RumbleMotor("Big Rumble", DataFlowDirection.Output);
            SmallRumble          = new RumbleMotor("Small Rumble", DataFlowDirection.Output);
            ControlAccelerometer = new Toggle("Control Accelerometer", DataFlowDirection.Output);
        }
Esempio n. 9
0
        public x360device()
        {
            LSx = new JoyAxis("Left Stick X", DataFlowDirection.Input, "", Properties.Resources._360_Left_Stick.ToImageSource());
            LSy = new JoyAxis("Left Stick Y", DataFlowDirection.Input, "", Properties.Resources._360_Left_Stick.ToImageSource());
            RSx = new JoyAxis("Right Stick X", DataFlowDirection.Input, "", Properties.Resources._360_Right_Stick.ToImageSource());
            RSy = new JoyAxis("Right Stick Y", DataFlowDirection.Input, "", Properties.Resources._360_Right_Stick.ToImageSource());

            LS = new Button("Left Stick", DataFlowDirection.Input, "", Properties.Resources._360_Left_Stick.ToImageSource());
            RS = new Button("Right Stick", DataFlowDirection.Input, "", Properties.Resources._360_Right_Stick.ToImageSource());

            LT = new JoyAxis("Left Trigger", DataFlowDirection.Input, "", Properties.Resources._360_LT.ToImageSource())
            {
                min_Value = 0
            };
            RT = new JoyAxis("Right Trigger", DataFlowDirection.Input, "", Properties.Resources._360_RT.ToImageSource())
            {
                min_Value = 0
            };
            LB = new Button("Left Bumper", DataFlowDirection.Input, "", Properties.Resources._360_LB.ToImageSource());
            RB = new Button("Right Bumper", DataFlowDirection.Input, "", Properties.Resources._360_RB.ToImageSource());

            DUp    = new Button("DPad Up", DataFlowDirection.Input, "", Properties.Resources._360_Dpad_Up.ToImageSource());
            DDown  = new Button("DPad Down", DataFlowDirection.Input, "", Properties.Resources._360_Dpad_Down.ToImageSource());
            DLeft  = new Button("DPad Left", DataFlowDirection.Input, "", Properties.Resources._360_Dpad_Left.ToImageSource());
            DRight = new Button("DPad Right", DataFlowDirection.Input, "", Properties.Resources._360_Dpad_Right.ToImageSource());

            A = new Button("A", DataFlowDirection.Input, "", Properties.Resources._360_A.ToImageSource());
            B = new Button("B", DataFlowDirection.Input, "", Properties.Resources._360_B.ToImageSource());
            X = new Button("X", DataFlowDirection.Input, "", Properties.Resources._360_X.ToImageSource());
            Y = new Button("Y", DataFlowDirection.Input, "", Properties.Resources._360_Y.ToImageSource());

            Start = new Button("Start", DataFlowDirection.Input, "", Properties.Resources._360_Start.ToImageSource());
            Back  = new Button("Back", DataFlowDirection.Input, "", Properties.Resources._360_Back.ToImageSource());
            Guide = new Button("Guide", DataFlowDirection.Input, "", Properties.Resources._360_Guide.ToImageSource());

            BigRumble   = new RumbleMotor("Big Rumble", DataFlowDirection.Output, "");
            SmallRumble = new RumbleMotor("Small Rumble", DataFlowDirection.Output, "");
        }
Esempio n. 10
0
        public DIdevice()
        {
            ax = new JoyAxis("Acceleration X", DataFlowDirection.Input);
            ay = new JoyAxis("Acceleration Y", DataFlowDirection.Input);
            az = new JoyAxis("Acceleration Z", DataFlowDirection.Input);

            aax = new JoyAxis("Angular Acceleration X", DataFlowDirection.Input);
            aay = new JoyAxis("Angular Acceleration Y", DataFlowDirection.Input);
            aaz = new JoyAxis("Angular Acceleration Z", DataFlowDirection.Input);

            avx = new JoyAxis("Angular Velocity X", DataFlowDirection.Input);
            avy = new JoyAxis("Angular Velocity Y", DataFlowDirection.Input);
            avz = new JoyAxis("Angular Velocity Z", DataFlowDirection.Input);

            fx = new JoyAxis("Force X", DataFlowDirection.Input);
            fy = new JoyAxis("Force Y", DataFlowDirection.Input);
            fz = new JoyAxis("Force Z", DataFlowDirection.Input);

            rx = new JoyAxis("Rotation X", DataFlowDirection.Input);
            ry = new JoyAxis("Rotation Y", DataFlowDirection.Input);
            rz = new JoyAxis("Rotation Z", DataFlowDirection.Input);

            vx = new JoyAxis("Velocity X", DataFlowDirection.Input);
            vy = new JoyAxis("Velocity Y", DataFlowDirection.Input);
            vz = new JoyAxis("Velocity Z", DataFlowDirection.Input);

            tx = new JoyAxis("Torque X", DataFlowDirection.Input);
            ty = new JoyAxis("Torque Y", DataFlowDirection.Input);
            tz = new JoyAxis("Torque Z", DataFlowDirection.Input);

            x = new JoyAxis("X", DataFlowDirection.Input);
            y = new JoyAxis("Y", DataFlowDirection.Input);
            z = new JoyAxis("Z", DataFlowDirection.Input);

            Slider1  = new JoyAxis("Slider 1", DataFlowDirection.Input);
            Slider2  = new JoyAxis("Slider 2", DataFlowDirection.Input);
            Slider3  = new JoyAxis("Slider 3", DataFlowDirection.Input);
            Slider4  = new JoyAxis("Slider 4", DataFlowDirection.Input);
            Slider5  = new JoyAxis("Slider 5", DataFlowDirection.Input);
            Slider6  = new JoyAxis("Slider 6", DataFlowDirection.Input);
            Slider7  = new JoyAxis("Slider 7", DataFlowDirection.Input);
            Slider8  = new JoyAxis("Slider 8", DataFlowDirection.Input);
            Slider9  = new JoyAxis("Slider 9", DataFlowDirection.Input);
            Slider10 = new JoyAxis("Slider 10", DataFlowDirection.Input);

            b1  = new Button("Button 1", DataFlowDirection.Input);
            b2  = new Button("Button 2", DataFlowDirection.Input);
            b3  = new Button("Button 3", DataFlowDirection.Input);
            b4  = new Button("Button 4", DataFlowDirection.Input);
            b5  = new Button("Button 5", DataFlowDirection.Input);
            b6  = new Button("Button 6", DataFlowDirection.Input);
            b7  = new Button("Button 7", DataFlowDirection.Input);
            b8  = new Button("Button 8", DataFlowDirection.Input);
            b9  = new Button("Button 9", DataFlowDirection.Input);
            b10 = new Button("Button 10", DataFlowDirection.Input);
            b11 = new Button("Button 11", DataFlowDirection.Input);
            b12 = new Button("Button 12", DataFlowDirection.Input);
            b13 = new Button("Button 13", DataFlowDirection.Input);
            b14 = new Button("Button 14", DataFlowDirection.Input);
            b15 = new Button("Button 15", DataFlowDirection.Input);
            b16 = new Button("Button 16", DataFlowDirection.Input);
            b17 = new Button("Button 17", DataFlowDirection.Input);
            b18 = new Button("Button 18", DataFlowDirection.Input);
            b19 = new Button("Button 19", DataFlowDirection.Input);
            b20 = new Button("Button 20", DataFlowDirection.Input);

            pov1up    = new Button("POV 1 Up", DataFlowDirection.Input);
            pov1down  = new Button("POV 1 Down", DataFlowDirection.Input);
            pov1left  = new Button("POV 1 Left", DataFlowDirection.Input);
            pov1right = new Button("POV 1 Right", DataFlowDirection.Input);

            pov2up    = new Button("POV 2 Up", DataFlowDirection.Input);
            pov2down  = new Button("POV 2 Down", DataFlowDirection.Input);
            pov2left  = new Button("POV 2 Left", DataFlowDirection.Input);
            pov2right = new Button("POV 2 Right", DataFlowDirection.Input);
        }
Esempio n. 11
0
 static extern float sfInput_GetJoystickAxis(IntPtr This, uint JoyId, JoyAxis Axis);
Esempio n. 12
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Get a joystick axis position
 /// </summary>
 /// <param name="joystickId">Identifier of the joystick to check (0 or 1)</param>
 /// <param name="axis">Axis to get</param>
 /// <returns>Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])</returns>
 ////////////////////////////////////////////////////////////
 public float GetJoystickAxis(uint joystickId, JoyAxis axis)
 {
     return sfInput_GetJoystickAxis(This, joystickId, axis);
 }
Esempio n. 13
0
 /// <summary>
 /// Set the threshold for an axis to act as an AxisButton.  Defaults to 50 or one half of the joystick's total range.
 /// </summary>
 /// <param name="axis">The JoyAxis to set.</param>
 /// <param name="threshold">The threshold that the axis must pass to act as a button press.</param>
 public void SetAxisThreshold(JoyAxis axis, float threshold)
 {
     axisThreshold[axis] = threshold;
 }
Esempio n. 14
0
 /// <summary>
 /// Gets the axis threshold for an axis to act as an AxisButton.
 /// </summary>
 /// <param name="axis">The JoyAxis.</param>
 public float GetAxisThreshold(JoyAxis axis)
 {
     return(axisThreshold[axis]);
 }
Esempio n. 15
0
 /// <summary>
 /// Construct the joystick move arguments from a joystick move event
 /// </summary>
 /// <param name="e">Joystick move event</param>
 ////////////////////////////////////////////////////////////
 public JoyMoveEventArgs(JoyMoveEvent e)
 {
     JoystickId = e.JoystickId;
     Axis = e.Axis;
     Position = e.Position;
 }
Esempio n. 16
0
 /// <summary>
 /// Create a new Axis using a joystick axis.
 /// </summary>
 /// <param name="x">The JoyAxis to use for X.</param>
 /// <param name="y">The JoyAxis to use for Y.</param>
 /// <param name="joystick">The joystick id to use.</param>
 public Axis(JoyAxis x, JoyAxis y, params int[] joystick)
     : this() {
         foreach (var j in joystick) {
             AddAxis(x, y, j);
         }
 }
Esempio n. 17
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Get a joystick axis position
 /// </summary>
 /// <param name="joystickId">Identifier of the joystick to check (0 or 1)</param>
 /// <param name="axis">Axis to get</param>
 /// <returns>Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])</returns>
 ////////////////////////////////////////////////////////////
 public float GetJoystickAxis(uint joystickId, JoyAxis axis)
 {
     return(sfInput_GetJoystickAxis(This, joystickId, axis));
 }
Esempio n. 18
0
 /// <summary>
 /// Create a new Axis using a joystick axis.
 /// </summary>
 /// <param name="x">The JoyAxis to use for X.</param>
 /// <param name="y">The JoyAxis to use for Y.</param>
 /// <param name="joystick">The joystick id to use.</param>
 public Axis(JoyAxis x, JoyAxis y, int joystick = 0)
     : this()
 {
     AddAxis(x, y, joystick);
 }
Esempio n. 19
0
 /// <summary>
 /// Gets the axis threshold for an axis to act as an AxisButton.
 /// </summary>
 /// <param name="axis">The JoyAxis.</param>
 public float GetAxisThreshold(JoyAxis axis)
 {
     return axisThreshold[axis];
 }
Esempio n. 20
0
 /// <summary>
 /// Add a joystick axis.
 /// </summary>
 /// <param name="x">The x axis of the joystick.</param>
 /// <param name="y">The y axis of the joystick.</param>
 /// <param name="joystick">The joystick id.</param>
 /// <returns>The Axis.</returns>
 public Axis AddAxis(JoyAxis x, JoyAxis y, params int[] joystick) {
     foreach (var j in joystick) {
         xAxes[j].Add(x);
         yAxes[j].Add(y);
     }
     return this;
 }
Esempio n. 21
0
    public JoystickButtonMenu(int numOfButtons, Rect[] rectangles, string[] labels, string inputActionButton, JoyAxis axis)
    {
        if (axis == JoyAxis.Horizontal)
        {
            joystickInputName = "Horizontal";
        }
        else if (axis == JoyAxis.Vertical)
        {
            joystickInputName = "Vertical";
        }

        numberOfButtons = numOfButtons;
        actionButton    = inputActionButton;

        buttons = new JoystickButton[numOfButtons];
        for (int i = 0; i < numOfButtons; i++)
        {
            buttons[i] = new JoystickButton(rectangles[i], labels[i]);
        }

        buttons[0].Focus();
        currentFocus = 0;
    }
Esempio n. 22
0
 /// <summary>
 /// Get the value of a joystick axis from -100 to 100.
 /// </summary>
 /// <param name="axis">The axis to check.</param>
 /// <param name="joystick">The joystick to check.</param>
 /// <returns>The axis value from -100 to 100.</returns>
 public float GetAxis(JoyAxis axis, int joystick = 0)
 {
     if (Joystick.HasAxis((uint)joystick, (Joystick.Axis)axis)) {
         if (axis == JoyAxis.PovY) { //special case for dpad y
             return Joystick.GetAxisPosition((uint)joystick, (Joystick.Axis)axis) * -1;
         }
         return Joystick.GetAxisPosition((uint)joystick, (Joystick.Axis)axis);
     }
     return 0;
 }
Esempio n. 23
0
 static extern float sfInput_GetJoystickAxis(IntPtr This, uint JoyId, JoyAxis Axis);
Esempio n. 24
0
 /// <summary>
 /// Set the threshold for an axis to act as an AxisButton.  Defaults to 50 or one half of the joystick's total range.
 /// </summary>
 /// <param name="axis">The JoyAxis to set.</param>
 /// <param name="threshold">The threshold that the axis must pass to act as a button press.</param>
 public void SetAxisThreshold(JoyAxis axis, float threshold)
 {
     axisThreshold[axis] = threshold;
 }
Esempio n. 25
0
 /// <summary>
 /// Add a joystick axis.
 /// </summary>
 /// <param name="x">The x axis of the joystick.</param>
 /// <param name="y">The y axis of the joystick.</param>
 /// <param name="joystick">The joystick id.</param>
 /// <returns>The Axis.</returns>
 public Axis AddAxis(JoyAxis x, JoyAxis y, int joystick = 0)
 {
     xAxes[joystick].Add(x);
     yAxes[joystick].Add(y);
     return this;
 }