2011-03-26 5 views
0

나는 최근에 Wiimote의 프로그램을 쓰고 있어요 :wiimotelib bug?

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Diagnostics; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using WiimoteLib; 

namespace WiiTester 
{ 
    public partial class Form1 : Form 
    { 
     Wiimote wm = new Wiimote(); 
     public Form1() 
     { 
      InitializeComponent(); 


      wm.WiimoteChanged += wm_WiimoteChanged; 
      wm.WiimoteExtensionChanged += wm_WiimoteExtensionChanged; 

      wm.Connect(); 
      wm.SetReportType(InputReport.IRAccel, true); 
     } 

     void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) 
     { 
      WiimoteState ws = args.WiimoteState; 

      if (ws.ButtonState.A == true) 
      { 
       wm.SetRumble(true); 
      } 
      else 
      { 
       wm.SetRumble(false); 
      } 
     } 

     void wm_WiimoteExtensionChanged(object sender, WiimoteExtensionChangedEventArgs args) 
     { 
      if (args.Inserted) 
      { 
       wm.SetReportType(InputReport.IRExtensionAccel, true); 
      } 
      else 
      { 
       wm.SetReportType(InputReport.IRAccel, true); 
      } 
     } 
    } 
} 

내 Wiimote의 연결이 끊어지고 계속이 오류가) (wm.Connect에서 실행 유지; 상태보고 대기 시간 초과

해결책이 있습니까?

+0

Wii Mote PC 지원이 공식적으로 지원되는 방식 인 것처럼이 질문을하는 것 같습니다. WiiMote로 작업하기 위해 비공식적 인 라이브러리를 제공하지 않으면 코드가 거의 지원되지 않을 것입니다! –

+0

wiimotelib.dll 라이브러리를 사용합니다. – user288231

답변

0

나는이 라이브러리에 많은 경험을 가지고 있고, 당신의 문제는 당신이 너무 자주 SetRumble를 호출하기 때문에 대부분 발생하고이 코드입니다 :

void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) 
    { 
     WiimoteState ws = args.WiimoteState; 

     if (ws.ButtonState.A == true) 
     { 
      wm.SetRumble(true); 
     } 
     else 
     { 
      wm.SetRumble(false); 
     } 
    } 

는 A가 다운되거나 아닌 지속적 여부를 SetRumble를 호출 할 것이다 대신에이 코드를 사용하는 것이 좋습니다 :

bool rumbleOn = false; 

    void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) 
    { 
     WiimoteState ws = args.WiimoteState; 

     bool newRumble = (ws.ButtonState.A == true); 

      if (rumbleOn != newRumble) 
     { 
      rumbleOn = newRumble; 
      wm.SetRumble(rumbleOn); 
     } 
    } 

필요하며 지속적으로 과부하 블루투스 BUS를 유발하는 Wiimote의 출력 보고서를 전송하지 않을 경우 설정 럼블 방법 만이라고합니다 이런 식으로.