예제 #1
0
        private void connectWiimote(Wiimote wiimote)
        {
            Console.WriteLine("Trying to connect " + wiimote.HIDDevicePath);
            // Try to establish a connection, enable the IR reader and flag some LEDs.
            wiimote.Connect();
            wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true);

            new Timer(new TimerCallback(connectRumble), wiimote, 0, Timeout.Infinite);

            int id = this.getFirstFreeId();

            wiimote.SetLEDs(id == 1, id == 2, id == 3, id == 4);

            WiimoteControl control = new WiimoteControl(id, wiimote);

            pDeviceMutex.WaitOne(); //Don't mess with the list of wiimotes if it is enumerating in an update
            pWiimoteMap[wiimote.HIDDevicePath] = control;
            pDeviceMutex.ReleaseMutex();

            // Hook up device event handlers.
            wiimote.WiimoteChanged          += this.wiimoteChangedEventHandler;
            wiimote.WiimoteExtensionChanged += this.wiimoteExtensionChangedEventHandler;

            OnConnect(id, this.pWiimoteMap.Count);
        }
예제 #2
0
 private void wakeFromPowerSave(WiimoteControl control)
 {
     control.WiimoteMutex.WaitOne();
     try
     {
         control.Wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true);
         control.Status.InPowerSave = false;
         int id = control.Status.ID;
         control.Wiimote.SetLEDs(id == 1, id == 2, id == 3, id == 4);
         control.Wiimote.SetRumble(true);
         new Timer(connectRumble, control.Wiimote, 0, Timeout.Infinite);
     }
     catch { }
     finally
     {
         control.WiimoteMutex.ReleaseMutex();
     }
 }
예제 #3
0
 private void putToPowerSave(WiimoteControl control)
 {
     if (Settings.Default.completelyDisconnect && this.pWiimoteMap.Count == 1) //If we want to completely disable the device
     {
         teardownWiimoteConnection(control.Wiimote);
         completelyDisconnectAll();
     }
     else
     {
         control.WiimoteMutex.WaitOne();
         try
         {
             control.Wiimote.SetReportType(InputReport.Buttons, false);
             control.Status.InPowerSave = true;
             control.Wiimote.SetLEDs(false, false, false, false);
             control.Wiimote.SetRumble(false);
         }
         catch { }
         finally
         {
             control.WiimoteMutex.ReleaseMutex();
         }
     }
 }
 private void wakeFromPowerSave(WiimoteControl control)
 {
     control.WiimoteMutex.WaitOne();
     try
     {
         control.Wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true);
         control.Status.InPowerSave = false;
         int id = control.Status.ID;
         control.Wiimote.SetLEDs(id == 1, id == 2, id == 3, id == 4);
         control.Wiimote.SetRumble(true);
         new Timer(connectRumble,control.Wiimote,0,Timeout.Infinite);
     }
     catch { }
     finally
     {
         control.WiimoteMutex.ReleaseMutex();
     }
 }
 private void putToPowerSave(WiimoteControl control)
 {
     if (Settings.Default.completelyDisconnect && this.pWiimoteMap.Count == 1) //If we want to completely disable the device
     {
         teardownWiimoteConnection(control.Wiimote);
         completelyDisconnectAll();
     }
     else
     {
         control.WiimoteMutex.WaitOne();
         try
         {
             control.Wiimote.SetReportType(InputReport.Buttons, false);
             control.Status.InPowerSave = true;
             control.Wiimote.SetLEDs(false, false, false, false);
             control.Wiimote.SetRumble(false);
         }
         catch { }
         finally
         {
             control.WiimoteMutex.ReleaseMutex();
         }
     }
 }
        private void connectWiimote(Wiimote wiimote)
        {
            Console.WriteLine("Trying to connect " + wiimote.HIDDevicePath);
            // Try to establish a connection, enable the IR reader and flag some LEDs.
            wiimote.Connect();
            wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true);

            new Timer(new TimerCallback(connectRumble), wiimote, 0, Timeout.Infinite);

            int id = this.getFirstFreeId();
            wiimote.SetLEDs(id == 1, id == 2, id == 3, id == 4);

            WiimoteControl control = new WiimoteControl(id, wiimote);

            pDeviceMutex.WaitOne(); //Don't mess with the list of wiimotes if it is enumerating in an update
            pWiimoteMap[wiimote.HIDDevicePath] = control;
            pDeviceMutex.ReleaseMutex();

            // Hook up device event handlers.
            wiimote.WiimoteChanged += this.wiimoteChangedEventHandler;
            wiimote.WiimoteExtensionChanged += this.wiimoteExtensionChangedEventHandler;

            OnConnect(id, this.pWiimoteMap.Count);
        }