Exemplo n.º 1
0
        public bool Connect()
        {
            _Connected = false;

            if (_Error)
            {
                return(false);
            }

            CHIDAPI.Exit();

            if (!CHIDAPI.Init())
            {
                CLog.LogError("WiiMoteLib: Can't initialize HID API");
                string msg = "Please install the Visual C++ Redistributable Packages 2008!";
                CLog.LogError(msg);

                _Active = false;
                _Error  = true;
                return(false);
            }

            //Try WiiMotion
            if (_Connected = CHIDAPI.Open(VID, PID, out _Handle))
            {
                if (!(_Connected = ReadCalibration()))
                {
                    CHIDAPI.Close(_Handle);
                }
            }

            if (_Connected)
            {
                return(true);
            }

            //Try WiiMotion Plus
            if (_Connected = CHIDAPI.Open(VID, PIDPlus, out _Handle))
            {
                if (!(_Connected = ReadCalibration()))
                {
                    CHIDAPI.Close(_Handle);
                }
            }

            return(_Connected);
        }
Exemplo n.º 2
0
 public void Disconnect()
 {
     _Connected = false;
     _Active    = false;
     CHIDAPI.Exit();
 }