コード例 #1
0
ファイル: DeviceControl.xaml.cs プロジェクト: zw5/WiinUPro
 public void Detatch()
 {
     device?.StopReading();
     holder?.Close();
     lowBatteryFired = false;
     ConnectionState = DeviceState.Discovered;
     Dispatcher.BeginInvoke
     (
         System.Windows.Threading.DispatcherPriority.Background,
         new Action(() => statusGradient.Color = (Color)FindResource("AntemBlue")
                    ));
 }
コード例 #2
0
        private void btnIdentify_Click(object sender, RoutedEventArgs e)
        {
            bool wasConnected = Connected;

            if (wasConnected || ((device.DataStream as WinBtStream).OpenConnection() && device.DataStream.CanRead))
            {
                if (!wasConnected)
                {
                    device.BeginReading();
                    if (device.IsControllerTypeAmbiguous)
                    {
                        //device.SetReportType(InputReport.ExtOnly, continuous: false);
                        device.GetStatus();
                    }
                }

                identifying          = true;
                device.RumbleEnabled = true;
                Delay(2000).ContinueWith(o =>
                {
                    identifying          = false;
                    device.RumbleEnabled = false;
                    if (!wasConnected)
                    {
                        device.StopReading();
                    }
                });

                // light show
                device.SetPlayerLED(1);
                Delay(250).ContinueWith(o => device.SetPlayerLED(2));
                Delay(500).ContinueWith(o => device.SetPlayerLED(3));
                Delay(750).ContinueWith(o => device.SetPlayerLED(4));
                Delay(1000).ContinueWith(o => device.SetPlayerLED(3));
                Delay(1250).ContinueWith(o => device.SetPlayerLED(2));
                Delay(1500).ContinueWith(o => device.SetPlayerLED(1));
                if (targetXDevice != 0)
                {
                    Delay(1750).ContinueWith(o => device.SetPlayerLED(targetXDevice));
                }
            }
        }
コード例 #3
0
        private void btnIdentify_Click(object sender, RoutedEventArgs e)
        {
            bool wasConnected = Connected;

            if (wasConnected || ((device.DataStream as WinBtStream).OpenConnection() && device.DataStream.CanRead))
            {
                if (!wasConnected)
                {
                    device.BeginReading();
                }

                identifying          = true;
                device.RumbleEnabled = true;
                Delay(2000).ContinueWith(o =>
                {
                    identifying          = false;
                    device.RumbleEnabled = false;
                    if (!wasConnected)
                    {
                        device.StopReading();
                    }
                });

                // light show
                device.SetBinaryLEDs(0b1010);
                Delay(250).ContinueWith(o => device.SetBinaryLEDs(0b0101));
                Delay(500).ContinueWith(o => device.SetBinaryLEDs(0b1010));
                Delay(750).ContinueWith(o => device.SetBinaryLEDs(0b0101));
                Delay(1000).ContinueWith(o => device.SetBinaryLEDs(0b1010));
                Delay(1250).ContinueWith(o => device.SetBinaryLEDs(0b0101));
                Delay(1500).ContinueWith(o => device.SetBinaryLEDs(0b0000));
                if (state == DeviceState.Discovered)
                {
                    Delay(1750).ContinueWith(o => device.SetBinaryLEDs(15));
                }
                else if (targetXDevice != 0)
                {
                    Delay(1750).ContinueWith(o => device.SetPlayerLED(targetXDevice));
                }
            }
        }
コード例 #4
0
        private void btnIdentify_Click(object sender, RoutedEventArgs e)
        {
            bool wasConnected = Connected;

            if (wasConnected || ((device.DataStream as WinBtStream).OpenConnection() && device.DataStream.CanRead))
            {
                if (!wasConnected)
                {
                    device.BeginReading();
                }

                identifying          = true;
                device.RumbleEnabled = true;
                Delay(500).ContinueWith(o =>
                {
                    identifying          = false;
                    device.RumbleEnabled = false;
                    if (!wasConnected)
                    {
                        device.StopReading();
                    }
                });

                // light show
                device.SetPlayerLED(1);
                const int LIGHTSHOW_LENGTH = 400;
                Delay((LIGHTSHOW_LENGTH / 7) * 1).ContinueWith(o => device.SetPlayerLED(2));
                Delay((LIGHTSHOW_LENGTH / 7) * 2).ContinueWith(o => device.SetPlayerLED(3));
                Delay((LIGHTSHOW_LENGTH / 7) * 3).ContinueWith(o => device.SetPlayerLED(4));
                Delay((LIGHTSHOW_LENGTH / 7) * 4).ContinueWith(o => device.SetPlayerLED(3));
                Delay((LIGHTSHOW_LENGTH / 7) * 5).ContinueWith(o => device.SetPlayerLED(2));
                Delay((LIGHTSHOW_LENGTH / 7) * 6).ContinueWith(o => device.SetPlayerLED(1));
                if (targetXDevice != 0)
                {
                    Delay(LIGHTSHOW_LENGTH).ContinueWith(o => device.SetPlayerLED(targetXDevice));
                }
            }
        }