예제 #1
0
        private void TestUpdate()
        {
            XInputState state = new XInputState();

            try { DuraznoGetStateEx(curSet.port, ref state); }
            catch { }

            double LX = (state.Gamepad.sThumbLX + 32767) / 65535.0 * 110.0;
            double LY = (32768 - state.Gamepad.sThumbLY) / 65535.0 * 110.0;

            double RX = (state.Gamepad.sThumbRX + 32767) / 65535.0 * 110.0;
            double RY = (32768 - state.Gamepad.sThumbRY) / 65535.0 * 110.0;

            double LT = state.Gamepad.bLeftTrigger / 255.0 * 120.0;
            double RT = state.Gamepad.bRightTrigger / 255.0 * 120.0;

            StickL.Margin = new Thickness(LX, LY, 0, 0);
            StickR.Margin = new Thickness(RX, RY, 0, 0);

            TriggerL.Height = LT;
            TriggerR.Height = RT;

            SolidColorBrush cOff = new SolidColorBrush(Color.FromArgb(0x19, 0xFF, 0xFF, 0xFF));
            SolidColorBrush cOn  = new SolidColorBrush(Color.FromArgb(0xCC, 0xFF, 0xFF, 0xFF));

            UInt16 buttons = state.Gamepad.wButtons;

            Button0.Fill  = (buttons & (UInt16)XInputButtons.DPAD_UP) > 0 ? cOn : cOff;
            Button1.Fill  = (buttons & (UInt16)XInputButtons.DPAD_DOWN) > 0 ? cOn : cOff;
            Button2.Fill  = (buttons & (UInt16)XInputButtons.DPAD_LEFT) > 0 ? cOn : cOff;
            Button3.Fill  = (buttons & (UInt16)XInputButtons.DPAD_RIGHT) > 0 ? cOn : cOff;
            Button4.Fill  = (buttons & (UInt16)XInputButtons.START) > 0 ? cOn : cOff;
            Button5.Fill  = (buttons & (UInt16)XInputButtons.BACK) > 0 ? cOn : cOff;
            Button6.Fill  = (buttons & (UInt16)XInputButtons.LEFT_THUMB) > 0 ? cOn : cOff;
            Button7.Fill  = (buttons & (UInt16)XInputButtons.RIGHT_THUMB) > 0 ? cOn : cOff;
            Button8.Fill  = (buttons & (UInt16)XInputButtons.LEFT_SHOULDER) > 0 ? cOn : cOff;
            Button9.Fill  = (buttons & (UInt16)XInputButtons.RIGHT_SHOULDER) > 0 ? cOn : cOff;
            Button10.Fill = (buttons & (UInt16)XInputButtons.GUIDE) > 0 ? cOn : cOff;
            Button11.Fill = (buttons & (UInt16)XInputButtons.A) > 0 ? cOn : cOff;
            Button12.Fill = (buttons & (UInt16)XInputButtons.B) > 0 ? cOn : cOff;
            Button13.Fill = (buttons & (UInt16)XInputButtons.X) > 0 ? cOn : cOff;
            Button14.Fill = (buttons & (UInt16)XInputButtons.Y) > 0 ? cOn : cOff;

            TextDebug.Text = state.Gamepad.sThumbLX.ToString() + "\n" + state.Gamepad.sThumbLY.ToString() + "\n" +
                             state.Gamepad.sThumbRX.ToString() + "\n" + state.Gamepad.sThumbRY.ToString() + "\n" +
                             state.Gamepad.bLeftTrigger.ToString() + "\n" + state.Gamepad.bRightTrigger.ToString() + "\n" +
                             state.Gamepad.wButtons.ToString("X4");

            try { XInputGetStateEx(curSet.port, ref state); }
            catch { }

            LX = (state.Gamepad.sThumbLX + 32767) / 65535.0 * 110.0;
            LY = (32768 - state.Gamepad.sThumbLY) / 65535.0 * 110.0;

            RX = (state.Gamepad.sThumbRX + 32767) / 65535.0 * 110.0;
            RY = (32768 - state.Gamepad.sThumbRY) / 65535.0 * 110.0;

            LT = state.Gamepad.bLeftTrigger / 255.0 * 120.0;
            RT = state.Gamepad.bRightTrigger / 255.0 * 120.0;

            t_StickL.Margin = new Thickness(LX, LY, 0, 0);
            t_StickR.Margin = new Thickness(RX, RY, 0, 0);

            t_TriggerL.Height = LT;
            t_TriggerR.Height = RT;

            buttons = state.Gamepad.wButtons;

            t_Button0.Fill  = (buttons & (UInt16)XInputButtons.DPAD_UP) > 0 ? cOn : cOff;
            t_Button1.Fill  = (buttons & (UInt16)XInputButtons.DPAD_DOWN) > 0 ? cOn : cOff;
            t_Button2.Fill  = (buttons & (UInt16)XInputButtons.DPAD_LEFT) > 0 ? cOn : cOff;
            t_Button3.Fill  = (buttons & (UInt16)XInputButtons.DPAD_RIGHT) > 0 ? cOn : cOff;
            t_Button4.Fill  = (buttons & (UInt16)XInputButtons.START) > 0 ? cOn : cOff;
            t_Button5.Fill  = (buttons & (UInt16)XInputButtons.BACK) > 0 ? cOn : cOff;
            t_Button6.Fill  = (buttons & (UInt16)XInputButtons.LEFT_THUMB) > 0 ? cOn : cOff;
            t_Button7.Fill  = (buttons & (UInt16)XInputButtons.RIGHT_THUMB) > 0 ? cOn : cOff;
            t_Button8.Fill  = (buttons & (UInt16)XInputButtons.LEFT_SHOULDER) > 0 ? cOn : cOff;
            t_Button9.Fill  = (buttons & (UInt16)XInputButtons.RIGHT_SHOULDER) > 0 ? cOn : cOff;
            t_Button10.Fill = (buttons & (UInt16)XInputButtons.GUIDE) > 0 ? cOn : cOff;
            t_Button11.Fill = (buttons & (UInt16)XInputButtons.A) > 0 ? cOn : cOff;
            t_Button12.Fill = (buttons & (UInt16)XInputButtons.B) > 0 ? cOn : cOff;
            t_Button13.Fill = (buttons & (UInt16)XInputButtons.X) > 0 ? cOn : cOff;
            t_Button14.Fill = (buttons & (UInt16)XInputButtons.Y) > 0 ? cOn : cOff;

            t_TextDebug.Text = state.Gamepad.sThumbLX.ToString() + "\n" + state.Gamepad.sThumbLY.ToString() + "\n" +
                               state.Gamepad.sThumbRX.ToString() + "\n" + state.Gamepad.sThumbRY.ToString() + "\n" +
                               state.Gamepad.bLeftTrigger.ToString() + "\n" + state.Gamepad.bRightTrigger.ToString() + "\n" +
                               state.Gamepad.wButtons.ToString("X4");
        }
예제 #2
0
 private static extern uint XInputGetStateEx(int port, ref XInputState state);
예제 #3
0
 private static extern uint DuraznoGetStateEx(int port, ref XInputState state);
예제 #4
0
        private void TestUpdate()
        {
            XInputState state = new XInputState();

            try { DuraznoGetStateEx(curSet.port, ref state); }
            catch { }

            double LX = (state.Gamepad.sThumbLX + 32767) / 65535.0 * 110.0;
            double LY = (32768 - state.Gamepad.sThumbLY) / 65535.0 * 110.0;

            double RX = (state.Gamepad.sThumbRX + 32767) / 65535.0 * 110.0;
            double RY = (32768 - state.Gamepad.sThumbRY) / 65535.0 * 110.0;

            double LT = state.Gamepad.bLeftTrigger / 255.0 * 120.0;
            double RT = state.Gamepad.bRightTrigger / 255.0 * 120.0;

            StickL.Margin = new Thickness(LX, LY, 0, 0);
            StickR.Margin = new Thickness(RX, RY, 0, 0);

            TriggerL.Height = LT;
            TriggerR.Height = RT;

            SolidColorBrush cOff = new SolidColorBrush(Color.FromArgb(0x19, 0xFF, 0xFF, 0xFF));
            SolidColorBrush cOn = new SolidColorBrush(Color.FromArgb(0xCC, 0xFF, 0xFF, 0xFF));

            UInt16 buttons = state.Gamepad.wButtons;

            Button0.Fill = (buttons & (UInt16)XInputButtons.DPAD_UP) > 0 ? cOn : cOff;
            Button1.Fill = (buttons & (UInt16)XInputButtons.DPAD_DOWN) > 0 ? cOn : cOff;
            Button2.Fill = (buttons & (UInt16)XInputButtons.DPAD_LEFT) > 0 ? cOn : cOff;
            Button3.Fill = (buttons & (UInt16)XInputButtons.DPAD_RIGHT) > 0 ? cOn : cOff;
            Button4.Fill = (buttons & (UInt16)XInputButtons.START) > 0 ? cOn : cOff;
            Button5.Fill = (buttons & (UInt16)XInputButtons.BACK) > 0 ? cOn : cOff;
            Button6.Fill = (buttons & (UInt16)XInputButtons.LEFT_THUMB) > 0 ? cOn : cOff;
            Button7.Fill = (buttons & (UInt16)XInputButtons.RIGHT_THUMB) > 0 ? cOn : cOff;
            Button8.Fill = (buttons & (UInt16)XInputButtons.LEFT_SHOULDER) > 0 ? cOn : cOff;
            Button9.Fill = (buttons & (UInt16)XInputButtons.RIGHT_SHOULDER) > 0 ? cOn : cOff;
            Button10.Fill = (buttons & (UInt16)XInputButtons.GUIDE) > 0 ? cOn : cOff;
            Button11.Fill = (buttons & (UInt16)XInputButtons.A) > 0 ? cOn : cOff;
            Button12.Fill = (buttons & (UInt16)XInputButtons.B) > 0 ? cOn : cOff;
            Button13.Fill = (buttons & (UInt16)XInputButtons.X) > 0 ? cOn : cOff;
            Button14.Fill = (buttons & (UInt16)XInputButtons.Y) > 0 ? cOn : cOff;

            TextDebug.Text = state.Gamepad.sThumbLX.ToString() + "\n" + state.Gamepad.sThumbLY.ToString() + "\n" +
                             state.Gamepad.sThumbRX.ToString() + "\n" + state.Gamepad.sThumbRY.ToString() + "\n" +
                             state.Gamepad.bLeftTrigger.ToString() + "\n" + state.Gamepad.bRightTrigger.ToString() + "\n" +
                             state.Gamepad.wButtons.ToString("X4");

            try { XInputGetStateEx(curSet.port, ref state); }
            catch { }

            LX = (state.Gamepad.sThumbLX + 32767) / 65535.0 * 110.0;
            LY = (32768 - state.Gamepad.sThumbLY) / 65535.0 * 110.0;

            RX = (state.Gamepad.sThumbRX + 32767) / 65535.0 * 110.0;
            RY = (32768 - state.Gamepad.sThumbRY) / 65535.0 * 110.0;

            LT = state.Gamepad.bLeftTrigger / 255.0 * 120.0;
            RT = state.Gamepad.bRightTrigger / 255.0 * 120.0;

            t_StickL.Margin = new Thickness(LX, LY, 0, 0);
            t_StickR.Margin = new Thickness(RX, RY, 0, 0);

            t_TriggerL.Height = LT;
            t_TriggerR.Height = RT;

            buttons = state.Gamepad.wButtons;

            t_Button0.Fill = (buttons & (UInt16)XInputButtons.DPAD_UP) > 0 ? cOn : cOff;
            t_Button1.Fill = (buttons & (UInt16)XInputButtons.DPAD_DOWN) > 0 ? cOn : cOff;
            t_Button2.Fill = (buttons & (UInt16)XInputButtons.DPAD_LEFT) > 0 ? cOn : cOff;
            t_Button3.Fill = (buttons & (UInt16)XInputButtons.DPAD_RIGHT) > 0 ? cOn : cOff;
            t_Button4.Fill = (buttons & (UInt16)XInputButtons.START) > 0 ? cOn : cOff;
            t_Button5.Fill = (buttons & (UInt16)XInputButtons.BACK) > 0 ? cOn : cOff;
            t_Button6.Fill = (buttons & (UInt16)XInputButtons.LEFT_THUMB) > 0 ? cOn : cOff;
            t_Button7.Fill = (buttons & (UInt16)XInputButtons.RIGHT_THUMB) > 0 ? cOn : cOff;
            t_Button8.Fill = (buttons & (UInt16)XInputButtons.LEFT_SHOULDER) > 0 ? cOn : cOff;
            t_Button9.Fill = (buttons & (UInt16)XInputButtons.RIGHT_SHOULDER) > 0 ? cOn : cOff;
            t_Button10.Fill = (buttons & (UInt16)XInputButtons.GUIDE) > 0 ? cOn : cOff;
            t_Button11.Fill = (buttons & (UInt16)XInputButtons.A) > 0 ? cOn : cOff;
            t_Button12.Fill = (buttons & (UInt16)XInputButtons.B) > 0 ? cOn : cOff;
            t_Button13.Fill = (buttons & (UInt16)XInputButtons.X) > 0 ? cOn : cOff;
            t_Button14.Fill = (buttons & (UInt16)XInputButtons.Y) > 0 ? cOn : cOff;

            t_TextDebug.Text = state.Gamepad.sThumbLX.ToString() + "\n" + state.Gamepad.sThumbLY.ToString() + "\n" +
                               state.Gamepad.sThumbRX.ToString() + "\n" + state.Gamepad.sThumbRY.ToString() + "\n" +
                               state.Gamepad.bLeftTrigger.ToString() + "\n" + state.Gamepad.bRightTrigger.ToString() + "\n" +
                               state.Gamepad.wButtons.ToString("X4");
        }
예제 #5
0
 private static extern uint XInputGetStateEx(int port, ref XInputState state);
예제 #6
0
 private static extern uint DuraznoGetStateEx(int port, ref XInputState state);