コード例 #1
0
        /// <summary>
        /// <p>Retrieves the current state of the specified controller.</p>
        /// </summary>
        /// <param name = "dwUserIndex"><dd> <p>Index of the user's controller. Can be a value from 0 to 3. For information about how this value is determined and how the value maps to indicators on the controller, see Multiple Controllers.</p> </dd></param>
        /// <param name = "stateRef"><dd> <p>Pointer to an <strong><see cref = "SharpDX.XInput.State"/></strong> structure that receives the current state of the controller.</p> </dd></param>
        /// <returns><p>If the function succeeds, the return value is <strong>ERROR_SUCCESS</strong>.</p><p>If the controller is not connected, the return value is <strong>ERROR_DEVICE_NOT_CONNECTED</strong>.</p><p>If the function fails, the return value is an error code defined in Winerror.h. The function does not use <strong>SetLastError</strong> to set the calling thread's last-error code.</p></returns>
        /// <remarks>
        /// <p>When <strong>XInputGetState</strong> is used to retrieve controller data, the left and right triggers are each reported separately. For legacy reasons, when DirectInput retrieves controller data, the two triggers share the same axis. The legacy behavior is noticeable in the current Game Device Control Panel, which uses DirectInput for controller state.</p>
        /// </remarks>
        /// <doc-id>microsoft.directx_sdk.reference.xinputgetstate</doc-id>
        /// <unmanaged>DWORD XInputGetState([In] DWORD dwUserIndex,[Out] XINPUT_STATE* pState)</unmanaged>
        /// <unmanaged-short>XInputGetState</unmanaged-short>
        public static unsafe System.Int32 XInputGetState(System.Int32 dwUserIndex, out SharpDX.XInput.State stateRef)
        {
            stateRef = default(SharpDX.XInput.State);
            System.Int32 __result__;

            fixed(void *stateRef_ = &stateRef)
            __result__ = XInputGetState_(dwUserIndex, stateRef_);

            return(__result__);
        }
コード例 #2
0
        /// <summary>
        /// <p>Retrieves the current state of the specified controller.</p>
        /// </summary>
        /// <param name="dwUserIndex"><dd> <p>Index of the user's controller. Can be a value from 0 to 3. For information about how this value is determined and how the value maps to indicators on the controller, see Multiple Controllers.</p> </dd></param>
        /// <param name="stateRef"><dd> <p>Pointer to an <strong><see cref="SharpDX.XInput.State"/></strong> structure that receives the current state of the controller.</p> </dd></param>
        /// <returns><p>If the function succeeds, the return value is <strong><see cref="SharpDX.Win32.ErrorCode.Success"/></strong>. </p><p>If the controller is not connected, the return value is <strong><see cref="SharpDX.Win32.ErrorCode.DeviceNotConnected"/></strong>. </p><p>If the function fails, the return value is an error code defined in Winerror.h. The function does not use <strong>SetLastError</strong> to set the calling thread's last-error code.</p></returns>
        /// <remarks>
        /// <p>When <strong><see cref="SharpDX.XInput.XInput.XInputGetState"/></strong> is used to retrieve controller data, the left and right triggers are each reported separately. For legacy reasons, when DirectInput retrieves controller data, the two triggers share the same axis. The legacy behavior is noticeable in the current Game Device Control Panel, which uses DirectInput for controller state.</p>
        /// </remarks>
        /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='XInputGetState']/*"/>
        /// <msdn-id>microsoft.directx_sdk.reference.xinputgetstate</msdn-id>
        /// <unmanaged>unsigned int XInputGetState([In] unsigned int dwUserIndex,[Out] XINPUT_STATE* pState)</unmanaged>
        /// <unmanaged-short>XInputGetState</unmanaged-short>
        public static int XInputGetState(int dwUserIndex, out SharpDX.XInput.State stateRef)
        {
            unsafe {
                stateRef = new SharpDX.XInput.State();
                int __result__;

                fixed(void *stateRef_ = &stateRef)
                __result__ =
                    XInputGetState_(dwUserIndex, stateRef_);

                return(__result__);
            }
        }
コード例 #3
0
        public void AddController(SharpDX.XInput.State state)
        {
            // -50 to 50
            _State.X  += state.Gamepad.LeftThumbX / 327.68 / 2;
            _State.Y  += state.Gamepad.LeftThumbY / 327.68 / 2;
            _State.RX += state.Gamepad.RightThumbX / 327.68 / 2;
            _State.RY += state.Gamepad.RightThumbY / 327.68 / 2;

            // 0 to 100
            _State.Z  += state.Gamepad.RightTrigger / 2.55;
            _State.RZ += state.Gamepad.LeftTrigger / 2.55;

            _State.Buttons = (PocketStrafeButtons)((uint)_State.Buttons | (uint)state.Gamepad.Buttons);
        }
コード例 #4
0
        private void RefreshControllerState()
        {
            this.lastMsRefreshed = Environment.TickCount * this.ticksPerMs;

            try
            {
                var state = this.dxC.GetState();
                this.lastGamepadState = state;
                connected             = true;
            } catch (SharpDX.SharpDXException ex)
            {
                if (ex.Message.ToUpper().Contains("THE DEVICE IS NOT CONNECTED"))
                {
                    connected = false;
                }
            }
        }
コード例 #5
0
ファイル: Controller.cs プロジェクト: pablo0722/x360ce
 public bool GetState(out SharpDX.XInput.State state)
 {
     return(SharpDX.XInput.XInput.XInputGetState((int)this.userIndex, out state) == 0);
 }
コード例 #6
0
        private void joy_update(object sender, EventArgs e)
        {
            if (ctrl != null && ctrl.IsConnected == true)
            {
                state   = ctrl.GetState();
                gamepad = ctrl.GetState().Gamepad;
                var joy     = new xbox_joy();
                var buttons = "";
                #region get joy data
                gamepad = ctrl.GetState().Gamepad;
                buttons = gamepad.Buttons.ToString();
                joy.A   = buttons.Contains("A");
                joy.B   = buttons.Contains("B");
                joy.X   = buttons.Contains("X");
                joy.Y   = buttons.Contains("Y");

                joy.start          = buttons.Contains("Start");
                joy.back           = buttons.Contains("Back");
                joy.left_shoulder  = buttons.Contains("LeftShoulder");
                joy.right_shoulder = buttons.Contains("RightShoulder");

                joy.rightthumb = buttons.Contains("RightThumb");
                joy.leftthumb  = buttons.Contains("LeftThumb");

                joy.dpadUp    = buttons.Contains("DPadUp");
                joy.dpadLeft  = buttons.Contains("DPadLeft");
                joy.dpadDown  = buttons.Contains("DPadDown");
                joy.dpadRight = buttons.Contains("DPadRight");

                joy.left_axis_x  = gamepad.LeftThumbX + 32768;
                joy.left_axis_y  = gamepad.LeftThumbY + 32768;
                joy.right_axis_x = gamepad.RightThumbX + 32768;
                joy.right_axis_y = gamepad.RightThumbY + 32768;

                joy.left_trigger  = gamepad.LeftTrigger;
                joy.right_trigger = gamepad.RightTrigger;
                #endregion

                this.label_left_trigger.Text  = joy.left_trigger.ToString();
                this.label_right_trigger.Text = joy.right_trigger.ToString();

                this.label_left_axis_x.Text  = joy.left_axis_x.ToString();
                this.label_left_axis_y.Text  = joy.left_axis_y.ToString();
                this.label_right_axis_x.Text = joy.right_axis_x.ToString();
                this.label_right_axis_y.Text = joy.right_axis_y.ToString();

                if (joy.start)
                {
                    this.checkBox_use_joy.Checked = true;
                }
                if (joy.back)
                {
                    this.checkBox_use_joy.Checked = false;
                }

                this.checkBox_use_joy.Visible = true;
                // MOVE !!!!
                if (checkBox_use_joy.Checked == true)
                {
                    try
                    {
                        ProfilePositionMode ppm = _epos_A.Operation.ProfilePositionMode;
                        ppm.ActivateProfilePositionMode();
                        textBoxAOM_A.Text = _epos_A.Operation.OperationMode.GetOperationModeAsString();
                        ppm.MoveToPosition(joy.left_axis_x, true, true);
                    }
                    catch { }

                    try
                    {
                        ProfilePositionMode ppm = _epos_B.Operation.ProfilePositionMode;
                        ppm.ActivateProfilePositionMode();
                        textBoxAOM_B.Text = _epos_B.Operation.OperationMode.GetOperationModeAsString();
                        ppm.MoveToPosition(joy.right_axis_x, true, true);
                    }
                    catch { }
                }
            }
            else
            {
                this.checkBox_use_joy.Visible = false;
            }
        }
コード例 #7
0
 public void AddController(SharpDX.XInput.State state)
 {
     // do nothing
 }
コード例 #8
0
 public Controller()
 {
     index = SharpDX.XInput.UserIndex.One;
     gamepad = new SharpDX.XInput.Controller(index);
     state = gamepad.GetState();
 }
コード例 #9
0
        private void RefreshControllerState()
        {
            this.lastMsRefreshed = Environment.TickCount * this.ticksPerMs;

            try
            {
                var state = this.dxC.GetState();
                this.lastGamepadState = state;
                connected = true;
            } catch (SharpDX.SharpDXException ex)
            {
                if (ex.Message.ToUpper().Contains("THE DEVICE IS NOT CONNECTED"))
                {
                    connected = false;
                }
            }
        }