示例#1
0
        /// \brief Attempts to activate the Wii Motion Plus.
        /// \sa RequestIdentifyWiiMotionPlus(), wmp_attached
        /// \return If the activation request was successfully sent to the Wii Remote.
        ///
        /// When the Wii Remote reports that the Wii Motion Plus has been activated, current_ext will be updated to ExtensionController::MOTIONPLUS
        /// If there is no Wii Motion Plus connected, undefined behavior may occur on the Wii Remote.
        public bool ActivateWiiMotionPlus()
        {
            //if (!wmp_attached)
            //Debug.LogWarning("There is a request to activate the Wii Motion Plus even though it has not been confirmed to exist!  Trying anyway.");
            // Initialize the Wii Motion Plus by writing 0x55 to register 0xA600F0
            int res = SendRegisterWriteRequest(RegisterType.CONTROL, 0xA600F0, new byte[] { 0x55 });

            if (res < 0)
            {
                return(false);
            }

            // Activate the Wii Motion Plus as the active extension by writing 0x04 to register 0xA600FE
            // This does 3 things:
            // 1. A status report (0x20) will be sent, which indicates that an extension has been
            //    plugged in - IF there is no extension plugged into the passthrough port.
            // 2. The standard extension identifier at 0xA400FA now reads 00 00 A4 20 04 05
            // 3. Extension reports now contain Wii Motion Plus data.
            res = SendRegisterWriteRequest(RegisterType.CONTROL, 0xA600FE, new byte[] { 0x04 });
            if (res < 0)
            {
                return(false);
            }

            _current_ext = ExtensionController.MOTIONPLUS;
            if (_Extension == null || _Extension.GetType() != typeof(MotionPlusData))
            {
                _Extension = new MotionPlusData(this);
            }
            ExpectingWiiMotionPlusSwitch = true;


            return(true);
        }
示例#2
0
        public Wiimote(IntPtr hidapi_handle, string hidapi_path, WiimoteType Type)
        {
            _hidapi_handle = hidapi_handle;
            _hidapi_path   = hidapi_path;
            _Type          = Type;

            _Accel     = new AccelData(this);
            _Button    = new ButtonData(this);
            _Ir        = new IRData(this);
            _Status    = new StatusData(this);
            _Extension = null;

            //RequestIdentifyWiiMotionPlus(); // why not?
        }
示例#3
0
文件: Wiimote.cs 项目: dsesclei/DS501
        public Wiimote(IntPtr hidapi_handle, string hidapi_path, WiimoteType Type)
        {
            _hidapi_handle  = hidapi_handle;
            _hidapi_path    = hidapi_path;
            _Type    = Type;

            _Accel  = new AccelData(this);
            _Button = new ButtonData(this);
            _Ir     = new IRData(this);
            _Status = new StatusData(this);
            _Extension = null;

            //RequestIdentifyWiiMotionPlus(); // why not?
        }
示例#4
0
        private void RespondIdentifyExtension(byte[] data)
        {
            if (data.Length != 6)
            {
                return;
            }

            byte[] resized = new byte[8];
            for (int x = 0; x < 6; x++)
            {
                resized[x] = data[5 - x];
            }
            long val = BitConverter.ToInt64(resized, 0);

            // Disregard bytes 0 and 5 - see RespondIdentifyWiiMotionPlus()
            if ((val | 0xff000000ff00) == (ID_ActiveMotionPlus | 0xff000000ff00))
            {
                _current_ext = ExtensionController.MOTIONPLUS;
                if (_Extension == null || _Extension.GetType() != typeof(MotionPlusData))
                {
                    _Extension = new MotionPlusData(this);
                }
            }
            else if (val == ID_ActiveMotionPlus_Nunchuck)
            {
                _current_ext = ExtensionController.MOTIONPLUS_NUNCHUCK;
                _Extension   = null;
            }
            else if (val == ID_ActiveMotionPlus_Classic)
            {
                _current_ext = ExtensionController.MOTIONPLUS_CLASSIC;
                _Extension   = null;
            }
            else if (val == ID_ClassicPro)
            {
                _current_ext = ExtensionController.CLASSIC_PRO;
                _Extension   = null;
            }
            else if (val == ID_Nunchuck)
            {
                _current_ext = ExtensionController.NUNCHUCK;
                if (_Extension == null || _Extension.GetType() != typeof(NunchuckData))
                {
                    _Extension = new NunchuckData(this);
                }
            }
            else if (val == ID_Classic)
            {
                _current_ext = ExtensionController.CLASSIC;
                if (_Extension == null || _Extension.GetType() != typeof(ClassicControllerData))
                {
                    _Extension = new ClassicControllerData(this);
                }
            }
            else if (val == ID_WiiUPro)
            {
                _current_ext = ExtensionController.WIIU_PRO;
                _Type        = WiimoteType.PROCONTROLLER;
                if (_Extension == null || _Extension.GetType() != typeof(WiiUProData))
                {
                    _Extension = new WiiUProData(this);
                }
            }
            else
            {
                _current_ext = ExtensionController.NONE;
                _Extension   = null;
            }
        }
示例#5
0
    /// \brief Attempts to activate the Wii Motion Plus.
    /// \sa RequestIdentifyWiiMotionPlus(), wmp_attached
    /// \return If the activation request was successfully sent to the Wii Remote.
    ///
    /// When the Wii Remote reports that the Wii Motion Plus has been activated, current_ext will be updated to ExtensionController::MOTIONPLUS
    /// If there is no Wii Motion Plus connected, undefined behavior may occur on the Wii Remote.
    public bool ActivateWiiMotionPlus()
    {
        if (!wmp_attached)
            Debug.LogWarning("There is a request to activate the Wii Motion Plus even though it has not been confirmed to exist!  Trying anyway.");

        // Initialize the Wii Motion Plus by writing 0x55 to register 0xA600F0
        int res = SendRegisterWriteRequest(RegisterType.CONTROL, 0xA600F0, new byte[] { 0x55 });
        if (res < 0) return false;

        // Activate the Wii Motion Plus as the active extension by writing 0x04 to register 0xA600FE
        // This does 3 things:
        // 1. A status report (0x20) will be sent, which indicates that an extension has been
        //    plugged in - IF there is no extension plugged into the passthrough port.
        // 2. The standard extension identifier at 0xA400FA now reads 00 00 A4 20 04 05
        // 3. Extension reports now contain Wii Motion Plus data.
        res = SendRegisterWriteRequest(RegisterType.CONTROL, 0xA600FE, new byte[] { 0x04 });
        if (res < 0) return false;

        _current_ext = ExtensionController.MOTIONPLUS;
        if (_Extension == null || _Extension.GetType() != typeof(MotionPlusData))
            _Extension = new MotionPlusData(this);
        ExpectingWiiMotionPlusSwitch = true;

        return true;
    }
示例#6
0
    private void RespondIdentifyExtension(byte[] data)
    {
        if (data.Length != 6)
            return;

        byte[] resized = new byte[8];
        for (int x = 0; x < 6; x++) resized[x] = data[5-x];
        long val = BitConverter.ToInt64(resized, 0);

        // Disregard bytes 0 and 5 - see RespondIdentifyWiiMotionPlus()
        if ((val | 0xff000000ff00) == (ID_ActiveMotionPlus | 0xff000000ff00))
        {
            _current_ext = ExtensionController.MOTIONPLUS;
            if(_Extension == null || _Extension.GetType() != typeof(MotionPlusData))
                _Extension = new MotionPlusData(this);
        }
        else if (val == ID_ActiveMotionPlus_Nunchuck)
        {
            _current_ext = ExtensionController.MOTIONPLUS_NUNCHUCK;
            _Extension = null;
        }
        else if (val == ID_ActiveMotionPlus_Classic)
        {
            _current_ext = ExtensionController.MOTIONPLUS_CLASSIC;
            _Extension = null;
        }
        else if (val == ID_ClassicPro)
        {
            _current_ext = ExtensionController.CLASSIC_PRO;
            _Extension = null;
        }
        else if (val == ID_Nunchuck || val == ID_Nunchuck2)
        {
            _current_ext = ExtensionController.NUNCHUCK;
            if (_Extension == null || _Extension.GetType() != typeof(NunchuckData))
                _Extension = new NunchuckData(this);
        }
        else if (val == ID_Classic)
        {
            _current_ext = ExtensionController.CLASSIC;
            if (_Extension == null || _Extension.GetType() != typeof(ClassicControllerData))
                _Extension = new ClassicControllerData(this);
        }
        else if (val == ID_WiiUPro)
        {
            _current_ext = ExtensionController.WIIU_PRO;
            _Type = WiimoteType.PROCONTROLLER;
            if (_Extension == null || _Extension.GetType() != typeof(WiiUProData))
                _Extension = new WiiUProData(this);
        }
		else if (val == ID_Guitar)
		{
			_current_ext = ExtensionController.GUITAR;
			if (_Extension == null || _Extension.GetType() != typeof(GuitarData))
				_Extension = new GuitarData(this);
		}
        else
        {
            _current_ext = ExtensionController.NONE;
            _Extension = null;
        }
    }